• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

go-datadog-api-2.21.0/H10-Jun-2019-

.gitignoreH A D30-Aug-201915

.travis.ymlH A D30-Aug-2019508

LICENSEH A D30-Aug-20191.5 KiB

MakefileH A D30-Aug-2019853

README.mdH A D30-Aug-20194.1 KiB

alerts.goH A D30-Aug-20192.4 KiB

api_keys.goH A D30-Aug-20193.2 KiB

board_widgets.goH A D30-Aug-201926.2 KiB

boards.goH A D30-Aug-20192.1 KiB

checks.goH A D30-Aug-2019576

client.goH A D30-Aug-20192.1 KiB

comments.goH A D30-Aug-20192 KiB

dashboard_lists.goH A D30-Aug-20194.8 KiB

dashboards.goH A D30-Aug-20198.8 KiB

datadog-accessors.goH A D30-Aug-2019543.4 KiB

downtimes.goH A D30-Aug-20193.7 KiB

events.goH A D30-Aug-20192.4 KiB

generate.goH A D30-Aug-201968

helpers.goH A D30-Aug-20192.7 KiB

hosts.goH A D30-Aug-2019947

integrations.goH A D30-Aug-20199.1 KiB

metric_metadata.goH A D30-Aug-20191.2 KiB

monitors.goH A D30-Aug-20198.8 KiB

request.goH A D30-Aug-20195.3 KiB

screen_widgets.goH A D30-Aug-20198.1 KiB

screenboards.goH A D30-Aug-20193.5 KiB

search.goH A D30-Aug-20191,018

series.goH A D30-Aug-20192.8 KiB

snapshot.goH A D30-Aug-20191.2 KiB

synthetics.goH A D30-Aug-20196.8 KiB

tags.goH A D30-Aug-20192.7 KiB

users.goH A D30-Aug-20192.7 KiB

README.md

1[![GoDoc](http://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/gopkg.in/zorkian/go-datadog-api.v2)
2[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
3[![Build
4status](https://travis-ci.org/zorkian/go-datadog-api.svg)](https://travis-ci.org/zorkian/go-datadog-api)
5[![Go Report Card](https://goreportcard.com/badge/github.com/zorkian/go-datadog-api)](https://goreportcard.com/report/github.com/zorkian/go-datadog-api)
6
7# Datadog API in Go
8
9**This is the v2.0 version of the API, and has breaking changes. Use the v1.0 branch if you need
10legacy code to be supported.**
11
12A Go wrapper for the Datadog API. Use this library if you need to interact
13with the Datadog system. You can post metrics with it if you want, but this library is probably
14mostly used for automating dashboards/alerting and retrieving data (events, etc).
15
16The source API documentation is here: <http://docs.datadoghq.com/api/>
17
18## Installation
19To use the default branch, include it in your code like:
20```go
21    import "github.com/zorkian/go-datadog-api"
22```
23
24Or, if you need to control which version to use, import using [gopkg.in](http://labix.org/gopkg.in). Like so:
25```go
26    import "gopkg.in/zorkian/go-datadog-api.v2"
27```
28
29Using go get:
30```bash
31go get gopkg.in/zorkian/go-datadog-api.v2
32```
33
34## USAGE
35This library uses pointers to be able to verify if values are set or not (vs the default value for the type). Like
36 protobuf there are helpers to enhance the API. You can decide to not use them, but you'll have to be careful handling
37 nil pointers.
38
39Using the client:
40```go
41    client := datadog.NewClient("api key", "application key")
42
43    dash, err := client.GetDashboard(*datadog.Int(10880))
44    if err != nil {
45        log.Fatalf("fatal: %s\n", err)
46    }
47
48    log.Printf("dashboard %d: %s\n", dash.GetId(), dash.GetTitle())
49```
50
51An example using datadog.String(), which allocates a pointer for you:
52```go
53	m := datadog.Monitor{
54		Name: datadog.String("Monitor other things"),
55		Creator: &datadog.Creator{
56			Name: datadog.String("Joe Creator"),
57		},
58	}
59```
60
61An example using the SetXx, HasXx, GetXx and GetXxOk accessors:
62```go
63	m := datadog.Monitor{}
64	m.SetName("Monitor all the things")
65	m.SetMessage("Electromagnetic energy loss")
66
67	// Use HasMessage(), to verify we have interest in the message.
68	// Using GetMessage() always safe as it returns the actual or, if never set, default value for that type.
69	if m.HasMessage() {
70		fmt.Printf("Found message %s\n", m.GetMessage())
71	}
72
73	// Alternatively, use GetMessageOk(), it returns a tuple with the (default) value and a boolean expressing
74	// if it was set at all:
75	if v, ok := m.GetMessageOk(); ok {
76		fmt.Printf("Found message %s\n", v)
77	}
78```
79
80Check out the Godoc link for the available API methods and, if you can't find the one you need,
81let us know (or patches welcome)!
82
83## DOCUMENTATION
84
85Please see: <https://godoc.org/gopkg.in/zorkian/go-datadog-api.v2>
86
87## BUGS/PROBLEMS/CONTRIBUTING
88
89There are certainly some, but presently no known major bugs. If you do
90find something that doesn't work as expected, please file an issue on
91Github:
92
93<https://github.com/zorkian/go-datadog-api/issues>
94
95Thanks in advance! And, as always, patches welcome!
96
97## DEVELOPMENT
98### Running tests
99* Run tests tests with `make test`.
100* Integration tests can be run with `make testacc`. Run specific integration tests with `make testacc TESTARGS='-run=TestCreateAndDeleteMonitor'`
101
102The acceptance tests require _DATADOG_API_KEY_ and _DATADOG_APP_KEY_ to be available
103in your environment variables.
104
105*Warning: the integrations tests will create and remove real resources in your Datadog account.*
106
107### Regenerating code
108Accessors `HasXx`, `GetXx`, `GetOkXx` and `SetXx` are generated for each struct field type type that contains pointers.
109When structs are updated a contributor has to regenerate these using `go generate` and commit these changes.
110Optionally there is a make target for the generation:
111
112```bash
113make generate
114```
115
116## COPYRIGHT AND LICENSE
117
118Please see the LICENSE file for the included license information.
119
120Copyright 2013-2019 by authors and contributors.
121