Documentation ¶
Index ¶
- Variables
- func MonitorType(t string) int
- type Account
- type AlertContact
- type Client
- func (c *Client) DeleteMonitor(m Monitor) (Monitor, error)
- func (c *Client) EnsureMonitor(m Monitor) (Monitor, error)
- func (c *Client) GetAccountDetails() (Account, error)
- func (c *Client) GetAlertContacts() (contacts []AlertContact, err error)
- func (c *Client) GetMonitors() (monitors []Monitor, err error)
- func (c *Client) GetMonitorsBySearch(s string) (monitors []Monitor, err error)
- func (c *Client) MakeAPICall(verb string, r *Response, params Params) error
- func (c *Client) NewMonitor(m Monitor) (Monitor, error)
- type Error
- type HTTPClient
- type Monitor
- type Params
- type Response
Constants ¶
This section is empty.
Variables ¶
var MonitorSubTypes = map[float64]string{
1: "HTTP (80)",
2: "HTTPS (443)",
3: "FTP (21)",
4: "SMTP (25)",
5: "POP3 (110)",
6: "IMAP (143)",
99: "Custom Port",
}
MonitorSubTypes maps a numeric monitor subtype to the name of the monitor subtype.
var MonitorTypes = map[int]string{
1: "HTTP",
2: "keyword",
3: "ping",
4: "port",
}
MonitorTypes maps an integer monitor type to the name of the monitor type.
Functions ¶
func MonitorType ¶
MonitorType returns the monitor type number associated with the given type name.
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 UptimeRobot 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 ¶
Client represents an UptimeRobot client. If the Debug field is set to an io.Writer, then the client will dump API requests to it instead of calling the real API.
func (*Client) DeleteMonitor ¶ added in v0.2.0
DeleteMonitor takes a Monitor with the ID field set, and deletes the corresponding monitor. It returns a Monitor with the ID field set to the ID of the deleted monitor, or an error if the operation failed.
func (*Client) EnsureMonitor ¶ added in v0.6.0
EnsureMonitor takes a Monitor and creates a new UptimeRobot monitor with the specified details, if a monitor for the same URL does not already exist. It returns a Monitor with the ID field set to 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) GetAlertContacts ¶
func (c *Client) GetAlertContacts() (contacts []AlertContact, err error)
GetAlertContacts returns all the AlertContacts associated with the account.
func (*Client) GetMonitors ¶
GetMonitors returns a slice of Monitors representing the existing monitors.
func (*Client) GetMonitorsBySearch ¶
GetMonitorsBySearch returns a slice of Monitors whose FriendlyName or URL match the search string.
func (*Client) MakeAPICall ¶
MakeAPICall calls the UptimeRobot API with the specified verb and stores the returned data in the Response struct.
type HTTPClient ¶
HTTPClient represents an http.Client, or a mock equivalent.
type Monitor ¶
type Monitor struct { ID int64 `json:"id"` FriendlyName string `json:"friendly_name"` URL string `json:"url"` Type int `json:"type"` // keyword_type, sub_type, and port are returned as either an integer // (if set) or an empty string (if unset), which Go's JSON library won't // parse for integer fields: https://github.com/golang/go/issues/22182 SubType interface{} `json:"sub_type"` KeywordType interface{} `json:"keyword_type"` Port interface{} `json:"port"` KeywordValue string `json:"keyword_value"` AlertContacts []string `json:"alert_contacts"` }
Monitor represents an UptimeRobot monitor.
func (Monitor) FriendlyKeywordType ¶ added in v0.8.0
FriendlyKeywordType returns a human-readable name for the monitor keyword type.
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.