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 Recipient
- type RecipientItem
- type RecipientService
- type RecipientType
- type Requests
- type ResponseTime
- type SSL
- type StatusPage
- type StatusPageItem
- type StatusPageService
- func (s *StatusPageService) Add(data StatusPageItem) (StatusPage, *http.Response, error)
- func (s *StatusPageService) Get(token string) (StatusPage, *http.Response, error)
- func (s *StatusPageService) List() ([]StatusPage, *http.Response, error)
- func (s *StatusPageService) Remove(token string) (bool, *http.Response, error)
- func (s *StatusPageService) Update(token string, data StatusPageItem) (StatusPage, *http.Response, error)
- 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"`
Type string `json:"type,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"`
HttpVerb string `json:"http_verb,omitempty"`
HttpBody string `json:"http_body,omitempty"`
RecipientIDs []string `json:"recipients,omitempty"`
}
Check represents a check performed by Updown on a regular basis
type CheckItem ¶
type CheckItem struct {
// The type of check (http, https, icmp, tcp, tcps)
Type string `json:"type,omitempty"`
// The URL you want to monitor
URL string `json:"url,omitempty"`
// Interval in seconds (15, 30, 60, 120, 300, 600, 1800 or 3600)
Period int `json:"period,omitempty"`
// APDEX threshold in seconds (0.125, 0.25, 0.5, 1.0, 2.0, 4.0 or 8.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"`
// HTTP verb (GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS)
HttpVerb string `json:"http_verb,omitempty"`
// HTTP body for POST/PUT/PATCH requests
HttpBody string `json:"http_body,omitempty"`
// IDs of the recipients related to the check
RecipientIDs []string `json:"recipients,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
// SkipCache adds a cache-busting parameter to GET requests
// to bypass the API's 30-second cache
SkipCache bool
// Services used for communications with the API
Check CheckService
Downtime DowntimeService
Metric MetricService
Node NodeService
Webhook WebhookService
Recipient RecipientService
StatusPage StatusPageService
// 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 Recipient ¶
type Recipient struct {
ID string `json:"id,omitempty"`
Type RecipientType `json:"type,omitempty"`
Value string `json:"value,omitempty"`
Name string `json:"name,omitempty"`
}
Recipient represents a recipient from the API
type RecipientItem ¶
type RecipientItem struct {
Type RecipientType `json:"type,omitempty"`
Value string `json:"value,omitempty"`
Name string `json:"name,omitempty"`
}
RecipientItem represents a recipient to create
type RecipientService ¶
type RecipientService struct {
// contains filtered or unexported fields
}
RecipientService interacts with the recipients API
func (*RecipientService) Add ¶
func (s *RecipientService) Add(data RecipientItem) (Recipient, *http.Response, error)
Add creates a new recipient
type RecipientType ¶
type RecipientType string
RecipientType represents the type of a recipient
const ( RecipientTypeEmail RecipientType = "email" RecipientTypeSMS RecipientType = "sms" RecipientTypeTelegram RecipientType = "telegram" RecipientTypeSlack RecipientType = "slack" RecipientTypeWebhook RecipientType = "webhook" RecipientTypeZapier RecipientType = "zapier" )
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 StatusPage ¶
type StatusPage struct {
Token string `json:"token,omitempty"`
URL string `json:"url,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Visibility string `json:"visibility,omitempty"`
AccessKey string `json:"access_key,omitempty"`
Checks []string `json:"checks,omitempty"`
}
StatusPage represents a status page
type StatusPageItem ¶
type StatusPageItem struct {
// List of checks to show in the page (array of check tokens, order is respected)
Checks []string `json:"checks,omitempty"`
// Name of the status page
Name string `json:"name,omitempty"`
// Description text (displayed below the name, supports newlines and links)
Description string `json:"description,omitempty"`
// Page visibility: 'public', 'protected', or 'private'
Visibility string `json:"visibility,omitempty"`
// Access key for protected pages
AccessKey string `json:"access_key,omitempty"`
}
StatusPageItem represents a status page to create or update
type StatusPageService ¶
type StatusPageService struct {
// contains filtered or unexported fields
}
StatusPageService interacts with the status pages section of the API
func (*StatusPageService) Add ¶
func (s *StatusPageService) Add(data StatusPageItem) (StatusPage, *http.Response, error)
Add creates a new status page
func (*StatusPageService) Get ¶
func (s *StatusPageService) Get(token string) (StatusPage, *http.Response, error)
Get gets a single status page by its token from the list
func (*StatusPageService) List ¶
func (s *StatusPageService) List() ([]StatusPage, *http.Response, error)
List lists all status pages
func (*StatusPageService) Update ¶
func (s *StatusPageService) Update(token string, data StatusPageItem) (StatusPage, *http.Response, error)
Update updates a status page
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