Documentation ¶
Index ¶
- Variables
- func RetryPolicy(ctx context.Context, resp *http.Response, err error) (bool, error)
- type ClassicV2Authorizer
- type Client
- func (c *Client) Delete(url string, queryParams interface{}, respBody interface{}) (*http.Response, error)
- func (c *Client) Do(req *Request) (*http.Response, error)
- func (c *Client) Get(url string, queryParams interface{}, respBody interface{}) (*http.Response, error)
- func (c *Client) GetBaseURL() string
- func (c *Client) Post(url string, queryParams interface{}, reqBody interface{}, respBody interface{}) (*http.Response, error)
- func (c *Client) Put(url string, queryParams interface{}, reqBody interface{}, respBody interface{}) (*http.Response, error)
- func (c *Client) Query(query string, vars map[string]interface{}, respBody interface{}) error
- func (c *Client) RawPost(url string, queryParams interface{}, reqBody interface{}, respBody interface{}) (*http.Response, error)
- func (c *Client) SetAuthStrategy(da RequestAuthorizer)
- func (c *Client) SetErrorValue(v ErrorResponse) *Client
- type DefaultErrorResponse
- type ErrorDetail
- type ErrorResponse
- type LinkHeaderPager
- type NerdGraphAuthorizer
- type Pager
- type Paging
- type PersonalAPIKeyCapableV2Authorizer
- type Request
- type RequestAuthorizer
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is returned when the resource was not found in New Relic. ErrNotFound = errors.New("newrelic: Resource not found") )
Functions ¶
Types ¶
type ClassicV2Authorizer ¶ added in v0.11.0
type ClassicV2Authorizer struct{}
ClassicV2Authorizer authorizes V2 endpoints that cannot use a personal API key.
func (*ClassicV2Authorizer) AuthorizeRequest ¶ added in v0.11.0
func (a *ClassicV2Authorizer) AuthorizeRequest(r *Request, c *config.Config)
AuthorizeRequest is responsible for setting up auth for a request.
type Client ¶ added in v0.17.0
type Client struct {
// contains filtered or unexported fields
}
Client represents a client for communicating with the New Relic APIs.
func NewTestAPIClient ¶
NewTestAPIClient returns a test Client instance that is configured to communicate with a mock server.
func (*Client) Delete ¶ added in v0.17.0
func (c *Client) Delete(url string, queryParams interface{}, respBody interface{}, ) (*http.Response, error)
Delete represents an HTTP DELETE request to a New Relic API. The queryParams argument can be used to add query string parameters to the requested URL. The respBody argument will be unmarshaled from JSON in the response body to the type provided. If respBody is not nil and the response body cannot be unmarshaled to the type provided, an error will be returned.
func (*Client) Do ¶ added in v0.17.0
Do initiates an HTTP request as configured by the passed Request struct.
func (*Client) Get ¶ added in v0.17.0
func (c *Client) Get( url string, queryParams interface{}, respBody interface{}, ) (*http.Response, error)
Get represents an HTTP GET request to a New Relic API. The queryParams argument can be used to add query string parameters to the requested URL. The respBody argument will be unmarshaled from JSON in the response body to the type provided. If respBody is not nil and the response body cannot be unmarshaled to the type provided, an error will be returned.
func (*Client) GetBaseURL ¶ added in v0.17.0
GetBaseURL returns the BaseURL used by the client
func (*Client) Post ¶ added in v0.17.0
func (c *Client) Post( url string, queryParams interface{}, reqBody interface{}, respBody interface{}, ) (*http.Response, error)
Post represents an HTTP POST request to a New Relic API. The queryParams argument can be used to add query string parameters to the requested URL. The reqBody argument will be marshaled to JSON from the type provided and included in the request body. The respBody argument will be unmarshaled from JSON in the response body to the type provided. If respBody is not nil and the response body cannot be unmarshaled to the type provided, an error will be returned.
func (*Client) Put ¶ added in v0.17.0
func (c *Client) Put( url string, queryParams interface{}, reqBody interface{}, respBody interface{}, ) (*http.Response, error)
Put represents an HTTP PUT request to a New Relic API. The queryParams argument can be used to add query string parameters to the requested URL. The reqBody argument will be marshaled to JSON from the type provided and included in the request body. The respBody argument will be unmarshaled from JSON in the response body to the type provided. If respBody is not nil and the response body cannot be unmarshaled to the type provided, an error will be returned.
func (*Client) RawPost ¶ added in v0.17.0
func (c *Client) RawPost( url string, queryParams interface{}, reqBody interface{}, respBody interface{}, ) (*http.Response, error)
RawPost behaves the same as Post, but without marshaling the body into JSON before making the request. This is required at least in the case of Synthetics Labels, since the POST doesn't handle JSON.
func (*Client) SetAuthStrategy ¶ added in v0.17.0
func (c *Client) SetAuthStrategy(da RequestAuthorizer)
SetAuthStrategy is used to set the default auth strategy for this client which can be overridden per request
func (*Client) SetErrorValue ¶ added in v0.17.0
func (c *Client) SetErrorValue(v ErrorResponse) *Client
SetErrorValue is used to unmarshal error body responses in JSON format.
type DefaultErrorResponse ¶
type DefaultErrorResponse struct {
ErrorDetail ErrorDetail `json:"error"`
}
DefaultErrorResponse represents the default error response from New Relic.
func (*DefaultErrorResponse) Error ¶
func (e *DefaultErrorResponse) Error() string
func (*DefaultErrorResponse) New ¶ added in v0.13.0
func (e *DefaultErrorResponse) New() ErrorResponse
New creates a new instance of the DefaultErrorResponse struct.
type ErrorDetail ¶
ErrorDetail represents a New Relic response error detail.
type ErrorResponse ¶
type ErrorResponse interface { Error() string New() ErrorResponse }
ErrorResponse provides an interface for obtaining a single error message from an error response object.
type LinkHeaderPager ¶
type LinkHeaderPager struct{}
LinkHeaderPager represents a pagination implementation that adheres to RFC 5988.
type NerdGraphAuthorizer ¶ added in v0.11.0
type NerdGraphAuthorizer struct{}
NerdGraphAuthorizer authorizes calls to NerdGraph.
func (*NerdGraphAuthorizer) AuthorizeRequest ¶ added in v0.11.0
func (a *NerdGraphAuthorizer) AuthorizeRequest(r *Request, c *config.Config)
AuthorizeRequest is responsible for setting up auth for a request.
type Paging ¶
type Paging struct {
Next string
}
Paging represents the pagination context returned from the Pager implementation.
type PersonalAPIKeyCapableV2Authorizer ¶ added in v0.11.0
type PersonalAPIKeyCapableV2Authorizer struct{}
PersonalAPIKeyCapableV2Authorizer authorizes V2 endpoints that can use a personal API key.
func (*PersonalAPIKeyCapableV2Authorizer) AuthorizeRequest ¶ added in v0.11.0
func (a *PersonalAPIKeyCapableV2Authorizer) AuthorizeRequest(r *Request, c *config.Config)
AuthorizeRequest is responsible for setting up auth for a request.
type Request ¶ added in v0.13.0
type Request struct {
// contains filtered or unexported fields
}
Request represents a configurable HTTP request.
func NewRequest ¶ added in v0.17.0
func NewRequest(c Client, method string, url string, params interface{}, reqBody interface{}, value interface{}) (*Request, error)
NewRequest creates a new Request struct.
func (*Request) SetAuthStrategy ¶ added in v0.13.0
func (r *Request) SetAuthStrategy(ra RequestAuthorizer)
SetAuthStrategy sets the authentication strategy for the request.
func (*Request) SetServiceName ¶ added in v0.15.0
SetServiceName sets the service name for the request.
type RequestAuthorizer ¶ added in v0.11.0
RequestAuthorizer is an interface that allows customizatino of how a request is authorized.