Skip to content

Commit 0713425

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
and
ci.datadog-api-spec
authored
Monitor priority can have custom ranges and be null (#2017)
Co-authored-by: ci.datadog-api-spec <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
1 parent cbdeb9c commit 0713425

File tree

8 files changed

+26
-41
lines changed

8 files changed

+26
-41
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.6",
7-
"regenerated": "2024-06-27 17:06:08.975577",
8-
"spec_repo_commit": "5ebef994"
7+
"regenerated": "2024-06-27 21:40:27.727114",
8+
"spec_repo_commit": "4ed44e4c"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-06-27 17:06:08.992296",
13-
"spec_repo_commit": "5ebef994"
12+
"regenerated": "2024-06-27 21:40:27.743937",
13+
"spec_repo_commit": "4ed44e4c"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6615,8 +6615,6 @@ components:
66156615
priority:
66166616
description: Integer from 1 (high) to 5 (low) indicating alert severity.
66176617
format: int64
6618-
maximum: 5
6619-
minimum: 1
66206618
nullable: true
66216619
type: integer
66226620
query:
@@ -7705,8 +7703,7 @@ components:
77057703
priority:
77067704
description: Integer from 1 (high) to 5 (low) indicating alert severity.
77077705
format: int64
7708-
maximum: 5
7709-
minimum: 1
7706+
nullable: true
77107707
type: integer
77117708
query:
77127709
description: The monitor query.

examples/v1/monitors/UpdateMonitor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
body = MonitorUpdateRequest(
1717
name="My monitor-updated",
18+
priority=None,
1819
options=MonitorOptions(
1920
evaluation_delay=None,
2021
new_group_delay=600,

src/datadog_api_client/v1/model/monitor.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@
2525

2626

2727
class Monitor(ModelNormal):
28-
validations = {
29-
"priority": {
30-
"inclusive_maximum": 5,
31-
"inclusive_minimum": 1,
32-
},
33-
}
34-
3528
@cached_property
3629
def openapi_types(_):
3730
from datadog_api_client.v1.model.creator import Creator

src/datadog_api_client/v1/model/monitor_update_request.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@
2424

2525

2626
class MonitorUpdateRequest(ModelNormal):
27-
validations = {
28-
"priority": {
29-
"inclusive_maximum": 5,
30-
"inclusive_minimum": 1,
31-
},
32-
}
33-
3427
@cached_property
3528
def openapi_types(_):
3629
from datadog_api_client.v1.model.creator import Creator
@@ -50,7 +43,7 @@ def openapi_types(_):
5043
"name": (str,),
5144
"options": (MonitorOptions,),
5245
"overall_state": (MonitorOverallStates,),
53-
"priority": (int,),
46+
"priority": (int, none_type),
5447
"query": (str,),
5548
"restricted_roles": ([str], none_type),
5649
"state": (MonitorState,),
@@ -99,7 +92,7 @@ def __init__(
9992
name: Union[str, UnsetType] = unset,
10093
options: Union[MonitorOptions, UnsetType] = unset,
10194
overall_state: Union[MonitorOverallStates, UnsetType] = unset,
102-
priority: Union[int, UnsetType] = unset,
95+
priority: Union[int, none_type, UnsetType] = unset,
10396
query: Union[str, UnsetType] = unset,
10497
restricted_roles: Union[List[str], none_type, UnsetType] = unset,
10598
state: Union[MonitorState, UnsetType] = unset,
@@ -141,7 +134,7 @@ def __init__(
141134
:type overall_state: MonitorOverallStates, optional
142135
143136
:param priority: Integer from 1 (high) to 5 (low) indicating alert severity.
144-
:type priority: int, optional
137+
:type priority: int, none_type, optional
145138
146139
:param query: The monitor query.
147140
:type query: str, optional
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2023-01-18T18:37:19.255Z
1+
2024-06-20T19:37:04.361Z

tests/v1/cassettes/test_scenarios/test_edit_a_monitor_returns_ok_response.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
interactions:
22
- request:
3-
body: '{"message":"some message Notify: @hipchat-channel","name":"Test-Edit_a_monitor_returns_OK_response-1674067039","options":{"enable_logs_sample":true,"escalation_message":"the
3+
body: '{"message":"some message Notify: @hipchat-channel","name":"Test-Edit_a_monitor_returns_OK_response-1718912224","options":{"enable_logs_sample":true,"escalation_message":"the
44
situation has escalated","evaluation_delay":700,"groupby_simple_monitor":true,"include_tags":true,"locked":false,"new_host_delay":600,"no_data_timeframe":null,"notification_preset_name":"hide_handles","notify_audit":false,"notify_no_data":false,"on_missing_data":"show_and_notify_no_data","renotify_interval":60,"require_full_window":true,"thresholds":{"critical":2,"warning":1},"timeout_h":24},"priority":3,"query":"logs(\"service:foo
55
AND type:error\").index(\"main\").rollup(\"count\").by(\"source\").last(\"5m\")
6-
> 2","tags":["test:testeditamonitorreturnsokresponse1674067039","env:ci"],"type":"log
6+
> 2","tags":["test:testeditamonitorreturnsokresponse1718912224","env:ci"],"type":"log
77
alert"}'
88
headers:
99
accept:
@@ -14,12 +14,12 @@ interactions:
1414
uri: https://api.datadoghq.com/api/v1/monitor
1515
response:
1616
body:
17-
string: '{"id":108260304,"org_id":321813,"type":"log alert","name":"Test-Edit_a_monitor_returns_OK_response-1674067039","message":"some
18-
message Notify: @hipchat-channel","tags":["test:testeditamonitorreturnsokresponse1674067039","env:ci"],"query":"logs(\"service:foo
17+
string: '{"id":147580793,"org_id":237503,"type":"log alert","name":"Test-Edit_a_monitor_returns_OK_response-1718912224","message":"some
18+
message Notify: @hipchat-channel","tags":["test:testeditamonitorreturnsokresponse1718912224","env:ci"],"query":"logs(\"service:foo
1919
AND type:error\").index(\"main\").rollup(\"count\").by(\"source\").last(\"5m\")
2020
> 2","options":{"enable_logs_sample":true,"escalation_message":"the situation
21-
has escalated","evaluation_delay":700,"groupby_simple_monitor":true,"include_tags":true,"locked":false,"new_host_delay":600,"no_data_timeframe":null,"notification_preset_name":"hide_handles","notify_audit":false,"notify_no_data":false,"on_missing_data":"show_and_notify_no_data","renotify_interval":60,"require_full_window":true,"thresholds":{"critical":2.0,"warning":1.0},"timeout_h":24,"silenced":{}},"multi":true,"created_at":1674067039000,"created":"2023-01-18T18:37:19.356677+00:00","modified":"2023-01-18T18:37:19.356677+00:00","deleted":null,"restricted_roles":null,"priority":3,"overall_state_modified":null,"overall_state":"No
22-
Data","creator":{"name":null,"handle":"frog@datadoghq.com","email":"frog@datadoghq.com","id":1445416}}
21+
has escalated","evaluation_delay":700,"groupby_simple_monitor":true,"include_tags":true,"locked":false,"new_host_delay":600,"no_data_timeframe":null,"notification_preset_name":"hide_handles","notify_audit":false,"notify_no_data":false,"on_missing_data":"show_and_notify_no_data","renotify_interval":60,"require_full_window":true,"thresholds":{"critical":2.0,"warning":1.0},"timeout_h":24,"silenced":{}},"multi":true,"created_at":1718912224000,"created":"2024-06-20T19:37:04.686145+00:00","modified":"2024-06-20T19:37:04.686145+00:00","deleted":null,"restricted_roles":null,"priority":3,"restriction_policy":null,"overall_state_modified":null,"overall_state":"No
22+
Data","creator":{"name":"Carl Martensen","handle":"carl.martensen@datadoghq.com","email":"carl.martensen@datadoghq.com","id":1078685}}
2323
2424
'
2525
headers:
@@ -29,20 +29,20 @@ interactions:
2929
code: 200
3030
message: OK
3131
- request:
32-
body: '{"name":"Test-Edit_a_monitor_returns_OK_response-1674067039-updated","options":{"evaluation_delay":null,"new_group_delay":600,"new_host_delay":null,"renotify_interval":null,"thresholds":{"critical":2,"warning":null},"timeout_h":null}}'
32+
body: '{"name":"Test-Edit_a_monitor_returns_OK_response-1718912224-updated","options":{"evaluation_delay":null,"new_group_delay":600,"new_host_delay":null,"renotify_interval":null,"thresholds":{"critical":2,"warning":null},"timeout_h":null},"priority":null}'
3333
headers:
3434
accept:
3535
- application/json
3636
content-type:
3737
- application/json
3838
method: PUT
39-
uri: https://api.datadoghq.com/api/v1/monitor/108260304
39+
uri: https://api.datadoghq.com/api/v1/monitor/147580793
4040
response:
4141
body:
42-
string: '{"id":108260304,"org_id":321813,"type":"log alert","name":"Test-Edit_a_monitor_returns_OK_response-1674067039-updated","message":"some
43-
message Notify: @hipchat-channel","tags":["test:testeditamonitorreturnsokresponse1674067039","env:ci"],"query":"logs(\"service:foo
42+
string: '{"id":147580793,"org_id":237503,"type":"log alert","name":"Test-Edit_a_monitor_returns_OK_response-1718912224-updated","message":"some
43+
message Notify: @hipchat-channel","tags":["test:testeditamonitorreturnsokresponse1718912224","env:ci"],"query":"logs(\"service:foo
4444
AND type:error\").index(\"main\").rollup(\"count\").by(\"source\").last(\"5m\")
45-
> 2","options":{"evaluation_delay":null,"new_group_delay":600,"new_host_delay":null,"renotify_interval":null,"thresholds":{"critical":2.0},"timeout_h":null,"notify_no_data":false,"notify_audit":false,"include_tags":true,"groupby_simple_monitor":false,"silenced":{}},"multi":true,"created_at":1674067039000,"created":"2023-01-18T18:37:19.356677+00:00","modified":"2023-01-18T18:37:19.511143+00:00","deleted":null,"restricted_roles":null,"priority":3,"overall_state_modified":null,"overall_state":"No
45+
> 2","options":{"evaluation_delay":null,"new_group_delay":600,"new_host_delay":null,"renotify_interval":null,"thresholds":{"critical":2.0},"timeout_h":null,"notify_no_data":false,"notify_audit":false,"include_tags":true,"groupby_simple_monitor":false,"silenced":{}},"multi":true,"created_at":1718912224000,"created":"2024-06-20T19:37:04.686145+00:00","modified":"2024-06-20T19:37:05.129654+00:00","deleted":null,"restricted_roles":null,"priority":null,"restriction_policy":null,"overall_state_modified":null,"overall_state":"No
4646
Data"}
4747
4848
'
@@ -58,10 +58,10 @@ interactions:
5858
accept:
5959
- application/json
6060
method: DELETE
61-
uri: https://api.datadoghq.com/api/v1/monitor/108260304
61+
uri: https://api.datadoghq.com/api/v1/monitor/147580793
6262
response:
6363
body:
64-
string: '{"deleted_monitor_id":108260304}
64+
string: '{"deleted_monitor_id":147580793}
6565
6666
'
6767
headers:

tests/v1/features/monitors.feature

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Feature: Monitors
157157
Scenario: Edit a monitor returns "Bad Request" response
158158
Given new "UpdateMonitor" request
159159
And request contains "monitor_id" parameter from "REPLACE.ME"
160-
And body with value {"options": {"evaluation_delay": null, "include_tags": true, "min_failure_duration": 0, "min_location_failed": 1, "new_group_delay": null, "new_host_delay": 300, "no_data_timeframe": null, "notification_preset_name": "show_all", "notify_audit": false, "notify_by": [], "on_missing_data": "default", "renotify_interval": null, "renotify_occurrences": null, "renotify_statuses": ["alert"], "scheduling_options": {"custom_schedule": {"recurrences": [{"rrule": "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR", "start": "2023-08-31T16:30:00", "timezone": "Europe/Paris"}]}, "evaluation_window": {"day_starts": "04:00", "hour_starts": 0, "month_starts": 1}}, "synthetics_check_id": null, "threshold_windows": {"recovery_window": null, "trigger_window": null}, "thresholds": {"critical_recovery": null, "ok": null, "unknown": null, "warning": null, "warning_recovery": null}, "timeout_h": null, "variables": [{"compute": {"aggregation": "avg", "interval": 60000, "metric": "@duration"}, "data_source": "rum", "group_by": [{"facet": "status", "limit": 10, "sort": {"aggregation": "avg", "order": "desc"}}], "indexes": ["days-3", "days-7"], "name": "query_errors", "search": {"query": "service:query"}}]}, "restricted_roles": [], "tags": [], "type": "query alert"}
160+
And body with value {"options": {"evaluation_delay": null, "include_tags": true, "min_failure_duration": 0, "min_location_failed": 1, "new_group_delay": null, "new_host_delay": 300, "no_data_timeframe": null, "notification_preset_name": "show_all", "notify_audit": false, "notify_by": [], "on_missing_data": "default", "renotify_interval": null, "renotify_occurrences": null, "renotify_statuses": ["alert"], "scheduling_options": {"custom_schedule": {"recurrences": [{"rrule": "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR", "start": "2023-08-31T16:30:00", "timezone": "Europe/Paris"}]}, "evaluation_window": {"day_starts": "04:00", "hour_starts": 0, "month_starts": 1}}, "synthetics_check_id": null, "threshold_windows": {"recovery_window": null, "trigger_window": null}, "thresholds": {"critical_recovery": null, "ok": null, "unknown": null, "warning": null, "warning_recovery": null}, "timeout_h": null, "variables": [{"compute": {"aggregation": "avg", "interval": 60000, "metric": "@duration"}, "data_source": "rum", "group_by": [{"facet": "status", "limit": 10, "sort": {"aggregation": "avg", "order": "desc"}}], "indexes": ["days-3", "days-7"], "name": "query_errors", "search": {"query": "service:query"}}]}, "priority": null, "restricted_roles": [], "tags": [], "type": "query alert"}
161161
When the request is sent
162162
Then the response status is 400 Bad Request
163163

@@ -174,10 +174,11 @@ Feature: Monitors
174174
Given there is a valid "monitor" in the system
175175
And new "UpdateMonitor" request
176176
And request contains "monitor_id" parameter from "monitor.id"
177-
And body with value {"name": "{{ monitor.name }}-updated", "options": {"evaluation_delay": null, "new_group_delay": 600, "new_host_delay":null, "renotify_interval":null, "thresholds": {"critical":2, "warning": null}, "timeout_h": null}}
177+
And body with value {"name": "{{ monitor.name }}-updated", "priority": null, "options": {"evaluation_delay": null, "new_group_delay": 600, "new_host_delay":null, "renotify_interval":null, "thresholds": {"critical":2, "warning": null}, "timeout_h": null}}
178178
When the request is sent
179179
Then the response status is 200 OK
180180
And the response "name" is equal to "{{ monitor.name }}-updated"
181+
And the response "priority" is equal to null
181182

182183
@generated @skip @team:DataDog/monitor-app
183184
Scenario: Get a monitor's details returns "Bad Request" response

0 commit comments

Comments
 (0)