Skip to content

Commit cec3a8b

Browse files
chore: change uptime alert comparison type (#637)
Co-authored-by: Andrew Starr-Bochicchio <andrewsomething@users.noreply.github.com>
1 parent 36e7c16 commit cec3a8b

1 file changed

Lines changed: 30 additions & 21 deletions

File tree

uptime.go

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ import (
77
"path"
88
)
99

10-
const uptimeChecksBasePath = "/v2/uptime/checks"
10+
const (
11+
uptimeChecksBasePath = "/v2/uptime/checks"
12+
// UptimeAlertGreaterThan is the comparison >
13+
UptimeAlertGreaterThan UptimeAlertComp = "greater_than"
14+
// UptimeAlertLessThan is the comparison <
15+
UptimeAlertLessThan UptimeAlertComp = "less_than"
16+
)
1117

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

4349
// UptimeAlert represents a DigitalOcean Uptime Alert configuration.
4450
type UptimeAlert struct {
45-
ID string `json:"id"`
46-
Name string `json:"name"`
47-
Type string `json:"type"`
48-
Threshold int `json:"threshold"`
49-
Comparison string `json:"comparison"`
50-
Notifications *Notifications `json:"notifications"`
51-
Period string `json:"period"`
51+
ID string `json:"id"`
52+
Name string `json:"name"`
53+
Type string `json:"type"`
54+
Threshold int `json:"threshold"`
55+
Comparison UptimeAlertComp `json:"comparison"`
56+
Notifications *Notifications `json:"notifications"`
57+
Period string `json:"period"`
5258
}
5359

5460
// Notifications represents a DigitalOcean Notifications configuration.
@@ -97,24 +103,27 @@ type UpdateUptimeCheckRequest struct {
97103

98104
// CreateUptimeUptimeAlertRequest represents the request to create a new Uptime Alert.
99105
type CreateUptimeAlertRequest struct {
100-
Name string `json:"name"`
101-
Type string `json:"type"`
102-
Threshold int `json:"threshold"`
103-
Comparison string `json:"comparison"`
104-
Notifications *Notifications `json:"notifications"`
105-
Period string `json:"period"`
106+
Name string `json:"name"`
107+
Type string `json:"type"`
108+
Threshold int `json:"threshold"`
109+
Comparison UptimeAlertComp `json:"comparison"`
110+
Notifications *Notifications `json:"notifications"`
111+
Period string `json:"period"`
106112
}
107113

108-
// UpdateUptimeAlertRequest represents the request to create a new alert.
114+
// UpdateUptimeAlertRequest represents the request to update an alert.
109115
type UpdateUptimeAlertRequest struct {
110-
Name string `json:"name"`
111-
Type string `json:"type"`
112-
Threshold int `json:"threshold"`
113-
Comparison string `json:"comparison"`
114-
Notifications *Notifications `json:"notifications"`
115-
Period string `json:"period"`
116+
Name string `json:"name"`
117+
Type string `json:"type"`
118+
Threshold int `json:"threshold"`
119+
Comparison UptimeAlertComp `json:"comparison"`
120+
Notifications *Notifications `json:"notifications"`
121+
Period string `json:"period"`
116122
}
117123

124+
// UptimeAlertComp represents an uptime alert comparison operation
125+
type UptimeAlertComp string
126+
118127
type uptimeChecksRoot struct {
119128
UptimeChecks []UptimeCheck `json:"checks"`
120129
Links *Links `json:"links"`

0 commit comments

Comments
 (0)