Skip to content

Commit be7dff2

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 2c49d12 of spec repo
1 parent d3bff53 commit be7dff2

15 files changed

+620
-27
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29063,6 +29063,8 @@ components:
2906329063
additionalProperties: false
2906429064
description: Attributes of the monitor notification rule.
2906529065
properties:
29066+
conditional_recipients:
29067+
$ref: '#/components/schemas/MonitorNotificationRuleConditionalRecipients'
2906629068
filter:
2906729069
$ref: '#/components/schemas/MonitorNotificationRuleFilter'
2906829070
name:
@@ -29071,8 +29073,36 @@ components:
2907129073
$ref: '#/components/schemas/MonitorNotificationRuleRecipients'
2907229074
required:
2907329075
- name
29076+
type: object
29077+
MonitorNotificationRuleCondition:
29078+
description: Conditions for `conditional_recipients`.
29079+
properties:
29080+
recipients:
29081+
$ref: '#/components/schemas/MonitorNotificationRuleRecipients'
29082+
scope:
29083+
$ref: '#/components/schemas/MonitorNotificationRuleScope'
29084+
required:
29085+
- scope
2907429086
- recipients
2907529087
type: object
29088+
MonitorNotificationRuleConditionalRecipients:
29089+
description: Use conditional recipients to define different recipients for different
29090+
situations.
29091+
properties:
29092+
conditions:
29093+
description: Conditions of the notification rule.
29094+
items:
29095+
$ref: '#/components/schemas/MonitorNotificationRuleCondition'
29096+
maxItems: 10
29097+
minItems: 1
29098+
type: array
29099+
fallback_recipients:
29100+
$ref: '#/components/schemas/MonitorNotificationRuleRecipients'
29101+
description: If none of the `conditions` applied, `fallback_recipients`
29102+
will get notified.
29103+
required:
29104+
- conditions
29105+
type: object
2907629106
MonitorNotificationRuleCreateRequest:
2907729107
description: Request for creating a monitor notification rule.
2907829108
properties:
@@ -29212,6 +29242,8 @@ components:
2921229242
additionalProperties: {}
2921329243
description: Attributes of the monitor notification rule.
2921429244
properties:
29245+
conditional_recipients:
29246+
$ref: '#/components/schemas/MonitorNotificationRuleConditionalRecipients'
2921529247
created:
2921629248
description: Creation time of the monitor notification rule.
2921729249
example: 2020-01-02 03:04:00+00:00
@@ -29233,6 +29265,12 @@ components:
2923329265
description: An object related to a monitor notification rule.
2923429266
oneOf:
2923529267
- $ref: '#/components/schemas/User'
29268+
MonitorNotificationRuleScope:
29269+
description: The scope to which the monitor applied.
29270+
example: transition_type:alert
29271+
maxLength: 3000
29272+
minLength: 1
29273+
type: string
2923629274
MonitorNotificationRuleUpdateRequest:
2923729275
description: Request for updating a monitor notification rule.
2923829276
properties:

examples/v2_monitors_CreateMonitorNotificationRule.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@ use datadog_api_client::datadogV2::model::MonitorNotificationRuleResourceType;
1212
async fn main() {
1313
let body = MonitorNotificationRuleCreateRequest::new(
1414
MonitorNotificationRuleCreateRequestData::new(
15-
MonitorNotificationRuleAttributes::new(
16-
"test rule".to_string(),
17-
vec!["slack-test-channel".to_string(), "jira-test".to_string()],
18-
)
19-
.filter(
20-
MonitorNotificationRuleFilter::MonitorNotificationRuleFilterTags(Box::new(
21-
MonitorNotificationRuleFilterTags::new(
22-
vec!["test:example-monitor".to_string()],
23-
),
24-
)),
25-
),
15+
MonitorNotificationRuleAttributes::new("test rule".to_string())
16+
.filter(
17+
MonitorNotificationRuleFilter::MonitorNotificationRuleFilterTags(Box::new(
18+
MonitorNotificationRuleFilterTags::new(vec![
19+
"test:example-monitor".to_string()
20+
]),
21+
)),
22+
)
23+
.recipients(vec![
24+
"slack-test-channel".to_string(),
25+
"jira-test".to_string(),
26+
]),
2627
)
2728
.type_(MonitorNotificationRuleResourceType::MONITOR_NOTIFICATION_RULE),
2829
);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Create a monitor notification rule with conditional recipients returns "OK"
2+
// response
3+
use datadog_api_client::datadog;
4+
use datadog_api_client::datadogV2::api_monitors::MonitorsAPI;
5+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleAttributes;
6+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleCondition;
7+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleConditionalRecipients;
8+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleCreateRequest;
9+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleCreateRequestData;
10+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleFilter;
11+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleFilterTags;
12+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleResourceType;
13+
14+
#[tokio::main]
15+
async fn main() {
16+
let body = MonitorNotificationRuleCreateRequest::new(
17+
MonitorNotificationRuleCreateRequestData::new(
18+
MonitorNotificationRuleAttributes::new("test rule".to_string())
19+
.conditional_recipients(MonitorNotificationRuleConditionalRecipients::new(vec![
20+
MonitorNotificationRuleCondition::new(
21+
vec!["slack-test-channel".to_string(), "jira-test".to_string()],
22+
"transition_type:is_alert".to_string(),
23+
),
24+
]))
25+
.filter(
26+
MonitorNotificationRuleFilter::MonitorNotificationRuleFilterTags(Box::new(
27+
MonitorNotificationRuleFilterTags::new(vec![
28+
"test:example-monitor".to_string()
29+
]),
30+
)),
31+
),
32+
)
33+
.type_(MonitorNotificationRuleResourceType::MONITOR_NOTIFICATION_RULE),
34+
);
35+
let configuration = datadog::Configuration::new();
36+
let api = MonitorsAPI::with_config(configuration);
37+
let resp = api.create_monitor_notification_rule(body).await;
38+
if let Ok(value) = resp {
39+
println!("{:#?}", value);
40+
} else {
41+
println!("{:#?}", resp.unwrap_err());
42+
}
43+
}

examples/v2_monitors_UpdateMonitorNotificationRule.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,16 @@ async fn main() {
1515
std::env::var("MONITOR_NOTIFICATION_RULE_DATA_ID").unwrap();
1616
let body = MonitorNotificationRuleUpdateRequest::new(
1717
MonitorNotificationRuleUpdateRequestData::new(
18-
MonitorNotificationRuleAttributes::new(
19-
"updated rule".to_string(),
20-
vec!["slack-test-channel".to_string()],
21-
)
22-
.filter(
23-
MonitorNotificationRuleFilter::MonitorNotificationRuleFilterTags(Box::new(
24-
MonitorNotificationRuleFilterTags::new(vec![
25-
"test:example-monitor".to_string(),
26-
"host:abc".to_string(),
27-
]),
28-
)),
29-
),
18+
MonitorNotificationRuleAttributes::new("updated rule".to_string())
19+
.filter(
20+
MonitorNotificationRuleFilter::MonitorNotificationRuleFilterTags(Box::new(
21+
MonitorNotificationRuleFilterTags::new(vec![
22+
"test:example-monitor".to_string(),
23+
"host:abc".to_string(),
24+
]),
25+
)),
26+
)
27+
.recipients(vec!["slack-test-channel".to_string()]),
3028
monitor_notification_rule_data_id.clone(),
3129
)
3230
.type_(MonitorNotificationRuleResourceType::MONITOR_NOTIFICATION_RULE),
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Update a monitor notification rule with conditional_recipients returns "OK"
2+
// response
3+
use datadog_api_client::datadog;
4+
use datadog_api_client::datadogV2::api_monitors::MonitorsAPI;
5+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleAttributes;
6+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleCondition;
7+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleConditionalRecipients;
8+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleFilter;
9+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleFilterTags;
10+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleResourceType;
11+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleUpdateRequest;
12+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleUpdateRequestData;
13+
14+
#[tokio::main]
15+
async fn main() {
16+
// there is a valid "monitor_notification_rule" in the system
17+
let monitor_notification_rule_data_id =
18+
std::env::var("MONITOR_NOTIFICATION_RULE_DATA_ID").unwrap();
19+
let body = MonitorNotificationRuleUpdateRequest::new(
20+
MonitorNotificationRuleUpdateRequestData::new(
21+
MonitorNotificationRuleAttributes::new("updated rule".to_string())
22+
.conditional_recipients(MonitorNotificationRuleConditionalRecipients::new(vec![
23+
MonitorNotificationRuleCondition::new(
24+
vec!["slack-test-channel".to_string(), "jira-test".to_string()],
25+
"transition_type:is_alert".to_string(),
26+
),
27+
]))
28+
.filter(
29+
MonitorNotificationRuleFilter::MonitorNotificationRuleFilterTags(Box::new(
30+
MonitorNotificationRuleFilterTags::new(vec![
31+
"test:example-monitor".to_string(),
32+
"host:abc".to_string(),
33+
]),
34+
)),
35+
),
36+
monitor_notification_rule_data_id.clone(),
37+
)
38+
.type_(MonitorNotificationRuleResourceType::MONITOR_NOTIFICATION_RULE),
39+
);
40+
let configuration = datadog::Configuration::new();
41+
let api = MonitorsAPI::with_config(configuration);
42+
let resp = api
43+
.update_monitor_notification_rule(monitor_notification_rule_data_id.clone(), body)
44+
.await;
45+
if let Ok(value) = resp {
46+
println!("{:#?}", value);
47+
} else {
48+
println!("{:#?}", resp.unwrap_err());
49+
}
50+
}

src/datadogV2/model/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3400,6 +3400,10 @@ pub mod model_monitor_notification_rule_data;
34003400
pub use self::model_monitor_notification_rule_data::MonitorNotificationRuleData;
34013401
pub mod model_monitor_notification_rule_response_attributes;
34023402
pub use self::model_monitor_notification_rule_response_attributes::MonitorNotificationRuleResponseAttributes;
3403+
pub mod model_monitor_notification_rule_conditional_recipients;
3404+
pub use self::model_monitor_notification_rule_conditional_recipients::MonitorNotificationRuleConditionalRecipients;
3405+
pub mod model_monitor_notification_rule_condition;
3406+
pub use self::model_monitor_notification_rule_condition::MonitorNotificationRuleCondition;
34033407
pub mod model_monitor_notification_rule_filter_tags;
34043408
pub use self::model_monitor_notification_rule_filter_tags::MonitorNotificationRuleFilterTags;
34053409
pub mod model_monitor_notification_rule_filter;

src/datadogV2/model/model_monitor_notification_rule_attributes.rs

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ use std::fmt::{self, Formatter};
1111
#[skip_serializing_none]
1212
#[derive(Clone, Debug, PartialEq, Serialize)]
1313
pub struct MonitorNotificationRuleAttributes {
14+
/// Use conditional recipients to define different recipients for different situations.
15+
#[serde(rename = "conditional_recipients")]
16+
pub conditional_recipients:
17+
Option<crate::datadogV2::model::MonitorNotificationRuleConditionalRecipients>,
1418
/// Filter used to associate the notification rule with monitors.
1519
#[serde(rename = "filter")]
1620
pub filter: Option<crate::datadogV2::model::MonitorNotificationRuleFilter>,
@@ -19,26 +23,40 @@ pub struct MonitorNotificationRuleAttributes {
1923
pub name: String,
2024
/// A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'.
2125
#[serde(rename = "recipients")]
22-
pub recipients: Vec<String>,
26+
pub recipients: Option<Vec<String>>,
2327
#[serde(skip)]
2428
#[serde(default)]
2529
pub(crate) _unparsed: bool,
2630
}
2731

2832
impl MonitorNotificationRuleAttributes {
29-
pub fn new(name: String, recipients: Vec<String>) -> MonitorNotificationRuleAttributes {
33+
pub fn new(name: String) -> MonitorNotificationRuleAttributes {
3034
MonitorNotificationRuleAttributes {
35+
conditional_recipients: None,
3136
filter: None,
3237
name,
33-
recipients,
38+
recipients: None,
3439
_unparsed: false,
3540
}
3641
}
3742

43+
pub fn conditional_recipients(
44+
mut self,
45+
value: crate::datadogV2::model::MonitorNotificationRuleConditionalRecipients,
46+
) -> Self {
47+
self.conditional_recipients = Some(value);
48+
self
49+
}
50+
3851
pub fn filter(mut self, value: crate::datadogV2::model::MonitorNotificationRuleFilter) -> Self {
3952
self.filter = Some(value);
4053
self
4154
}
55+
56+
pub fn recipients(mut self, value: Vec<String>) -> Self {
57+
self.recipients = Some(value);
58+
self
59+
}
4260
}
4361

4462
impl<'de> Deserialize<'de> for MonitorNotificationRuleAttributes {
@@ -58,6 +76,9 @@ impl<'de> Deserialize<'de> for MonitorNotificationRuleAttributes {
5876
where
5977
M: MapAccess<'a>,
6078
{
79+
let mut conditional_recipients: Option<
80+
crate::datadogV2::model::MonitorNotificationRuleConditionalRecipients,
81+
> = None;
6182
let mut filter: Option<crate::datadogV2::model::MonitorNotificationRuleFilter> =
6283
None;
6384
let mut name: Option<String> = None;
@@ -66,6 +87,13 @@ impl<'de> Deserialize<'de> for MonitorNotificationRuleAttributes {
6687

6788
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
6889
match k.as_str() {
90+
"conditional_recipients" => {
91+
if v.is_null() {
92+
continue;
93+
}
94+
conditional_recipients =
95+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
96+
}
6997
"filter" => {
7098
if v.is_null() {
7199
continue;
@@ -84,6 +112,9 @@ impl<'de> Deserialize<'de> for MonitorNotificationRuleAttributes {
84112
name = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
85113
}
86114
"recipients" => {
115+
if v.is_null() {
116+
continue;
117+
}
87118
recipients = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
88119
}
89120
&_ => {
@@ -94,9 +125,9 @@ impl<'de> Deserialize<'de> for MonitorNotificationRuleAttributes {
94125
}
95126
}
96127
let name = name.ok_or_else(|| M::Error::missing_field("name"))?;
97-
let recipients = recipients.ok_or_else(|| M::Error::missing_field("recipients"))?;
98128

99129
let content = MonitorNotificationRuleAttributes {
130+
conditional_recipients,
100131
filter,
101132
name,
102133
recipients,

0 commit comments

Comments
 (0)