Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: change uptime alert comparison type #637

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading