Skip to content

Commit

Permalink
chore: change uptime alert comparison type (#637)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Starr-Bochicchio <andrewsomething@users.noreply.github.com>
  • Loading branch information
mikesmithgh and andrewsomething committed Oct 10, 2023
1 parent 36e7c16 commit cec3a8b
Showing 1 changed file with 30 additions and 21 deletions.
51 changes: 30 additions & 21 deletions uptime.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import (
"path"
)

const uptimeChecksBasePath = "/v2/uptime/checks"
const (
uptimeChecksBasePath = "/v2/uptime/checks"
// UptimeAlertGreaterThan is the comparison >
UptimeAlertGreaterThan UptimeAlertComp = "greater_than"
// UptimeAlertLessThan is the comparison <
UptimeAlertLessThan UptimeAlertComp = "less_than"
)

// UptimeChecksService is an interface for creating and managing Uptime checks with the DigitalOcean API.
// See: https://docs.digitalocean.com/reference/api/api-reference/#tag/Uptime
Expand Down Expand Up @@ -42,13 +48,13 @@ type UptimeCheck struct {

// UptimeAlert represents a DigitalOcean Uptime Alert configuration.
type UptimeAlert struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Threshold int `json:"threshold"`
Comparison string `json:"comparison"`
Notifications *Notifications `json:"notifications"`
Period string `json:"period"`
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Threshold int `json:"threshold"`
Comparison UptimeAlertComp `json:"comparison"`
Notifications *Notifications `json:"notifications"`
Period string `json:"period"`
}

// Notifications represents a DigitalOcean Notifications configuration.
Expand Down Expand Up @@ -97,24 +103,27 @@ type UpdateUptimeCheckRequest struct {

// CreateUptimeUptimeAlertRequest represents the request to create a new Uptime Alert.
type CreateUptimeAlertRequest struct {
Name string `json:"name"`
Type string `json:"type"`
Threshold int `json:"threshold"`
Comparison string `json:"comparison"`
Notifications *Notifications `json:"notifications"`
Period string `json:"period"`
Name string `json:"name"`
Type string `json:"type"`
Threshold int `json:"threshold"`
Comparison UptimeAlertComp `json:"comparison"`
Notifications *Notifications `json:"notifications"`
Period string `json:"period"`
}

// UpdateUptimeAlertRequest represents the request to create a new alert.
// UpdateUptimeAlertRequest represents the request to update an alert.
type UpdateUptimeAlertRequest struct {
Name string `json:"name"`
Type string `json:"type"`
Threshold int `json:"threshold"`
Comparison string `json:"comparison"`
Notifications *Notifications `json:"notifications"`
Period string `json:"period"`
Name string `json:"name"`
Type string `json:"type"`
Threshold int `json:"threshold"`
Comparison UptimeAlertComp `json:"comparison"`
Notifications *Notifications `json:"notifications"`
Period string `json:"period"`
}

// UptimeAlertComp represents an uptime alert comparison operation
type UptimeAlertComp string

type uptimeChecksRoot struct {
UptimeChecks []UptimeCheck `json:"checks"`
Links *Links `json:"links"`
Expand Down

0 comments on commit cec3a8b

Please sign in to comment.