nodeping

package
v0.0.0-...-08e2436 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2020 License: BSD-3-Clause, CC-BY-3.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.

The error type will be *RateLimitError for rate limit exceeded errors, and *TwoFactorAuthError for two-factor authentication errors.

func Int

func Int(v int) *int

Int is a helper routine that allocates a new int value to store v and returns a pointer to it.

func String

func String(v string) *string

String is a helper routine that allocates a new string value to store v and returns a pointer to it.

Types

type BasicAuthTransport

type BasicAuthTransport struct {
	Token string // Nodeping API Token

	// Transport is the underlying HTTP transport to use when making requests.
	// It will default to http.DefaultTransport if nil.
	Transport http.RoundTripper
}

BasicAuthTransport is an http.RoundTripper that authenticates all requests using HTTP Basic Authentication with the provided API token.

func (*BasicAuthTransport) Client

func (t *BasicAuthTransport) Client() *http.Client

Client returns an *http.Client that makes requests that are authenticated using HTTP Basic Authentication.

func (*BasicAuthTransport) RoundTrip

func (t *BasicAuthTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the RoundTripper interface.

type Check

type Check struct {
	Id     string `json:"_id"`
	Enable string `json:"enable"`
	Label  string `json:"label"`
	State  int64  `json:"state"`
}

type CheckMap

type CheckMap map[string]*Check

type ChecksService

type ChecksService service

func (*ChecksService) Get

func (s *ChecksService) Get(id string) (*Check, *Response, error)

func (*ChecksService) List

func (s *ChecksService) List() ([]*Check, *Response, error)

type Client

type Client struct {

	// Base URL for API requests.  Defaults to the public GitHub API, but can be
	// set to a domain endpoint to use with GitHub Enterprise.  BaseURL should
	// always be specified with a trailing slash.
	BaseURL *url.URL

	// User agent used when communicating with the GitHub API.
	UserAgent string

	// Services used for talking to different parts of the Nodeping API.
	Checks *ChecksService
	// contains filtered or unexported fields
}

A Client manages communication with the Nodeping API.

func NewClient

func NewClient(token string) *Client

NewClient returns a new Nodeping API client.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it. If rate limit is exceeded and reset time is in the future, Do returns *RateLimitError immediately without making a network API call.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response // HTTP response that caused this error
	Message  string         `json:"error"` // error message
}

An ErrorResponse reports one or more errors caused by an API request.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type Response

type Response struct {
	*http.Response
}

Response is a Nodeping API response. This wraps the standard http.Response returned from Nodeping and provides convenient access to... things.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL