github.com/wtfutil/wtf@v0.43.0/modules/newrelic/client/README.md (about)

     1  [![GoDoc](http://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/yfronto/newrelic)
     2  [![Build
     3  status](https://travis-ci.org/yfronto/newrelic.svg)](https://travis-ci.org/yfronto/newrelic)
     4  
     5  # New Relic API library for Go
     6  
     7  This is a Go library that wraps the [New Relic][1] REST
     8  API. It provides the needed types to interact with the New Relic REST API.
     9  
    10  It's still in progress and I haven't finished the entirety of the API, yet. I
    11  plan to finish all GET (read) operations before any POST (create) operations,
    12  and then PUT (update) operations, and, finally, the DELETE operations.
    13  
    14  The API documentation can be found from [New Relic][1],
    15  and you'll need an API key (for some operations, an Admin API key is
    16  required).
    17  
    18  ## USAGE
    19  
    20  This library will provide a client object and any operations can be performed
    21  through it. Simply import this library and create a client to get started:
    22  
    23  ```go
    24  package main
    25  
    26  import (
    27    "github.com/yfronto/newrelic"
    28  )
    29  
    30  var api_key = "..." // Required
    31  
    32  func 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  
    66  As I work to populate all actions, bugs are bound to come up. Feel free to
    67  send me a pull request or just file an issue. Staying up to date with an API
    68  is 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
    71  merely a convenience project for myself with no guarantees. It should be
    72  considered "as-is" with no implication of responsibility. See the included
    73  LICENSE for more details.*
    74  
    75  [1]: http://www.newrelic.com