Skip to content

Commit 8ed9af9

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add tests for notify_end monitor options (#1452)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 836b4ab commit 8ed9af9

8 files changed

+72
-19
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.4",
7-
"regenerated": "2023-05-05 15:02:39.419381",
8-
"spec_repo_commit": "380840ff"
7+
"regenerated": "2023-05-05 20:21:45.661672",
8+
"spec_repo_commit": "70465187"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2023-05-05 15:02:39.431715",
13-
"spec_repo_commit": "380840ff"
12+
"regenerated": "2023-05-05 20:21:45.676846",
13+
"spec_repo_commit": "70465187"
1414
}
1515
}
1616
}

examples/v1/downtimes/CreateDowntime.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
from datadog_api_client.v1.api.downtimes_api import DowntimesApi
99
from datadog_api_client.v1.model.downtime import Downtime
1010
from datadog_api_client.v1.model.downtime_recurrence import DowntimeRecurrence
11+
from datadog_api_client.v1.model.notify_end_state import NotifyEndState
12+
from datadog_api_client.v1.model.notify_end_states import NotifyEndStates
13+
from datadog_api_client.v1.model.notify_end_type import NotifyEndType
14+
from datadog_api_client.v1.model.notify_end_types import NotifyEndTypes
1115

1216
body = Downtime(
1317
message="Example-Downtime",
@@ -28,6 +32,19 @@
2832
],
2933
until_date=int((datetime.now() + relativedelta(days=21)).timestamp()),
3034
),
35+
notify_end_states=NotifyEndStates(
36+
[
37+
NotifyEndState.ALERT,
38+
NotifyEndState.NO_DATA,
39+
NotifyEndState.WARN,
40+
]
41+
),
42+
notify_end_types=NotifyEndTypes(
43+
[
44+
NotifyEndType.CANCELED,
45+
NotifyEndType.EXPIRED,
46+
]
47+
),
3148
)
3249

3350
configuration = Configuration()

examples/v1/downtimes/UpdateDowntime.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,30 @@
66
from datadog_api_client import ApiClient, Configuration
77
from datadog_api_client.v1.api.downtimes_api import DowntimesApi
88
from datadog_api_client.v1.model.downtime import Downtime
9+
from datadog_api_client.v1.model.notify_end_state import NotifyEndState
10+
from datadog_api_client.v1.model.notify_end_states import NotifyEndStates
11+
from datadog_api_client.v1.model.notify_end_type import NotifyEndType
12+
from datadog_api_client.v1.model.notify_end_types import NotifyEndTypes
913

1014
# there is a valid "downtime" in the system
1115
DOWNTIME_ID = environ["DOWNTIME_ID"]
1216

1317
body = Downtime(
1418
message="Example-Downtime-updated",
1519
mute_first_recovery_notification=True,
20+
notify_end_states=NotifyEndStates(
21+
[
22+
NotifyEndState.ALERT,
23+
NotifyEndState.NO_DATA,
24+
NotifyEndState.WARN,
25+
]
26+
),
27+
notify_end_types=NotifyEndTypes(
28+
[
29+
NotifyEndType.CANCELED,
30+
NotifyEndType.EXPIRED,
31+
]
32+
),
1633
)
1734

1835
configuration = Configuration()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2022-05-12T09:49:59.145Z
1+
2023-05-05T17:14:34.652Z

tests/v1/cassettes/test_scenarios/test_schedule_a_downtime_returns_ok_response.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
interactions:
22
- request:
3-
body: '{"message":"Test-Schedule_a_downtime_returns_OK_response-1652348999","recurrence":{"period":1,"type":"weeks","until_date":1654163399,"week_days":["Mon","Tue","Wed","Thu","Fri"]},"scope":["test:testscheduleadowntimereturnsokresponse1652348999"],"start":1652348999,"timezone":"Etc/UTC"}'
3+
body: '{"message":"Test-Schedule_a_downtime_returns_OK_response-1683306874","notify_end_states":["alert","no
4+
data","warn"],"notify_end_types":["canceled","expired"],"recurrence":{"period":1,"type":"weeks","until_date":1685121274,"week_days":["Mon","Tue","Wed","Thu","Fri"]},"scope":["test:testscheduleadowntimereturnsokresponse1683306874"],"start":1683306874,"timezone":"Etc/UTC"}'
45
headers:
56
accept:
67
- application/json
@@ -10,7 +11,10 @@ interactions:
1011
uri: https://api.datadoghq.com/api/v1/downtime
1112
response:
1213
body:
13-
string: '{"recurrence":{"until_date":1654163399,"until_occurrences":null,"week_days":["Mon","Tue","Wed","Thu","Fri"],"type":"weeks","period":1},"end":null,"monitor_tags":["*"],"child_id":null,"canceled":null,"monitor_id":null,"mute_first_recovery_notification":false,"created":1652348999,"org_id":321813,"modified":1652348999,"disabled":false,"start":1652348999,"creator_id":1445416,"parent_id":null,"timezone":"Etc/UTC","active":true,"scope":["test:testscheduleadowntimereturnsokresponse1652348999"],"message":"Test-Schedule_a_downtime_returns_OK_response-1652348999","downtime_type":2,"id":1944162282,"updater_id":null}'
14+
string: '{"id":2893677175,"monitor_id":null,"org_id":321813,"start":1683306874,"end":null,"canceled":null,"created":1683306874,"modified":1683306874,"message":"Test-Schedule_a_downtime_returns_OK_response-1683306874","active":true,"disabled":false,"recurrence":{"type":"weeks","period":1,"week_days":["Mon","Tue","Wed","Thu","Fri"],"until_occurrences":null,"until_date":1685121274},"timezone":"Etc/UTC","parent_id":null,"child_id":null,"creator_id":1445416,"updater_id":null,"downtime_type":2,"status":"active","monitor_tags":["*"],"mute_first_recovery_notification":false,"notify_end_types":["canceled","expired"],"notify_end_states":["alert","no
15+
data","warn"],"uuid":"4ebe21fc-eb68-11ed-a070-da7ad0900002","scope":["test:testscheduleadowntimereturnsokresponse1683306874"]}
16+
17+
'
1418
headers:
1519
content-type:
1620
- application/json
@@ -23,11 +27,13 @@ interactions:
2327
accept:
2428
- '*/*'
2529
method: DELETE
26-
uri: https://api.datadoghq.com/api/v1/downtime/1944162282
30+
uri: https://api.datadoghq.com/api/v1/downtime/2893677175
2731
response:
2832
body:
2933
string: ''
30-
headers: {}
34+
headers:
35+
content-type:
36+
- text/html; charset=utf-8
3137
status:
3238
code: 204
3339
message: No Content
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2022-05-12T09:50:03.922Z
1+
2023-05-05T17:13:01.274Z

tests/v1/cassettes/test_scenarios/test_update_a_downtime_returns_ok_response.yaml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
interactions:
22
- request:
3-
body: '{"message":"Test-Update_a_downtime_returns_OK_response-1652349003","recurrence":{"period":1,"type":"weeks","until_date":1654163403,"week_days":["Mon","Tue","Wed","Thu","Fri"]},"scope":["test:testupdateadowntimereturnsokresponse1652349003"],"start":1652349003,"timezone":"Etc/UTC"}'
3+
body: '{"message":"Test-Update_a_downtime_returns_OK_response-1683306781","recurrence":{"period":1,"type":"weeks","until_date":1685121181,"week_days":["Mon","Tue","Wed","Thu","Fri"]},"scope":["test:testupdateadowntimereturnsokresponse1683306781"],"start":1683306781,"timezone":"Etc/UTC"}'
44
headers:
55
accept:
66
- application/json
@@ -10,25 +10,32 @@ interactions:
1010
uri: https://api.datadoghq.com/api/v1/downtime
1111
response:
1212
body:
13-
string: '{"recurrence":{"until_date":1654163403,"until_occurrences":null,"week_days":["Mon","Tue","Wed","Thu","Fri"],"type":"weeks","period":1},"end":null,"monitor_tags":["*"],"child_id":null,"canceled":null,"monitor_id":null,"mute_first_recovery_notification":false,"created":1652349004,"org_id":321813,"modified":1652349004,"disabled":false,"start":1652349003,"creator_id":1445416,"parent_id":null,"timezone":"Etc/UTC","active":true,"scope":["test:testupdateadowntimereturnsokresponse1652349003"],"message":"Test-Update_a_downtime_returns_OK_response-1652349003","downtime_type":2,"id":1944162328,"updater_id":null}'
13+
string: '{"id":2893673146,"monitor_id":null,"org_id":321813,"start":1683306781,"end":null,"canceled":null,"created":1683306781,"modified":1683306781,"message":"Test-Update_a_downtime_returns_OK_response-1683306781","active":true,"disabled":false,"recurrence":{"type":"weeks","period":1,"week_days":["Mon","Tue","Wed","Thu","Fri"],"until_occurrences":null,"until_date":1685121181},"timezone":"Etc/UTC","parent_id":null,"child_id":null,"creator_id":1445416,"updater_id":null,"downtime_type":2,"status":"active","monitor_tags":["*"],"mute_first_recovery_notification":false,"notify_end_types":["expired"],"notify_end_states":["alert","no
14+
data","warn"],"uuid":"171537cc-eb68-11ed-8a83-da7ad0900002","scope":["test:testupdateadowntimereturnsokresponse1683306781"]}
15+
16+
'
1417
headers:
1518
content-type:
1619
- application/json
1720
status:
1821
code: 200
1922
message: OK
2023
- request:
21-
body: '{"message":"Test-Update_a_downtime_returns_OK_response-1652349003-updated","mute_first_recovery_notification":true}'
24+
body: '{"message":"Test-Update_a_downtime_returns_OK_response-1683306781-updated","mute_first_recovery_notification":true,"notify_end_states":["alert","no
25+
data","warn"],"notify_end_types":["canceled","expired"]}'
2226
headers:
2327
accept:
2428
- application/json
2529
content-type:
2630
- application/json
2731
method: PUT
28-
uri: https://api.datadoghq.com/api/v1/downtime/1944162328
32+
uri: https://api.datadoghq.com/api/v1/downtime/2893673146
2933
response:
3034
body:
31-
string: '{"recurrence":{"until_date":1654163403,"until_occurrences":null,"week_days":["Mon","Tue","Wed","Thu","Fri"],"type":"weeks","period":1},"end":null,"monitor_tags":["*"],"child_id":null,"canceled":null,"monitor_id":null,"mute_first_recovery_notification":true,"created":1652349004,"org_id":321813,"modified":1652349004,"disabled":false,"start":1652349003,"creator_id":1445416,"parent_id":null,"timezone":"Etc/UTC","active":true,"scope":["test:testupdateadowntimereturnsokresponse1652349003"],"message":"Test-Update_a_downtime_returns_OK_response-1652349003-updated","downtime_type":2,"id":1944162328,"updater_id":1445416}'
35+
string: '{"id":2893673146,"monitor_id":null,"org_id":321813,"start":1683306781,"end":null,"canceled":null,"created":1683306781,"modified":1683306781,"message":"Test-Update_a_downtime_returns_OK_response-1683306781-updated","active":true,"disabled":false,"recurrence":{"type":"weeks","period":1,"week_days":["Mon","Tue","Wed","Thu","Fri"],"until_occurrences":null,"until_date":1685121181},"timezone":"Etc/UTC","parent_id":null,"child_id":null,"creator_id":1445416,"updater_id":1445416,"downtime_type":2,"status":"active","monitor_tags":["*"],"mute_first_recovery_notification":true,"notify_end_types":["canceled","expired"],"notify_end_states":["alert","no
36+
data","warn"],"uuid":null,"scope":["test:testupdateadowntimereturnsokresponse1683306781"]}
37+
38+
'
3239
headers:
3340
content-type:
3441
- application/json
@@ -41,11 +48,13 @@ interactions:
4148
accept:
4249
- '*/*'
4350
method: DELETE
44-
uri: https://api.datadoghq.com/api/v1/downtime/1944162328
51+
uri: https://api.datadoghq.com/api/v1/downtime/2893673146
4552
response:
4653
body:
4754
string: ''
48-
headers: {}
55+
headers:
56+
content-type:
57+
- text/html; charset=utf-8
4958
status:
5059
code: 204
5160
message: No Content

tests/v1/features/downtimes.feature

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,13 @@ Feature: Downtimes
115115
@team:DataDog/monitor-app
116116
Scenario: Schedule a downtime returns "OK" response
117117
Given new "CreateDowntime" request
118-
And body with value {"message": "{{ unique }}", "start": {{ timestamp("now") }}, "timezone": "Etc/UTC", "scope": ["test:{{ unique_lower_alnum }}"], "recurrence": {"type": "weeks", "period": 1, "week_days": ["Mon", "Tue", "Wed", "Thu", "Fri"], "until_date": {{ timestamp("now + 21d")}} }}
118+
And body with value {"message": "{{ unique }}", "start": {{ timestamp("now") }}, "timezone": "Etc/UTC", "scope": ["test:{{ unique_lower_alnum }}"], "recurrence": {"type": "weeks", "period": 1, "week_days": ["Mon", "Tue", "Wed", "Thu", "Fri"], "until_date": {{ timestamp("now + 21d")}} }, "notify_end_states": ["alert", "no data", "warn"], "notify_end_types": ["canceled", "expired"]}
119119
When the request is sent
120120
Then the response status is 200 OK
121121
And the response "message" is equal to "{{ unique }}"
122122
And the response "active" is equal to true
123+
And the response "notify_end_states" array contains value "alert"
124+
And the response "notify_end_types" array contains value "canceled"
123125

124126
@team:DataDog/monitor-app
125127
Scenario: Schedule a downtime until date
@@ -192,7 +194,9 @@ Feature: Downtimes
192194
Given there is a valid "downtime" in the system
193195
And new "UpdateDowntime" request
194196
And request contains "downtime_id" parameter from "downtime.id"
195-
And body with value {"message": "{{ unique}}-updated", "mute_first_recovery_notification": true}
197+
And body with value {"message": "{{ unique}}-updated", "mute_first_recovery_notification": true, "notify_end_states": ["alert", "no data", "warn"], "notify_end_types": ["canceled", "expired"]}
196198
When the request is sent
197199
Then the response status is 200 OK
198200
And the response "message" is equal to "{{ unique }}-updated"
201+
And the response "notify_end_states" array contains value "alert"
202+
And the response "notify_end_types" array contains value "canceled"

0 commit comments

Comments
 (0)