Skip to content

Commit ae4dab6

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Support metric filtering in integration azure GET, PUT APIs (#167)
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 91de1d3 commit ae4dab6

13 files changed

+178
-25
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-07-02 18:50:32.192164",
8-
"spec_repo_commit": "fae9d797"
7+
"regenerated": "2024-07-03 18:25:13.089219",
8+
"spec_repo_commit": "ce846cd6"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-07-02 18:50:32.211734",
13-
"spec_repo_commit": "fae9d797"
12+
"regenerated": "2024-07-03 18:25:13.107222",
13+
"spec_repo_commit": "ce846cd6"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,8 @@ components:
840840
Only hosts that match one of the defined tags are imported into Datadog.'
841841
example: key:value,filter:example
842842
type: string
843+
metrics_config:
844+
$ref: '#/components/schemas/AzureAccountMetricsConfig'
843845
new_client_id:
844846
description: Your New Azure web application ID.
845847
example: new1c7f6-1234-5678-9101-3fcbf464test
@@ -864,6 +866,27 @@ components:
864866
items:
865867
$ref: '#/components/schemas/AzureAccount'
866868
type: array
869+
AzureAccountMetricsConfig:
870+
description: 'Dictionary containing the key `excluded_resource_providers` which
871+
has to be a list of Microsoft Azure Resource Provider names.
872+
873+
This feature is currently being beta tested.
874+
875+
In order to enable all resource providers for metric collection, pass:
876+
877+
`metrics_config: {"excluded_resource_providers": []}` (i.e., an empty list
878+
for `excluded_resource_providers`).'
879+
properties:
880+
excluded_resource_providers:
881+
description: List of Microsoft Azure Resource Providers to exclude from
882+
metric collection.
883+
example:
884+
- Microsoft.Sql
885+
- Microsoft.Cdn
886+
items:
887+
type: string
888+
type: array
889+
type: object
867890
CancelDowntimesByScopeRequest:
868891
description: Cancel downtimes according to scope.
869892
properties:

examples/v1_azure-integration_update_azure_host_filters.rs

Lines changed: 7 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_azure_integration::AzureIntegrationAPI;
44
use datadog_api_client::datadogV1::model::AzureAccount;
5+
use datadog_api_client::datadogV1::model::AzureAccountMetricsConfig;
56

67
#[tokio::main]
78
async fn main() {
@@ -15,6 +16,12 @@ async fn main() {
1516
.custom_metrics_enabled(true)
1617
.errors(vec!["*".to_string()])
1718
.host_filters("key:value,filter:example".to_string())
19+
.metrics_config(
20+
AzureAccountMetricsConfig::new().excluded_resource_providers(vec![
21+
"Microsoft.Sql".to_string(),
22+
"Microsoft.Cdn".to_string(),
23+
]),
24+
)
1825
.new_client_id("new1c7f6-1234-5678-9101-3fcbf464test".to_string())
1926
.new_tenant_name("new1c44-1234-5678-9101-cc00736ftest".to_string())
2027
.resource_collection_enabled(true)

examples/v1_azure-integration_update_azure_integration.rs

Lines changed: 7 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_azure_integration::AzureIntegrationAPI;
44
use datadog_api_client::datadogV1::model::AzureAccount;
5+
use datadog_api_client::datadogV1::model::AzureAccountMetricsConfig;
56

67
#[tokio::main]
78
async fn main() {
@@ -15,6 +16,12 @@ async fn main() {
1516
.custom_metrics_enabled(true)
1617
.errors(vec!["*".to_string()])
1718
.host_filters("key:value,filter:example".to_string())
19+
.metrics_config(
20+
AzureAccountMetricsConfig::new().excluded_resource_providers(vec![
21+
"Microsoft.Sql".to_string(),
22+
"Microsoft.Cdn".to_string(),
23+
]),
24+
)
1825
.new_client_id("".to_string())
1926
.new_tenant_name("".to_string())
2027
.resource_collection_enabled(true)

src/datadogV1/model/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,8 @@ pub mod model_aws_logs_services_request;
722722
pub use self::model_aws_logs_services_request::AWSLogsServicesRequest;
723723
pub mod model_azure_account;
724724
pub use self::model_azure_account::AzureAccount;
725+
pub mod model_azure_account_metrics_config;
726+
pub use self::model_azure_account_metrics_config::AzureAccountMetricsConfig;
725727
pub mod model_gcp_account;
726728
pub use self::model_gcp_account::GCPAccount;
727729
pub mod model_pager_duty_service;

src/datadogV1/model/model_azure_account.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ pub struct AzureAccount {
4242
/// Only hosts that match one of the defined tags are imported into Datadog.
4343
#[serde(rename = "host_filters")]
4444
pub host_filters: Option<String>,
45+
/// Dictionary containing the key `excluded_resource_providers` which has to be a list of Microsoft Azure Resource Provider names.
46+
/// This feature is currently being beta tested.
47+
/// In order to enable all resource providers for metric collection, pass:
48+
/// `metrics_config: {"excluded_resource_providers": []}` (i.e., an empty list for `excluded_resource_providers`).
49+
#[serde(rename = "metrics_config")]
50+
pub metrics_config: Option<crate::datadogV1::model::AzureAccountMetricsConfig>,
4551
/// Your New Azure web application ID.
4652
#[serde(rename = "new_client_id")]
4753
pub new_client_id: Option<String>,
@@ -71,6 +77,7 @@ impl AzureAccount {
7177
custom_metrics_enabled: None,
7278
errors: None,
7379
host_filters: None,
80+
metrics_config: None,
7481
new_client_id: None,
7582
new_tenant_name: None,
7683
resource_collection_enabled: None,
@@ -124,6 +131,14 @@ impl AzureAccount {
124131
self
125132
}
126133

134+
pub fn metrics_config(
135+
mut self,
136+
value: crate::datadogV1::model::AzureAccountMetricsConfig,
137+
) -> Self {
138+
self.metrics_config = Some(value);
139+
self
140+
}
141+
127142
pub fn new_client_id(mut self, value: String) -> Self {
128143
self.new_client_id = Some(value);
129144
self
@@ -177,6 +192,8 @@ impl<'de> Deserialize<'de> for AzureAccount {
177192
let mut custom_metrics_enabled: Option<bool> = None;
178193
let mut errors: Option<Vec<String>> = None;
179194
let mut host_filters: Option<String> = None;
195+
let mut metrics_config: Option<crate::datadogV1::model::AzureAccountMetricsConfig> =
196+
None;
180197
let mut new_client_id: Option<String> = None;
181198
let mut new_tenant_name: Option<String> = None;
182199
let mut resource_collection_enabled: Option<bool> = None;
@@ -245,6 +262,13 @@ impl<'de> Deserialize<'de> for AzureAccount {
245262
host_filters =
246263
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
247264
}
265+
"metrics_config" => {
266+
if v.is_null() {
267+
continue;
268+
}
269+
metrics_config =
270+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
271+
}
248272
"new_client_id" => {
249273
if v.is_null() {
250274
continue;
@@ -287,6 +311,7 @@ impl<'de> Deserialize<'de> for AzureAccount {
287311
custom_metrics_enabled,
288312
errors,
289313
host_filters,
314+
metrics_config,
290315
new_client_id,
291316
new_tenant_name,
292317
resource_collection_enabled,
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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+
/// Dictionary containing the key `excluded_resource_providers` which has to be a list of Microsoft Azure Resource Provider names.
10+
/// This feature is currently being beta tested.
11+
/// In order to enable all resource providers for metric collection, pass:
12+
/// `metrics_config: {"excluded_resource_providers": []}` (i.e., an empty list for `excluded_resource_providers`).
13+
#[non_exhaustive]
14+
#[skip_serializing_none]
15+
#[derive(Clone, Debug, PartialEq, Serialize)]
16+
pub struct AzureAccountMetricsConfig {
17+
/// List of Microsoft Azure Resource Providers to exclude from metric collection.
18+
#[serde(rename = "excluded_resource_providers")]
19+
pub excluded_resource_providers: Option<Vec<String>>,
20+
#[serde(skip)]
21+
#[serde(default)]
22+
pub(crate) _unparsed: bool,
23+
}
24+
25+
impl AzureAccountMetricsConfig {
26+
pub fn new() -> AzureAccountMetricsConfig {
27+
AzureAccountMetricsConfig {
28+
excluded_resource_providers: None,
29+
_unparsed: false,
30+
}
31+
}
32+
33+
pub fn excluded_resource_providers(mut self, value: Vec<String>) -> Self {
34+
self.excluded_resource_providers = Some(value);
35+
self
36+
}
37+
}
38+
39+
impl Default for AzureAccountMetricsConfig {
40+
fn default() -> Self {
41+
Self::new()
42+
}
43+
}
44+
45+
impl<'de> Deserialize<'de> for AzureAccountMetricsConfig {
46+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
47+
where
48+
D: Deserializer<'de>,
49+
{
50+
struct AzureAccountMetricsConfigVisitor;
51+
impl<'a> Visitor<'a> for AzureAccountMetricsConfigVisitor {
52+
type Value = AzureAccountMetricsConfig;
53+
54+
fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
55+
f.write_str("a mapping")
56+
}
57+
58+
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
59+
where
60+
M: MapAccess<'a>,
61+
{
62+
let mut excluded_resource_providers: Option<Vec<String>> = None;
63+
let mut _unparsed = false;
64+
65+
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
66+
match k.as_str() {
67+
"excluded_resource_providers" => {
68+
if v.is_null() {
69+
continue;
70+
}
71+
excluded_resource_providers =
72+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
73+
}
74+
&_ => {}
75+
}
76+
}
77+
78+
let content = AzureAccountMetricsConfig {
79+
excluded_resource_providers,
80+
_unparsed,
81+
};
82+
83+
Ok(content)
84+
}
85+
}
86+
87+
deserializer.deserialize_any(AzureAccountMetricsConfigVisitor)
88+
}
89+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2024-02-28T20:25:59.931Z
1+
2024-07-01T18:40:05.567Z

tests/scenarios/cassettes/v1/azure_integration/Delete-an-Azure-integration-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": "{\"app_service_plan_filters\":\"key:value,filter:example\",\"automute\":true,\"client_id\":\"17091519-0000-0000-0000-170915195900\",\"client_secret\":\"testingx./Sw*g/Y33t..R1cH+hScMDt\",\"container_app_filters\":\"key:value,filter:example\",\"cspm_enabled\":true,\"custom_metrics_enabled\":true,\"errors\":[\"*\"],\"host_filters\":\"key:value,filter:example\",\"new_client_id\":\"17091519-0000-0000-0000-170915195900\",\"new_tenant_name\":\"17091519-0000-0000-0000-170915195900\",\"resource_collection_enabled\":true,\"tenant_name\":\"17091519-0000-0000-0000-170915195900\"}",
6+
"string": "{\"app_service_plan_filters\":\"key:value,filter:example\",\"automute\":true,\"client_id\":\"17198592-0000-0000-0000-171985920500\",\"client_secret\":\"testingx./Sw*g/Y33t..R1cH+hScMDt\",\"container_app_filters\":\"key:value,filter:example\",\"cspm_enabled\":true,\"custom_metrics_enabled\":true,\"errors\":[\"*\"],\"host_filters\":\"key:value,filter:example\",\"metrics_config\":{\"excluded_resource_providers\":[\"Microsoft.Sql\",\"Microsoft.Cdn\"]},\"new_client_id\":\"17198592-0000-0000-0000-171985920500\",\"new_tenant_name\":\"17198592-0000-0000-0000-171985920500\",\"resource_collection_enabled\":true,\"tenant_name\":\"17198592-0000-0000-0000-171985920500\"}",
77
"encoding": null
88
},
99
"headers": {
@@ -32,12 +32,12 @@
3232
"message": "OK"
3333
}
3434
},
35-
"recorded_at": "Wed, 28 Feb 2024 20:25:59 GMT"
35+
"recorded_at": "Mon, 01 Jul 2024 18:40:05 GMT"
3636
},
3737
{
3838
"request": {
3939
"body": {
40-
"string": "{\"client_id\":\"17091519-0000-0000-0000-170915195900\",\"tenant_name\":\"17091519-0000-0000-0000-170915195900\"}",
40+
"string": "{\"client_id\":\"17198592-0000-0000-0000-171985920500\",\"tenant_name\":\"17198592-0000-0000-0000-171985920500\"}",
4141
"encoding": null
4242
},
4343
"headers": {
@@ -66,12 +66,12 @@
6666
"message": "OK"
6767
}
6868
},
69-
"recorded_at": "Wed, 28 Feb 2024 20:25:59 GMT"
69+
"recorded_at": "Mon, 01 Jul 2024 18:40:05 GMT"
7070
},
7171
{
7272
"request": {
7373
"body": {
74-
"string": "{\"client_id\":\"17091519-0000-0000-0000-170915195900\",\"tenant_name\":\"17091519-0000-0000-0000-170915195900\"}",
74+
"string": "{\"client_id\":\"17198592-0000-0000-0000-171985920500\",\"tenant_name\":\"17198592-0000-0000-0000-171985920500\"}",
7575
"encoding": null
7676
},
7777
"headers": {
@@ -100,7 +100,7 @@
100100
"message": "OK"
101101
}
102102
},
103-
"recorded_at": "Wed, 28 Feb 2024 20:25:59 GMT"
103+
"recorded_at": "Mon, 01 Jul 2024 18:40:05 GMT"
104104
}
105105
],
106106
"recorded_with": "VCR 6.0.0"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2024-02-28T20:26:00.368Z
1+
2024-07-01T18:40:05.942Z

0 commit comments

Comments
 (0)