Skip to content

Commit b926b16

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit cd9869f of spec repo
1 parent c7a82a3 commit b926b16

16 files changed

+387
-20
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32306,14 +32306,20 @@ components:
3230632306
recipients:
3230732307
$ref: '#/components/schemas/MonitorNotificationRuleRecipients'
3230832308
scope:
32309-
$ref: '#/components/schemas/MonitorNotificationRuleScope'
32309+
$ref: '#/components/schemas/MonitorNotificationRuleConditionScope'
3231032310
required:
3231132311
- scope
3231232312
- recipients
3231332313
type: object
32314+
MonitorNotificationRuleConditionScope:
32315+
description: The scope to which the monitor applied.
32316+
example: transition_type:alert
32317+
maxLength: 3000
32318+
minLength: 1
32319+
type: string
3231432320
MonitorNotificationRuleConditionalRecipients:
3231532321
description: Use conditional recipients to define different recipients for different
32316-
situations.
32322+
situations. Cannot be used with `recipients`.
3231732323
properties:
3231832324
conditions:
3231932325
description: Conditions of the notification rule.
@@ -32363,12 +32369,30 @@ components:
3236332369
description: Filter used to associate the notification rule with monitors.
3236432370
oneOf:
3236532371
- $ref: '#/components/schemas/MonitorNotificationRuleFilterTags'
32372+
- $ref: '#/components/schemas/MonitorNotificationRuleFilterScope'
32373+
MonitorNotificationRuleFilterScope:
32374+
additionalProperties: false
32375+
description: Filter monitor notifications. A monitor notification must match
32376+
the scope.
32377+
properties:
32378+
scope:
32379+
description: A scope composed of one or several key:value pairs, which can
32380+
be used to filter monitor notifications on monitor and group tags.
32381+
example: service:(foo OR bar) AND team:test NOT environment:staging
32382+
maxLength: 3000
32383+
minLength: 1
32384+
type: string
32385+
required:
32386+
- scope
32387+
type: object
3236632388
MonitorNotificationRuleFilterTags:
3236732389
additionalProperties: false
32368-
description: Filter monitors by tags. Monitors must match all tags.
32390+
description: Filter monitor notifications by tags. A monitor notification must
32391+
match all tags.
3236932392
properties:
3237032393
tags:
32371-
description: A list of monitor tags.
32394+
description: A list of tags (key:value pairs), which can be used to filter
32395+
monitor notifications on monitor and group tags.
3237232396
example:
3237332397
- team:product
3237432398
- host:abc
@@ -32408,7 +32432,7 @@ components:
3240832432
type: string
3240932433
MonitorNotificationRuleRecipients:
3241032434
description: A list of recipients to notify. Uses the same format as the monitor
32411-
`message` field. Must not start with an '@'.
32435+
`message` field. Must not start with an '@'. Cannot be used with `conditional_recipients`.
3241232436
example:
3241332437
- slack-test-channel
3241432438
- jira-test
@@ -32491,12 +32515,6 @@ components:
3249132515
description: An object related to a monitor notification rule.
3249232516
oneOf:
3249332517
- $ref: '#/components/schemas/User'
32494-
MonitorNotificationRuleScope:
32495-
description: The scope to which the monitor applied.
32496-
example: transition_type:alert
32497-
maxLength: 3000
32498-
minLength: 1
32499-
type: string
3250032518
MonitorNotificationRuleUpdateRequest:
3250132519
description: Request for updating a monitor notification rule.
3250232520
properties:
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Create a monitor notification rule with scope returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_monitors::MonitorsAPI;
4+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleAttributes;
5+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleCreateRequest;
6+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleCreateRequestData;
7+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleFilter;
8+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleFilterScope;
9+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleResourceType;
10+
11+
#[tokio::main]
12+
async fn main() {
13+
let body = MonitorNotificationRuleCreateRequest::new(
14+
MonitorNotificationRuleCreateRequestData::new(
15+
MonitorNotificationRuleAttributes::new("test rule".to_string())
16+
.filter(
17+
MonitorNotificationRuleFilter::MonitorNotificationRuleFilterScope(Box::new(
18+
MonitorNotificationRuleFilterScope::new("test:example-monitor".to_string()),
19+
)),
20+
)
21+
.recipients(vec![
22+
"slack-test-channel".to_string(),
23+
"jira-test".to_string(),
24+
]),
25+
)
26+
.type_(MonitorNotificationRuleResourceType::MONITOR_NOTIFICATION_RULE),
27+
);
28+
let configuration = datadog::Configuration::new();
29+
let api = MonitorsAPI::with_config(configuration);
30+
let resp = api.create_monitor_notification_rule(body).await;
31+
if let Ok(value) = resp {
32+
println!("{:#?}", value);
33+
} else {
34+
println!("{:#?}", resp.unwrap_err());
35+
}
36+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Update a monitor notification rule with scope returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_monitors::MonitorsAPI;
4+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleAttributes;
5+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleFilter;
6+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleFilterScope;
7+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleResourceType;
8+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleUpdateRequest;
9+
use datadog_api_client::datadogV2::model::MonitorNotificationRuleUpdateRequestData;
10+
11+
#[tokio::main]
12+
async fn main() {
13+
// there is a valid "monitor_notification_rule" in the system
14+
let monitor_notification_rule_data_id =
15+
std::env::var("MONITOR_NOTIFICATION_RULE_DATA_ID").unwrap();
16+
let body = MonitorNotificationRuleUpdateRequest::new(
17+
MonitorNotificationRuleUpdateRequestData::new(
18+
MonitorNotificationRuleAttributes::new("updated rule".to_string())
19+
.filter(
20+
MonitorNotificationRuleFilter::MonitorNotificationRuleFilterScope(Box::new(
21+
MonitorNotificationRuleFilterScope::new("test:example-monitor".to_string()),
22+
)),
23+
)
24+
.recipients(vec!["slack-test-channel".to_string()]),
25+
monitor_notification_rule_data_id.clone(),
26+
)
27+
.type_(MonitorNotificationRuleResourceType::MONITOR_NOTIFICATION_RULE),
28+
);
29+
let configuration = datadog::Configuration::new();
30+
let api = MonitorsAPI::with_config(configuration);
31+
let resp = api
32+
.update_monitor_notification_rule(monitor_notification_rule_data_id.clone(), body)
33+
.await;
34+
if let Ok(value) = resp {
35+
println!("{:#?}", value);
36+
} else {
37+
println!("{:#?}", resp.unwrap_err());
38+
}
39+
}

src/datadogV2/model/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3688,6 +3688,8 @@ pub mod model_monitor_notification_rule_condition;
36883688
pub use self::model_monitor_notification_rule_condition::MonitorNotificationRuleCondition;
36893689
pub mod model_monitor_notification_rule_filter_tags;
36903690
pub use self::model_monitor_notification_rule_filter_tags::MonitorNotificationRuleFilterTags;
3691+
pub mod model_monitor_notification_rule_filter_scope;
3692+
pub use self::model_monitor_notification_rule_filter_scope::MonitorNotificationRuleFilterScope;
36913693
pub mod model_monitor_notification_rule_filter;
36923694
pub use self::model_monitor_notification_rule_filter::MonitorNotificationRuleFilter;
36933695
pub mod model_monitor_notification_rule_relationships;

src/datadogV2/model/model_monitor_notification_rule_attributes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ 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.
14+
/// Use conditional recipients to define different recipients for different situations. Cannot be used with `recipients`.
1515
#[serde(rename = "conditional_recipients")]
1616
pub conditional_recipients:
1717
Option<crate::datadogV2::model::MonitorNotificationRuleConditionalRecipients>,
@@ -21,7 +21,7 @@ pub struct MonitorNotificationRuleAttributes {
2121
/// The name of the monitor notification rule.
2222
#[serde(rename = "name")]
2323
pub name: String,
24-
/// A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'.
24+
/// A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'. Cannot be used with `conditional_recipients`.
2525
#[serde(rename = "recipients")]
2626
pub recipients: Option<Vec<String>>,
2727
#[serde(skip)]

src/datadogV2/model/model_monitor_notification_rule_condition.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::fmt::{self, Formatter};
1111
#[skip_serializing_none]
1212
#[derive(Clone, Debug, PartialEq, Serialize)]
1313
pub struct MonitorNotificationRuleCondition {
14-
/// A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'.
14+
/// A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'. Cannot be used with `conditional_recipients`.
1515
#[serde(rename = "recipients")]
1616
pub recipients: Vec<String>,
1717
/// The scope to which the monitor applied.

src/datadogV2/model/model_monitor_notification_rule_conditional_recipients.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ use serde::{Deserialize, Deserializer, Serialize};
66
use serde_with::skip_serializing_none;
77
use std::fmt::{self, Formatter};
88

9-
/// Use conditional recipients to define different recipients for different situations.
9+
/// Use conditional recipients to define different recipients for different situations. Cannot be used with `recipients`.
1010
#[non_exhaustive]
1111
#[skip_serializing_none]
1212
#[derive(Clone, Debug, PartialEq, Serialize)]
1313
pub struct MonitorNotificationRuleConditionalRecipients {
1414
/// Conditions of the notification rule.
1515
#[serde(rename = "conditions")]
1616
pub conditions: Vec<crate::datadogV2::model::MonitorNotificationRuleCondition>,
17-
/// A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'.
17+
/// A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'. Cannot be used with `conditional_recipients`.
1818
#[serde(rename = "fallback_recipients")]
1919
pub fallback_recipients: Option<Vec<String>>,
2020
#[serde(flatten)]

src/datadogV2/model/model_monitor_notification_rule_filter.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ pub enum MonitorNotificationRuleFilter {
1111
MonitorNotificationRuleFilterTags(
1212
Box<crate::datadogV2::model::MonitorNotificationRuleFilterTags>,
1313
),
14+
MonitorNotificationRuleFilterScope(
15+
Box<crate::datadogV2::model::MonitorNotificationRuleFilterScope>,
16+
),
1417
UnparsedObject(crate::datadog::UnparsedObject),
1518
}
1619

@@ -28,6 +31,14 @@ impl<'de> Deserialize<'de> for MonitorNotificationRuleFilter {
2831
return Ok(MonitorNotificationRuleFilter::MonitorNotificationRuleFilterTags(_v));
2932
}
3033
}
34+
if let Ok(_v) = serde_json::from_value::<
35+
Box<crate::datadogV2::model::MonitorNotificationRuleFilterScope>,
36+
>(value.clone())
37+
{
38+
if !_v._unparsed {
39+
return Ok(MonitorNotificationRuleFilter::MonitorNotificationRuleFilterScope(_v));
40+
}
41+
}
3142

3243
return Ok(MonitorNotificationRuleFilter::UnparsedObject(
3344
crate::datadog::UnparsedObject { value },
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
use serde::de::{Error, MapAccess, Visitor};
5+
use serde::{Deserialize, Deserializer, Serialize};
6+
use serde_with::skip_serializing_none;
7+
use std::fmt::{self, Formatter};
8+
9+
/// Filter monitor notifications. A monitor notification must match the scope.
10+
#[non_exhaustive]
11+
#[skip_serializing_none]
12+
#[derive(Clone, Debug, PartialEq, Serialize)]
13+
pub struct MonitorNotificationRuleFilterScope {
14+
/// A scope composed of one or several key:value pairs, which can be used to filter monitor notifications on monitor and group tags.
15+
#[serde(rename = "scope")]
16+
pub scope: String,
17+
#[serde(skip)]
18+
#[serde(default)]
19+
pub(crate) _unparsed: bool,
20+
}
21+
22+
impl MonitorNotificationRuleFilterScope {
23+
pub fn new(scope: String) -> MonitorNotificationRuleFilterScope {
24+
MonitorNotificationRuleFilterScope {
25+
scope,
26+
_unparsed: false,
27+
}
28+
}
29+
}
30+
31+
impl<'de> Deserialize<'de> for MonitorNotificationRuleFilterScope {
32+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
33+
where
34+
D: Deserializer<'de>,
35+
{
36+
struct MonitorNotificationRuleFilterScopeVisitor;
37+
impl<'a> Visitor<'a> for MonitorNotificationRuleFilterScopeVisitor {
38+
type Value = MonitorNotificationRuleFilterScope;
39+
40+
fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
41+
f.write_str("a mapping")
42+
}
43+
44+
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
45+
where
46+
M: MapAccess<'a>,
47+
{
48+
let mut scope: Option<String> = None;
49+
let mut _unparsed = false;
50+
51+
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
52+
match k.as_str() {
53+
"scope" => {
54+
scope = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
55+
}
56+
&_ => {
57+
return Err(serde::de::Error::custom(
58+
"Additional properties not allowed",
59+
));
60+
}
61+
}
62+
}
63+
let scope = scope.ok_or_else(|| M::Error::missing_field("scope"))?;
64+
65+
let content = MonitorNotificationRuleFilterScope { scope, _unparsed };
66+
67+
Ok(content)
68+
}
69+
}
70+
71+
deserializer.deserialize_any(MonitorNotificationRuleFilterScopeVisitor)
72+
}
73+
}

src/datadogV2/model/model_monitor_notification_rule_filter_tags.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ use serde::{Deserialize, Deserializer, Serialize};
66
use serde_with::skip_serializing_none;
77
use std::fmt::{self, Formatter};
88

9-
/// Filter monitors by tags. Monitors must match all tags.
9+
/// Filter monitor notifications by tags. A monitor notification must match all tags.
1010
#[non_exhaustive]
1111
#[skip_serializing_none]
1212
#[derive(Clone, Debug, PartialEq, Serialize)]
1313
pub struct MonitorNotificationRuleFilterTags {
14-
/// A list of monitor tags.
14+
/// A list of tags (key:value pairs), which can be used to filter monitor notifications on monitor and group tags.
1515
#[serde(rename = "tags")]
1616
pub tags: Vec<String>,
1717
#[serde(skip)]

0 commit comments

Comments
 (0)