Skip to content

Commit f956a2b

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add monitor draft status field (#661)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent d9a2ddc commit f956a2b

16 files changed

+183
-28
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": "2025-06-04 12:51:39.592781",
8-
"spec_repo_commit": "35a63137"
7+
"regenerated": "2025-06-04 17:40:40.467497",
8+
"spec_repo_commit": "38b3c05a"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-06-04 12:51:39.609704",
13-
"spec_repo_commit": "35a63137"
12+
"regenerated": "2025-06-04 17:40:40.483266",
13+
"spec_repo_commit": "38b3c05a"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6742,6 +6742,8 @@ components:
67426742
nullable: true
67436743
readOnly: true
67446744
type: string
6745+
draft_status:
6746+
$ref: '#/components/schemas/MonitorDraftStatus'
67456747
id:
67466748
description: ID of this monitor.
67476749
format: int64
@@ -6834,6 +6836,28 @@ components:
68346836
- FIREFOX_LAPTOP_LARGE
68356837
- FIREFOX_TABLET
68366838
- FIREFOX_MOBILE_SMALL
6839+
MonitorDraftStatus:
6840+
default: published
6841+
description: 'Indicates whether the monitor is in a draft or published state.
6842+
6843+
6844+
`draft`: The monitor appears as Draft and does not send notifications.
6845+
6846+
`published`: The monitor is active and evaluates conditions and notify as
6847+
configured.
6848+
6849+
6850+
This field is in preview. The draft value is only available to customers with
6851+
the feature enabled.
6852+
6853+
'
6854+
enum:
6855+
- draft
6856+
- published
6857+
type: string
6858+
x-enum-varnames:
6859+
- DRAFT
6860+
- PUBLISHED
68376861
MonitorFormulaAndFunctionCostAggregator:
68386862
description: Aggregation methods for metric queries.
68396863
enum:
@@ -7917,6 +7941,8 @@ components:
79177941
nullable: true
79187942
readOnly: true
79197943
type: string
7944+
draft_status:
7945+
$ref: '#/components/schemas/MonitorDraftStatus'
79207946
id:
79217947
description: ID of this monitor.
79227948
format: int64

examples/v1_monitors_CreateMonitor_1539578087.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
use datadog_api_client::datadog;
33
use datadog_api_client::datadogV1::api_monitors::MonitorsAPI;
44
use datadog_api_client::datadogV1::model::Monitor;
5+
use datadog_api_client::datadogV1::model::MonitorDraftStatus;
56
use datadog_api_client::datadogV1::model::MonitorOptions;
67
use datadog_api_client::datadogV1::model::MonitorOptionsCustomSchedule;
78
use datadog_api_client::datadogV1::model::MonitorOptionsCustomScheduleRecurrence;
@@ -16,6 +17,7 @@ async fn main() {
1617
"avg(current_1mo):avg:system.load.5{*} > 0.5".to_string(),
1718
MonitorType::QUERY_ALERT,
1819
)
20+
.draft_status(MonitorDraftStatus::PUBLISHED)
1921
.message("some message Notify: @hipchat-channel".to_string())
2022
.name("Example-Monitor".to_string())
2123
.options(

examples/v1_monitors_CreateMonitor_440013737.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
use datadog_api_client::datadog;
33
use datadog_api_client::datadogV1::api_monitors::MonitorsAPI;
44
use datadog_api_client::datadogV1::model::Monitor;
5+
use datadog_api_client::datadogV1::model::MonitorDraftStatus;
56
use datadog_api_client::datadogV1::model::MonitorOptions;
67
use datadog_api_client::datadogV1::model::MonitorThresholds;
78
use datadog_api_client::datadogV1::model::MonitorType;
@@ -13,6 +14,7 @@ async fn main() {
1314
r#"error-tracking-rum("service:foo AND @error.source:source").rollup("count").by("@issue.id").last("1h") >= 1"#.to_string(),
1415
MonitorType::ERROR_TRACKING_ALERT,
1516
)
17+
.draft_status(MonitorDraftStatus::DRAFT)
1618
.message("some message".to_string())
1719
.name("Example-Monitor".to_string())
1820
.options(MonitorOptions::new().thresholds(MonitorThresholds::new().critical(1.0 as f64)))

src/datadogV1/model/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,8 @@ pub mod model_metric_metadata;
922922
pub use self::model_metric_metadata::MetricMetadata;
923923
pub mod model_monitor;
924924
pub use self::model_monitor::Monitor;
925+
pub mod model_monitor_draft_status;
926+
pub use self::model_monitor_draft_status::MonitorDraftStatus;
925927
pub mod model_matching_downtime;
926928
pub use self::model_matching_downtime::MatchingDowntime;
927929
pub mod model_monitor_options;

src/datadogV1/model/model_monitor.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ pub struct Monitor {
2424
with = "::serde_with::rust::double_option"
2525
)]
2626
pub deleted: Option<Option<chrono::DateTime<chrono::Utc>>>,
27+
/// Indicates whether the monitor is in a draft or published state.
28+
///
29+
/// `draft`: The monitor appears as Draft and does not send notifications.
30+
/// `published`: The monitor is active and evaluates conditions and notify as configured.
31+
///
32+
/// This field is in preview. The draft value is only available to customers with the feature enabled.
33+
///
34+
#[serde(rename = "draft_status")]
35+
pub draft_status: Option<crate::datadogV1::model::MonitorDraftStatus>,
2736
/// ID of this monitor.
2837
#[serde(rename = "id")]
2938
pub id: Option<i64>,
@@ -87,6 +96,7 @@ impl Monitor {
8796
created: None,
8897
creator: None,
8998
deleted: None,
99+
draft_status: None,
90100
id: None,
91101
matching_downtimes: None,
92102
message: None,
@@ -121,6 +131,11 @@ impl Monitor {
121131
self
122132
}
123133

134+
pub fn draft_status(mut self, value: crate::datadogV1::model::MonitorDraftStatus) -> Self {
135+
self.draft_status = Some(value);
136+
self
137+
}
138+
124139
pub fn id(mut self, value: i64) -> Self {
125140
self.id = Some(value);
126141
self
@@ -213,6 +228,7 @@ impl<'de> Deserialize<'de> for Monitor {
213228
let mut created: Option<chrono::DateTime<chrono::Utc>> = None;
214229
let mut creator: Option<crate::datadogV1::model::Creator> = None;
215230
let mut deleted: Option<Option<chrono::DateTime<chrono::Utc>>> = None;
231+
let mut draft_status: Option<crate::datadogV1::model::MonitorDraftStatus> = None;
216232
let mut id: Option<i64> = None;
217233
let mut matching_downtimes: Option<Vec<crate::datadogV1::model::MatchingDowntime>> =
218234
None;
@@ -251,6 +267,23 @@ impl<'de> Deserialize<'de> for Monitor {
251267
"deleted" => {
252268
deleted = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
253269
}
270+
"draft_status" => {
271+
if v.is_null() {
272+
continue;
273+
}
274+
draft_status =
275+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
276+
if let Some(ref _draft_status) = draft_status {
277+
match _draft_status {
278+
crate::datadogV1::model::MonitorDraftStatus::UnparsedObject(
279+
_draft_status,
280+
) => {
281+
_unparsed = true;
282+
}
283+
_ => {}
284+
}
285+
}
286+
}
254287
"id" => {
255288
if v.is_null() {
256289
continue;
@@ -358,6 +391,7 @@ impl<'de> Deserialize<'de> for Monitor {
358391
created,
359392
creator,
360393
deleted,
394+
draft_status,
361395
id,
362396
matching_downtimes,
363397
message,
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
5+
use serde::{Deserialize, Deserializer, Serialize, Serializer};
6+
7+
#[non_exhaustive]
8+
#[derive(Clone, Debug, Eq, PartialEq)]
9+
pub enum MonitorDraftStatus {
10+
DRAFT,
11+
PUBLISHED,
12+
UnparsedObject(crate::datadog::UnparsedObject),
13+
}
14+
15+
impl ToString for MonitorDraftStatus {
16+
fn to_string(&self) -> String {
17+
match self {
18+
Self::DRAFT => String::from("draft"),
19+
Self::PUBLISHED => String::from("published"),
20+
Self::UnparsedObject(v) => v.value.to_string(),
21+
}
22+
}
23+
}
24+
25+
impl Serialize for MonitorDraftStatus {
26+
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
27+
where
28+
S: Serializer,
29+
{
30+
match self {
31+
Self::UnparsedObject(v) => v.serialize(serializer),
32+
_ => serializer.serialize_str(self.to_string().as_str()),
33+
}
34+
}
35+
}
36+
37+
impl<'de> Deserialize<'de> for MonitorDraftStatus {
38+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
39+
where
40+
D: Deserializer<'de>,
41+
{
42+
let s: String = String::deserialize(deserializer)?;
43+
Ok(match s.as_str() {
44+
"draft" => Self::DRAFT,
45+
"published" => Self::PUBLISHED,
46+
_ => Self::UnparsedObject(crate::datadog::UnparsedObject {
47+
value: serde_json::Value::String(s.into()),
48+
}),
49+
})
50+
}
51+
}

src/datadogV1/model/model_monitor_update_request.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ pub struct MonitorUpdateRequest {
2424
with = "::serde_with::rust::double_option"
2525
)]
2626
pub deleted: Option<Option<chrono::DateTime<chrono::Utc>>>,
27+
/// Indicates whether the monitor is in a draft or published state.
28+
///
29+
/// `draft`: The monitor appears as Draft and does not send notifications.
30+
/// `published`: The monitor is active and evaluates conditions and notify as configured.
31+
///
32+
/// This field is in preview. The draft value is only available to customers with the feature enabled.
33+
///
34+
#[serde(rename = "draft_status")]
35+
pub draft_status: Option<crate::datadogV1::model::MonitorDraftStatus>,
2736
/// ID of this monitor.
2837
#[serde(rename = "id")]
2938
pub id: Option<i64>,
@@ -84,6 +93,7 @@ impl MonitorUpdateRequest {
8493
created: None,
8594
creator: None,
8695
deleted: None,
96+
draft_status: None,
8797
id: None,
8898
message: None,
8999
modified: None,
@@ -117,6 +127,11 @@ impl MonitorUpdateRequest {
117127
self
118128
}
119129

130+
pub fn draft_status(mut self, value: crate::datadogV1::model::MonitorDraftStatus) -> Self {
131+
self.draft_status = Some(value);
132+
self
133+
}
134+
120135
pub fn id(mut self, value: i64) -> Self {
121136
self.id = Some(value);
122137
self
@@ -217,6 +232,7 @@ impl<'de> Deserialize<'de> for MonitorUpdateRequest {
217232
let mut created: Option<chrono::DateTime<chrono::Utc>> = None;
218233
let mut creator: Option<crate::datadogV1::model::Creator> = None;
219234
let mut deleted: Option<Option<chrono::DateTime<chrono::Utc>>> = None;
235+
let mut draft_status: Option<crate::datadogV1::model::MonitorDraftStatus> = None;
220236
let mut id: Option<i64> = None;
221237
let mut message: Option<String> = None;
222238
let mut modified: Option<chrono::DateTime<chrono::Utc>> = None;
@@ -253,6 +269,23 @@ impl<'de> Deserialize<'de> for MonitorUpdateRequest {
253269
"deleted" => {
254270
deleted = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
255271
}
272+
"draft_status" => {
273+
if v.is_null() {
274+
continue;
275+
}
276+
draft_status =
277+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
278+
if let Some(ref _draft_status) = draft_status {
279+
match _draft_status {
280+
crate::datadogV1::model::MonitorDraftStatus::UnparsedObject(
281+
_draft_status,
282+
) => {
283+
_unparsed = true;
284+
}
285+
_ => {}
286+
}
287+
}
288+
}
256289
"id" => {
257290
if v.is_null() {
258291
continue;
@@ -357,6 +390,7 @@ impl<'de> Deserialize<'de> for MonitorUpdateRequest {
357390
created,
358391
creator,
359392
deleted,
393+
draft_status,
360394
id,
361395
message,
362396
modified,
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2022-02-02T21:04:10.597Z
1+
2025-05-14T22:27:13.829Z

tests/scenarios/cassettes/v1/monitors/Create-a-RUM-formula-and-functions-monitor-returns-OK-response.json

Lines changed: 6 additions & 6 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-Create_a_RUM_formula_and_functions_monitor_returns_OK_response-1643835850\",\"options\":{\"thresholds\":{\"critical\":0.8},\"variables\":[{\"compute\":{\"aggregation\":\"count\"},\"data_source\":\"rum\",\"group_by\":[],\"indexes\":[\"*\"],\"name\":\"query2\",\"search\":{\"query\":\"\"}},{\"compute\":{\"aggregation\":\"count\"},\"data_source\":\"rum\",\"group_by\":[],\"indexes\":[\"*\"],\"name\":\"query1\",\"search\":{\"query\":\"status:error\"}}]},\"priority\":3,\"query\":\"formula(\\\"query2 / query1 * 100\\\").last(\\\"15m\\\") >= 0.8\",\"tags\":[\"test:testcreatearumformulaandfunctionsmonitorreturnsokresponse1643835850\",\"env:ci\"],\"type\":\"rum alert\"}",
6+
"string": "{\"message\":\"some message Notify: @hipchat-channel\",\"name\":\"Test-Create_a_RUM_formula_and_functions_monitor_returns_OK_response-1747261633\",\"options\":{\"thresholds\":{\"critical\":0.8},\"variables\":[{\"compute\":{\"aggregation\":\"count\"},\"data_source\":\"rum\",\"group_by\":[],\"indexes\":[\"*\"],\"name\":\"query2\",\"search\":{\"query\":\"\"}},{\"compute\":{\"aggregation\":\"count\"},\"data_source\":\"rum\",\"group_by\":[],\"indexes\":[\"*\"],\"name\":\"query1\",\"search\":{\"query\":\"status:error\"}}]},\"priority\":3,\"query\":\"formula(\\\"query2 / query1 * 100\\\").last(\\\"15m\\\") >= 0.8\",\"tags\":[\"test:testcreatearumformulaandfunctionsmonitorreturnsokresponse1747261633\",\"env:ci\"],\"type\":\"rum alert\"}",
77
"encoding": null
88
},
99
"headers": {
@@ -19,7 +19,7 @@
1919
},
2020
"response": {
2121
"body": {
22-
"string": "{\"restricted_roles\":null,\"tags\":[\"test:testcreatearumformulaandfunctionsmonitorreturnsokresponse1643835850\",\"env:ci\"],\"deleted\":null,\"query\":\"formula(\\\"query2 / query1 * 100\\\").last(\\\"15m\\\") >= 0.8\",\"message\":\"some message Notify: @hipchat-channel\",\"id\":62683819,\"multi\":false,\"name\":\"Test-Create_a_RUM_formula_and_functions_monitor_returns_OK_response-1643835850\",\"created\":\"2022-02-02T21:04:10.947341+00:00\",\"created_at\":1643835850000,\"creator\":{\"id\":1445416,\"handle\":\"[email protected]\",\"name\":null,\"email\":\"[email protected]\"},\"org_id\":321813,\"modified\":\"2022-02-02T21:04:10.947341+00:00\",\"priority\":3,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"type\":\"rum alert\",\"options\":{\"notify_audit\":false,\"locked\":false,\"silenced\":{},\"include_tags\":true,\"thresholds\":{\"critical\":0.8},\"new_host_delay\":300,\"notify_no_data\":false,\"groupby_simple_monitor\":false,\"variables\":[{\"search\":{\"query\":\"\"},\"data_source\":\"rum\",\"compute\":{\"aggregation\":\"count\"},\"name\":\"query2\",\"indexes\":[\"*\"],\"group_by\":[]},{\"search\":{\"query\":\"status:error\"},\"data_source\":\"rum\",\"compute\":{\"aggregation\":\"count\"},\"name\":\"query1\",\"indexes\":[\"*\"],\"group_by\":[]}]}}",
22+
"string": "{\"id\":172140181,\"org_id\":2,\"type\":\"rum alert\",\"name\":\"Test-Create_a_RUM_formula_and_functions_monitor_returns_OK_response-1747261633\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testcreatearumformulaandfunctionsmonitorreturnsokresponse1747261633\",\"env:ci\"],\"query\":\"formula(\\\"query2 / query1 * 100\\\").last(\\\"15m\\\") >= 0.8\",\"options\":{\"thresholds\":{\"critical\":0.8},\"variables\":[{\"compute\":{\"aggregation\":\"count\"},\"data_source\":\"rum\",\"group_by\":[],\"indexes\":[\"*\"],\"name\":\"query2\",\"search\":{\"query\":\"\"}},{\"compute\":{\"aggregation\":\"count\"},\"data_source\":\"rum\",\"group_by\":[],\"indexes\":[\"*\"],\"name\":\"query1\",\"search\":{\"query\":\"status:error\"}}],\"notify_no_data\":false,\"notify_audit\":false,\"new_host_delay\":300,\"include_tags\":true,\"groupby_simple_monitor\":false,\"silenced\":{},\"avalanche_window\":20},\"multi\":false,\"created_at\":1747261634000,\"created\":\"2025-05-14T22:27:14.329045+00:00\",\"modified\":\"2025-05-14T22:27:14.329045+00:00\",\"deleted\":null,\"priority\":3,\"draft_status\":\"published\",\"restricted_roles\":null,\"restriction_policy\":null,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":\"Carl Martensen\",\"handle\":\"[email protected]\",\"email\":\"[email protected]\",\"id\":638339},\"run_as\":null,\"restricted\":true}\n",
2323
"encoding": null
2424
},
2525
"headers": {
@@ -32,7 +32,7 @@
3232
"message": "OK"
3333
}
3434
},
35-
"recorded_at": "Wed, 02 Feb 2022 21:04:10 GMT"
35+
"recorded_at": "Wed, 14 May 2025 22:27:13 GMT"
3636
},
3737
{
3838
"request": {
@@ -43,11 +43,11 @@
4343
]
4444
},
4545
"method": "delete",
46-
"uri": "https://api.datadoghq.com/api/v1/monitor/62683819"
46+
"uri": "https://api.datadoghq.com/api/v1/monitor/172140181"
4747
},
4848
"response": {
4949
"body": {
50-
"string": "{\"deleted_monitor_id\":62683819}",
50+
"string": "{\"deleted_monitor_id\":172140181}\n",
5151
"encoding": null
5252
},
5353
"headers": {
@@ -60,7 +60,7 @@
6060
"message": "OK"
6161
}
6262
},
63-
"recorded_at": "Wed, 02 Feb 2022 21:04:10 GMT"
63+
"recorded_at": "Wed, 14 May 2025 22:27:13 GMT"
6464
}
6565
],
6666
"recorded_with": "VCR 6.0.0"

0 commit comments

Comments
 (0)