Skip to content

Commit f76ae6d

Browse files
Fix Multiple ACLP Alerting Issues (#873)
* ACLP stuff * revert not needed changes to unit test base * test fixes * fixtures fix
1 parent 3c29b43 commit f76ae6d

7 files changed

+599
-189
lines changed

monitor_alert_definitions.go

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -117,24 +117,24 @@ const (
117117

118118
// AlertDefinitionCreateOptions are the options used to create a new alert definition.
119119
type AlertDefinitionCreateOptions struct {
120-
Label string `json:"label"` // mandatory
121-
Severity int `json:"severity"` // mandatory
122-
ChannelIDs []int `json:"channel_ids"` // mandatory
123-
RuleCriteria RuleCriteriaOptions `json:"rule_criteria"` // optional
124-
TriggerConditions TriggerConditions `json:"trigger_conditions"` // optional
125-
EntityIDs []string `json:"entity_ids,omitempty"` // optional
126-
Description string `json:"description,omitempty"` // optional
120+
Label string `json:"label"`
121+
Severity int `json:"severity"`
122+
ChannelIDs []int `json:"channel_ids"`
123+
RuleCriteria *RuleCriteriaOptions `json:"rule_criteria,omitempty"`
124+
TriggerConditions *TriggerConditions `json:"trigger_conditions,omitempty"`
125+
EntityIDs []string `json:"entity_ids,omitempty"`
126+
Description *string `json:"description,omitempty"`
127127
}
128128

129129
// AlertDefinitionUpdateOptions are the options used to update an alert definition.
130130
type AlertDefinitionUpdateOptions struct {
131-
Label string `json:"label"` // mandatory
132-
Severity int `json:"severity"` // mandatory
133-
ChannelIDs []int `json:"channel_ids"` // mandatory
134-
RuleCriteria RuleCriteriaOptions `json:"rule_criteria"` // optional
135-
TriggerConditions TriggerConditions `json:"trigger_conditions"` // optional
136-
EntityIDs []string `json:"entity_ids,omitempty"` // optional
137-
Description string `json:"description,omitempty"` // optional
131+
Label string `json:"label"`
132+
Severity int `json:"severity"`
133+
ChannelIDs []int `json:"channel_ids"`
134+
RuleCriteria *RuleCriteriaOptions `json:"rule_criteria,omitempty"`
135+
TriggerConditions *TriggerConditions `json:"trigger_conditions,omitempty"`
136+
EntityIDs []string `json:"entity_ids,omitempty"`
137+
Description *string `json:"description,omitempty"`
138138
}
139139

140140
// UnmarshalJSON implements the json.Unmarshaler interface
@@ -166,13 +166,7 @@ func (c *Client) ListMonitorAlertDefinitions(
166166
serviceType string,
167167
opts *ListOptions,
168168
) ([]AlertDefinition, error) {
169-
var endpoint string
170-
if serviceType != "" {
171-
endpoint = formatAPIPath("monitor/services/%s/alert-definitions", serviceType)
172-
} else {
173-
endpoint = formatAPIPath("monitor/alert-definitions")
174-
}
175-
169+
endpoint := formatAPIPath("monitor/services/%s/alert-definitions", serviceType)
176170
return getPaginatedResults[AlertDefinition](ctx, c, endpoint, opts)
177171
}
178172

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
---
2+
version: 1
3+
interactions:
4+
- request:
5+
body: ""
6+
form: {}
7+
headers:
8+
Accept:
9+
- application/json
10+
Content-Type:
11+
- application/json
12+
User-Agent:
13+
- linodego/dev https://github.com/linode/linodego
14+
url: https://api.linode.com/v4beta/monitor/alert-channels?page=1
15+
method: GET
16+
response:
17+
body: '{"pages": 1, "page": 1, "results": 1, "data": [{"id": 10000, "label": "Read-Write
18+
Channel", "channel_type": "email", "type": "system", "content": {"email": {"email_addresses":
19+
["Users-with-read-write-access-to-resources"]}}, "alerts": [{"id": 10000, "label":
20+
"High Memory Usage Plan Dedicated", "url": "/monitor/alerts-definitions/10000",
21+
"type": "alerts-definitions"}, {"id": 10001, "label": "High Memory Usage Plan
22+
Shared", "url": "/monitor/alerts-definitions/10001", "type": "alerts-definitions"},
23+
{"id": 10002, "label": "High CPU Usage Plan Dedicated", "url": "/monitor/alerts-definitions/10002",
24+
"type": "alerts-definitions"}, {"id": 10003, "label": "High CPU Usage Plan Shared",
25+
"url": "/monitor/alerts-definitions/10003", "type": "alerts-definitions"}, {"id":
26+
10004, "label": "High Disk Usage Plan Dedicated", "url": "/monitor/alerts-definitions/10004",
27+
"type": "alerts-definitions"}, {"id": 10005, "label": "High Disk Usage Plan
28+
Shared", "url": "/monitor/alerts-definitions/10005", "type": "alerts-definitions"},
29+
{"id": 10470, "label": "jgliahjs_updated", "url": "/monitor/alerts-definitions/10470",
30+
"type": "alerts-definitions"}, {"id": 10503, "label": "obohragp-e2e-alert-1763051867-updated",
31+
"url": "/monitor/alerts-definitions/10503", "type": "alerts-definitions"}, {"id":
32+
10504, "label": "lczvmpvu-e2e-alert-1763053808", "url": "/monitor/alerts-definitions/10504",
33+
"type": "alerts-definitions"}, {"id": 10505, "label": "ocachcjp-e2e-alert-1763055498-updated",
34+
"url": "/monitor/alerts-definitions/10505", "type": "alerts-definitions"}, {"id":
35+
10506, "label": "lrbbifob-e2e-alert-1763057283", "url": "/monitor/alerts-definitions/10506",
36+
"type": "alerts-definitions"}, {"id": 10507, "label": "cbbrhfnv-e2e-alert-1763057415",
37+
"url": "/monitor/alerts-definitions/10507", "type": "alerts-definitions"}, {"id":
38+
10508, "label": "gqzzxdgh-e2e-alert-1763057687", "url": "/monitor/alerts-definitions/10508",
39+
"type": "alerts-definitions"}, {"id": 10509, "label": "smqsmhst-e2e-alert-1763058424",
40+
"url": "/monitor/alerts-definitions/10509", "type": "alerts-definitions"}, {"id":
41+
10510, "label": "vygdkmkw-e2e-alert-1763058509", "url": "/monitor/alerts-definitions/10510",
42+
"type": "alerts-definitions"}, {"id": 10511, "label": "dvlgyyvr-e2e-alert-1763058560",
43+
"url": "/monitor/alerts-definitions/10511", "type": "alerts-definitions"}, {"id":
44+
10512, "label": "pscihptu-e2e-alert-1763058653-updated", "url": "/monitor/alerts-definitions/10512",
45+
"type": "alerts-definitions"}, {"id": 10513, "label": "emxhsdlm-e2e-alert-1763059164-updated",
46+
"url": "/monitor/alerts-definitions/10513", "type": "alerts-definitions"}, {"id":
47+
10514, "label": "fxbekqdl-e2e-alert-1763059845-updated", "url": "/monitor/alerts-definitions/10514",
48+
"type": "alerts-definitions"}, {"id": 10529, "label": "Test Database Standby
49+
Host", "url": "/monitor/alerts-definitions/10529", "type": "alerts-definitions"},
50+
{"id": 10623, "label": "go-test-alert-definition-idempotency-1766438857602066000",
51+
"url": "/monitor/alerts-definitions/10623", "type": "alerts-definitions"}, {"id":
52+
10624, "label": "go-test-alert-definition-create-updated", "url": "/monitor/alerts-definitions/10624",
53+
"type": "alerts-definitions"}, {"id": 10625, "label": "go-test-alert-definition-idempotency-1766439008803464000",
54+
"url": "/monitor/alerts-definitions/10625", "type": "alerts-definitions"}, {"id":
55+
10626, "label": "go-test-alert-definition-create-updated", "url": "/monitor/alerts-definitions/10626",
56+
"type": "alerts-definitions"}, {"id": 10627, "label": "go-test-alert-definition-idempotency-1766439204872603000",
57+
"url": "/monitor/alerts-definitions/10627", "type": "alerts-definitions"}, {"id":
58+
10628, "label": "go-test-alert-definition-create-updated", "url": "/monitor/alerts-definitions/10628",
59+
"type": "alerts-definitions"}, {"id": 10629, "label": "go-test-alert-definition-idempotency-1766439362488609000",
60+
"url": "/monitor/alerts-definitions/10629", "type": "alerts-definitions"}, {"id":
61+
10630, "label": "go-test-alert-definition-create-updated", "url": "/monitor/alerts-definitions/10630",
62+
"type": "alerts-definitions"}, {"id": 10631, "label": "go-test-alert-definition-idempotency-1766439501203284000",
63+
"url": "/monitor/alerts-definitions/10631", "type": "alerts-definitions"}, {"id":
64+
10632, "label": "go-test-alert-definition-create-updated", "url": "/monitor/alerts-definitions/10632",
65+
"type": "alerts-definitions"}], "created": "2018-01-02T03:04:05", "updated":
66+
"2018-01-02T03:04:05", "created_by": "system", "updated_by": "system"}]}'
67+
headers:
68+
Access-Control-Allow-Credentials:
69+
- "true"
70+
Access-Control-Allow-Headers:
71+
- Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter
72+
Access-Control-Allow-Methods:
73+
- HEAD, GET, OPTIONS, POST, PUT, DELETE
74+
Access-Control-Allow-Origin:
75+
- '*'
76+
Access-Control-Expose-Headers:
77+
- X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status
78+
Akamai-Internal-Account:
79+
- '*'
80+
Cache-Control:
81+
- max-age=0, no-cache, no-store
82+
Connection:
83+
- keep-alive
84+
Content-Security-Policy:
85+
- default-src 'none'
86+
Content-Type:
87+
- application/json
88+
Expires:
89+
- Mon, 22 Dec 2025 21:41:17 GMT
90+
Pragma:
91+
- no-cache
92+
Strict-Transport-Security:
93+
- max-age=31536000
94+
Vary:
95+
- Authorization, X-Filter
96+
- Authorization, X-Filter
97+
- Accept-Encoding
98+
X-Accepted-Oauth-Scopes:
99+
- monitor:read_only
100+
X-Content-Type-Options:
101+
- nosniff
102+
X-Frame-Options:
103+
- DENY
104+
- DENY
105+
X-Oauth-Scopes:
106+
- '*'
107+
X-Ratelimit-Limit:
108+
- "1840"
109+
X-Xss-Protection:
110+
- 1; mode=block
111+
status: 200 OK
112+
code: 200
113+
duration: ""

0 commit comments

Comments
 (0)