Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33935,6 +33935,21 @@ components:
format: int64
type: integer
type: object
DeviceTagsBySource:
description: Tags associated with a device from a specific source.
properties:
source:
description: The source of the tags.
example: user
type: string
tags:
description: The list of tags for the source.
example: ["tag:test", "tag:testbis"]
items:
description: A tag string in `key:value` format.
type: string
type: array
type: object
DevicesListData:
description: The devices list data
properties:
Expand Down Expand Up @@ -63468,6 +63483,12 @@ components:
ListTagsResponseDataAttributes:
description: The definition of ListTagsResponseDataAttributes object.
properties:
by_source:
description: The list of device tags grouped by source.
items:
$ref: "#/components/schemas/DeviceTagsBySource"
readOnly: true
type: array
tags:
description: The list of tags
example: ["tag:test", "tag:testbis"]
Expand Down Expand Up @@ -173995,6 +174016,20 @@ paths:
content:
application/json:
examples:
by_source:
value:
data:
attributes:
by_source:
- source: user
tags:
- "tag:test"
- "tag:testbis"
- source: snmp
tags:
- "device_ip:1.2.3.4"
id: foiwf7rgw38fh
type: tags
default:
value:
data:
Expand Down
2 changes: 2 additions & 0 deletions src/datadogV2/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7684,6 +7684,8 @@ pub mod model_list_tags_response_data;
pub use self::model_list_tags_response_data::ListTagsResponseData;
pub mod model_list_tags_response_data_attributes;
pub use self::model_list_tags_response_data_attributes::ListTagsResponseDataAttributes;
pub mod model_device_tags_by_source;
pub use self::model_device_tags_by_source::DeviceTagsBySource;
pub mod model_list_interface_tags_response;
pub use self::model_list_interface_tags_response::ListInterfaceTagsResponse;
pub mod model_list_interface_tags_response_data;
Expand Down
122 changes: 122 additions & 0 deletions src/datadogV2/model/model_device_tags_by_source.rs
Original file line number Diff line number Diff line change
@@ -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};

/// Tags associated with a device from a specific source.
#[non_exhaustive]
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct DeviceTagsBySource {
/// The source of the tags.
#[serde(rename = "source")]
pub source: Option<String>,
/// The list of tags for the source.
#[serde(rename = "tags")]
pub tags: Option<Vec<String>>,
#[serde(flatten)]
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
#[serde(skip)]
#[serde(default)]
pub(crate) _unparsed: bool,
}

impl DeviceTagsBySource {
pub fn new() -> DeviceTagsBySource {
DeviceTagsBySource {
source: None,
tags: None,
additional_properties: std::collections::BTreeMap::new(),
_unparsed: false,
}
}

pub fn source(mut self, value: String) -> Self {
self.source = Some(value);
self
}

pub fn tags(mut self, value: Vec<String>) -> Self {
self.tags = Some(value);
self
}

pub fn additional_properties(
mut self,
value: std::collections::BTreeMap<String, serde_json::Value>,
) -> Self {
self.additional_properties = value;
self
}
}

impl Default for DeviceTagsBySource {
fn default() -> Self {
Self::new()
}
}

impl<'de> Deserialize<'de> for DeviceTagsBySource {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct DeviceTagsBySourceVisitor;
impl<'a> Visitor<'a> for DeviceTagsBySourceVisitor {
type Value = DeviceTagsBySource;

fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.write_str("a mapping")
}

fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
where
M: MapAccess<'a>,
{
let mut source: Option<String> = None;
let mut tags: Option<Vec<String>> = 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::<String, serde_json::Value>()? {
match k.as_str() {
"source" => {
if v.is_null() {
continue;
}
source = 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 = DeviceTagsBySource {
source,
tags,
additional_properties,
_unparsed,
};

Ok(content)
}
}

deserializer.deserialize_any(DeviceTagsBySourceVisitor)
}
}
17 changes: 17 additions & 0 deletions src/datadogV2/model/model_list_tags_response_data_attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ use std::fmt::{self, Formatter};
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct ListTagsResponseDataAttributes {
/// The list of device tags grouped by source.
#[serde(rename = "by_source")]
pub by_source: Option<Vec<crate::datadogV2::model::DeviceTagsBySource>>,
/// The list of tags
#[serde(rename = "tags")]
pub tags: Option<Vec<String>>,
Expand All @@ -24,12 +27,18 @@ pub struct ListTagsResponseDataAttributes {
impl ListTagsResponseDataAttributes {
pub fn new() -> ListTagsResponseDataAttributes {
ListTagsResponseDataAttributes {
by_source: None,
tags: None,
additional_properties: std::collections::BTreeMap::new(),
_unparsed: false,
}
}

pub fn by_source(mut self, value: Vec<crate::datadogV2::model::DeviceTagsBySource>) -> Self {
self.by_source = Some(value);
self
}

pub fn tags(mut self, value: Vec<String>) -> Self {
self.tags = Some(value);
self
Expand Down Expand Up @@ -67,6 +76,7 @@ impl<'de> Deserialize<'de> for ListTagsResponseDataAttributes {
where
M: MapAccess<'a>,
{
let mut by_source: Option<Vec<crate::datadogV2::model::DeviceTagsBySource>> = None;
let mut tags: Option<Vec<String>> = None;
let mut additional_properties: std::collections::BTreeMap<
String,
Expand All @@ -76,6 +86,12 @@ impl<'de> Deserialize<'de> for ListTagsResponseDataAttributes {

while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
match k.as_str() {
"by_source" => {
if v.is_null() {
continue;
}
by_source = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"tags" => {
if v.is_null() {
continue;
Expand All @@ -91,6 +107,7 @@ impl<'de> Deserialize<'de> for ListTagsResponseDataAttributes {
}

let content = ListTagsResponseDataAttributes {
by_source,
tags,
additional_properties,
_unparsed,
Expand Down
Loading