2016-02-07 23:16:07 +01:00
|
|
|
/*
|
|
|
|
* 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.
|
2016-12-08 11:17:42 +01:00
|
|
|
func (client *Client) Snapshot(query string, start, end time.Time, eventQuery string) (string, error) {
|
2016-02-07 23:16:07 +01:00
|
|
|
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"`
|
|
|
|
}{}
|
2016-12-08 11:17:42 +01:00
|
|
|
if err := client.doJsonRequest("GET", "/v1/graph/snapshot?"+v.Encode(), nil, &out); err != nil {
|
2016-02-07 23:16:07 +01:00
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
return out.SnapshotURL, nil
|
|
|
|
}
|