uptimerobotapi

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2021 License: MIT Imports: 8 Imported by: 0

README

uptimerobotapi Build Status Go Reference

A Go client for UptimeRobot API.

Usage

See the full API reference on Go.dev.

Client initialization

All API requests are made through uptimerobotapi.Client. Make sure to include an API token:

package main
import (
	"os"
	
	"github.com/exileed/uptimerobotapi"
)
func main() {
	client := uptimerobotapi.NewClient(os.Getenv("UPTIMEROBOT_API_TOKEN"))
	...
}
Making API requests

Use an initialized client to make API requests:

package main
import (
	"os"
	
	"github.com/exileed/uptimerobotapi"
)
func main() {
	client := uptimerobotapi.NewClient(os.Getenv("UPTIMEROBOT_API_TOKEN"))
	
	accounts, err := client.Account.GetAccountDetails()
	if err != nil {
		panic(err)
	}
	...
}

Documentation

Index

Constants

View Source
const (
	StatFail = "fail"
	StatOk   = "ok"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResponse

type APIResponse struct {
	Stat string `json:"stat"`
}

APIResponse is a response from the Uptime robot API

type Account

type Account struct {
	Email              string `json:"email"`
	UserId             int    `json:"user_id"`
	FirstName          string `json:"firstname"`
	SmsCredits         int    `json:"sms_credits"`
	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"`
	TotalMonitorsCount int    `json:"total_monitors_count"`
}

Account returns basic information for the account making the API request,

type AccountResp

type AccountResp struct {
	Object
	Account Account `json:"account"`
}

type AccountService

type AccountService struct {
	// contains filtered or unexported fields
}

func (*AccountService) GetAccountDetails

func (ac *AccountService) GetAccountDetails() (*AccountResp, error)

GetAccountDetails Get https://uptimerobot.com/#getAccountDetailsWrap

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

type AlertContactEditResp

type AlertContactEditResp struct {
	Stat         string `json:"stat"`
	AlertContact struct {
		Id int `json:"id"`
	} `json:"alertcontact"`
}

type AlertContactResp

type AlertContactResp struct {
	Stat          string         `json:"stat"`
	Limit         int            `json:"limit"`
	Offset        int            `json:"offset"`
	Total         int            `json:"total"`
	AlertContacts []AlertContact `json:"alert_contacts"`
}

type AlertContactService

type AlertContactService struct {
	// contains filtered or unexported fields
}

func (*AlertContactService) DeleteAlertContact

func (ac *AlertContactService) DeleteAlertContact(id int) (*AlertContactEditResp, error)

DeleteAlertContact Get https://uptimerobot.com/#deleteAlertContactWrap

func (*AlertContactService) EditAlertContact

func (ac *AlertContactService) EditAlertContact(params EditAlertContactParams) (*AlertContactEditResp, error)

EditAlertContact Get https://uptimerobot.com/#editAlertContactWrap

func (*AlertContactService) GetAlertContacts

func (ac *AlertContactService) GetAlertContacts(params GetAlertContactsParams) (*AlertContactResp, error)

GetAlertContacts Get https://uptimerobot.com/#getAccountDetailsWrap The list of alert contacts

func (*AlertContactService) NewAlertContact

NewAlertContact Get https://uptimerobot.com/#newAlertContactWrap

type AlertContactSingle

type AlertContactSingle struct {
	Id int `json:"id"`
}

type AlertContactSingleResp

type AlertContactSingleResp struct {
	Stat         string             `json:"stat"`
	AlertContact AlertContactSingle `json:"alertcontact"`
}

type Client

type Client struct {

	// Token used to make authenticated API calls.
	Token string

	// Services used for talking to different parts of the UptimeRobot API.
	Account      AccountService
	AlertContact AlertContactService
	Monitor      MonitorService
	MWindow      MWindowService
	// contains filtered or unexported fields
}

A Client manages communication with the UptimeRobot API.

func NewClient

func NewClient(token string) *Client

NewClient returns a new UptimeRobot API client.

func NewClientWithConfig

func NewClientWithConfig(config *ClientConfig) *Client

NewClientWithConfig returns a new UptimeRobot API client.

type ClientConfig

type ClientConfig struct {
	// APIToken is the UptimeRobot API token to use for authentication.
	APIToken string

	// HTTPClient is your own HTTP client. The library will otherwise use a
	// parameter-less `&http.Client{}`, resulting in default everything.
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

ClientConfig specifies configuration with which to initialize a UptimeRobot API client.

type DeleteAlertContactWrapper

type DeleteAlertContactWrapper struct {
	Id int `url:"id"`
}

DeleteAlertContactWrapper are wrapper for DeleteAlertContact.

type DeleteMWindowWrapper

type DeleteMWindowWrapper struct {
	Id int `url:"id"`
}

type DeleteOrResetMonitorsWrappers

type DeleteOrResetMonitorsWrappers struct {
	Id int `url:"id"`
}

type EditAlertContactParams

type EditAlertContactParams struct {
	Id           int     `url:"id"`
	Value        *string `url:"value,omitempty"`
	FriendlyName *string `url:"friendly_name,omitempty"`
}

EditAlertContactParams are parameters for EditAlertContact.

type EditMWindowParams

type EditMWindowParams struct {
	FriendlyName    string  `url:"friendly_name"`
	Url             string  `url:"url"`
	SubType         *int    `url:"sub_type,omitempty"`
	Port            *int    `url:"port,omitempty"`
	KeywordType     *int    `url:"keyword_type,omitempty"`
	KeywordCaseType *int    `json:"keyword_case_type,omitempty"`
	KeywordValue    *string `url:"keyword_value,omitempty"`
	Interval        *int    `url:"interval,omitempty"`
	Timeout         *int    `url:"timeout,omitempty"`
	HttpUsername    *string `url:"http_username,omitempty"`
	HttpPassword    *string `url:"http_username,omitempty"`
	HttpAuthType    *int    `url:"http_username,omitempty"`
	HttpMethod      *int    `url:"http_method,omitempty"`
	AlertContacts   *string `url:"alert_contacts,omitempty"`
	MWindows        *string `url:"mwindows,omitempty"`
	//CustomHttpHeaders  *string `url:"custom_http_headers,omitempty"`
	//CustomHttpStatuses *string `url:"custom_http_statuses,omitempty"`
	IgnoreSSLErrors *bool `url:"ignore_ssl_errors,omitempty"`
}

type EditMonitorsParams

type EditMonitorsParams struct {
	FriendlyName    string  `url:"friendly_name"`
	Url             string  `url:"url"`
	SubType         *int    `url:"sub_type,omitempty"`
	Port            *int    `url:"port,omitempty"`
	KeywordType     *int    `url:"keyword_type,omitempty"`
	KeywordCaseType *int    `json:"keyword_case_type,omitempty"`
	KeywordValue    *string `url:"keyword_value,omitempty"`
	Interval        *int    `url:"interval,omitempty"`
	Timeout         *int    `url:"timeout,omitempty"`
	HttpUsername    *string `url:"http_username,omitempty"`
	HttpPassword    *string `url:"http_username,omitempty"`
	HttpAuthType    *int    `url:"http_username,omitempty"`
	HttpMethod      *int    `url:"http_method,omitempty"`
	AlertContacts   *string `url:"alert_contacts,omitempty"`
	MWindows        *string `url:"mwindows,omitempty"`
	//CustomHttpHeaders  *string `url:"custom_http_headers,omitempty"`
	//CustomHttpStatuses *string `url:"custom_http_statuses,omitempty"`
	IgnoreSSLErrors *bool `url:"ignore_ssl_errors,omitempty"`
}

type EditMonitorsWrappers

type EditMonitorsWrappers struct {
	Id int `url:"id"`
	EditMonitorsParams
}

type Error

type Error struct {
	Stat    string            `json:"stat"`
	Value   map[string]string `json:"value"`
	Message string
}

func (*Error) Error

func (e *Error) Error() string

Error returns the error message that came back with the API error.

type ErrorResponse

type ErrorResponse struct {
	Stat  string `json:"stat"`
	Error Error  `json:"error"`
}

type GetAlertContactsParams

type GetAlertContactsParams struct {
	Offset        *int    `url:"offset,omitempty"`
	Limit         *int    `url:"limit,omitempty"`
	AlertContacts *string `url:"alert_contacts,omitempty"`
}

GetAlertContactsParams are parameters for GetAlertContacts.

type GetMWindowParams

type GetMWindowParams struct {
	FriendlyName string `url:"friendly_name"`
	Type         string `url:"type"`
	Value        string `url:"value"`
	StartTime    string `url:"start_time"`
	Duration     string `url:"duration"`
}

type GetMonitorsParams

type GetMonitorsParams struct {
	Monitors string `url:"monitors,omitempty"`
	Types    string `url:"types,omitempty"`
	Statuses string `url:"statuses,omitempty"`
}

type MWindow

type MWindow struct {
	Id           int    `json:"id"`
	User         int    `json:"user"`
	Type         int    `json:"type"`
	FriendlyName string `json:"friendly_name"`
	StartTime    int    `json:"start_time"`
	Duration     int    `json:"duration"`
	Value        string `json:"value"`
	Status       int    `json:"status"`
}

type MWindowResp

type MWindowResp struct {
	Stat    string `json:"stat"`
	MWindow struct {
		Id     int  `json:"id"`
		Status *int `json:"status"`
	} `json:"mwindow"`
}

type MWindowService

type MWindowService struct {
	// contains filtered or unexported fields
}

func (*MWindowService) DeleteMWindow

func (ms *MWindowService) DeleteMWindow(id int) (*MWindowResp, error)

DeleteMWindow Get https://uptimerobot.com/#deleteMwindowWrap

func (*MWindowService) EditMWindow

func (ms *MWindowService) EditMWindow(params EditMWindowParams) (*MWindowResp, error)

EditMWindow Get https://uptimerobot.com/#editMWindow

func (*MWindowService) GetMWindows

func (ms *MWindowService) GetMWindows(params GetMWindowParams) (*MWindowsResp, error)

GetMWindows Get https://uptimerobot.com/#getMWindows

func (*MWindowService) NewMWindow

func (ms *MWindowService) NewMWindow(params NewMWindowParams) (*MWindowsResp, error)

NewMWindow Get https://uptimerobot.com/#newMWindow

type MWindowsResp

type MWindowsResp struct {
	Stat       string     `json:"stat"`
	Pagination Pagination `json:"pagination"`
	MWindows   []MWindow  `json:"mwindows"`
}

type Monitor

type Monitor struct {
	Id              int          `json:"id"`
	FriendlyName    string       `json:"friendly_name"`
	Url             string       `json:"url"`
	Type            int          `json:"type"`
	SubType         string       `json:"sub_type"`
	Port            string       `json:"port"`
	KeywordType     *int         `json:"keyword_type"`
	KeywordCaseType *int         `json:"keyword_case_type"`
	KeywordValue    string       `json:"keyword_value"`
	HttpUsername    string       `json:"http_username"`
	HttpPassword    string       `json:"http_password"`
	Interval        int          `json:"interval"`
	Timeout         int          `json:"timeout"`
	Status          int          `json:"status"`
	CreateDatetime  int          `json:"create_datetime"`
	MonitorGroup    int          `json:"monitor_group"`
	IsGroupMain     int          `json:"is_group_main"`
	Logs            []MonitorLog `json:"logs"`
}

type MonitorLog

type MonitorLog struct {
	Type     int `json:"type"`
	Datetime int `json:"datetime"`
	Duration int `json:"duration"`
}

type MonitorService

type MonitorService struct {
	// contains filtered or unexported fields
}

func (*MonitorService) DeleteMonitor

func (ms *MonitorService) DeleteMonitor(id int) (*MonitorsSingResp, error)

DeleteMonitor Get https://uptimerobot.com/#deleteMonitorWrap

func (*MonitorService) EditMonitor

func (ms *MonitorService) EditMonitor(id int, request EditMonitorsParams) (*MonitorsSingResp, error)

EditMonitor Get https://uptimerobot.com/#editMonitorWrap

func (*MonitorService) GetMonitors

func (ms *MonitorService) GetMonitors(params GetMonitorsParams) (*MonitorsResp, error)

GetMonitors Get https://uptimerobot.com/#getMonitorsWrap

func (*MonitorService) NewMonitor

func (ms *MonitorService) NewMonitor(params NewMonitorsParams) (*MonitorsSingResp, error)

NewMonitor Get https://uptimerobot.com/#newMonitorWrap

func (*MonitorService) ResetMonitor

func (ms *MonitorService) ResetMonitor(id int) (*MonitorsSingResp, error)

ResetMonitor Get https://uptimerobot.com/#resetMonitorWrap

type MonitorSingle

type MonitorSingle struct {
	Id     int  `json:"id"`
	Status *int `json:"status"`
}

type MonitorsResp

type MonitorsResp struct {
	Stat       string     `json:"stat"`
	Pagination Pagination `json:"pagination"`
	Monitors   []Monitor  `json:"monitors"`
}

type MonitorsSingResp

type MonitorsSingResp struct {
	Stat    string        `json:"stat"`
	Monitor MonitorSingle `json:"monitor"`
}

type NewAlertContactParams

type NewAlertContactParams struct {
	TypeContact  string `url:"type"`
	Value        string `url:"value"`
	FriendlyName string `url:"friendly_name"`
}

NewAlertContactParams are parameters for NewAlertContact.

type NewMWindowParams

type NewMWindowParams struct {
	FriendlyName string `url:"friendly_name"`
	Type         string `url:"type"`
	Value        string `url:"value"`
	StartTime    string `url:"start_time"`
	Duration     string `url:"duration"`
}

type NewMonitorsParams

type NewMonitorsParams struct {
	Type            int     `url:"type"`
	FriendlyName    string  `url:"friendly_name"`
	Url             string  `url:"url"`
	SubType         *int    `url:"sub_type,omitempty"`
	Port            *int    `url:"port,omitempty"`
	KeywordType     *int    `url:"keyword_type,omitempty"`
	KeywordCaseType *int    `json:"keyword_case_type,omitempty"`
	KeywordValue    *string `url:"keyword_value,omitempty"`
	Interval        *int    `url:"interval,omitempty"`
	Timeout         *int    `url:"timeout,omitempty"`
	HttpUsername    *string `url:"http_username,omitempty"`
	HttpPassword    *string `url:"http_username,omitempty"`
	HttpAuthType    *int    `url:"http_username,omitempty"`
	HttpMethod      *int    `url:"http_method,omitempty"`
	AlertContacts   *string `url:"alert_contacts,omitempty"`
	MWindows        *string `url:"mwindows,omitempty"`
	//CustomHttpHeaders  *string `url:"custom_http_headers,omitempty"`
	//CustomHttpStatuses *string `url:"custom_http_statuses,omitempty"`
	IgnoreSSLErrors *bool `url:"ignore_ssl_errors,omitempty"`
}

type Object

type Object struct {
	Stat string `json:"stat"`
}

Object contains the common fields of every resource in the Uptimerobot API.

type Pagination

type Pagination struct {
	Limit  int `json:"limit"`
	Offset int `json:"offset"`
	Total  int `json:"total"`
}

Jump to

Keyboard shortcuts

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