mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
40 lines
775 B
Go
40 lines
775 B
Go
package newrelic
|
|
|
|
import (
|
|
nr "github.com/yfronto/newrelic"
|
|
)
|
|
|
|
type Client struct {
|
|
applicationId int
|
|
nrClient *nr.Client
|
|
}
|
|
|
|
func NewClient(apiKey string, applicationId int) *Client {
|
|
return &Client{
|
|
applicationId: applicationId,
|
|
nrClient: nr.NewClient(apiKey),
|
|
}
|
|
|
|
}
|
|
|
|
func (client *Client) Application() (*nr.Application, error) {
|
|
|
|
application, err := client.nrClient.GetApplication(client.applicationId)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return application, nil
|
|
}
|
|
|
|
func (client *Client) 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
|
|
}
|