Skip to content

Commit b5635ae

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Monitor priority can have custom ranges and be null (#154)
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 61207da commit b5635ae

File tree

7 files changed

+29
-29
lines changed

7 files changed

+29
-29
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:12.818018",
8-
"spec_repo_commit": "5ebef994"
7+
"regenerated": "2024-06-27 21:40:26.008823",
8+
"spec_repo_commit": "4ed44e4c"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-06-27 17:06:12.835182",
13-
"spec_repo_commit": "5ebef994"
12+
"regenerated": "2024-06-27 21:40:26.026385",
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_update_monitor.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ async fn main() {
1919
.renotify_interval(None)
2020
.thresholds(MonitorThresholds::new().critical(2.0 as f64).warning(None))
2121
.timeout_h(None),
22-
);
22+
)
23+
.priority(None);
2324
let configuration = datadog::Configuration::new();
2425
let api = MonitorsAPI::with_config(configuration);
2526
let resp = api.update_monitor(monitor_id.clone(), body).await;

src/datadogV1/model/model_monitor_update_request.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ pub struct MonitorUpdateRequest {
4646
#[serde(rename = "overall_state")]
4747
pub overall_state: Option<crate::datadogV1::model::MonitorOverallStates>,
4848
/// Integer from 1 (high) to 5 (low) indicating alert severity.
49-
#[serde(rename = "priority")]
50-
pub priority: Option<i64>,
49+
#[serde(
50+
rename = "priority",
51+
default,
52+
with = "::serde_with::rust::double_option"
53+
)]
54+
pub priority: Option<Option<i64>>,
5155
/// The monitor query.
5256
#[serde(rename = "query")]
5357
pub query: Option<String>,
@@ -145,7 +149,7 @@ impl MonitorUpdateRequest {
145149
self
146150
}
147151

148-
pub fn priority(mut self, value: i64) -> Self {
152+
pub fn priority(mut self, value: Option<i64>) -> Self {
149153
self.priority = Some(value);
150154
self
151155
}
@@ -209,7 +213,7 @@ impl<'de> Deserialize<'de> for MonitorUpdateRequest {
209213
let mut name: Option<String> = None;
210214
let mut options: Option<crate::datadogV1::model::MonitorOptions> = None;
211215
let mut overall_state: Option<crate::datadogV1::model::MonitorOverallStates> = None;
212-
let mut priority: Option<i64> = None;
216+
let mut priority: Option<Option<i64>> = None;
213217
let mut query: Option<String> = None;
214218
let mut restricted_roles: Option<Option<Vec<String>>> = None;
215219
let mut state: Option<crate::datadogV1::model::MonitorState> = None;
@@ -286,9 +290,6 @@ impl<'de> Deserialize<'de> for MonitorUpdateRequest {
286290
}
287291
}
288292
"priority" => {
289-
if v.is_null() {
290-
continue;
291-
}
292293
priority = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
293294
}
294295
"query" => {
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/scenarios/cassettes/v1/monitors/Edit-a-monitor-returns-OK-response.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"request": {
55
"body": {
6-
"string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Edit_a_monitor_returns_OK_response-1674067039\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the 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 AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"tags\":[\"test:testeditamonitorreturnsokresponse1674067039\",\"env:ci\"],\"type\":\"log alert\"}",
6+
"string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Edit_a_monitor_returns_OK_response-1718912224\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the 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 AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"tags\":[\"test:testeditamonitorreturnsokresponse1718912224\",\"env:ci\"],\"type\":\"log alert\"}",
77
"encoding": null
88
},
99
"headers": {
@@ -19,7 +19,7 @@
1919
},
2020
"response": {
2121
"body": {
22-
"string": "{\"id\":108260304,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Edit_a_monitor_returns_OK_response-1674067039\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testeditamonitorreturnsokresponse1674067039\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the 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.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 Data\",\"creator\":{\"name\":null,\"handle\":\"[email protected]\",\"email\":\"[email protected]\",\"id\":1445416}}\n",
22+
"string": "{\"id\":147580793,\"org_id\":237503,\"type\":\"log alert\",\"name\":\"Test-Edit_a_monitor_returns_OK_response-1718912224\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testeditamonitorreturnsokresponse1718912224\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the 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.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 Data\",\"creator\":{\"name\":\"Carl Martensen\",\"handle\":\"[email protected]\",\"email\":\"[email protected]\",\"id\":1078685}}\n",
2323
"encoding": null
2424
},
2525
"headers": {
@@ -32,12 +32,12 @@
3232
"message": "OK"
3333
}
3434
},
35-
"recorded_at": "Wed, 18 Jan 2023 18:37:19 GMT"
35+
"recorded_at": "Thu, 20 Jun 2024 19:37:04 GMT"
3636
},
3737
{
3838
"request": {
3939
"body": {
40-
"string": "{\"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}}",
40+
"string": "{\"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}",
4141
"encoding": null
4242
},
4343
"headers": {
@@ -49,11 +49,11 @@
4949
]
5050
},
5151
"method": "put",
52-
"uri": "https://api.datadoghq.com/api/v1/monitor/108260304"
52+
"uri": "https://api.datadoghq.com/api/v1/monitor/147580793"
5353
},
5454
"response": {
5555
"body": {
56-
"string": "{\"id\":108260304,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Edit_a_monitor_returns_OK_response-1674067039-updated\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testeditamonitorreturnsokresponse1674067039\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 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 Data\"}\n",
56+
"string": "{\"id\":147580793,\"org_id\":237503,\"type\":\"log alert\",\"name\":\"Test-Edit_a_monitor_returns_OK_response-1718912224-updated\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testeditamonitorreturnsokresponse1718912224\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 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 Data\"}\n",
5757
"encoding": null
5858
},
5959
"headers": {
@@ -66,7 +66,7 @@
6666
"message": "OK"
6767
}
6868
},
69-
"recorded_at": "Wed, 18 Jan 2023 18:37:19 GMT"
69+
"recorded_at": "Thu, 20 Jun 2024 19:37:04 GMT"
7070
},
7171
{
7272
"request": {
@@ -77,11 +77,11 @@
7777
]
7878
},
7979
"method": "delete",
80-
"uri": "https://api.datadoghq.com/api/v1/monitor/108260304"
80+
"uri": "https://api.datadoghq.com/api/v1/monitor/147580793"
8181
},
8282
"response": {
8383
"body": {
84-
"string": "{\"deleted_monitor_id\":108260304}\n",
84+
"string": "{\"deleted_monitor_id\":147580793}\n",
8585
"encoding": null
8686
},
8787
"headers": {
@@ -94,7 +94,7 @@
9494
"message": "OK"
9595
}
9696
},
97-
"recorded_at": "Wed, 18 Jan 2023 18:37:19 GMT"
97+
"recorded_at": "Thu, 20 Jun 2024 19:37:04 GMT"
9898
}
9999
],
100100
"recorded_with": "VCR 6.0.0"

tests/scenarios/features/v1/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)