Documentation ¶
Index ¶
- Constants
- type Account
- type AlertContact
- type Client
- func (c *Client) AllAlertContacts() ([]AlertContact, error)
- func (c *Client) AllMonitors() ([]Monitor, error)
- func (c *Client) CreateMonitor(m Monitor) (int64, error)
- func (c *Client) DeleteMonitor(ID int64) error
- func (c *Client) EnsureMonitor(m Monitor) (int64, error)
- func (c *Client) GetAccountDetails() (Account, error)
- func (c *Client) GetMonitor(ID int64) (Monitor, error)
- func (c *Client) MakeAPICall(verb string, r *Response, data []byte) error
- func (c *Client) PauseMonitor(m Monitor) (Monitor, error)
- func (c *Client) SearchMonitors(s string) ([]Monitor, error)
- func (c *Client) StartMonitor(m Monitor) (Monitor, error)
- type Error
- type Monitor
- type Pagination
- type Response
Constants ¶
const KeywordExists = 1
KeywordExists represents a keyword check which is critical if the keyword is found.
const KeywordNotExists = 2
KeywordNotExists represents a keyword check which is critical if the keyword is not found.
const StatusDown = 9
StatusDown is the status value indicating that the monitor is currently down.
const StatusMaybeDown = 8
StatusMaybeDown is the status value indicating that the monitor may be down, but this has not yet been confirmed.
const StatusPaused = 0
StatusPaused is the status value which sets a monitor to paused status when calling EditMonitor.
const StatusResumed = 1
StatusResumed is the status value which sets a monitor to resumed (unpaused) status when calling EditMonitor.
const StatusUnknown = 1
StatusUnknown is the status value indicating that the monitor status is currently unknown.
const StatusUp = 2
StatusUp is the status value indicating that the monitor is currently up.
const SubTypeCustomPort = 99
SubTypeCustomPort represents a custom port monitor subtype.
const SubTypeFTP = 3
SubTypeFTP represents an FTP monitor subtype.
const SubTypeHTTP = 1
SubTypeHTTP represents an HTTP monitor subtype.
const SubTypeHTTPS = 2
SubTypeHTTPS represents an HTTPS monitor subtype.
const SubTypeIMAP = 6
SubTypeIMAP represents an IMAP monitor subtype.
const SubTypePOP3 = 5
SubTypePOP3 represents a POP3 monitor subtype.
const SubTypeSMTP = 4
SubTypeSMTP represents an SMTP monitor subtype.
const TypeHTTP = 1
TypeHTTP represents an HTTP monitor.
const TypeKeyword = 2
TypeKeyword represents a keyword monitor.
const TypePing = 3
TypePing represents a ping monitor.
const TypePort = 4
TypePort represents a port monitor.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { Email string `json:"email"` MonitorLimit int `json:"monitor_limit"` MonitorInterval int `json:"monitor_interval"` UpMonitors int `json:"up_monitors"` DownMonitors int `json:"down_monitors"` PausedMonitors int `json:"paused_monitors"` }
Account represents an Uptime Robot account.
type AlertContact ¶
type AlertContact struct { ID string `json:"id"` FriendlyName string `json:"friendly_name"` Type int `json:"type"` Status int `json:"status"` Value string `json:"value"` }
AlertContact represents an alert contact.
func (AlertContact) String ¶
func (a AlertContact) String() string
String returns a pretty-printed version of the alert contact.
type Client ¶
type Client struct { HTTPClient *http.Client URL string Debug io.Writer // contains filtered or unexported fields }
Client represents an Uptime Robot client.
The HTTPClient field holds a pointer to the HTTP client which will be used to make the requests; the default client is configured with a timeout of 10 seconds. If you would like to use a client with different settings, create an http.Client with the parameters you want, and assign it to the HTTPClient field.
If the Debug field is set to any io.Writer (for example os.Stdout), then the client will dump all HTTP requests and responses to the supplied writer.
The URL field determines where requests will be sent; by default this is 'https://api.uptimerobot.com', but if you want to use an alternate or test server URL, set it here. For example, if you are writing tests which use the Uptime Robot client and you do not want it to make network calls, create an httptest.NewTLSServer and set the URL field to the test server's URL.
func New ¶
New takes an Uptime Robot API key and returns a Client. See the documentation for the Client type for configuration options.
func (*Client) AllAlertContacts ¶ added in v0.11.0
func (c *Client) AllAlertContacts() ([]AlertContact, error)
AllAlertContacts returns all the AlertContacts associated with the account.
func (*Client) AllMonitors ¶ added in v0.11.0
AllMonitors returns a slice of Monitors representing the monitors currently configured in your Uptime Robot account.
func (*Client) CreateMonitor ¶ added in v0.11.0
CreateMonitor takes a Monitor and creates a new Uptime Robot monitor with the specified details. It returns the ID of the newly created monitor, or an error if the operation failed.
func (*Client) DeleteMonitor ¶ added in v0.2.0
DeleteMonitor takes a monitor ID and deletes the corresponding monitor. It returns an error if the operation failed.
func (*Client) EnsureMonitor ¶ added in v0.6.0
EnsureMonitor takes a Monitor and creates a new Uptime Robot monitor with the specified details, if a monitor for the same URL does not already exist. It returns the ID of the newly created monitor or the existing monitor if it already existed, or an error if the operation failed.
func (*Client) GetAccountDetails ¶
GetAccountDetails returns an Account representing the account details.
func (*Client) GetMonitor ¶ added in v0.11.0
GetMonitor takes an int64 representing the ID number of an existing monitor, and returns the corresponding Monitor, or an error if the operation failed.
func (*Client) MakeAPICall ¶
MakeAPICall calls the Uptime Robot API with the specified verb and data, and stores the returned data in the Response struct.
func (*Client) PauseMonitor ¶ added in v0.9.0
PauseMonitor takes a Monitor with the ID field set, and attempts to set the monitor status to paused via the API. It returns a Monitor with the ID field set to the ID of the monitor, or an error if the operation failed.
func (*Client) SearchMonitors ¶ added in v0.11.0
SearchMonitors returns a slice of Monitors whose FriendlyName or URL match the search string.
func (*Client) StartMonitor ¶ added in v0.9.0
StartMonitor takes a Monitor with the ID field set, and attempts to set the monitor status to resumed (unpaused) via the API. It returns a Monitor with the ID field set to the ID of the monitor, or an error if the operation failed.
type Monitor ¶
type Monitor struct { ID int64 `json:"id,omitempty"` FriendlyName string `json:"friendly_name"` URL string `json:"url"` Type int `json:"type"` SubType int `json:"sub_type,omitempty"` KeywordType int `json:"keyword_type,omitempty"` Port int `json:"port"` KeywordValue string `json:"keyword_value,omitempty"` AlertContacts []string `json:"alert_contacts,omitempty"` Status int `json:"status,omitempty"` }
Monitor represents an Uptime Robot monitor.
func (Monitor) FriendlyKeywordType ¶ added in v0.8.0
FriendlyKeywordType returns a human-readable name for the monitor keyword type.
func (Monitor) FriendlyStatus ¶ added in v0.13.0
func (Monitor) FriendlySubType ¶ added in v0.8.0
FriendlySubType returns a human-readable name for the monitor subtype, including the port number.
func (Monitor) FriendlyType ¶
FriendlyType returns a human-readable name for the monitor type.
func (Monitor) MarshalJSON ¶ added in v0.11.0
MarshalJSON converts a Monitor struct into its string JSON representation, handling the special encoding of the alert_contacts field.
func (*Monitor) UnmarshalJSON ¶ added in v0.11.0
UnmarshalJSON converts a JSON monitor representation to a Monitor struct, handling the Uptime Robot API's invalid encoding of integer zeros as empty strings.
type Pagination ¶ added in v0.12.0
type Pagination struct { Offset int `json:"offset"` Limit int `json:"limit"` Total int `json:"total"` }
Pagination represents the pagination info of an API response.
type Response ¶
type Response struct { Stat string `json:"stat"` Account Account `json:"account"` Monitors []Monitor `json:"monitors"` Monitor Monitor `json:"monitor"` AlertContacts []AlertContact `json:"alert_contacts"` Error Error `json:"error,omitempty"` Pagination Pagination `json:"pagination"` }
Response represents an API response.