Skip to content

Commit 22ab012

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 627a896 of spec repo
1 parent 8cffc73 commit 22ab012

16 files changed

+621
-27
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29565,6 +29565,8 @@ components:
2956529565
additionalProperties: false
2956629566
description: Attributes of the monitor notification rule.
2956729567
properties:
29568+
conditional_recipients:
29569+
$ref: '#/components/schemas/MonitorNotificationRuleConditionalRecipients'
2956829570
filter:
2956929571
$ref: '#/components/schemas/MonitorNotificationRuleFilter'
2957029572
name:
@@ -29573,8 +29575,36 @@ components:
2957329575
$ref: '#/components/schemas/MonitorNotificationRuleRecipients'
2957429576
required:
2957529577
- name
29578+
type: object
29579+
MonitorNotificationRuleCondition:
29580+
description: Conditions for `conditional_recipients`.
29581+
properties:
29582+
recipients:
29583+
$ref: '#/components/schemas/MonitorNotificationRuleRecipients'
29584+
scope:
29585+
$ref: '#/components/schemas/MonitorNotificationRuleScope'
29586+
required:
29587+
- scope
2957629588
- recipients
2957729589
type: object
29590+
MonitorNotificationRuleConditionalRecipients:
29591+
description: Use conditional recipients to define different recipients for different
29592+
situations.
29593+
properties:
29594+
conditions:
29595+
description: Conditions of the notification rule.
29596+
items:
29597+
$ref: '#/components/schemas/MonitorNotificationRuleCondition'
29598+
maxItems: 10
29599+
minItems: 1
29600+
type: array
29601+
fallback_recipients:
29602+
$ref: '#/components/schemas/MonitorNotificationRuleRecipients'
29603+
description: If none of the `conditions` applied, `fallback_recipients`
29604+
will get notified.
29605+
required:
29606+
- conditions
29607+
type: object
2957829608
MonitorNotificationRuleCreateRequest:
2957929609
description: Request for creating a monitor notification rule.
2958029610
properties:
@@ -29714,6 +29744,8 @@ components:
2971429744
additionalProperties: {}
2971529745
description: Attributes of the monitor notification rule.
2971629746
properties:
29747+
conditional_recipients:
29748+
$ref: '#/components/schemas/MonitorNotificationRuleConditionalRecipients'
2971729749
created:
2971829750
description: Creation time of the monitor notification rule.
2971929751
example: 2020-01-02 03:04:00+00:00
@@ -29735,6 +29767,12 @@ components:
2973529767
description: An object related to a monitor notification rule.
2973629768
oneOf:
2973729769
- $ref: '#/components/schemas/User'
29770+
MonitorNotificationRuleScope:
29771+
description: The scope to which the monitor applied.
29772+
example: transition_type:alert
29773+
maxLength: 3000
29774+
minLength: 1
29775+
type: string
2973829776
MonitorNotificationRuleUpdateRequest:
2973929777
description: Request for updating a monitor notification rule.
2974029778
properties:

LICENSE-3rdparty.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ serde_json,https://github.com/serde-rs/json,MIT OR Apache-2.0,"Erick Tryzelaar <
129129
serde_urlencoded,https://github.com/nox/serde_urlencoded,MIT OR Apache-2.0,Anthony Ramine <[email protected]>
130130
serde_with,https://github.com/jonasbb/serde_with,MIT OR Apache-2.0,"Jonas Bushart, Marcin Kaźmierczak"
131131
serde_with_macros,https://github.com/jonasbb/serde_with,MIT OR Apache-2.0,Jonas Bushart
132+
simd-adler32,https://github.com/mcountryman/simd-adler32,MIT,Marvin Countryman <[email protected]>
132133
slab,https://github.com/tokio-rs/slab,MIT,Carl Lerche <[email protected]>
133134
smallvec,https://github.com/servo/rust-smallvec,MIT OR Apache-2.0,The Servo Project Developers
134135
socket2,https://github.com/rust-lang/socket2,MIT OR Apache-2.0,"Alex Crichton <[email protected]>, Thomas de Zeeuw <[email protected]>"

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
@@ -3428,6 +3428,10 @@ pub mod model_monitor_notification_rule_data;
34283428
pub use self::model_monitor_notification_rule_data::MonitorNotificationRuleData;
34293429
pub mod model_monitor_notification_rule_response_attributes;
34303430
pub use self::model_monitor_notification_rule_response_attributes::MonitorNotificationRuleResponseAttributes;
3431+
pub mod model_monitor_notification_rule_conditional_recipients;
3432+
pub use self::model_monitor_notification_rule_conditional_recipients::MonitorNotificationRuleConditionalRecipients;
3433+
pub mod model_monitor_notification_rule_condition;
3434+
pub use self::model_monitor_notification_rule_condition::MonitorNotificationRuleCondition;
34313435
pub mod model_monitor_notification_rule_filter_tags;
34323436
pub use self::model_monitor_notification_rule_filter_tags::MonitorNotificationRuleFilterTags;
34333437
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)