Documentation
¶
Index ¶
- func Int(v int) *int
- func Int64(v int64) *int64
- type Alert
- type Check
- type CheckEscalation
- type CheckListOptions
- type CheckListResponse
- type CheckResponse
- type CheckService
- func (s *CheckService) Create(ctx context.Context, check *Check) (*Check, *http.Response, error)
- func (s *CheckService) Delete(ctx context.Context, pk int) (*http.Response, error)
- func (s *CheckService) Get(ctx context.Context, pk int) (*Check, *http.Response, error)
- func (s *CheckService) List(ctx context.Context, opt *CheckListOptions) ([]*Check, *http.Response, error)
- func (s *CheckService) ListAll(ctx context.Context, opt *CheckListOptions) ([]*Check, error)
- func (s *CheckService) Stats(ctx context.Context, pk int, opt *CheckStatsOptions) (*CheckStatsResponse, *http.Response, error)
- func (s *CheckService) Update(ctx context.Context, check *Check) (*Check, *http.Response, error)
- type CheckStats
- type CheckStatsOptions
- type CheckStatsResponse
- type CheckStatsTotals
- type Client
- type Config
- type Error
- type Integration
- type IntegrationListOptions
- type IntegrationListResponse
- type IntegrationResponse
- type IntegrationService
- func (s *IntegrationService) Create(ctx context.Context, integration *Integration) (*Integration, *http.Response, error)
- func (s *IntegrationService) Delete(ctx context.Context, pk int) (*http.Response, error)
- func (s *IntegrationService) Get(ctx context.Context, pk int) (*Integration, *http.Response, error)
- func (s *IntegrationService) List(ctx context.Context, opt *IntegrationListOptions) ([]*Integration, *http.Response, error)
- func (s *IntegrationService) ListAll(ctx context.Context, opt *IntegrationListOptions) ([]*Integration, error)
- func (s *IntegrationService) Update(ctx context.Context, integration *Integration) (*Integration, *http.Response, error)
- type Outage
- type OutageListOptions
- type OutageListResponse
- type OutageService
- type Tag
- type TagListOptions
- type TagListResponse
- type TagResponse
- type TagService
- func (s *TagService) Create(ctx context.Context, tag *Tag) (*Tag, *http.Response, error)
- func (s *TagService) Delete(ctx context.Context, pk int) (*http.Response, error)
- func (s *TagService) Get(ctx context.Context, pk int) (*Tag, *http.Response, error)
- func (s *TagService) List(ctx context.Context, opt *TagListOptions) ([]*Tag, *http.Response, error)
- func (s *TagService) Update(ctx context.Context, tag *Tag) (*Tag, *http.Response, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Alert ¶
type Alert struct { PK int64 `json:"pk,omitempty"` URL string `json:"url,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` MonitoringServerName string `json:"monitoring_server_name,omitempty"` MonitoringServerIPv4 *net.IP `json:"monitoring_server_ipv4,omitempty"` MonitoringServerIPv6 *net.IP `json:"monitoring_server_ipv6,omitempty"` Location string `json:"location,omitempty"` Output string `json:"output,omitempty"` }
Alert represents an alert generated during an outage.
type Check ¶
type Check struct { PK int `json:"pk,omitempty"` CheckType string `json:"check_type,omitempty"` URL string `json:"url,omitempty"` Name string `json:"name,omitempty"` Address string `json:"msp_address,omitempty"` Port int `json:"msp_port,omitempty"` IPVersion string `json:"msp_use_ip_version,omitempty"` Interval int `json:"msp_interval,omitempty"` Locations []string `json:"locations,omitempty"` Sensitivity int `json:"msp_sensitivity,omitempty"` Threshold int `json:"msp_threshold,omitempty"` Headers string `json:"msp_headers,omitempty"` Username string `json:"msp_username,omitempty"` Password string `json:"msp_password,omitempty"` SendString string `json:"msp_send_string,omitempty"` ExpectString string `json:"msp_expect_string,omitempty"` ContactGroups []string `json:"contact_groups,omitempty"` Tags []string `json:"tags,omitempty"` Escalations []CheckEscalation `json:"escalations,omitempty"` Notes string `json:"msp_notes,omitempty"` IncludeInGlobalMetrics bool `json:"msp_include_in_global_metrics,omitempty"` IsPaused bool `json:"is_paused,omitempty"` IsUnderMaintenance bool `json:"is_under_maintenance,omitempty"` StateIsUp bool `json:"state_is_up,omitempty"` // For DNS checks DNSServer string `json:"msp_dns_server,omitempty"` DNSRecordType string `json:"msp_dns_record_type,omitempty"` // For IMAP, POP checks Encryption string `json:"msp_encrytion,omitempty"` // For Transaction checks Script string `json:"msp_script,omitempty"` // For SSL checks Protocol string `json:"msp_protocol,omitempty"` // For Heartbeat checks HeartbeatURL string `json:"heartbeat_url,omitempty"` }
Check represents a check in Uptime.com.
type CheckEscalation ¶ added in v1.4.1
type CheckListOptions ¶
type CheckListOptions struct { Page int `url:"page,omitempty"` PageSize int `url:"page_size,omitempty"` Search string `url:"search,omitempty"` Ordering string `url:"ordering,omitempty"` MonitoringServiceType string `url:"monitoring_service_type,omitempty"` IsPaused bool `url:"is_paused,omitempty"` StateIsUp bool `url:"state_is_up,omitempty"` Tag []string `url:"tag,omitempty"` }
CheckListOptions specifies the optional parameters to the CheckService.List method.
type CheckListResponse ¶
type CheckResponse ¶
type CheckService ¶
type CheckService service
func (*CheckService) Create ¶
Create a new check in Uptime.com based on the provided Check.
Example ¶
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) defer cancel() cfg := uptime.Config{ Token: os.Getenv("UPTIME_TOKEN"), RateMilliseconds: 2000, } api, err := uptime.NewClient(&cfg) if err != nil { panic(err) } _, res, err := api.Checks.Create(ctx, &uptime.Check{ CheckType: "HTTP", Address: "https://uptime.com", Interval: 1, Threshold: 15, Locations: []string{"US East", "US West"}, ContactGroups: []string{"examples"}, // must exist Tags: []string{"examples"}, // must exist }) if err != nil { panic(err) } fmt.Println(res.Status)
Output: 200 OK
func (*CheckService) Delete ¶
Delete a check.
Example ¶
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) defer cancel() cfg := uptime.Config{ Token: os.Getenv("UPTIME_TOKEN"), RateMilliseconds: 2000, } api, err := uptime.NewClient(&cfg) if err != nil { panic(err) } checks, res, err := api.Checks.List(ctx, &uptime.CheckListOptions{ Tag: []string{"examples"}, }) if err != nil { panic(err) } fmt.Println(res.Status) for _, check := range checks { res, err := api.Checks.Delete(ctx, check.PK) if err != nil { panic(err) } fmt.Println(res.Status) }
Output: 200 OK 200 OK
func (*CheckService) List ¶
func (s *CheckService) List(ctx context.Context, opt *CheckListOptions) ([]*Check, *http.Response, error)
func (*CheckService) ListAll ¶
func (s *CheckService) ListAll(ctx context.Context, opt *CheckListOptions) ([]*Check, error)
func (*CheckService) Stats ¶
func (s *CheckService) Stats(ctx context.Context, pk int, opt *CheckStatsOptions) (*CheckStatsResponse, *http.Response, error)
Stats gets statistics on the specified check.
type CheckStats ¶
type CheckStats struct { Date string `json:"date"` Outages int `json:"outages"` DowntimeSecs int `json:"downtime_secs"` }
CheckStats represents the check statistics for a given day.
type CheckStatsOptions ¶
type CheckStatsOptions struct { StartDate string EndDate string Location string LocationsResponseTimes bool IncludeAlerts bool Download bool PDF bool }
CheckStatsOptions specifies the parameters to the CheckService.Stats method.
type CheckStatsResponse ¶
type CheckStatsResponse struct { StartDate string `json:"start_date"` EndDate string `json:"end_date"` Statistics []*CheckStats `json:"statistics"` Totals CheckStatsTotals `json:"totals"` }
CheckStatsResponse represents the API's response to a Stats query.
type CheckStatsTotals ¶
type CheckStatsTotals struct { Outages int `json:"outages,omitempty"` DowntimeSecs int64 `json:"downtime_secs,omitempty"` }
CheckStatsTotals represents the 'totals' section of check statistics in Uptime.com.
type Client ¶
type Client struct { // Base URL for API requests. BaseURL should always be specified // with a trailing slash. BaseURL *url.URL UserAgent string Config *Config Checks *CheckService Outages *OutageService Tags *TagService Integrations *IntegrationService // contains filtered or unexported fields }
Client manages communication with the Uptime.com API.
type Config ¶
type Config struct { BaseURL string HTTPClient *http.Client Token string UserAgent string RateMilliseconds int }
Config represents the configuration for an Client.com client
type Error ¶
type Integration ¶
type Integration struct { PK int `json:"pk,omitempty"` URL string `json:"url,omitempty"` Name string `json:"name,omitempty"` Module string `json:"module,omitempty"` ContactGroups []string `json:"contact_groups,omitempty"` APIEndpoint string `json:"api_endpoint,omitempty"` APIKey string `json:"api_key,omitempty"` Teams string `json:"teams,omitempty"` Tags string `json:"tags,omitempty"` AutoResolve bool `json:"autoresolve,omitempty"` }
Integration represents an integration in Uptime.com.
type IntegrationListOptions ¶
type IntegrationListResponse ¶
type IntegrationListResponse struct { Count int `json:"count,omitempty"` Next string `json:"next,omitempty"` Previous string `json:"previous,omitempty"` Results []*Integration `json:"results,omitempty"` }
type IntegrationResponse ¶
type IntegrationResponse struct { Messages map[string]interface{} `json:"messages,omitempty"` Results Integration `json:"results,omitempty"` }
type IntegrationService ¶
type IntegrationService service
func (*IntegrationService) Create ¶
func (s *IntegrationService) Create(ctx context.Context, integration *Integration) (*Integration, *http.Response, error)
Create a new integration in Uptime.com based on the provided Integration.
func (*IntegrationService) Get ¶
func (s *IntegrationService) Get(ctx context.Context, pk int) (*Integration, *http.Response, error)
func (*IntegrationService) List ¶
func (s *IntegrationService) List(ctx context.Context, opt *IntegrationListOptions) ([]*Integration, *http.Response, error)
func (*IntegrationService) ListAll ¶
func (s *IntegrationService) ListAll(ctx context.Context, opt *IntegrationListOptions) ([]*Integration, error)
func (*IntegrationService) Update ¶
func (s *IntegrationService) Update(ctx context.Context, integration *Integration) (*Integration, *http.Response, error)
Update an integration.
type Outage ¶
type Outage struct { PK int64 `json:"pk,omitempty"` URL string `json:"url,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` ResolvedAt time.Time `json:"resolved_at,omitempty"` DurationSecs int64 `json:"duration_secs,omitempty"` IgnoreAlertURL string `json:"ignore_alert_url,omitempty"` CheckPK int64 `json:"check_pk,omitempty"` CheckURL string `json:"check_url,omitempty"` CheckAddresss string `json:"check_address,omitempty"` CheckName string `json:"check_name,omitempty"` CheckMonitoringServiceType string `json:"check_monitoring_service_type,omitempty"` StateIsUp bool `json:"state_is_up,omitempty"` Ignored bool `json:"ignored,omitempty"` NumLocationsDown int `json:"num_locations_down,omitempty"` AllAlerts *[]Alert `json:"all_alerts,omitempty"` }
Outage represents an outage reported by Uptime.com.
type OutageListOptions ¶
type OutageListOptions struct { Page int `url:"page,omitempty"` PageSize int `url:"page_size,omitempty"` Search string `url:"search,omitempty"` Ordering string `url:"ordering,omitempty"` CheckMonitoringServiceType string `url:"check_monitoring_service_type,omitempty"` }
OutageListOptions specifies the optional parameters to the OutagesService.List and OutagesService.ListByServiceType methods.
type OutageListResponse ¶
type OutageListResponse struct { Count int `json:"count,omitempty"` Next string `json:"next,omitempty"` Previous string `json:"previous,omitempty"` Results []*Outage `json:"results,omitempty"` }
OutageListResponse represents a page of Outage results returned by the Uptime.com API.
type OutageService ¶
type OutageService service
OutageService handles communication with the outage related methods of the Uptime.com API.
Uptime.com API docs: https://uptime.com/api/v1/docs/#!/outages/
func (*OutageService) List ¶
func (s *OutageService) List(ctx context.Context, opt *OutageListOptions) ([]*Outage, *http.Response, error)
List all outages on the account.
type Tag ¶
type Tag struct { PK int `json:"pk,omitempty"` URL string `json:"url,omitempty"` Tag string `json:"tag,omitempty"` ColorHex string `json:"color_hex,omitempty"` }
Tag represents a check tag in Uptime.com.
type TagListOptions ¶
type TagListResponse ¶
type TagListResponse struct { Count int `json:"count,omitempty"` Next string `json:"next,omitempty"` Previous string `json:"previous,omitempty"` Results []*Tag `json:"results,omitempty"` }
TagListOptions specifies the optional parameters to the TagService.List method.
type TagResponse ¶
type TagService ¶
type TagService service
func (*TagService) List ¶
func (s *TagService) List(ctx context.Context, opt *TagListOptions) ([]*Tag, *http.Response, error)
List retrieves a list of Uptime.com check tags.