forked from DataDog/go-datadog-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnapshot.go
33 lines (29 loc) · 773 Bytes
/
snapshot.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* Datadog API for Go
*
* Please see the included LICENSE file for licensing information.
*
* Copyright 2016 by authors and contributors.
*/
package datadog
import (
"fmt"
"net/url"
"time"
)
// Snapshot creates an image from a graph and returns the URL of the image.
func (self *Client) Snapshot(query string, start, end time.Time, eventQuery string) (string, error) {
v := url.Values{}
v.Add("start", fmt.Sprintf("%d", start.Unix()))
v.Add("end", fmt.Sprintf("%d", end.Unix()))
v.Add("metric_query", query)
v.Add("event_query", eventQuery)
out := struct {
SnapshotURL string `json:"snapshot_url"`
}{}
err := self.doJsonRequest("GET", "/v1/graph/snapshot?"+v.Encode(), nil, &out)
if err != nil {
return "", err
}
return out.SnapshotURL, nil
}