Documentation ¶
Index ¶
- Variables
- func CheckResponse(r *http.Response) error
- type Cache
- type Check
- type CheckItem
- type CheckService
- func (s *CheckService) Add(data CheckItem) (Check, *http.Response, error)
- func (s *CheckService) Get(token string) (Check, *http.Response, error)
- func (s *CheckService) List() ([]Check, *http.Response, error)
- func (s *CheckService) Remove(token string) (bool, *http.Response, error)
- func (s *CheckService) TokenForAlias(name string) (string, error)
- func (s *CheckService) Update(token string, data CheckItem) (Check, *http.Response, error)
- type Client
- type Downtime
- type DowntimeService
- type ErrorResponse
- type Host
- type IPs
- type MemoryCache
- type MetricItem
- type MetricService
- type Metrics
- type NodeDetails
- type NodeService
- type Nodes
- type Requests
- type ResponseTime
- type SSL
- type Timings
- type Webhook
- type WebhookService
Constants ¶
This section is empty.
Variables ¶
var ErrTokenNotFound = errors.New("Could not determine a token for the given name")
ErrTokenNotFound indicates that we cannot find a token for the given name
Functions ¶
func CheckResponse ¶
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.
Types ¶
type Cache ¶
type Cache interface { Has(key string) bool Put(key, value string) Get(key string) (has bool, value string) }
Cache lets you cache indefinitely values
type Check ¶
type Check struct { Token string `json:"token,omitempty"` URL string `json:"url,omitempty"` Alias string `json:"alias,omitempty"` LastStatus int `json:"last_status,omitempty"` Uptime float64 `json:"uptime,omitempty"` Down bool `json:"down"` DownSince string `json:"down_since,omitempty"` Error string `json:"error,omitempty"` Period int `json:"period,omitempty"` Apdex float64 `json:"apdex_t,omitempty"` Enabled bool `json:"enabled"` Published bool `json:"published"` LastCheckAt string `json:"last_check_at,omitempty"` NextCheckAt string `json:"next_check_at,omitempty"` FaviconURL string `json:"favicon_url,omitempty"` SSL SSL `json:"ssl,omitempty"` StringMatch string `json:"string_match,omitempty"` MuteUntil string `json:"mute_until,omitempty"` DisabledLocations []string `json:"disabled_locations,omitempty"` CustomHeaders map[string]string `json:"custom_headers,omitempty"` }
Check represents a check performed by Updown on a regular basis
type CheckItem ¶
type CheckItem struct { // The URL you want to monitor URL string `json:"url,omitempty"` // Interval in seconds (30, 60, 120, 300 or 600) Period int `json:"period,omitempty"` // APDEX threshold in seconds (0.125, 0.25, 0.5 or 1.0) Apdex float64 `json:"apdex_t,omitempty"` // Is the check enabled Enabled bool `json:"enabled"` // Shall the status page be public Published bool `json:"published"` // Human readable name Alias string `json:"alias,omitempty"` // Search for this string in the page StringMatch string `json:"string_match,omitempty"` // Mute notifications until given time, accepts a time, 'recovery' or 'forever' MuteUntil string `json:"mute_until,omitempty"` // Disabled monitoring locations. It's an array of abbreviated location names DisabledLocations []string `json:"disabled_locations,omitempty"` // The HTTP headers you want in updown requests CustomHeaders map[string]string `json:"custom_headers,omitempty"` }
CheckItem represents a new check you want to be performed by Updown
type CheckService ¶
type CheckService struct {
// contains filtered or unexported fields
}
CheckService interacts with the checks section of the API
func (*CheckService) List ¶
func (s *CheckService) List() ([]Check, *http.Response, error)
List lists all the checks
func (*CheckService) TokenForAlias ¶
func (s *CheckService) TokenForAlias(name string) (string, error)
TokenForAlias finds the Updown token for a check's alias
type Client ¶
type Client struct { // Base URL for API requests BaseURL *url.URL // User agent for client UserAgent string // APIKey to use for the API APIKey string // Services used for communications with the API Check CheckService Downtime DowntimeService Metric MetricService Node NodeService Webhook WebhookService // contains filtered or unexported fields }
Client manages communication the API
func (*Client) Do ¶
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 will be written to v, without attempting to decode it.
func (*Client) NewRequest ¶
NewRequest creates an API request. A relative URL can be provided in urlStr, which will be resolved 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 in as the request body.
type Downtime ¶
type Downtime struct { Error string `json:"error,omitempty"` StartedAt string `json:"started_at,omitempty"` EndedAt string `json:"ended_at,omitempty"` Duration int `json:"duration,omitempty"` }
Downtime represents a downtime period for a check
type DowntimeService ¶
type DowntimeService struct {
// contains filtered or unexported fields
}
DowntimeService interacts with the downtimes section of the API
type ErrorResponse ¶
type ErrorResponse struct { // HTTP response that caused this error Response *http.Response // Error message Message string }
An ErrorResponse reports the error caused by an API request
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type Host ¶
type Host struct { IP string `json:"ip,omitempty"` City string `json:"city,omitempty"` Country string `json:"country,omitempty"` CountryCode string `json:"country_code,omitempty"` }
Host represents the host where the check was made
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache is a cache that works in memory
func (*MemoryCache) Get ¶
func (c *MemoryCache) Get(key string) (has bool, value string)
Get gets a value from the cache by its key and tells if it was found or not
func (*MemoryCache) Has ¶
func (c *MemoryCache) Has(key string) bool
Has determines if we can find in the cache a key for the given value
func (*MemoryCache) Put ¶
func (c *MemoryCache) Put(key, value string)
Put associates a key to a given value in the cache
type MetricItem ¶
type MetricItem struct { Apdex float64 `json:"apdex,omitempty"` Requests Requests `json:"requests,omitempty"` Timings Timings `json:"timings,omitempty"` Host Host `json:"host,omitempty"` }
MetricItem is basically the core metric
type MetricService ¶
type MetricService struct {
// contains filtered or unexported fields
}
MetricService interacts with the metrics section of the API
type NodeDetails ¶
type NodeDetails struct { IP string `json:"ip,omitempty"` IP6 string `json:"ip6,omitempty"` City string `json:"city,omitempty"` Country string `json:"country,omitempty"` CountryCode string `json:"country_code,omitempty"` }
NodeDetails gives information about a node
type NodeService ¶
type NodeService struct {
// contains filtered or unexported fields
}
NodeService interacts with the nodes section of the API
func (*NodeService) List ¶
func (s *NodeService) List() (Nodes, *http.Response, error)
List gets the nodes performing checks
type Requests ¶
type Requests struct { Samples int `json:"samples,omitempty"` Failures int `json:"failures,omitempty"` Satisfied int `json:"satisfied,omitempty"` Tolerated int `json:"tolerated,omitempty"` ResponseTime ResponseTime `json:"by_response_time,omitempty"` }
Requests gives statistics about requests made to check the status
type ResponseTime ¶
type ResponseTime struct { Under125 int `json:"under125,omitempty"` Under250 int `json:"under250,omitempty"` Under500 int `json:"under500,omitempty"` Under1000 int `json:"under1000,omitempty"` Under2000 int `json:"under2000,omitempty"` Under4000 int `json:"under4000,omitempty"` }
ResponseTime represents the response times in milliseconds
type SSL ¶
type SSL struct { TestedAt string `json:"tested_at,omitempty"` Valid bool `json:"valid,omitempty"` Error string `json:"error,omitempty"` }
SSL represents the SSL section of a check
type Timings ¶
type Timings struct { Redirect int `json:"redirect,omitempty"` NameLookup int `json:"namelookup,omitempty"` Connection int `json:"connection,omitempty"` Handshake int `json:"handshake,omitempty"` Response int `json:"response,omitempty"` Total int `json:"total,omitempty"` }
Timings represents the amount of time taken by each part of the connection
type WebhookService ¶
type WebhookService struct {
// contains filtered or unexported fields
}
WebhookService interacts with the webhooks section of the API