uptimerobot

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2018 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func MonitorType(t string) int

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.

func (Account) String

func (a Account) String() string

String returns a pretty-printed version of the account details.

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 {
	Debug bool
	// contains filtered or unexported fields
}

Client represents an UptimeRobot client. Setting the Debug flag to true will cause the client to print out the API requests it would make, without actually making them.

func New

func New(apiKey string) Client

New takes an UptimeRobot API key and returns a Client.

func (*Client) DeleteMonitor added in v0.2.0

func (c *Client) DeleteMonitor(m Monitor) (Monitor, error)

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) GetAccountDetails

func (c *Client) GetAccountDetails() (Account, error)

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

func (c *Client) GetMonitors() (monitors []Monitor, err error)

GetMonitors returns a slice of Monitors representing the existing monitors.

func (*Client) GetMonitorsBySearch

func (c *Client) GetMonitorsBySearch(s string) (monitors []Monitor, err error)

GetMonitorsBySearch returns a slice of Monitors whose FriendlyName or URL match the search string.

func (*Client) MakeAPICall

func (c *Client) MakeAPICall(verb string, r *Response, params Params) error

MakeAPICall calls the UptimeRobot API with the specified verb and stores the returned data in the Response struct.

func (*Client) NewMonitor

func (c *Client) NewMonitor(m Monitor) (Monitor, error)

NewMonitor takes a Monitor and creates a new UptimeRobot monitor with the specified details. It returns a Monitor with the ID field set to the ID of the newly created monitor, or an error if the operation failed.

type Error

type Error map[string]interface{}

Error represents an API error.

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

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"`
	SubType      string `json:"sub_type"`
	// keyword_type is returned as either an integer or an empty string,
	// which Go doesn't allow: https://github.com/golang/go/issues/22182
	KeywordType   interface{} `json:"keyword_type"`
	KeywordValue  string      `json:"keyword_value"`
	AlertContacts []string    `json:"alert_contacts"`
}

Monitor represents an UptimeRobot monitor.

func (Monitor) FriendlyType

func (m Monitor) FriendlyType() string

FriendlyType returns a human-readable name for the monitor type.

func (Monitor) String

func (m Monitor) String() string

String returns a pretty-printed version of the monitor.

type Params

type Params map[string]string

Params holds optional parameters for API calls

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"`
}

Response represents an API response.

Jump to

Keyboard shortcuts

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