diff --git a/.apigentools-info b/.apigentools-info index 6d3d8a3e8..b07846fb5 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2025-01-31 15:03:07.218117", - "spec_repo_commit": "b01f90f4" + "regenerated": "2025-02-03 15:47:55.976108", + "spec_repo_commit": "d6014add" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2025-01-31 15:03:07.236273", - "spec_repo_commit": "b01f90f4" + "regenerated": "2025-02-03 15:47:55.991637", + "spec_repo_commit": "d6014add" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 53917f83c..62f1c571c 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -10524,6 +10524,99 @@ components: - $ref: '#/components/schemas/EntityV3Datastore' - $ref: '#/components/schemas/EntityV3Queue' - $ref: '#/components/schemas/EntityV3System' + - $ref: '#/components/schemas/EntityV3API' + EntityV3API: + additionalProperties: false + description: Schema for API entities. + properties: + apiVersion: + $ref: '#/components/schemas/EntityV3APIVersion' + datadog: + $ref: '#/components/schemas/EntityV3APIDatadog' + extensions: + additionalProperties: {} + description: Custom extensions. This is the free-formed field to send client-side + metadata. No Datadog features are affected by this field. + type: object + integrations: + $ref: '#/components/schemas/EntityV3Integrations' + kind: + $ref: '#/components/schemas/EntityV3APIKind' + metadata: + $ref: '#/components/schemas/EntityV3Metadata' + spec: + $ref: '#/components/schemas/EntityV3APISpec' + required: + - apiVersion + - kind + - metadata + type: object + EntityV3APIDatadog: + additionalProperties: false + description: Datadog product integrations for the API entity. + properties: + codeLocations: + $ref: '#/components/schemas/EntityV3DatadogCodeLocations' + events: + $ref: '#/components/schemas/EntityV3DatadogEvents' + logs: + $ref: '#/components/schemas/EntityV3DatadogLogs' + performanceData: + $ref: '#/components/schemas/EntityV3DatadogPerformance' + pipelines: + $ref: '#/components/schemas/EntityV3DatadogPipelines' + type: object + EntityV3APIKind: + description: The definition of Entity V3 API Kind object. + enum: + - api + example: api + type: string + x-enum-varnames: + - API + EntityV3APISpec: + additionalProperties: false + description: The definition of Entity V3 API Spec object. + properties: + implementedBy: + description: Services which implemented the API. + items: + type: string + type: array + interface: + $ref: '#/components/schemas/EntityV3APISpecInterface' + lifecycle: + description: The lifecycle state of the component. + minLength: 1 + type: string + tier: + description: The importance of the component. + minLength: 1 + type: string + type: + description: The type of API. + type: string + type: object + EntityV3APISpecInterface: + additionalProperties: false + description: The API definition. + oneOf: + - $ref: '#/components/schemas/EntityV3APISpecInterfaceFileRef' + - $ref: '#/components/schemas/EntityV3APISpecInterfaceDefinition' + EntityV3APISpecInterfaceDefinition: + additionalProperties: false + description: The definition of `EntityV3APISpecInterfaceDefinition` object. + properties: + definition: + description: The API definition. + type: object + EntityV3APISpecInterfaceFileRef: + additionalProperties: false + description: The definition of `EntityV3APISpecInterfaceFileRef` object. + properties: + fileRef: + description: The reference to the API definition file. + type: string EntityV3APIVersion: description: The schema version of entity type. The field is known as schema-version in the previous version. diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index ab6f244be..7e35f11b4 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -706,6 +706,20 @@ pub mod model_entity_v3_system_kind; pub use self::model_entity_v3_system_kind::EntityV3SystemKind; pub mod model_entity_v3_system_spec; pub use self::model_entity_v3_system_spec::EntityV3SystemSpec; +pub mod model_entity_v3_api; +pub use self::model_entity_v3_api::EntityV3API; +pub mod model_entity_v3_api_datadog; +pub use self::model_entity_v3_api_datadog::EntityV3APIDatadog; +pub mod model_entity_v3_api_kind; +pub use self::model_entity_v3_api_kind::EntityV3APIKind; +pub mod model_entity_v3_api_spec; +pub use self::model_entity_v3_api_spec::EntityV3APISpec; +pub mod model_entity_v3_api_spec_interface_file_ref; +pub use self::model_entity_v3_api_spec_interface_file_ref::EntityV3APISpecInterfaceFileRef; +pub mod model_entity_v3_api_spec_interface_definition; +pub use self::model_entity_v3_api_spec_interface_definition::EntityV3APISpecInterfaceDefinition; +pub mod model_entity_v3_api_spec_interface; +pub use self::model_entity_v3_api_spec_interface::EntityV3APISpecInterface; pub mod model_entity_v3; pub use self::model_entity_v3::EntityV3; pub mod model_entity_response_included_raw_schema; diff --git a/src/datadogV2/model/model_entity_v3.rs b/src/datadogV2/model/model_entity_v3.rs index 14c462855..57d802589 100644 --- a/src/datadogV2/model/model_entity_v3.rs +++ b/src/datadogV2/model/model_entity_v3.rs @@ -12,6 +12,7 @@ pub enum EntityV3 { EntityV3Datastore(Box), EntityV3Queue(Box), EntityV3System(Box), + EntityV3API(Box), UnparsedObject(crate::datadog::UnparsedObject), } @@ -49,6 +50,13 @@ impl<'de> Deserialize<'de> for EntityV3 { return Ok(EntityV3::EntityV3System(_v)); } } + if let Ok(_v) = + serde_json::from_value::>(value.clone()) + { + if !_v._unparsed { + return Ok(EntityV3::EntityV3API(_v)); + } + } return Ok(EntityV3::UnparsedObject(crate::datadog::UnparsedObject { value, diff --git a/src/datadogV2/model/model_entity_v3_api.rs b/src/datadogV2/model/model_entity_v3_api.rs new file mode 100644 index 000000000..e96b370d0 --- /dev/null +++ b/src/datadogV2/model/model_entity_v3_api.rs @@ -0,0 +1,195 @@ +// 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}; + +/// Schema for API entities. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EntityV3API { + /// The schema version of entity type. The field is known as schema-version in the previous version. + #[serde(rename = "apiVersion")] + pub api_version: crate::datadogV2::model::EntityV3APIVersion, + /// Datadog product integrations for the API entity. + #[serde(rename = "datadog")] + pub datadog: Option, + /// Custom extensions. This is the free-formed field to send client-side metadata. No Datadog features are affected by this field. + #[serde(rename = "extensions")] + pub extensions: Option>, + /// A base schema for defining third-party integrations. + #[serde(rename = "integrations")] + pub integrations: Option, + /// The definition of Entity V3 API Kind object. + #[serde(rename = "kind")] + pub kind: crate::datadogV2::model::EntityV3APIKind, + /// The definition of Entity V3 Metadata object. + #[serde(rename = "metadata")] + pub metadata: crate::datadogV2::model::EntityV3Metadata, + /// The definition of Entity V3 API Spec object. + #[serde(rename = "spec")] + pub spec: Option, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EntityV3API { + pub fn new( + api_version: crate::datadogV2::model::EntityV3APIVersion, + kind: crate::datadogV2::model::EntityV3APIKind, + metadata: crate::datadogV2::model::EntityV3Metadata, + ) -> EntityV3API { + EntityV3API { + api_version, + datadog: None, + extensions: None, + integrations: None, + kind, + metadata, + spec: None, + _unparsed: false, + } + } + + pub fn datadog(mut self, value: crate::datadogV2::model::EntityV3APIDatadog) -> Self { + self.datadog = Some(value); + self + } + + pub fn extensions( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.extensions = Some(value); + self + } + + pub fn integrations(mut self, value: crate::datadogV2::model::EntityV3Integrations) -> Self { + self.integrations = Some(value); + self + } + + pub fn spec(mut self, value: crate::datadogV2::model::EntityV3APISpec) -> Self { + self.spec = Some(value); + self + } +} + +impl<'de> Deserialize<'de> for EntityV3API { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EntityV3APIVisitor; + impl<'a> Visitor<'a> for EntityV3APIVisitor { + type Value = EntityV3API; + + 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 api_version: Option = None; + let mut datadog: Option = None; + let mut extensions: Option> = + None; + let mut integrations: Option = None; + let mut kind: Option = None; + let mut metadata: Option = None; + let mut spec: Option = None; + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "apiVersion" => { + api_version = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _api_version) = api_version { + match _api_version { + crate::datadogV2::model::EntityV3APIVersion::UnparsedObject( + _api_version, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "datadog" => { + if v.is_null() { + continue; + } + datadog = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "extensions" => { + if v.is_null() { + continue; + } + extensions = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "integrations" => { + if v.is_null() { + continue; + } + integrations = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "kind" => { + kind = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _kind) = kind { + match _kind { + crate::datadogV2::model::EntityV3APIKind::UnparsedObject( + _kind, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "metadata" => { + metadata = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "spec" => { + if v.is_null() { + continue; + } + spec = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + return Err(serde::de::Error::custom( + "Additional properties not allowed", + )); + } + } + } + let api_version = + api_version.ok_or_else(|| M::Error::missing_field("api_version"))?; + let kind = kind.ok_or_else(|| M::Error::missing_field("kind"))?; + let metadata = metadata.ok_or_else(|| M::Error::missing_field("metadata"))?; + + let content = EntityV3API { + api_version, + datadog, + extensions, + integrations, + kind, + metadata, + spec, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EntityV3APIVisitor) + } +} diff --git a/src/datadogV2/model/model_entity_v3_api_datadog.rs b/src/datadogV2/model/model_entity_v3_api_datadog.rs new file mode 100644 index 000000000..869983264 --- /dev/null +++ b/src/datadogV2/model/model_entity_v3_api_datadog.rs @@ -0,0 +1,170 @@ +// 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}; + +/// Datadog product integrations for the API entity. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EntityV3APIDatadog { + /// Schema for mapping source code locations to an entity. + #[serde(rename = "codeLocations")] + pub code_locations: Option>, + /// Events associations. + #[serde(rename = "events")] + pub events: Option>, + /// Logs association. + #[serde(rename = "logs")] + pub logs: Option>, + /// Performance stats association. + #[serde(rename = "performanceData")] + pub performance_data: Option, + /// CI Pipelines association. + #[serde(rename = "pipelines")] + pub pipelines: Option, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EntityV3APIDatadog { + pub fn new() -> EntityV3APIDatadog { + EntityV3APIDatadog { + code_locations: None, + events: None, + logs: None, + performance_data: None, + pipelines: None, + _unparsed: false, + } + } + + pub fn code_locations( + mut self, + value: Vec, + ) -> Self { + self.code_locations = Some(value); + self + } + + pub fn events(mut self, value: Vec) -> Self { + self.events = Some(value); + self + } + + pub fn logs(mut self, value: Vec) -> Self { + self.logs = Some(value); + self + } + + pub fn performance_data( + mut self, + value: crate::datadogV2::model::EntityV3DatadogPerformance, + ) -> Self { + self.performance_data = Some(value); + self + } + + pub fn pipelines(mut self, value: crate::datadogV2::model::EntityV3DatadogPipelines) -> Self { + self.pipelines = Some(value); + self + } +} + +impl Default for EntityV3APIDatadog { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for EntityV3APIDatadog { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EntityV3APIDatadogVisitor; + impl<'a> Visitor<'a> for EntityV3APIDatadogVisitor { + type Value = EntityV3APIDatadog; + + 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 code_locations: Option< + Vec, + > = None; + let mut events: Option> = + None; + let mut logs: Option> = None; + let mut performance_data: Option< + crate::datadogV2::model::EntityV3DatadogPerformance, + > = None; + let mut pipelines: Option = None; + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "codeLocations" => { + if v.is_null() { + continue; + } + code_locations = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "events" => { + if v.is_null() { + continue; + } + events = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "logs" => { + if v.is_null() { + continue; + } + logs = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "performanceData" => { + if v.is_null() { + continue; + } + performance_data = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "pipelines" => { + if v.is_null() { + continue; + } + pipelines = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + return Err(serde::de::Error::custom( + "Additional properties not allowed", + )); + } + } + } + + let content = EntityV3APIDatadog { + code_locations, + events, + logs, + performance_data, + pipelines, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EntityV3APIDatadogVisitor) + } +} diff --git a/src/datadogV2/model/model_entity_v3_api_kind.rs b/src/datadogV2/model/model_entity_v3_api_kind.rs new file mode 100644 index 000000000..59b70f01a --- /dev/null +++ b/src/datadogV2/model/model_entity_v3_api_kind.rs @@ -0,0 +1,48 @@ +// 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::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum EntityV3APIKind { + API, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for EntityV3APIKind { + fn to_string(&self) -> String { + match self { + Self::API => String::from("api"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for EntityV3APIKind { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for EntityV3APIKind { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "api" => Self::API, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_entity_v3_api_spec.rs b/src/datadogV2/model/model_entity_v3_api_spec.rs new file mode 100644 index 000000000..eeb93f274 --- /dev/null +++ b/src/datadogV2/model/model_entity_v3_api_spec.rs @@ -0,0 +1,166 @@ +// 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}; + +/// The definition of Entity V3 API Spec object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EntityV3APISpec { + /// Services which implemented the API. + #[serde(rename = "implementedBy")] + pub implemented_by: Option>, + /// The API definition. + #[serde(rename = "interface")] + pub interface: Option, + /// The lifecycle state of the component. + #[serde(rename = "lifecycle")] + pub lifecycle: Option, + /// The importance of the component. + #[serde(rename = "tier")] + pub tier: Option, + /// The type of API. + #[serde(rename = "type")] + pub type_: Option, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EntityV3APISpec { + pub fn new() -> EntityV3APISpec { + EntityV3APISpec { + implemented_by: None, + interface: None, + lifecycle: None, + tier: None, + type_: None, + _unparsed: false, + } + } + + pub fn implemented_by(mut self, value: Vec) -> Self { + self.implemented_by = Some(value); + self + } + + pub fn interface(mut self, value: crate::datadogV2::model::EntityV3APISpecInterface) -> Self { + self.interface = Some(value); + self + } + + pub fn lifecycle(mut self, value: String) -> Self { + self.lifecycle = Some(value); + self + } + + pub fn tier(mut self, value: String) -> Self { + self.tier = Some(value); + self + } + + pub fn type_(mut self, value: String) -> Self { + self.type_ = Some(value); + self + } +} + +impl Default for EntityV3APISpec { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for EntityV3APISpec { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EntityV3APISpecVisitor; + impl<'a> Visitor<'a> for EntityV3APISpecVisitor { + type Value = EntityV3APISpec; + + 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 implemented_by: Option> = None; + let mut interface: Option = None; + let mut lifecycle: Option = None; + let mut tier: Option = None; + let mut type_: Option = None; + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "implementedBy" => { + if v.is_null() { + continue; + } + implemented_by = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "interface" => { + if v.is_null() { + continue; + } + interface = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _interface) = interface { + match _interface { + crate::datadogV2::model::EntityV3APISpecInterface::UnparsedObject(_interface) => { + _unparsed = true; + }, + _ => {} + } + } + } + "lifecycle" => { + if v.is_null() { + continue; + } + lifecycle = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "tier" => { + if v.is_null() { + continue; + } + tier = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + if v.is_null() { + continue; + } + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + return Err(serde::de::Error::custom( + "Additional properties not allowed", + )); + } + } + } + + let content = EntityV3APISpec { + implemented_by, + interface, + lifecycle, + tier, + type_, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EntityV3APISpecVisitor) + } +} diff --git a/src/datadogV2/model/model_entity_v3_api_spec_interface.rs b/src/datadogV2/model/model_entity_v3_api_spec_interface.rs new file mode 100644 index 000000000..1727496e0 --- /dev/null +++ b/src/datadogV2/model/model_entity_v3_api_spec_interface.rs @@ -0,0 +1,47 @@ +// 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::{Deserialize, Deserializer, Serialize}; + +/// The API definition. +#[non_exhaustive] +#[derive(Clone, Debug, PartialEq, Serialize)] +#[serde(untagged)] +pub enum EntityV3APISpecInterface { + EntityV3APISpecInterfaceFileRef(Box), + EntityV3APISpecInterfaceDefinition( + Box, + ), + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl<'de> Deserialize<'de> for EntityV3APISpecInterface { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let value: serde_json::Value = Deserialize::deserialize(deserializer)?; + if let Ok(_v) = serde_json::from_value::< + Box, + >(value.clone()) + { + if !_v._unparsed { + return Ok(EntityV3APISpecInterface::EntityV3APISpecInterfaceFileRef( + _v, + )); + } + } + if let Ok(_v) = serde_json::from_value::< + Box, + >(value.clone()) + { + if !_v._unparsed { + return Ok(EntityV3APISpecInterface::EntityV3APISpecInterfaceDefinition(_v)); + } + } + + return Ok(EntityV3APISpecInterface::UnparsedObject( + crate::datadog::UnparsedObject { value }, + )); + } +} diff --git a/src/datadogV2/model/model_entity_v3_api_spec_interface_definition.rs b/src/datadogV2/model/model_entity_v3_api_spec_interface_definition.rs new file mode 100644 index 000000000..192586fcc --- /dev/null +++ b/src/datadogV2/model/model_entity_v3_api_spec_interface_definition.rs @@ -0,0 +1,93 @@ +// 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}; + +/// The definition of `EntityV3APISpecInterfaceDefinition` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EntityV3APISpecInterfaceDefinition { + /// The API definition. + #[serde(rename = "definition")] + pub definition: Option>, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EntityV3APISpecInterfaceDefinition { + pub fn new() -> EntityV3APISpecInterfaceDefinition { + EntityV3APISpecInterfaceDefinition { + definition: None, + _unparsed: false, + } + } + + pub fn definition( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.definition = Some(value); + self + } +} + +impl Default for EntityV3APISpecInterfaceDefinition { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for EntityV3APISpecInterfaceDefinition { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EntityV3APISpecInterfaceDefinitionVisitor; + impl<'a> Visitor<'a> for EntityV3APISpecInterfaceDefinitionVisitor { + type Value = EntityV3APISpecInterfaceDefinition; + + 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 definition: Option> = + None; + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "definition" => { + if v.is_null() { + continue; + } + definition = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + return Err(serde::de::Error::custom( + "Additional properties not allowed", + )); + } + } + } + + let content = EntityV3APISpecInterfaceDefinition { + definition, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EntityV3APISpecInterfaceDefinitionVisitor) + } +} diff --git a/src/datadogV2/model/model_entity_v3_api_spec_interface_file_ref.rs b/src/datadogV2/model/model_entity_v3_api_spec_interface_file_ref.rs new file mode 100644 index 000000000..ccb9a0b61 --- /dev/null +++ b/src/datadogV2/model/model_entity_v3_api_spec_interface_file_ref.rs @@ -0,0 +1,89 @@ +// 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}; + +/// The definition of `EntityV3APISpecInterfaceFileRef` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EntityV3APISpecInterfaceFileRef { + /// The reference to the API definition file. + #[serde(rename = "fileRef")] + pub file_ref: Option, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EntityV3APISpecInterfaceFileRef { + pub fn new() -> EntityV3APISpecInterfaceFileRef { + EntityV3APISpecInterfaceFileRef { + file_ref: None, + _unparsed: false, + } + } + + pub fn file_ref(mut self, value: String) -> Self { + self.file_ref = Some(value); + self + } +} + +impl Default for EntityV3APISpecInterfaceFileRef { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for EntityV3APISpecInterfaceFileRef { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EntityV3APISpecInterfaceFileRefVisitor; + impl<'a> Visitor<'a> for EntityV3APISpecInterfaceFileRefVisitor { + type Value = EntityV3APISpecInterfaceFileRef; + + 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 file_ref: Option = None; + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "fileRef" => { + if v.is_null() { + continue; + } + file_ref = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + return Err(serde::de::Error::custom( + "Additional properties not allowed", + )); + } + } + } + + let content = EntityV3APISpecInterfaceFileRef { + file_ref, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EntityV3APISpecInterfaceFileRefVisitor) + } +}