diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 4afc5c00f..206b8ba19 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -17294,11 +17294,201 @@ components: schema: $ref: '#/components/schemas/EntityToSchema' type: object + EntityResponseArray: + properties: + data: + items: + $ref: '#/components/schemas/PreviewEntityResponseData' + type: array + required: + - data + type: object EntityResponseData: description: List of entity data. items: $ref: '#/components/schemas/EntityData' type: array + EntityResponseDataAttributes: + properties: + apiVersion: + type: string + description: + type: string + displayName: + type: string + kind: + type: string + name: + type: string + namespace: + type: string + owner: + type: string + properties: + additionalProperties: {} + type: object + tags: + items: + type: string + type: array + type: object + EntityResponseDataRelationships: + properties: + incidents: + $ref: '#/components/schemas/EntityResponseDataRelationshipsIncidents' + oncalls: + $ref: '#/components/schemas/EntityResponseDataRelationshipsOncalls' + rawSchema: + $ref: '#/components/schemas/EntityResponseDataRelationshipsRawSchema' + relatedEntities: + $ref: '#/components/schemas/EntityResponseDataRelationshipsRelatedEntities' + schema: + $ref: '#/components/schemas/EntityResponseDataRelationshipsSchema' + type: object + EntityResponseDataRelationshipsIncidents: + properties: + data: + items: + $ref: '#/components/schemas/EntityResponseDataRelationshipsIncidentsDataItems' + type: array + type: object + EntityResponseDataRelationshipsIncidentsDataItems: + properties: + id: + example: '' + type: string + type: + $ref: '#/components/schemas/EntityResponseDataRelationshipsIncidentsDataItemsType' + required: + - type + - id + type: object + EntityResponseDataRelationshipsIncidentsDataItemsType: + default: incident + description: Incident resource type. + enum: + - incident + example: incident + type: string + x-enum-varnames: + - INCIDENT + EntityResponseDataRelationshipsOncalls: + properties: + data: + items: + $ref: '#/components/schemas/EntityResponseDataRelationshipsOncallsDataItems' + type: array + type: object + EntityResponseDataRelationshipsOncallsDataItems: + properties: + id: + example: '' + type: string + type: + $ref: '#/components/schemas/EntityResponseDataRelationshipsOncallsDataItemsType' + required: + - type + - id + type: object + EntityResponseDataRelationshipsOncallsDataItemsType: + default: oncall + description: Oncall resource type. + enum: + - oncall + example: oncall + type: string + x-enum-varnames: + - ONCALL + EntityResponseDataRelationshipsRawSchema: + properties: + data: + $ref: '#/components/schemas/EntityResponseDataRelationshipsRawSchemaData' + required: + - data + type: object + EntityResponseDataRelationshipsRawSchemaData: + properties: + id: + example: '' + type: string + type: + $ref: '#/components/schemas/EntityResponseDataRelationshipsRawSchemaDataType' + required: + - type + - id + type: object + EntityResponseDataRelationshipsRawSchemaDataType: + default: rawSchema + description: Raw schema resource type. + enum: + - rawSchema + example: rawSchema + type: string + x-enum-varnames: + - RAWSCHEMA + EntityResponseDataRelationshipsRelatedEntities: + properties: + data: + items: + $ref: '#/components/schemas/EntityResponseDataRelationshipsRelatedEntitiesDataItems' + type: array + type: object + EntityResponseDataRelationshipsRelatedEntitiesDataItems: + properties: + id: + example: '' + type: string + type: + $ref: '#/components/schemas/EntityResponseDataRelationshipsRelatedEntitiesDataItemsType' + required: + - type + - id + type: object + EntityResponseDataRelationshipsRelatedEntitiesDataItemsType: + default: relatedEntity + description: Related entity resource type. + enum: + - relatedEntity + example: relatedEntity + type: string + x-enum-varnames: + - RELATEDENTITY + EntityResponseDataRelationshipsSchema: + properties: + data: + $ref: '#/components/schemas/EntityResponseDataRelationshipsSchemaData' + required: + - data + type: object + EntityResponseDataRelationshipsSchemaData: + properties: + id: + example: '' + type: string + type: + $ref: '#/components/schemas/EntityResponseDataRelationshipsSchemaDataType' + required: + - type + - id + type: object + EntityResponseDataRelationshipsSchemaDataType: + default: schema + description: Schema resource type. + enum: + - schema + example: schema + type: string + x-enum-varnames: + - SCHEMA + EntityResponseDataType: + default: entity + description: Entity resource type. + enum: + - entity + example: entity + type: string + x-enum-varnames: + - ENTITY EntityResponseIncludedIncident: description: Included incident. properties: @@ -37681,6 +37871,19 @@ components: description: Offset type. type: string type: object + PreviewEntityResponseData: + properties: + attributes: + $ref: '#/components/schemas/EntityResponseDataAttributes' + id: + type: string + relationships: + $ref: '#/components/schemas/EntityResponseDataRelationships' + type: + $ref: '#/components/schemas/EntityResponseDataType' + required: + - type + type: object ProcessSummariesMeta: description: Response metadata object. properties: @@ -58421,6 +58624,26 @@ paths: tags: - Software Catalog x-codegen-request-body-name: body + /api/v2/catalog/entity/preview: + post: + operationId: PreviewCatalogEntities + responses: + '202': + content: + application/json: + schema: + $ref: '#/components/schemas/EntityResponseArray' + description: Accepted + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - apm_service_catalog_read + summary: Preview catalog entities + tags: + - Software Catalog /api/v2/catalog/entity/{entity_id}: delete: description: Delete a single entity in Software Catalog. diff --git a/examples/v2_software-catalog_PreviewCatalogEntities.rs b/examples/v2_software-catalog_PreviewCatalogEntities.rs new file mode 100644 index 000000000..5b258f8a3 --- /dev/null +++ b/examples/v2_software-catalog_PreviewCatalogEntities.rs @@ -0,0 +1,15 @@ +// Preview catalog entities returns "Accepted" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_software_catalog::SoftwareCatalogAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = SoftwareCatalogAPI::with_config(configuration); + let resp = api.preview_catalog_entities().await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadogV2/api/api_software_catalog.rs b/src/datadogV2/api/api_software_catalog.rs index 80de8a3f2..4b044c17f 100644 --- a/src/datadogV2/api/api_software_catalog.rs +++ b/src/datadogV2/api/api_software_catalog.rs @@ -219,6 +219,14 @@ pub enum ListCatalogRelationError { UnknownValue(serde_json::Value), } +/// PreviewCatalogEntitiesError is a struct for typed errors of method [`SoftwareCatalogAPI::preview_catalog_entities`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PreviewCatalogEntitiesError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// UpsertCatalogEntityError is a struct for typed errors of method [`SoftwareCatalogAPI::upsert_catalog_entity`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -1017,6 +1025,110 @@ impl SoftwareCatalogAPI { } } + pub async fn preview_catalog_entities( + &self, + ) -> Result< + crate::datadogV2::model::EntityResponseArray, + datadog::Error, + > { + match self.preview_catalog_entities_with_http_info().await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + pub async fn preview_catalog_entities_with_http_info( + &self, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.preview_catalog_entities"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/catalog/entity/preview", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + /// Create or update entities in Software Catalog. pub async fn upsert_catalog_entity( &self, diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 0a29a3b35..5e0c2d610 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -1440,6 +1440,46 @@ pub mod model_upsert_catalog_entity_response; pub use self::model_upsert_catalog_entity_response::UpsertCatalogEntityResponse; pub mod model_upsert_catalog_entity_response_included_item; pub use self::model_upsert_catalog_entity_response_included_item::UpsertCatalogEntityResponseIncludedItem; +pub mod model_entity_response_array; +pub use self::model_entity_response_array::EntityResponseArray; +pub mod model_preview_entity_response_data; +pub use self::model_preview_entity_response_data::PreviewEntityResponseData; +pub mod model_entity_response_data_attributes; +pub use self::model_entity_response_data_attributes::EntityResponseDataAttributes; +pub mod model_entity_response_data_relationships; +pub use self::model_entity_response_data_relationships::EntityResponseDataRelationships; +pub mod model_entity_response_data_relationships_incidents; +pub use self::model_entity_response_data_relationships_incidents::EntityResponseDataRelationshipsIncidents; +pub mod model_entity_response_data_relationships_incidents_data_items; +pub use self::model_entity_response_data_relationships_incidents_data_items::EntityResponseDataRelationshipsIncidentsDataItems; +pub mod model_entity_response_data_relationships_incidents_data_items_type; +pub use self::model_entity_response_data_relationships_incidents_data_items_type::EntityResponseDataRelationshipsIncidentsDataItemsType; +pub mod model_entity_response_data_relationships_oncalls; +pub use self::model_entity_response_data_relationships_oncalls::EntityResponseDataRelationshipsOncalls; +pub mod model_entity_response_data_relationships_oncalls_data_items; +pub use self::model_entity_response_data_relationships_oncalls_data_items::EntityResponseDataRelationshipsOncallsDataItems; +pub mod model_entity_response_data_relationships_oncalls_data_items_type; +pub use self::model_entity_response_data_relationships_oncalls_data_items_type::EntityResponseDataRelationshipsOncallsDataItemsType; +pub mod model_entity_response_data_relationships_raw_schema; +pub use self::model_entity_response_data_relationships_raw_schema::EntityResponseDataRelationshipsRawSchema; +pub mod model_entity_response_data_relationships_raw_schema_data; +pub use self::model_entity_response_data_relationships_raw_schema_data::EntityResponseDataRelationshipsRawSchemaData; +pub mod model_entity_response_data_relationships_raw_schema_data_type; +pub use self::model_entity_response_data_relationships_raw_schema_data_type::EntityResponseDataRelationshipsRawSchemaDataType; +pub mod model_entity_response_data_relationships_related_entities; +pub use self::model_entity_response_data_relationships_related_entities::EntityResponseDataRelationshipsRelatedEntities; +pub mod model_entity_response_data_relationships_related_entities_data_items; +pub use self::model_entity_response_data_relationships_related_entities_data_items::EntityResponseDataRelationshipsRelatedEntitiesDataItems; +pub mod model_entity_response_data_relationships_related_entities_data_items_type; +pub use self::model_entity_response_data_relationships_related_entities_data_items_type::EntityResponseDataRelationshipsRelatedEntitiesDataItemsType; +pub mod model_entity_response_data_relationships_schema; +pub use self::model_entity_response_data_relationships_schema::EntityResponseDataRelationshipsSchema; +pub mod model_entity_response_data_relationships_schema_data; +pub use self::model_entity_response_data_relationships_schema_data::EntityResponseDataRelationshipsSchemaData; +pub mod model_entity_response_data_relationships_schema_data_type; +pub use self::model_entity_response_data_relationships_schema_data_type::EntityResponseDataRelationshipsSchemaDataType; +pub mod model_entity_response_data_type; +pub use self::model_entity_response_data_type::EntityResponseDataType; pub mod model_list_kind_catalog_response; pub use self::model_list_kind_catalog_response::ListKindCatalogResponse; pub mod model_kind_data; diff --git a/src/datadogV2/model/model_entity_response_array.rs b/src/datadogV2/model/model_entity_response_array.rs new file mode 100644 index 000000000..130d1881c --- /dev/null +++ b/src/datadogV2/model/model_entity_response_array.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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EntityResponseArray { + #[serde(rename = "data")] + pub data: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EntityResponseArray { + pub fn new( + data: Vec, + ) -> EntityResponseArray { + EntityResponseArray { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for EntityResponseArray { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EntityResponseArrayVisitor; + impl<'a> Visitor<'a> for EntityResponseArrayVisitor { + type Value = EntityResponseArray; + + 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 data: 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() { + "data" => { + data = 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 data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = EntityResponseArray { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EntityResponseArrayVisitor) + } +} diff --git a/src/datadogV2/model/model_entity_response_data_attributes.rs b/src/datadogV2/model/model_entity_response_data_attributes.rs new file mode 100644 index 000000000..e3c6c9f46 --- /dev/null +++ b/src/datadogV2/model/model_entity_response_data_attributes.rs @@ -0,0 +1,238 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EntityResponseDataAttributes { + #[serde(rename = "apiVersion")] + pub api_version: Option, + #[serde(rename = "description")] + pub description: Option, + #[serde(rename = "displayName")] + pub display_name: Option, + #[serde(rename = "kind")] + pub kind: Option, + #[serde(rename = "name")] + pub name: Option, + #[serde(rename = "namespace")] + pub namespace: Option, + #[serde(rename = "owner")] + pub owner: Option, + #[serde(rename = "properties")] + pub properties: Option>, + #[serde(rename = "tags")] + pub tags: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EntityResponseDataAttributes { + pub fn new() -> EntityResponseDataAttributes { + EntityResponseDataAttributes { + api_version: None, + description: None, + display_name: None, + kind: None, + name: None, + namespace: None, + owner: None, + properties: None, + tags: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn api_version(mut self, value: String) -> Self { + self.api_version = Some(value); + self + } + + pub fn description(mut self, value: String) -> Self { + self.description = Some(value); + self + } + + pub fn display_name(mut self, value: String) -> Self { + self.display_name = Some(value); + self + } + + pub fn kind(mut self, value: String) -> Self { + self.kind = Some(value); + self + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn namespace(mut self, value: String) -> Self { + self.namespace = Some(value); + self + } + + pub fn owner(mut self, value: String) -> Self { + self.owner = Some(value); + self + } + + pub fn properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.properties = 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 EntityResponseDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for EntityResponseDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EntityResponseDataAttributesVisitor; + impl<'a> Visitor<'a> for EntityResponseDataAttributesVisitor { + type Value = EntityResponseDataAttributes; + + 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 description: Option = None; + let mut display_name: Option = None; + let mut kind: Option = None; + let mut name: Option = None; + let mut namespace: Option = None; + let mut owner: Option = None; + let mut properties: 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() { + "apiVersion" => { + if v.is_null() { + continue; + } + api_version = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "description" => { + if v.is_null() { + continue; + } + description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "displayName" => { + if v.is_null() { + continue; + } + display_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "kind" => { + if v.is_null() { + continue; + } + kind = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + if v.is_null() { + continue; + } + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "namespace" => { + if v.is_null() { + continue; + } + namespace = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "owner" => { + if v.is_null() { + continue; + } + owner = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "properties" => { + if v.is_null() { + continue; + } + properties = 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 = EntityResponseDataAttributes { + api_version, + description, + display_name, + kind, + name, + namespace, + owner, + properties, + tags, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EntityResponseDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_entity_response_data_relationships.rs b/src/datadogV2/model/model_entity_response_data_relationships.rs new file mode 100644 index 000000000..21a6961e3 --- /dev/null +++ b/src/datadogV2/model/model_entity_response_data_relationships.rs @@ -0,0 +1,194 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EntityResponseDataRelationships { + #[serde(rename = "incidents")] + pub incidents: Option, + #[serde(rename = "oncalls")] + pub oncalls: Option, + #[serde(rename = "rawSchema")] + pub raw_schema: Option, + #[serde(rename = "relatedEntities")] + pub related_entities: + Option, + #[serde(rename = "schema")] + pub schema: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EntityResponseDataRelationships { + pub fn new() -> EntityResponseDataRelationships { + EntityResponseDataRelationships { + incidents: None, + oncalls: None, + raw_schema: None, + related_entities: None, + schema: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn incidents( + mut self, + value: crate::datadogV2::model::EntityResponseDataRelationshipsIncidents, + ) -> Self { + self.incidents = Some(value); + self + } + + pub fn oncalls( + mut self, + value: crate::datadogV2::model::EntityResponseDataRelationshipsOncalls, + ) -> Self { + self.oncalls = Some(value); + self + } + + pub fn raw_schema( + mut self, + value: crate::datadogV2::model::EntityResponseDataRelationshipsRawSchema, + ) -> Self { + self.raw_schema = Some(value); + self + } + + pub fn related_entities( + mut self, + value: crate::datadogV2::model::EntityResponseDataRelationshipsRelatedEntities, + ) -> Self { + self.related_entities = Some(value); + self + } + + pub fn schema( + mut self, + value: crate::datadogV2::model::EntityResponseDataRelationshipsSchema, + ) -> Self { + self.schema = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for EntityResponseDataRelationships { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for EntityResponseDataRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EntityResponseDataRelationshipsVisitor; + impl<'a> Visitor<'a> for EntityResponseDataRelationshipsVisitor { + type Value = EntityResponseDataRelationships; + + 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 incidents: Option< + crate::datadogV2::model::EntityResponseDataRelationshipsIncidents, + > = None; + let mut oncalls: Option< + crate::datadogV2::model::EntityResponseDataRelationshipsOncalls, + > = None; + let mut raw_schema: Option< + crate::datadogV2::model::EntityResponseDataRelationshipsRawSchema, + > = None; + let mut related_entities: Option< + crate::datadogV2::model::EntityResponseDataRelationshipsRelatedEntities, + > = None; + let mut schema: Option< + crate::datadogV2::model::EntityResponseDataRelationshipsSchema, + > = 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() { + "incidents" => { + if v.is_null() { + continue; + } + incidents = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "oncalls" => { + if v.is_null() { + continue; + } + oncalls = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "rawSchema" => { + if v.is_null() { + continue; + } + raw_schema = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "relatedEntities" => { + if v.is_null() { + continue; + } + related_entities = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "schema" => { + if v.is_null() { + continue; + } + schema = 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 = EntityResponseDataRelationships { + incidents, + oncalls, + raw_schema, + related_entities, + schema, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EntityResponseDataRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_entity_response_data_relationships_incidents.rs b/src/datadogV2/model/model_entity_response_data_relationships_incidents.rs new file mode 100644 index 000000000..5eff1a34a --- /dev/null +++ b/src/datadogV2/model/model_entity_response_data_relationships_incidents.rs @@ -0,0 +1,109 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EntityResponseDataRelationshipsIncidents { + #[serde(rename = "data")] + pub data: + Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EntityResponseDataRelationshipsIncidents { + pub fn new() -> EntityResponseDataRelationshipsIncidents { + EntityResponseDataRelationshipsIncidents { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: Vec, + ) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for EntityResponseDataRelationshipsIncidents { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for EntityResponseDataRelationshipsIncidents { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EntityResponseDataRelationshipsIncidentsVisitor; + impl<'a> Visitor<'a> for EntityResponseDataRelationshipsIncidentsVisitor { + type Value = EntityResponseDataRelationshipsIncidents; + + 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 data: Option< + Vec, + > = 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() { + "data" => { + if v.is_null() { + continue; + } + data = 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 = EntityResponseDataRelationshipsIncidents { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EntityResponseDataRelationshipsIncidentsVisitor) + } +} diff --git a/src/datadogV2/model/model_entity_response_data_relationships_incidents_data_items.rs b/src/datadogV2/model/model_entity_response_data_relationships_incidents_data_items.rs new file mode 100644 index 000000000..39637b75a --- /dev/null +++ b/src/datadogV2/model/model_entity_response_data_relationships_incidents_data_items.rs @@ -0,0 +1,113 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EntityResponseDataRelationshipsIncidentsDataItems { + #[serde(rename = "id")] + pub id: String, + /// Incident resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::EntityResponseDataRelationshipsIncidentsDataItemsType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EntityResponseDataRelationshipsIncidentsDataItems { + pub fn new( + id: String, + type_: crate::datadogV2::model::EntityResponseDataRelationshipsIncidentsDataItemsType, + ) -> EntityResponseDataRelationshipsIncidentsDataItems { + EntityResponseDataRelationshipsIncidentsDataItems { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for EntityResponseDataRelationshipsIncidentsDataItems { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EntityResponseDataRelationshipsIncidentsDataItemsVisitor; + impl<'a> Visitor<'a> for EntityResponseDataRelationshipsIncidentsDataItemsVisitor { + type Value = EntityResponseDataRelationshipsIncidentsDataItems; + + 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 id: Option = None; + let mut type_: Option< + crate::datadogV2::model::EntityResponseDataRelationshipsIncidentsDataItemsType, + > = 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() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::EntityResponseDataRelationshipsIncidentsDataItemsType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = EntityResponseDataRelationshipsIncidentsDataItems { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EntityResponseDataRelationshipsIncidentsDataItemsVisitor) + } +} diff --git a/src/datadogV2/model/model_entity_response_data_relationships_incidents_data_items_type.rs b/src/datadogV2/model/model_entity_response_data_relationships_incidents_data_items_type.rs new file mode 100644 index 000000000..20be094c1 --- /dev/null +++ b/src/datadogV2/model/model_entity_response_data_relationships_incidents_data_items_type.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 EntityResponseDataRelationshipsIncidentsDataItemsType { + INCIDENT, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for EntityResponseDataRelationshipsIncidentsDataItemsType { + fn to_string(&self) -> String { + match self { + Self::INCIDENT => String::from("incident"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for EntityResponseDataRelationshipsIncidentsDataItemsType { + 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 EntityResponseDataRelationshipsIncidentsDataItemsType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "incident" => Self::INCIDENT, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_entity_response_data_relationships_oncalls.rs b/src/datadogV2/model/model_entity_response_data_relationships_oncalls.rs new file mode 100644 index 000000000..038d9904d --- /dev/null +++ b/src/datadogV2/model/model_entity_response_data_relationships_oncalls.rs @@ -0,0 +1,108 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EntityResponseDataRelationshipsOncalls { + #[serde(rename = "data")] + pub data: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EntityResponseDataRelationshipsOncalls { + pub fn new() -> EntityResponseDataRelationshipsOncalls { + EntityResponseDataRelationshipsOncalls { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: Vec, + ) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for EntityResponseDataRelationshipsOncalls { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for EntityResponseDataRelationshipsOncalls { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EntityResponseDataRelationshipsOncallsVisitor; + impl<'a> Visitor<'a> for EntityResponseDataRelationshipsOncallsVisitor { + type Value = EntityResponseDataRelationshipsOncalls; + + 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 data: Option< + Vec, + > = 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() { + "data" => { + if v.is_null() { + continue; + } + data = 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 = EntityResponseDataRelationshipsOncalls { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EntityResponseDataRelationshipsOncallsVisitor) + } +} diff --git a/src/datadogV2/model/model_entity_response_data_relationships_oncalls_data_items.rs b/src/datadogV2/model/model_entity_response_data_relationships_oncalls_data_items.rs new file mode 100644 index 000000000..358d9adf6 --- /dev/null +++ b/src/datadogV2/model/model_entity_response_data_relationships_oncalls_data_items.rs @@ -0,0 +1,113 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EntityResponseDataRelationshipsOncallsDataItems { + #[serde(rename = "id")] + pub id: String, + /// Oncall resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::EntityResponseDataRelationshipsOncallsDataItemsType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EntityResponseDataRelationshipsOncallsDataItems { + pub fn new( + id: String, + type_: crate::datadogV2::model::EntityResponseDataRelationshipsOncallsDataItemsType, + ) -> EntityResponseDataRelationshipsOncallsDataItems { + EntityResponseDataRelationshipsOncallsDataItems { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for EntityResponseDataRelationshipsOncallsDataItems { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EntityResponseDataRelationshipsOncallsDataItemsVisitor; + impl<'a> Visitor<'a> for EntityResponseDataRelationshipsOncallsDataItemsVisitor { + type Value = EntityResponseDataRelationshipsOncallsDataItems; + + 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 id: Option = None; + let mut type_: Option< + crate::datadogV2::model::EntityResponseDataRelationshipsOncallsDataItemsType, + > = 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() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::EntityResponseDataRelationshipsOncallsDataItemsType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = EntityResponseDataRelationshipsOncallsDataItems { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EntityResponseDataRelationshipsOncallsDataItemsVisitor) + } +} diff --git a/src/datadogV2/model/model_entity_response_data_relationships_oncalls_data_items_type.rs b/src/datadogV2/model/model_entity_response_data_relationships_oncalls_data_items_type.rs new file mode 100644 index 000000000..f1b0a5b6e --- /dev/null +++ b/src/datadogV2/model/model_entity_response_data_relationships_oncalls_data_items_type.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 EntityResponseDataRelationshipsOncallsDataItemsType { + ONCALL, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for EntityResponseDataRelationshipsOncallsDataItemsType { + fn to_string(&self) -> String { + match self { + Self::ONCALL => String::from("oncall"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for EntityResponseDataRelationshipsOncallsDataItemsType { + 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 EntityResponseDataRelationshipsOncallsDataItemsType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "oncall" => Self::ONCALL, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_entity_response_data_relationships_raw_schema.rs b/src/datadogV2/model/model_entity_response_data_relationships_raw_schema.rs new file mode 100644 index 000000000..8bde32015 --- /dev/null +++ b/src/datadogV2/model/model_entity_response_data_relationships_raw_schema.rs @@ -0,0 +1,94 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EntityResponseDataRelationshipsRawSchema { + #[serde(rename = "data")] + pub data: crate::datadogV2::model::EntityResponseDataRelationshipsRawSchemaData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EntityResponseDataRelationshipsRawSchema { + pub fn new( + data: crate::datadogV2::model::EntityResponseDataRelationshipsRawSchemaData, + ) -> EntityResponseDataRelationshipsRawSchema { + EntityResponseDataRelationshipsRawSchema { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for EntityResponseDataRelationshipsRawSchema { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EntityResponseDataRelationshipsRawSchemaVisitor; + impl<'a> Visitor<'a> for EntityResponseDataRelationshipsRawSchemaVisitor { + type Value = EntityResponseDataRelationshipsRawSchema; + + 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 data: Option< + crate::datadogV2::model::EntityResponseDataRelationshipsRawSchemaData, + > = 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() { + "data" => { + data = 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 data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = EntityResponseDataRelationshipsRawSchema { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EntityResponseDataRelationshipsRawSchemaVisitor) + } +} diff --git a/src/datadogV2/model/model_entity_response_data_relationships_raw_schema_data.rs b/src/datadogV2/model/model_entity_response_data_relationships_raw_schema_data.rs new file mode 100644 index 000000000..e335a7d6a --- /dev/null +++ b/src/datadogV2/model/model_entity_response_data_relationships_raw_schema_data.rs @@ -0,0 +1,113 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EntityResponseDataRelationshipsRawSchemaData { + #[serde(rename = "id")] + pub id: String, + /// Raw schema resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::EntityResponseDataRelationshipsRawSchemaDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EntityResponseDataRelationshipsRawSchemaData { + pub fn new( + id: String, + type_: crate::datadogV2::model::EntityResponseDataRelationshipsRawSchemaDataType, + ) -> EntityResponseDataRelationshipsRawSchemaData { + EntityResponseDataRelationshipsRawSchemaData { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for EntityResponseDataRelationshipsRawSchemaData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EntityResponseDataRelationshipsRawSchemaDataVisitor; + impl<'a> Visitor<'a> for EntityResponseDataRelationshipsRawSchemaDataVisitor { + type Value = EntityResponseDataRelationshipsRawSchemaData; + + 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 id: Option = None; + let mut type_: Option< + crate::datadogV2::model::EntityResponseDataRelationshipsRawSchemaDataType, + > = 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() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::EntityResponseDataRelationshipsRawSchemaDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = EntityResponseDataRelationshipsRawSchemaData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EntityResponseDataRelationshipsRawSchemaDataVisitor) + } +} diff --git a/src/datadogV2/model/model_entity_response_data_relationships_raw_schema_data_type.rs b/src/datadogV2/model/model_entity_response_data_relationships_raw_schema_data_type.rs new file mode 100644 index 000000000..3cdef676f --- /dev/null +++ b/src/datadogV2/model/model_entity_response_data_relationships_raw_schema_data_type.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 EntityResponseDataRelationshipsRawSchemaDataType { + RAWSCHEMA, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for EntityResponseDataRelationshipsRawSchemaDataType { + fn to_string(&self) -> String { + match self { + Self::RAWSCHEMA => String::from("rawSchema"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for EntityResponseDataRelationshipsRawSchemaDataType { + 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 EntityResponseDataRelationshipsRawSchemaDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "rawSchema" => Self::RAWSCHEMA, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_entity_response_data_relationships_related_entities.rs b/src/datadogV2/model/model_entity_response_data_relationships_related_entities.rs new file mode 100644 index 000000000..522744e24 --- /dev/null +++ b/src/datadogV2/model/model_entity_response_data_relationships_related_entities.rs @@ -0,0 +1,110 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EntityResponseDataRelationshipsRelatedEntities { + #[serde(rename = "data")] + pub data: Option< + Vec, + >, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EntityResponseDataRelationshipsRelatedEntities { + pub fn new() -> EntityResponseDataRelationshipsRelatedEntities { + EntityResponseDataRelationshipsRelatedEntities { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: Vec< + crate::datadogV2::model::EntityResponseDataRelationshipsRelatedEntitiesDataItems, + >, + ) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for EntityResponseDataRelationshipsRelatedEntities { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for EntityResponseDataRelationshipsRelatedEntities { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EntityResponseDataRelationshipsRelatedEntitiesVisitor; + impl<'a> Visitor<'a> for EntityResponseDataRelationshipsRelatedEntitiesVisitor { + type Value = EntityResponseDataRelationshipsRelatedEntities; + + 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 data: 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() { + "data" => { + if v.is_null() { + continue; + } + data = 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 = EntityResponseDataRelationshipsRelatedEntities { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EntityResponseDataRelationshipsRelatedEntitiesVisitor) + } +} diff --git a/src/datadogV2/model/model_entity_response_data_relationships_related_entities_data_items.rs b/src/datadogV2/model/model_entity_response_data_relationships_related_entities_data_items.rs new file mode 100644 index 000000000..c01c28b8b --- /dev/null +++ b/src/datadogV2/model/model_entity_response_data_relationships_related_entities_data_items.rs @@ -0,0 +1,111 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EntityResponseDataRelationshipsRelatedEntitiesDataItems { + #[serde(rename = "id")] + pub id: String, + /// Related entity resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::EntityResponseDataRelationshipsRelatedEntitiesDataItemsType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EntityResponseDataRelationshipsRelatedEntitiesDataItems { + pub fn new( + id: String, + type_: crate::datadogV2::model::EntityResponseDataRelationshipsRelatedEntitiesDataItemsType, + ) -> EntityResponseDataRelationshipsRelatedEntitiesDataItems { + EntityResponseDataRelationshipsRelatedEntitiesDataItems { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for EntityResponseDataRelationshipsRelatedEntitiesDataItems { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EntityResponseDataRelationshipsRelatedEntitiesDataItemsVisitor; + impl<'a> Visitor<'a> for EntityResponseDataRelationshipsRelatedEntitiesDataItemsVisitor { + type Value = EntityResponseDataRelationshipsRelatedEntitiesDataItems; + + 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 id: Option = None; + let mut type_: 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() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::EntityResponseDataRelationshipsRelatedEntitiesDataItemsType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = EntityResponseDataRelationshipsRelatedEntitiesDataItems { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EntityResponseDataRelationshipsRelatedEntitiesDataItemsVisitor) + } +} diff --git a/src/datadogV2/model/model_entity_response_data_relationships_related_entities_data_items_type.rs b/src/datadogV2/model/model_entity_response_data_relationships_related_entities_data_items_type.rs new file mode 100644 index 000000000..5d6dbd75a --- /dev/null +++ b/src/datadogV2/model/model_entity_response_data_relationships_related_entities_data_items_type.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 EntityResponseDataRelationshipsRelatedEntitiesDataItemsType { + RELATEDENTITY, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for EntityResponseDataRelationshipsRelatedEntitiesDataItemsType { + fn to_string(&self) -> String { + match self { + Self::RELATEDENTITY => String::from("relatedEntity"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for EntityResponseDataRelationshipsRelatedEntitiesDataItemsType { + 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 EntityResponseDataRelationshipsRelatedEntitiesDataItemsType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "relatedEntity" => Self::RELATEDENTITY, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_entity_response_data_relationships_schema.rs b/src/datadogV2/model/model_entity_response_data_relationships_schema.rs new file mode 100644 index 000000000..e7cd55f1c --- /dev/null +++ b/src/datadogV2/model/model_entity_response_data_relationships_schema.rs @@ -0,0 +1,94 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EntityResponseDataRelationshipsSchema { + #[serde(rename = "data")] + pub data: crate::datadogV2::model::EntityResponseDataRelationshipsSchemaData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EntityResponseDataRelationshipsSchema { + pub fn new( + data: crate::datadogV2::model::EntityResponseDataRelationshipsSchemaData, + ) -> EntityResponseDataRelationshipsSchema { + EntityResponseDataRelationshipsSchema { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for EntityResponseDataRelationshipsSchema { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EntityResponseDataRelationshipsSchemaVisitor; + impl<'a> Visitor<'a> for EntityResponseDataRelationshipsSchemaVisitor { + type Value = EntityResponseDataRelationshipsSchema; + + 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 data: Option< + crate::datadogV2::model::EntityResponseDataRelationshipsSchemaData, + > = 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() { + "data" => { + data = 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 data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = EntityResponseDataRelationshipsSchema { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EntityResponseDataRelationshipsSchemaVisitor) + } +} diff --git a/src/datadogV2/model/model_entity_response_data_relationships_schema_data.rs b/src/datadogV2/model/model_entity_response_data_relationships_schema_data.rs new file mode 100644 index 000000000..8e846301d --- /dev/null +++ b/src/datadogV2/model/model_entity_response_data_relationships_schema_data.rs @@ -0,0 +1,113 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EntityResponseDataRelationshipsSchemaData { + #[serde(rename = "id")] + pub id: String, + /// Schema resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::EntityResponseDataRelationshipsSchemaDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EntityResponseDataRelationshipsSchemaData { + pub fn new( + id: String, + type_: crate::datadogV2::model::EntityResponseDataRelationshipsSchemaDataType, + ) -> EntityResponseDataRelationshipsSchemaData { + EntityResponseDataRelationshipsSchemaData { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for EntityResponseDataRelationshipsSchemaData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EntityResponseDataRelationshipsSchemaDataVisitor; + impl<'a> Visitor<'a> for EntityResponseDataRelationshipsSchemaDataVisitor { + type Value = EntityResponseDataRelationshipsSchemaData; + + 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 id: Option = None; + let mut type_: Option< + crate::datadogV2::model::EntityResponseDataRelationshipsSchemaDataType, + > = 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() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::EntityResponseDataRelationshipsSchemaDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = EntityResponseDataRelationshipsSchemaData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EntityResponseDataRelationshipsSchemaDataVisitor) + } +} diff --git a/src/datadogV2/model/model_entity_response_data_relationships_schema_data_type.rs b/src/datadogV2/model/model_entity_response_data_relationships_schema_data_type.rs new file mode 100644 index 000000000..93e8afba1 --- /dev/null +++ b/src/datadogV2/model/model_entity_response_data_relationships_schema_data_type.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 EntityResponseDataRelationshipsSchemaDataType { + SCHEMA, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for EntityResponseDataRelationshipsSchemaDataType { + fn to_string(&self) -> String { + match self { + Self::SCHEMA => String::from("schema"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for EntityResponseDataRelationshipsSchemaDataType { + 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 EntityResponseDataRelationshipsSchemaDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "schema" => Self::SCHEMA, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_entity_response_data_type.rs b/src/datadogV2/model/model_entity_response_data_type.rs new file mode 100644 index 000000000..6ba08be22 --- /dev/null +++ b/src/datadogV2/model/model_entity_response_data_type.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 EntityResponseDataType { + ENTITY, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for EntityResponseDataType { + fn to_string(&self) -> String { + match self { + Self::ENTITY => String::from("entity"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for EntityResponseDataType { + 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 EntityResponseDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "entity" => Self::ENTITY, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_preview_entity_response_data.rs b/src/datadogV2/model/model_preview_entity_response_data.rs new file mode 100644 index 000000000..0d867e53b --- /dev/null +++ b/src/datadogV2/model/model_preview_entity_response_data.rs @@ -0,0 +1,159 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PreviewEntityResponseData { + #[serde(rename = "attributes")] + pub attributes: Option, + #[serde(rename = "id")] + pub id: Option, + #[serde(rename = "relationships")] + pub relationships: Option, + /// Entity resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::EntityResponseDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PreviewEntityResponseData { + pub fn new( + type_: crate::datadogV2::model::EntityResponseDataType, + ) -> PreviewEntityResponseData { + PreviewEntityResponseData { + attributes: None, + id: None, + relationships: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::EntityResponseDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn relationships( + mut self, + value: crate::datadogV2::model::EntityResponseDataRelationships, + ) -> Self { + self.relationships = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for PreviewEntityResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PreviewEntityResponseDataVisitor; + impl<'a> Visitor<'a> for PreviewEntityResponseDataVisitor { + type Value = PreviewEntityResponseData; + + 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 attributes: Option = + None; + let mut id: Option = None; + let mut relationships: Option< + crate::datadogV2::model::EntityResponseDataRelationships, + > = None; + let mut type_: 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() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "relationships" => { + if v.is_null() { + continue; + } + relationships = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::EntityResponseDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = PreviewEntityResponseData { + attributes, + id, + relationships, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PreviewEntityResponseDataVisitor) + } +} diff --git a/tests/scenarios/features/v2/software_catalog.feature b/tests/scenarios/features/v2/software_catalog.feature index 070e066a9..34e9f9531 100644 --- a/tests/scenarios/features/v2/software_catalog.feature +++ b/tests/scenarios/features/v2/software_catalog.feature @@ -144,3 +144,9 @@ Feature: Software Catalog And request contains "page[limit]" parameter with value 20 When the request with pagination is sent Then the response status is 200 OK + + @generated @skip @team:DataDog/service-catalog + Scenario: Preview catalog entities returns "Accepted" response + Given new "PreviewCatalogEntities" request + When the request is sent + Then the response status is 202 Accepted diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index f4a7f9e7f..1865379dd 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -751,6 +751,12 @@ "type": "unsafe" } }, + "PreviewCatalogEntities": { + "tag": "Software Catalog", + "undo": { + "type": "safe" + } + }, "DeleteCatalogEntity": { "tag": "Software Catalog", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 43cff6b63..1848fb8bd 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -2217,6 +2217,10 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.UpsertCatalogEntity".into(), test_v2_upsert_catalog_entity, ); + world.function_mappings.insert( + "v2.PreviewCatalogEntities".into(), + test_v2_preview_catalog_entities, + ); world.function_mappings.insert( "v2.DeleteCatalogEntity".into(), test_v2_delete_catalog_entity, @@ -15142,6 +15146,33 @@ fn test_v2_upsert_catalog_entity(world: &mut DatadogWorld, _parameters: &HashMap world.response.code = response.status.as_u16(); } +fn test_v2_preview_catalog_entities( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_software_catalog + .as_ref() + .expect("api instance not found"); + let response = match block_on(api.preview_catalog_entities_with_http_info()) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + fn test_v2_delete_catalog_entity(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances