From 79961ce73877bfc1e57606c0d7a6fa4171aa8724 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Mon, 15 Dec 2025 22:19:46 +0000 Subject: [PATCH] Regenerate client from commit 249f48e of spec repo --- .generator/schemas/v1/openapi.yaml | 87 +++++++------ .generator/schemas/v2/openapi.yaml | 1 + examples/v1_tags_CreateHostTags.rs | 4 +- examples/v1_tags_GetHostTags.rs | 2 +- examples/v1_tags_ListHostTags.rs | 2 +- examples/v1_tags_UpdateHostTags.rs | 4 +- src/datadog/configuration.rs | 1 + src/datadogV1/api/api_tags.rs | 70 +++++----- src/datadogV1/model/mod.rs | 6 +- ..._host_tags.rs => model_host_tags_input.rs} | 22 ++-- src/datadogV1/model/model_host_tags_output.rs | 122 ++++++++++++++++++ src/datadogV1/model/model_tag_to_hosts.rs | 4 +- tests/scenarios/features/v1/tags.feature | 15 ++- 13 files changed, 238 insertions(+), 102 deletions(-) rename src/datadogV1/model/{model_host_tags.rs => model_host_tags_input.rs} (89%) create mode 100644 src/datadogV1/model/model_host_tags_output.rs diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index d9bb88a10..660ab5044 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -4179,7 +4179,7 @@ components: example: false type: boolean type: object - HostTags: + HostTagsInput: description: Set of tags to associate with your host. properties: host: @@ -4194,6 +4194,21 @@ components: type: string type: array type: object + HostTagsOutput: + description: Host name and an array of its tags + properties: + host: + description: Your host name. + example: test.host + type: string + tags: + description: A list of tags attached to a given host. + items: + description: A given tag in a list. + example: environment:production + type: string + type: array + type: object HostTotals: description: Total number of host currently monitored by Datadog. properties: @@ -18689,18 +18704,18 @@ components: - match type: object TagToHosts: - description: In this object, the key is the tag, the value is a list of host - names that are reporting that tag. + description: In this object, the key is the tag, and the value is a list of + host names that are reporting that tag. properties: tags: additionalProperties: - description: A list of additional properties for tags. + description: A list of host names which contain this tag items: description: A given tag in a list. example: test.metric.host type: string type: array - description: A list of tags to apply to the host. + description: A mapping of tags to host names type: object type: object TargetFormatType: @@ -35712,11 +35727,13 @@ paths: - synthetics_global_variable_write /api/v1/tags/hosts: get: - description: Return a mapping of tags to hosts for your whole infrastructure. + description: Returns a mapping of tags to hosts. For each tag, the response + returns a list of host names that contain this tag. There is a restriction + of 10k total host names from the org that can be attached to tags and returned. operationId: ListHostTags parameters: - - description: When specified, filters host list to those tags with the specified - source. + - description: Source to filter. [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). + Use "user" source for custom-defined tags. in: query name: source required: false @@ -35747,7 +35764,7 @@ paths: - apiKeyAuth: [] appKeyAuth: [] - AuthZ: [] - summary: Get Tags + summary: Get All Host Tags tags: - Tags x-permission: @@ -35755,21 +35772,20 @@ paths: permissions: [] /api/v1/tags/hosts/{host_name}: delete: - description: 'This endpoint allows you to remove all user-assigned tags + description: 'This endpoint allows you to remove all tags - for a single host.' + for a single host. If no source is specified, only deletes tags with no source.' operationId: DeleteHostTags parameters: - - description: This endpoint allows you to remove all user-assigned tags for - a single host. + - description: Specified host name to delete tags in: path name: host_name required: true schema: type: string - - description: 'The source of the tags (for example chef, puppet). - - [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value).' + - description: Source of the tags to be deleted. [Complete list of source attribute + values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). + Use "user" source for custom-defined tags. in: query name: source required: false @@ -35799,14 +35815,14 @@ paths: description: Return the list of tags that apply to a given host. operationId: GetHostTags parameters: - - description: When specified, filters list of tags to those tags with the specified - source. + - description: Name of the host to retrieve tags for in: path name: host_name required: true schema: type: string - - description: Source to filter. + - description: Source to filter. [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). + Use "user" source for custom-defined tags. in: query name: source required: false @@ -35817,7 +35833,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/HostTags' + $ref: '#/components/schemas/HostTagsOutput' description: OK '403': content: @@ -35833,25 +35849,23 @@ paths: description: Not Found '429': $ref: '#/components/responses/TooManyRequestsResponse' - summary: Get host tags + summary: Get Host Tags tags: - Tags post: description: 'This endpoint allows you to add new tags to a host, - optionally specifying where these tags come from.' + optionally specifying what source these tags come from.' operationId: CreateHostTags parameters: - - description: This endpoint allows you to add new tags to a host, optionally - specifying where the tags came from. + - description: Specified host name to add new tags in: path name: host_name required: true schema: type: string - - description: 'The source of the tags. - - [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value).' + - description: Source to filter. [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). + Use "user" source for custom-defined tags. example: chef in: query name: source @@ -35862,7 +35876,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/HostTags' + $ref: '#/components/schemas/HostTagsInput' description: Update host tags request body. required: true responses: @@ -35870,7 +35884,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/HostTags' + $ref: '#/components/schemas/HostTagsOutput' description: Created '403': content: @@ -35896,16 +35910,14 @@ paths: an integration source with those supplied in the request.' operationId: UpdateHostTags parameters: - - description: This endpoint allows you to update/replace all in an integration - source with those supplied in the request. + - description: Specified host name to change tags in: path name: host_name required: true schema: type: string - - description: 'The source of the tags (for example chef, puppet). - - [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value)' + - description: Source to filter. [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). + Use "user" source for custom-defined tags. in: query name: source required: false @@ -35915,7 +35927,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/HostTags' + $ref: '#/components/schemas/HostTagsInput' description: Add tags to host required: true responses: @@ -35923,7 +35935,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/HostTags' + $ref: '#/components/schemas/HostTagsOutput' description: OK '403': content: @@ -38918,7 +38930,8 @@ tags: by a source. For example, some valid sources include nagios, hudson, jenkins, - users, feed, chef, puppet, git, bitbucket, fabric, capistrano, etc. + users, feed, chef, puppet, git, bitbucket, fabric, capistrano, etc. Find a complete + list of source type names under [API Source Attributes](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). Read more about tags on [Getting Started with Tags](https://docs.datadoghq.com/getting_started/tagging/).' diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 0bf5e783b..f6fce6043 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -67941,6 +67941,7 @@ paths: - us3.datadoghq.com - us5.datadoghq.com - ap1.datadoghq.com + - ap2.datadoghq.com - datadoghq.eu - ddog-gov.com subdomain: diff --git a/examples/v1_tags_CreateHostTags.rs b/examples/v1_tags_CreateHostTags.rs index 57a9d0353..3c9942245 100644 --- a/examples/v1_tags_CreateHostTags.rs +++ b/examples/v1_tags_CreateHostTags.rs @@ -2,11 +2,11 @@ use datadog_api_client::datadog; use datadog_api_client::datadogV1::api_tags::CreateHostTagsOptionalParams; use datadog_api_client::datadogV1::api_tags::TagsAPI; -use datadog_api_client::datadogV1::model::HostTags; +use datadog_api_client::datadogV1::model::HostTagsInput; #[tokio::main] async fn main() { - let body = HostTags::new() + let body = HostTagsInput::new() .host("test.host".to_string()) .tags(vec!["environment:production".to_string()]); let configuration = datadog::Configuration::new(); diff --git a/examples/v1_tags_GetHostTags.rs b/examples/v1_tags_GetHostTags.rs index 9f03e66e4..c390f15a1 100644 --- a/examples/v1_tags_GetHostTags.rs +++ b/examples/v1_tags_GetHostTags.rs @@ -1,4 +1,4 @@ -// Get host tags returns "OK" response +// Get Host Tags returns "OK" response use datadog_api_client::datadog; use datadog_api_client::datadogV1::api_tags::GetHostTagsOptionalParams; use datadog_api_client::datadogV1::api_tags::TagsAPI; diff --git a/examples/v1_tags_ListHostTags.rs b/examples/v1_tags_ListHostTags.rs index 982cddb17..a78cd3489 100644 --- a/examples/v1_tags_ListHostTags.rs +++ b/examples/v1_tags_ListHostTags.rs @@ -1,4 +1,4 @@ -// Get Tags returns "OK" response +// Get All Host Tags returns "OK" response use datadog_api_client::datadog; use datadog_api_client::datadogV1::api_tags::ListHostTagsOptionalParams; use datadog_api_client::datadogV1::api_tags::TagsAPI; diff --git a/examples/v1_tags_UpdateHostTags.rs b/examples/v1_tags_UpdateHostTags.rs index 7e1c24992..31617605f 100644 --- a/examples/v1_tags_UpdateHostTags.rs +++ b/examples/v1_tags_UpdateHostTags.rs @@ -2,11 +2,11 @@ use datadog_api_client::datadog; use datadog_api_client::datadogV1::api_tags::TagsAPI; use datadog_api_client::datadogV1::api_tags::UpdateHostTagsOptionalParams; -use datadog_api_client::datadogV1::model::HostTags; +use datadog_api_client::datadogV1::model::HostTagsInput; #[tokio::main] async fn main() { - let body = HostTags::new() + let body = HostTagsInput::new() .host("test.host".to_string()) .tags(vec!["environment:production".to_string()]); let configuration = datadog::Configuration::new(); diff --git a/src/datadog/configuration.rs b/src/datadog/configuration.rs index d5bb85b60..f343078c3 100644 --- a/src/datadog/configuration.rs +++ b/src/datadog/configuration.rs @@ -581,6 +581,7 @@ lazy_static! { "us3.datadoghq.com".into(), "us5.datadoghq.com".into(), "ap1.datadoghq.com".into(), + "ap2.datadoghq.com".into(), "datadoghq.eu".into(), "ddog-gov.com".into(), ], diff --git a/src/datadogV1/api/api_tags.rs b/src/datadogV1/api/api_tags.rs index 2ed57aeef..51cea332f 100644 --- a/src/datadogV1/api/api_tags.rs +++ b/src/datadogV1/api/api_tags.rs @@ -14,14 +14,12 @@ use std::io::Write; #[non_exhaustive] #[derive(Clone, Default, Debug)] pub struct CreateHostTagsOptionalParams { - /// The source of the tags. - /// [Complete list of source attribute values](). + /// Source to filter. [Complete list of source attribute values](). Use "user" source for custom-defined tags. pub source: Option, } impl CreateHostTagsOptionalParams { - /// The source of the tags. - /// [Complete list of source attribute values](). + /// Source to filter. [Complete list of source attribute values](). Use "user" source for custom-defined tags. pub fn source(mut self, value: String) -> Self { self.source = Some(value); self @@ -32,14 +30,12 @@ impl CreateHostTagsOptionalParams { #[non_exhaustive] #[derive(Clone, Default, Debug)] pub struct DeleteHostTagsOptionalParams { - /// The source of the tags (for example chef, puppet). - /// [Complete list of source attribute values](). + /// Source of the tags to be deleted. [Complete list of source attribute values](). Use "user" source for custom-defined tags. pub source: Option, } impl DeleteHostTagsOptionalParams { - /// The source of the tags (for example chef, puppet). - /// [Complete list of source attribute values](). + /// Source of the tags to be deleted. [Complete list of source attribute values](). Use "user" source for custom-defined tags. pub fn source(mut self, value: String) -> Self { self.source = Some(value); self @@ -50,12 +46,12 @@ impl DeleteHostTagsOptionalParams { #[non_exhaustive] #[derive(Clone, Default, Debug)] pub struct GetHostTagsOptionalParams { - /// Source to filter. + /// Source to filter. [Complete list of source attribute values](). Use "user" source for custom-defined tags. pub source: Option, } impl GetHostTagsOptionalParams { - /// Source to filter. + /// Source to filter. [Complete list of source attribute values](). Use "user" source for custom-defined tags. pub fn source(mut self, value: String) -> Self { self.source = Some(value); self @@ -66,12 +62,12 @@ impl GetHostTagsOptionalParams { #[non_exhaustive] #[derive(Clone, Default, Debug)] pub struct ListHostTagsOptionalParams { - /// When specified, filters host list to those tags with the specified source. + /// Source to filter. [Complete list of source attribute values](). Use "user" source for custom-defined tags. pub source: Option, } impl ListHostTagsOptionalParams { - /// When specified, filters host list to those tags with the specified source. + /// Source to filter. [Complete list of source attribute values](). Use "user" source for custom-defined tags. pub fn source(mut self, value: String) -> Self { self.source = Some(value); self @@ -82,14 +78,12 @@ impl ListHostTagsOptionalParams { #[non_exhaustive] #[derive(Clone, Default, Debug)] pub struct UpdateHostTagsOptionalParams { - /// The source of the tags (for example chef, puppet). - /// [Complete list of source attribute values]() + /// Source to filter. [Complete list of source attribute values](). Use "user" source for custom-defined tags. pub source: Option, } impl UpdateHostTagsOptionalParams { - /// The source of the tags (for example chef, puppet). - /// [Complete list of source attribute values]() + /// Source to filter. [Complete list of source attribute values](). Use "user" source for custom-defined tags. pub fn source(mut self, value: String) -> Self { self.source = Some(value); self @@ -144,7 +138,7 @@ pub enum UpdateHostTagsError { /// /// The component of your infrastructure responsible for a tag is identified /// by a source. For example, some valid sources include nagios, hudson, jenkins, -/// users, feed, chef, puppet, git, bitbucket, fabric, capistrano, etc. +/// users, feed, chef, puppet, git, bitbucket, fabric, capistrano, etc. Find a complete list of source type names under [API Source Attributes](). /// /// Read more about tags on [Getting Started with Tags](). #[derive(Debug, Clone)] @@ -212,13 +206,13 @@ impl TagsAPI { } /// This endpoint allows you to add new tags to a host, - /// optionally specifying where these tags come from. + /// optionally specifying what source these tags come from. pub async fn create_host_tags( &self, host_name: String, - body: crate::datadogV1::model::HostTags, + body: crate::datadogV1::model::HostTagsInput, params: CreateHostTagsOptionalParams, - ) -> Result> { + ) -> Result> { match self .create_host_tags_with_http_info(host_name, body, params) .await @@ -237,14 +231,14 @@ impl TagsAPI { } /// This endpoint allows you to add new tags to a host, - /// optionally specifying where these tags come from. + /// optionally specifying what source these tags come from. pub async fn create_host_tags_with_http_info( &self, host_name: String, - body: crate::datadogV1::model::HostTags, + body: crate::datadogV1::model::HostTagsInput, params: CreateHostTagsOptionalParams, ) -> Result< - datadog::ResponseContent, + datadog::ResponseContent, datadog::Error, > { let local_configuration = &self.config; @@ -356,7 +350,7 @@ impl TagsAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::(&local_content) { + match serde_json::from_str::(&local_content) { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -378,8 +372,8 @@ impl TagsAPI { } } - /// This endpoint allows you to remove all user-assigned tags - /// for a single host. + /// This endpoint allows you to remove all tags + /// for a single host. If no source is specified, only deletes tags with no source. pub async fn delete_host_tags( &self, host_name: String, @@ -394,8 +388,8 @@ impl TagsAPI { } } - /// This endpoint allows you to remove all user-assigned tags - /// for a single host. + /// This endpoint allows you to remove all tags + /// for a single host. If no source is specified, only deletes tags with no source. pub async fn delete_host_tags_with_http_info( &self, host_name: String, @@ -486,7 +480,7 @@ impl TagsAPI { &self, host_name: String, params: GetHostTagsOptionalParams, - ) -> Result> { + ) -> Result> { match self.get_host_tags_with_http_info(host_name, params).await { Ok(response_content) => { if let Some(e) = response_content.entity { @@ -507,7 +501,7 @@ impl TagsAPI { host_name: String, params: GetHostTagsOptionalParams, ) -> Result< - datadog::ResponseContent, + datadog::ResponseContent, datadog::Error, > { let local_configuration = &self.config; @@ -573,7 +567,7 @@ impl TagsAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::(&local_content) { + match serde_json::from_str::(&local_content) { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -594,7 +588,7 @@ impl TagsAPI { } } - /// Return a mapping of tags to hosts for your whole infrastructure. + /// Returns a mapping of tags to hosts. For each tag, the response returns a list of host names that contain this tag. There is a restriction of 10k total host names from the org that can be attached to tags and returned. pub async fn list_host_tags( &self, params: ListHostTagsOptionalParams, @@ -613,7 +607,7 @@ impl TagsAPI { } } - /// Return a mapping of tags to hosts for your whole infrastructure. + /// Returns a mapping of tags to hosts. For each tag, the response returns a list of host names that contain this tag. There is a restriction of 10k total host names from the org that can be attached to tags and returned. pub async fn list_host_tags_with_http_info( &self, params: ListHostTagsOptionalParams, @@ -709,9 +703,9 @@ impl TagsAPI { pub async fn update_host_tags( &self, host_name: String, - body: crate::datadogV1::model::HostTags, + body: crate::datadogV1::model::HostTagsInput, params: UpdateHostTagsOptionalParams, - ) -> Result> { + ) -> Result> { match self .update_host_tags_with_http_info(host_name, body, params) .await @@ -734,10 +728,10 @@ impl TagsAPI { pub async fn update_host_tags_with_http_info( &self, host_name: String, - body: crate::datadogV1::model::HostTags, + body: crate::datadogV1::model::HostTagsInput, params: UpdateHostTagsOptionalParams, ) -> Result< - datadog::ResponseContent, + datadog::ResponseContent, datadog::Error, > { let local_configuration = &self.config; @@ -849,7 +843,7 @@ impl TagsAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::(&local_content) { + match serde_json::from_str::(&local_content) { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, diff --git a/src/datadogV1/model/mod.rs b/src/datadogV1/model/mod.rs index 8fd073565..6195ae655 100644 --- a/src/datadogV1/model/mod.rs +++ b/src/datadogV1/model/mod.rs @@ -1714,8 +1714,10 @@ pub mod model_synthetics_global_variable_request; pub use self::model_synthetics_global_variable_request::SyntheticsGlobalVariableRequest; pub mod model_tag_to_hosts; pub use self::model_tag_to_hosts::TagToHosts; -pub mod model_host_tags; -pub use self::model_host_tags::HostTags; +pub mod model_host_tags_output; +pub use self::model_host_tags_output::HostTagsOutput; +pub mod model_host_tags_input; +pub use self::model_host_tags_input::HostTagsInput; pub mod model_usage_analyzed_logs_response; pub use self::model_usage_analyzed_logs_response::UsageAnalyzedLogsResponse; pub mod model_usage_analyzed_logs_hour; diff --git a/src/datadogV1/model/model_host_tags.rs b/src/datadogV1/model/model_host_tags_input.rs similarity index 89% rename from src/datadogV1/model/model_host_tags.rs rename to src/datadogV1/model/model_host_tags_input.rs index 8ad461fa7..a73fe59e8 100644 --- a/src/datadogV1/model/model_host_tags.rs +++ b/src/datadogV1/model/model_host_tags_input.rs @@ -10,7 +10,7 @@ use std::fmt::{self, Formatter}; #[non_exhaustive] #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] -pub struct HostTags { +pub struct HostTagsInput { /// Your host name. #[serde(rename = "host")] pub host: Option, @@ -24,9 +24,9 @@ pub struct HostTags { pub(crate) _unparsed: bool, } -impl HostTags { - pub fn new() -> HostTags { - HostTags { +impl HostTagsInput { + pub fn new() -> HostTagsInput { + HostTagsInput { host: None, tags: None, additional_properties: std::collections::BTreeMap::new(), @@ -53,20 +53,20 @@ impl HostTags { } } -impl Default for HostTags { +impl Default for HostTagsInput { fn default() -> Self { Self::new() } } -impl<'de> Deserialize<'de> for HostTags { +impl<'de> Deserialize<'de> for HostTagsInput { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { - struct HostTagsVisitor; - impl<'a> Visitor<'a> for HostTagsVisitor { - type Value = HostTags; + struct HostTagsInputVisitor; + impl<'a> Visitor<'a> for HostTagsInputVisitor { + type Value = HostTagsInput; fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { f.write_str("a mapping") @@ -106,7 +106,7 @@ impl<'de> Deserialize<'de> for HostTags { } } - let content = HostTags { + let content = HostTagsInput { host, tags, additional_properties, @@ -117,6 +117,6 @@ impl<'de> Deserialize<'de> for HostTags { } } - deserializer.deserialize_any(HostTagsVisitor) + deserializer.deserialize_any(HostTagsInputVisitor) } } diff --git a/src/datadogV1/model/model_host_tags_output.rs b/src/datadogV1/model/model_host_tags_output.rs new file mode 100644 index 000000000..f9dfdab47 --- /dev/null +++ b/src/datadogV1/model/model_host_tags_output.rs @@ -0,0 +1,122 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Host name and an array of its tags +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct HostTagsOutput { + /// Your host name. + #[serde(rename = "host")] + pub host: Option, + /// A list of tags attached to a given host. + #[serde(rename = "tags")] + pub tags: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl HostTagsOutput { + pub fn new() -> HostTagsOutput { + HostTagsOutput { + host: None, + tags: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn host(mut self, value: String) -> Self { + self.host = Some(value); + self + } + + pub fn tags(mut self, value: Vec) -> Self { + self.tags = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for HostTagsOutput { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for HostTagsOutput { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct HostTagsOutputVisitor; + impl<'a> Visitor<'a> for HostTagsOutputVisitor { + type Value = HostTagsOutput; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut host: Option = None; + let mut tags: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "host" => { + if v.is_null() { + continue; + } + host = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "tags" => { + if v.is_null() { + continue; + } + tags = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = HostTagsOutput { + host, + tags, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(HostTagsOutputVisitor) + } +} diff --git a/src/datadogV1/model/model_tag_to_hosts.rs b/src/datadogV1/model/model_tag_to_hosts.rs index 13b4c9d08..463fbb90b 100644 --- a/src/datadogV1/model/model_tag_to_hosts.rs +++ b/src/datadogV1/model/model_tag_to_hosts.rs @@ -6,12 +6,12 @@ use serde::{Deserialize, Deserializer, Serialize}; use serde_with::skip_serializing_none; use std::fmt::{self, Formatter}; -/// In this object, the key is the tag, the value is a list of host names that are reporting that tag. +/// In this object, the key is the tag, and the value is a list of host names that are reporting that tag. #[non_exhaustive] #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] pub struct TagToHosts { - /// A list of tags to apply to the host. + /// A mapping of tags to host names #[serde(rename = "tags")] pub tags: Option>>, #[serde(flatten)] diff --git a/tests/scenarios/features/v1/tags.feature b/tests/scenarios/features/v1/tags.feature index 36e1eabfd..d6557ca18 100644 --- a/tests/scenarios/features/v1/tags.feature +++ b/tests/scenarios/features/v1/tags.feature @@ -6,8 +6,11 @@ Feature: Tags tags to a particular host. The component of your infrastructure responsible for a tag is identified by a source. For example, some valid sources include nagios, hudson, jenkins, users, feed, chef, puppet, git, - bitbucket, fabric, capistrano, etc. Read more about tags on [Getting - Started with Tags](https://docs.datadoghq.com/getting_started/tagging/). + bitbucket, fabric, capistrano, etc. Find a complete list of source type + names under [API Source + Attributes](https://docs.datadoghq.com/integrations/faq/list-of-api- + source-attribute-value). Read more about tags on [Getting Started with + Tags](https://docs.datadoghq.com/getting_started/tagging/). Background: Given a valid "apiKeyAuth" key in the system @@ -31,26 +34,26 @@ Feature: Tags Then the response status is 404 Not Found @generated @skip @team:DataDog/core-index - Scenario: Get Tags returns "Not Found" response + Scenario: Get All Host Tags returns "Not Found" response Given new "ListHostTags" request When the request is sent Then the response status is 404 Not Found @generated @skip @team:DataDog/core-index - Scenario: Get Tags returns "OK" response + Scenario: Get All Host Tags returns "OK" response Given new "ListHostTags" request When the request is sent Then the response status is 200 OK @generated @skip @team:DataDog/core-index - Scenario: Get host tags returns "Not Found" response + Scenario: Get Host Tags returns "Not Found" response Given new "GetHostTags" request And request contains "host_name" parameter from "REPLACE.ME" When the request is sent Then the response status is 404 Not Found @generated @skip @team:DataDog/core-index - Scenario: Get host tags returns "OK" response + Scenario: Get Host Tags returns "OK" response Given new "GetHostTags" request And request contains "host_name" parameter from "REPLACE.ME" When the request is sent