README.md
1[![GoDoc](http://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/yfronto/newrelic)
2[![Build
3status](https://travis-ci.org/yfronto/newrelic.svg)](https://travis-ci.org/yfronto/newrelic)
4
5# New Relic API library for Go
6
7This is a Go library that wraps the [New Relic][1] REST
8API. It provides the needed types to interact with the New Relic REST API.
9
10It's still in progress and I haven't finished the entirety of the API, yet. I
11plan to finish all GET (read) operations before any POST (create) operations,
12and then PUT (update) operations, and, finally, the DELETE operations.
13
14The API documentation can be found from [New Relic][1],
15and you'll need an API key (for some operations, an Admin API key is
16required).
17
18## USAGE
19
20This library will provide a client object and any operations can be performed
21through it. Simply import this library and create a client to get started:
22
23```go
24package main
25
26import (
27 "github.com/yfronto/newrelic"
28)
29
30var api_key = "..." // Required
31
32func main() {
33 // Create the client object
34 client := newrelic.NewClient(api_key)
35
36 // Get the applciation with ID 12345
37 myApp, err := client.GetApplication(12345)
38 if err != nil {
39 // Handle error
40 }
41
42 // Work with the object
43 fmt.Println(myApp.Name)
44
45 // Some operations accept options
46 opts := &newrelic.AlertEventOptions{
47 // Only events with "MyProduct" as the product name
48 Filter: newRelic.AlertEventFilter{
49 Product: "MyProduct",
50 },
51 }
52 // Get a list of recent events for my product
53 events, err := client.GetAlertEvents(opts)
54 if err != nil {
55 // Handle error
56 }
57 // Display each event with some information
58 for _, e := range events {
59 fmt.Printf("%d -- %d (%s): %s\n", e.Timestamp, e.Id, e.Priority, e.Description)
60 }
61}
62```
63
64## Contributing
65
66As I work to populate all actions, bugs are bound to come up. Feel free to
67send me a pull request or just file an issue. Staying up to date with an API
68is hard work and I'm happy to accept contributors.
69
70**DISCLAIMER:** *I am in no way affiliated with New Relic and this work is
71merely a convenience project for myself with no guarantees. It should be
72considered "as-is" with no implication of responsibility. See the included
73LICENSE for more details.*
74
75[1]: http://www.newrelic.com