1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
wtf/modules/newrelic/client.go
Chris Cummer 31926fd4a7
Integrate vendored NewRelic dependency (#767)
The NewRelic module relies on yfronto/newrelic, which no longer exists.
yfronto deleted that directory quite awhile ago, and since then it has
been vendored.

But vendoring a missing repository creates problems when trying to
update the vendored code.

This PR brings the yfronto/newrelic code into the mainline.

Signed-off-by: Chris Cummer <chriscummer@me.com>
2019-12-01 20:47:02 -08:00

40 lines
799 B
Go

package newrelic
import (
nr "github.com/wtfutil/wtf/modules/newrelic/client"
)
type Client2 struct {
applicationId int
nrClient *nr.Client
}
func NewClient(apiKey string, applicationId int) *Client2 {
return &Client2{
applicationId: applicationId,
nrClient: nr.NewClient(apiKey),
}
}
func (client *Client2) Application() (*nr.Application, error) {
application, err := client.nrClient.GetApplication(client.applicationId)
if err != nil {
return nil, err
}
return application, nil
}
func (client *Client2) Deployments() ([]nr.ApplicationDeployment, error) {
opts := &nr.ApplicationDeploymentOptions{Page: 1}
deployments, err := client.nrClient.GetApplicationDeployments(client.applicationId, opts)
if err != nil {
return nil, err
}
return deployments, nil
}