From cec3a8beed1b9b977d1e11d8b7ccde00da412d32 Mon Sep 17 00:00:00 2001 From: Mike <10135646+mikesmithgh@users.noreply.github.com> Date: Tue, 10 Oct 2023 10:38:35 -0400 Subject: [PATCH] chore: change uptime alert comparison type (#637) Co-authored-by: Andrew Starr-Bochicchio --- uptime.go | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/uptime.go b/uptime.go index 915d6c71..f312e0e8 100644 --- a/uptime.go +++ b/uptime.go @@ -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 @@ -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. @@ -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"`