From b8e89d6339c001ba09029d0e20031848469ff124 Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Tue, 9 Apr 2024 13:51:16 +0000 Subject: [PATCH] Add Team relationship to AuthNMappings (#60) Co-authored-by: ci.datadog-api-spec Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 107 +++++++++- .../v2_authn-mappings_create_authn_mapping.rs | 15 +- .../v2_authn-mappings_update_authn_mapping.rs | 15 +- src/datadogV2/model/mod.rs | 16 +- .../model/model_authn_mapping_create_data.rs | 10 +- ...odel_authn_mapping_create_relationships.rs | 85 +++----- .../model/model_authn_mapping_included.rs | 8 + ...odel_authn_mapping_relationship_to_role.rs | 71 +++++++ ...odel_authn_mapping_relationship_to_team.rs | 71 +++++++ .../model_authn_mapping_relationships.rs | 17 ++ .../model/model_authn_mapping_team.rs | 131 +++++++++++++ .../model_authn_mapping_team_attributes.rs | 182 ++++++++++++++++++ .../model/model_authn_mapping_update_data.rs | 10 +- ...odel_authn_mapping_update_relationships.rs | 85 +++----- .../model/model_relationship_to_team.rs | 82 ++++++++ .../model/model_relationship_to_team_data.rs | 110 +++++++++++ 17 files changed, 869 insertions(+), 154 deletions(-) create mode 100644 src/datadogV2/model/model_authn_mapping_relationship_to_role.rs create mode 100644 src/datadogV2/model/model_authn_mapping_relationship_to_team.rs create mode 100644 src/datadogV2/model/model_authn_mapping_team.rs create mode 100644 src/datadogV2/model/model_authn_mapping_team_attributes.rs create mode 100644 src/datadogV2/model/model_relationship_to_team.rs create mode 100644 src/datadogV2/model/model_relationship_to_team_data.rs diff --git a/.apigentools-info b/.apigentools-info index 3d61186e3..1cefd58fe 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-04-05 19:46:20.796817", - "spec_repo_commit": "cdcf2ed6" + "regenerated": "2024-04-08 20:24:02.356402", + "spec_repo_commit": "037e376a" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-04-05 19:46:20.814022", - "spec_repo_commit": "cdcf2ed6" + "regenerated": "2024-04-08 20:24:02.377503", + "spec_repo_commit": "037e376a" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 79b987937..3ec2a7d6b 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1325,11 +1325,10 @@ components: - type type: object AuthNMappingCreateRelationships: - description: Relationship of AuthN Mapping create object to Role. - properties: - role: - $ref: '#/components/schemas/RelationshipToRole' - type: object + description: Relationship of AuthN Mapping create object to a Role or Team. + oneOf: + - $ref: '#/components/schemas/AuthNMappingRelationshipToRole' + - $ref: '#/components/schemas/AuthNMappingRelationshipToTeam' AuthNMappingCreateRequest: description: Request for creating an AuthN Mapping. properties: @@ -1343,6 +1342,23 @@ components: oneOf: - $ref: '#/components/schemas/SAMLAssertionAttribute' - $ref: '#/components/schemas/Role' + - $ref: '#/components/schemas/AuthNMappingTeam' + AuthNMappingRelationshipToRole: + description: Relationship of AuthN Mapping to a Role. + properties: + role: + $ref: '#/components/schemas/RelationshipToRole' + required: + - role + type: object + AuthNMappingRelationshipToTeam: + description: Relationship of AuthN Mapping to a Team. + properties: + team: + $ref: '#/components/schemas/RelationshipToTeam' + required: + - team + type: object AuthNMappingRelationships: description: All relationships associated with AuthN Mapping. properties: @@ -1350,6 +1366,8 @@ components: $ref: '#/components/schemas/RelationshipToRole' saml_assertion_attribute: $ref: '#/components/schemas/RelationshipToSAMLAssertionAttribute' + team: + $ref: '#/components/schemas/RelationshipToTeam' type: object AuthNMappingResponse: description: AuthN Mapping response from the API. @@ -1362,6 +1380,60 @@ components: $ref: '#/components/schemas/AuthNMappingIncluded' type: array type: object + AuthNMappingTeam: + description: Team. + properties: + attributes: + $ref: '#/components/schemas/AuthNMappingTeamAttributes' + id: + description: The ID of the Team. + example: f9bb8444-af7f-11ec-ac2c-da7ad0900001 + type: string + type: + $ref: '#/components/schemas/TeamType' + type: object + AuthNMappingTeamAttributes: + description: Team attributes. + properties: + avatar: + description: Unicode representation of the avatar for the team, limited + to a single grapheme + example: "\U0001F951" + nullable: true + type: string + banner: + description: Banner selection for the team + format: int64 + nullable: true + type: integer + handle: + description: The team's identifier + example: example-team + maxLength: 195 + type: string + link_count: + description: The number of links belonging to the team + format: int32 + maximum: 2147483647 + readOnly: true + type: integer + name: + description: The name of the team + example: Example Team + maxLength: 200 + type: string + summary: + description: A brief summary of the team, derived from the `description` + maxLength: 120 + nullable: true + type: string + user_count: + description: The number of users belonging to the team + format: int32 + maximum: 2147483647 + readOnly: true + type: integer + type: object AuthNMappingUpdateAttributes: description: Key/Value pair of attributes used for update request. properties: @@ -1394,11 +1466,10 @@ components: - type type: object AuthNMappingUpdateRelationships: - description: Relationship of AuthN Mapping update object to Role. - properties: - role: - $ref: '#/components/schemas/RelationshipToRole' - type: object + description: Relationship of AuthN Mapping update object to a Role or Team. + oneOf: + - $ref: '#/components/schemas/AuthNMappingRelationshipToRole' + - $ref: '#/components/schemas/AuthNMappingRelationshipToTeam' AuthNMappingUpdateRequest: description: Request to update an AuthN Mapping. properties: @@ -15667,6 +15738,22 @@ components: - id - type type: object + RelationshipToTeam: + description: Relationship to team. + properties: + data: + $ref: '#/components/schemas/RelationshipToTeamData' + type: object + RelationshipToTeamData: + description: Relationship to Team object. + properties: + id: + description: The unique identifier of the team. + example: f9bb8444-af7f-11ec-ac2c-da7ad0900001 + type: string + type: + $ref: '#/components/schemas/TeamType' + type: object RelationshipToTeamLinkData: description: Relationship between a link and a team properties: diff --git a/examples/v2_authn-mappings_create_authn_mapping.rs b/examples/v2_authn-mappings_create_authn_mapping.rs index 4e706de66..929ab6832 100644 --- a/examples/v2_authn-mappings_create_authn_mapping.rs +++ b/examples/v2_authn-mappings_create_authn_mapping.rs @@ -5,6 +5,7 @@ use datadog_api_client::datadogV2::model::AuthNMappingCreateAttributes; use datadog_api_client::datadogV2::model::AuthNMappingCreateData; use datadog_api_client::datadogV2::model::AuthNMappingCreateRelationships; use datadog_api_client::datadogV2::model::AuthNMappingCreateRequest; +use datadog_api_client::datadogV2::model::AuthNMappingRelationshipToRole; use datadog_api_client::datadogV2::model::AuthNMappingsType; use datadog_api_client::datadogV2::model::RelationshipToRole; use datadog_api_client::datadogV2::model::RelationshipToRoleData; @@ -22,13 +23,15 @@ async fn main() { .attribute_value("Example-AuthN-Mapping".to_string()), ) .relationships( - AuthNMappingCreateRelationships::new().role( - RelationshipToRole::new().data( - RelationshipToRoleData::new() - .id(role_data_id.clone()) - .type_(RolesType::ROLES), + AuthNMappingCreateRelationships::AuthNMappingRelationshipToRole(Box::new( + AuthNMappingRelationshipToRole::new( + RelationshipToRole::new().data( + RelationshipToRoleData::new() + .id(role_data_id.clone()) + .type_(RolesType::ROLES), + ), ), - ), + )), ), ); let configuration = Configuration::new(); diff --git a/examples/v2_authn-mappings_update_authn_mapping.rs b/examples/v2_authn-mappings_update_authn_mapping.rs index 07d297ba2..02877f578 100644 --- a/examples/v2_authn-mappings_update_authn_mapping.rs +++ b/examples/v2_authn-mappings_update_authn_mapping.rs @@ -1,6 +1,7 @@ // Edit an AuthN Mapping returns "OK" response use datadog_api_client::datadog::configuration::Configuration; use datadog_api_client::datadogV2::api::api_authn_mappings::AuthNMappingsAPI; +use datadog_api_client::datadogV2::model::AuthNMappingRelationshipToRole; use datadog_api_client::datadogV2::model::AuthNMappingUpdateAttributes; use datadog_api_client::datadogV2::model::AuthNMappingUpdateData; use datadog_api_client::datadogV2::model::AuthNMappingUpdateRelationships; @@ -28,13 +29,15 @@ async fn main() { .attribute_value("Development".to_string()), ) .relationships( - AuthNMappingUpdateRelationships::new().role( - RelationshipToRole::new().data( - RelationshipToRoleData::new() - .id(role_data_id.clone()) - .type_(RolesType::ROLES), + AuthNMappingUpdateRelationships::AuthNMappingRelationshipToRole(Box::new( + AuthNMappingRelationshipToRole::new( + RelationshipToRole::new().data( + RelationshipToRoleData::new() + .id(role_data_id.clone()) + .type_(RolesType::ROLES), + ), ), - ), + )), ), ); let configuration = Configuration::new(); diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 5185521c9..c118c62d2 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -250,12 +250,22 @@ pub mod model_relationship_to_saml_assertion_attribute_data; pub use self::model_relationship_to_saml_assertion_attribute_data::RelationshipToSAMLAssertionAttributeData; pub mod model_saml_assertion_attributes_type; pub use self::model_saml_assertion_attributes_type::SAMLAssertionAttributesType; +pub mod model_relationship_to_team; +pub use self::model_relationship_to_team::RelationshipToTeam; +pub mod model_relationship_to_team_data; +pub use self::model_relationship_to_team_data::RelationshipToTeamData; +pub mod model_team_type; +pub use self::model_team_type::TeamType; pub mod model_authn_mappings_type; pub use self::model_authn_mappings_type::AuthNMappingsType; pub mod model_saml_assertion_attribute; pub use self::model_saml_assertion_attribute::SAMLAssertionAttribute; pub mod model_saml_assertion_attribute_attributes; pub use self::model_saml_assertion_attribute_attributes::SAMLAssertionAttributeAttributes; +pub mod model_authn_mapping_team; +pub use self::model_authn_mapping_team::AuthNMappingTeam; +pub mod model_authn_mapping_team_attributes; +pub use self::model_authn_mapping_team_attributes::AuthNMappingTeamAttributes; pub mod model_authn_mapping_included; pub use self::model_authn_mapping_included::AuthNMappingIncluded; pub mod model_response_meta_attributes; @@ -268,6 +278,10 @@ pub mod model_authn_mapping_create_data; pub use self::model_authn_mapping_create_data::AuthNMappingCreateData; pub mod model_authn_mapping_create_attributes; pub use self::model_authn_mapping_create_attributes::AuthNMappingCreateAttributes; +pub mod model_authn_mapping_relationship_to_role; +pub use self::model_authn_mapping_relationship_to_role::AuthNMappingRelationshipToRole; +pub mod model_authn_mapping_relationship_to_team; +pub use self::model_authn_mapping_relationship_to_team::AuthNMappingRelationshipToTeam; pub mod model_authn_mapping_create_relationships; pub use self::model_authn_mapping_create_relationships::AuthNMappingCreateRelationships; pub mod model_authn_mapping_response; @@ -2676,8 +2690,6 @@ pub mod model_relationship_to_user_team_permission_data; pub use self::model_relationship_to_user_team_permission_data::RelationshipToUserTeamPermissionData; pub mod model_user_team_permission_type; pub use self::model_user_team_permission_type::UserTeamPermissionType; -pub mod model_team_type; -pub use self::model_team_type::TeamType; pub mod model_team_link; pub use self::model_team_link::TeamLink; pub mod model_team_link_attributes; diff --git a/src/datadogV2/model/model_authn_mapping_create_data.rs b/src/datadogV2/model/model_authn_mapping_create_data.rs index 769c4819b..c6641c24e 100644 --- a/src/datadogV2/model/model_authn_mapping_create_data.rs +++ b/src/datadogV2/model/model_authn_mapping_create_data.rs @@ -14,7 +14,7 @@ pub struct AuthNMappingCreateData { /// Key/Value pair of attributes used for create request. #[serde(rename = "attributes")] pub attributes: Option, - /// Relationship of AuthN Mapping create object to Role. + /// Relationship of AuthN Mapping create object to a Role or Team. #[serde(rename = "relationships")] pub relationships: Option, /// AuthN Mappings resource type. @@ -91,6 +91,14 @@ impl<'de> Deserialize<'de> for AuthNMappingCreateData { } relationships = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _relationships) = relationships { + match _relationships { + crate::datadogV2::model::AuthNMappingCreateRelationships::UnparsedObject(_relationships) => { + _unparsed = true; + }, + _ => {} + } + } } "type" => { type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); diff --git a/src/datadogV2/model/model_authn_mapping_create_relationships.rs b/src/datadogV2/model/model_authn_mapping_create_relationships.rs index 0fc1aed11..74ff61333 100644 --- a/src/datadogV2/model/model_authn_mapping_create_relationships.rs +++ b/src/datadogV2/model/model_authn_mapping_create_relationships.rs @@ -1,42 +1,16 @@ // 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}; -/// Relationship of AuthN Mapping create object to Role. +/// Relationship of AuthN Mapping create object to a Role or Team. #[non_exhaustive] -#[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] -pub struct AuthNMappingCreateRelationships { - /// Relationship to role. - #[serde(rename = "role")] - pub role: Option, - #[serde(skip)] - #[serde(default)] - pub(crate) _unparsed: bool, -} - -impl AuthNMappingCreateRelationships { - pub fn new() -> AuthNMappingCreateRelationships { - AuthNMappingCreateRelationships { - role: None, - _unparsed: false, - } - } - - pub fn role(mut self, value: crate::datadogV2::model::RelationshipToRole) -> Self { - self.role = Some(value); - self - } -} - -impl Default for AuthNMappingCreateRelationships { - fn default() -> Self { - Self::new() - } +#[serde(untagged)] +pub enum AuthNMappingCreateRelationships { + AuthNMappingRelationshipToRole(Box), + AuthNMappingRelationshipToTeam(Box), + UnparsedObject(crate::datadog::UnparsedObject), } impl<'de> Deserialize<'de> for AuthNMappingCreateRelationships { @@ -44,39 +18,26 @@ impl<'de> Deserialize<'de> for AuthNMappingCreateRelationships { where D: Deserializer<'de>, { - struct AuthNMappingCreateRelationshipsVisitor; - impl<'a> Visitor<'a> for AuthNMappingCreateRelationshipsVisitor { - type Value = AuthNMappingCreateRelationships; - - fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { - f.write_str("a mapping") + let value: serde_json::Value = Deserialize::deserialize(deserializer)?; + if let Ok(_v) = serde_json::from_value::< + Box, + >(value.clone()) + { + if !_v._unparsed { + return Ok(AuthNMappingCreateRelationships::AuthNMappingRelationshipToRole(_v)); } - - fn visit_map(self, mut map: M) -> Result - where - M: MapAccess<'a>, - { - let mut role: Option = None; - let mut _unparsed = false; - - while let Some((k, v)) = map.next_entry::()? { - match k.as_str() { - "role" => { - if v.is_null() { - continue; - } - role = Some(serde_json::from_value(v).map_err(M::Error::custom)?); - } - &_ => {} - } - } - - let content = AuthNMappingCreateRelationships { role, _unparsed }; - - Ok(content) + } + if let Ok(_v) = serde_json::from_value::< + Box, + >(value.clone()) + { + if !_v._unparsed { + return Ok(AuthNMappingCreateRelationships::AuthNMappingRelationshipToTeam(_v)); } } - deserializer.deserialize_any(AuthNMappingCreateRelationshipsVisitor) + return Ok(AuthNMappingCreateRelationships::UnparsedObject( + crate::datadog::UnparsedObject { value }, + )); } } diff --git a/src/datadogV2/model/model_authn_mapping_included.rs b/src/datadogV2/model/model_authn_mapping_included.rs index 8a4dc800d..c37e023ce 100644 --- a/src/datadogV2/model/model_authn_mapping_included.rs +++ b/src/datadogV2/model/model_authn_mapping_included.rs @@ -10,6 +10,7 @@ use serde::{Deserialize, Deserializer, Serialize}; pub enum AuthNMappingIncluded { SAMLAssertionAttribute(Box), Role(Box), + AuthNMappingTeam(Box), UnparsedObject(crate::datadog::UnparsedObject), } @@ -32,6 +33,13 @@ impl<'de> Deserialize<'de> for AuthNMappingIncluded { return Ok(AuthNMappingIncluded::Role(_v)); } } + if let Ok(_v) = + serde_json::from_value::>(value.clone()) + { + if !_v._unparsed { + return Ok(AuthNMappingIncluded::AuthNMappingTeam(_v)); + } + } return Ok(AuthNMappingIncluded::UnparsedObject( crate::datadog::UnparsedObject { value }, diff --git a/src/datadogV2/model/model_authn_mapping_relationship_to_role.rs b/src/datadogV2/model/model_authn_mapping_relationship_to_role.rs new file mode 100644 index 000000000..61d2cefc3 --- /dev/null +++ b/src/datadogV2/model/model_authn_mapping_relationship_to_role.rs @@ -0,0 +1,71 @@ +// 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}; + +/// Relationship of AuthN Mapping to a Role. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AuthNMappingRelationshipToRole { + /// Relationship to role. + #[serde(rename = "role")] + pub role: crate::datadogV2::model::RelationshipToRole, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AuthNMappingRelationshipToRole { + pub fn new( + role: crate::datadogV2::model::RelationshipToRole, + ) -> AuthNMappingRelationshipToRole { + AuthNMappingRelationshipToRole { + role, + _unparsed: false, + } + } +} + +impl<'de> Deserialize<'de> for AuthNMappingRelationshipToRole { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AuthNMappingRelationshipToRoleVisitor; + impl<'a> Visitor<'a> for AuthNMappingRelationshipToRoleVisitor { + type Value = AuthNMappingRelationshipToRole; + + 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 role: Option = None; + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "role" => { + role = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => {} + } + } + let role = role.ok_or_else(|| M::Error::missing_field("role"))?; + + let content = AuthNMappingRelationshipToRole { role, _unparsed }; + + Ok(content) + } + } + + deserializer.deserialize_any(AuthNMappingRelationshipToRoleVisitor) + } +} diff --git a/src/datadogV2/model/model_authn_mapping_relationship_to_team.rs b/src/datadogV2/model/model_authn_mapping_relationship_to_team.rs new file mode 100644 index 000000000..9fa2c7426 --- /dev/null +++ b/src/datadogV2/model/model_authn_mapping_relationship_to_team.rs @@ -0,0 +1,71 @@ +// 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}; + +/// Relationship of AuthN Mapping to a Team. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AuthNMappingRelationshipToTeam { + /// Relationship to team. + #[serde(rename = "team")] + pub team: crate::datadogV2::model::RelationshipToTeam, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AuthNMappingRelationshipToTeam { + pub fn new( + team: crate::datadogV2::model::RelationshipToTeam, + ) -> AuthNMappingRelationshipToTeam { + AuthNMappingRelationshipToTeam { + team, + _unparsed: false, + } + } +} + +impl<'de> Deserialize<'de> for AuthNMappingRelationshipToTeam { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AuthNMappingRelationshipToTeamVisitor; + impl<'a> Visitor<'a> for AuthNMappingRelationshipToTeamVisitor { + type Value = AuthNMappingRelationshipToTeam; + + 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 team: Option = None; + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "team" => { + team = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => {} + } + } + let team = team.ok_or_else(|| M::Error::missing_field("team"))?; + + let content = AuthNMappingRelationshipToTeam { team, _unparsed }; + + Ok(content) + } + } + + deserializer.deserialize_any(AuthNMappingRelationshipToTeamVisitor) + } +} diff --git a/src/datadogV2/model/model_authn_mapping_relationships.rs b/src/datadogV2/model/model_authn_mapping_relationships.rs index 66ab3632b..cfd96b5bf 100644 --- a/src/datadogV2/model/model_authn_mapping_relationships.rs +++ b/src/datadogV2/model/model_authn_mapping_relationships.rs @@ -18,6 +18,9 @@ pub struct AuthNMappingRelationships { #[serde(rename = "saml_assertion_attribute")] pub saml_assertion_attribute: Option, + /// Relationship to team. + #[serde(rename = "team")] + pub team: Option, #[serde(skip)] #[serde(default)] pub(crate) _unparsed: bool, @@ -28,6 +31,7 @@ impl AuthNMappingRelationships { AuthNMappingRelationships { role: None, saml_assertion_attribute: None, + team: None, _unparsed: false, } } @@ -44,6 +48,11 @@ impl AuthNMappingRelationships { self.saml_assertion_attribute = Some(value); self } + + pub fn team(mut self, value: crate::datadogV2::model::RelationshipToTeam) -> Self { + self.team = Some(value); + self + } } impl Default for AuthNMappingRelationships { @@ -73,6 +82,7 @@ impl<'de> Deserialize<'de> for AuthNMappingRelationships { let mut saml_assertion_attribute: Option< crate::datadogV2::model::RelationshipToSAMLAssertionAttribute, > = None; + let mut team: Option = None; let mut _unparsed = false; while let Some((k, v)) = map.next_entry::()? { @@ -90,6 +100,12 @@ impl<'de> Deserialize<'de> for AuthNMappingRelationships { saml_assertion_attribute = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } + "team" => { + if v.is_null() { + continue; + } + team = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } &_ => {} } } @@ -97,6 +113,7 @@ impl<'de> Deserialize<'de> for AuthNMappingRelationships { let content = AuthNMappingRelationships { role, saml_assertion_attribute, + team, _unparsed, }; diff --git a/src/datadogV2/model/model_authn_mapping_team.rs b/src/datadogV2/model/model_authn_mapping_team.rs new file mode 100644 index 000000000..504509dde --- /dev/null +++ b/src/datadogV2/model/model_authn_mapping_team.rs @@ -0,0 +1,131 @@ +// 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}; + +/// Team. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AuthNMappingTeam { + /// Team attributes. + #[serde(rename = "attributes")] + pub attributes: Option, + /// The ID of the Team. + #[serde(rename = "id")] + pub id: Option, + /// Team type + #[serde(rename = "type")] + pub type_: Option, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AuthNMappingTeam { + pub fn new() -> AuthNMappingTeam { + AuthNMappingTeam { + attributes: None, + id: None, + type_: None, + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::AuthNMappingTeamAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn type_(mut self, value: crate::datadogV2::model::TeamType) -> Self { + self.type_ = Some(value); + self + } +} + +impl Default for AuthNMappingTeam { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for AuthNMappingTeam { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AuthNMappingTeamVisitor; + impl<'a> Visitor<'a> for AuthNMappingTeamVisitor { + type Value = AuthNMappingTeam; + + 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 type_: Option = None; + 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)?); + } + "type" => { + if v.is_null() { + continue; + } + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::TeamType::UnparsedObject(_type_) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => {} + } + } + + let content = AuthNMappingTeam { + attributes, + id, + type_, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AuthNMappingTeamVisitor) + } +} diff --git a/src/datadogV2/model/model_authn_mapping_team_attributes.rs b/src/datadogV2/model/model_authn_mapping_team_attributes.rs new file mode 100644 index 000000000..9e6ff9708 --- /dev/null +++ b/src/datadogV2/model/model_authn_mapping_team_attributes.rs @@ -0,0 +1,182 @@ +// 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}; + +/// Team attributes. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AuthNMappingTeamAttributes { + /// Unicode representation of the avatar for the team, limited to a single grapheme + #[serde(rename = "avatar", default, with = "::serde_with::rust::double_option")] + pub avatar: Option>, + /// Banner selection for the team + #[serde(rename = "banner", default, with = "::serde_with::rust::double_option")] + pub banner: Option>, + /// The team's identifier + #[serde(rename = "handle")] + pub handle: Option, + /// The number of links belonging to the team + #[serde(rename = "link_count")] + pub link_count: Option, + /// The name of the team + #[serde(rename = "name")] + pub name: Option, + /// A brief summary of the team, derived from the `description` + #[serde( + rename = "summary", + default, + with = "::serde_with::rust::double_option" + )] + pub summary: Option>, + /// The number of users belonging to the team + #[serde(rename = "user_count")] + pub user_count: Option, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AuthNMappingTeamAttributes { + pub fn new() -> AuthNMappingTeamAttributes { + AuthNMappingTeamAttributes { + avatar: None, + banner: None, + handle: None, + link_count: None, + name: None, + summary: None, + user_count: None, + _unparsed: false, + } + } + + pub fn avatar(mut self, value: Option) -> Self { + self.avatar = Some(value); + self + } + + pub fn banner(mut self, value: Option) -> Self { + self.banner = Some(value); + self + } + + pub fn handle(mut self, value: String) -> Self { + self.handle = Some(value); + self + } + + pub fn link_count(mut self, value: i32) -> Self { + self.link_count = Some(value); + self + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn summary(mut self, value: Option) -> Self { + self.summary = Some(value); + self + } + + pub fn user_count(mut self, value: i32) -> Self { + self.user_count = Some(value); + self + } +} + +impl Default for AuthNMappingTeamAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for AuthNMappingTeamAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AuthNMappingTeamAttributesVisitor; + impl<'a> Visitor<'a> for AuthNMappingTeamAttributesVisitor { + type Value = AuthNMappingTeamAttributes; + + 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 avatar: Option> = None; + let mut banner: Option> = None; + let mut handle: Option = None; + let mut link_count: Option = None; + let mut name: Option = None; + let mut summary: Option> = None; + let mut user_count: Option = None; + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "avatar" => { + avatar = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "banner" => { + banner = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "handle" => { + if v.is_null() { + continue; + } + handle = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "link_count" => { + if v.is_null() { + continue; + } + link_count = 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)?); + } + "summary" => { + summary = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "user_count" => { + if v.is_null() { + continue; + } + user_count = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => {} + } + } + + let content = AuthNMappingTeamAttributes { + avatar, + banner, + handle, + link_count, + name, + summary, + user_count, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AuthNMappingTeamAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_authn_mapping_update_data.rs b/src/datadogV2/model/model_authn_mapping_update_data.rs index 633cf243d..5ae4ed39c 100644 --- a/src/datadogV2/model/model_authn_mapping_update_data.rs +++ b/src/datadogV2/model/model_authn_mapping_update_data.rs @@ -17,7 +17,7 @@ pub struct AuthNMappingUpdateData { /// ID of the AuthN Mapping. #[serde(rename = "id")] pub id: String, - /// Relationship of AuthN Mapping update object to Role. + /// Relationship of AuthN Mapping update object to a Role or Team. #[serde(rename = "relationships")] pub relationships: Option, /// AuthN Mappings resource type. @@ -102,6 +102,14 @@ impl<'de> Deserialize<'de> for AuthNMappingUpdateData { } relationships = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _relationships) = relationships { + match _relationships { + crate::datadogV2::model::AuthNMappingUpdateRelationships::UnparsedObject(_relationships) => { + _unparsed = true; + }, + _ => {} + } + } } "type" => { type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); diff --git a/src/datadogV2/model/model_authn_mapping_update_relationships.rs b/src/datadogV2/model/model_authn_mapping_update_relationships.rs index 07551cd75..436b2e0fa 100644 --- a/src/datadogV2/model/model_authn_mapping_update_relationships.rs +++ b/src/datadogV2/model/model_authn_mapping_update_relationships.rs @@ -1,42 +1,16 @@ // 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}; -/// Relationship of AuthN Mapping update object to Role. +/// Relationship of AuthN Mapping update object to a Role or Team. #[non_exhaustive] -#[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] -pub struct AuthNMappingUpdateRelationships { - /// Relationship to role. - #[serde(rename = "role")] - pub role: Option, - #[serde(skip)] - #[serde(default)] - pub(crate) _unparsed: bool, -} - -impl AuthNMappingUpdateRelationships { - pub fn new() -> AuthNMappingUpdateRelationships { - AuthNMappingUpdateRelationships { - role: None, - _unparsed: false, - } - } - - pub fn role(mut self, value: crate::datadogV2::model::RelationshipToRole) -> Self { - self.role = Some(value); - self - } -} - -impl Default for AuthNMappingUpdateRelationships { - fn default() -> Self { - Self::new() - } +#[serde(untagged)] +pub enum AuthNMappingUpdateRelationships { + AuthNMappingRelationshipToRole(Box), + AuthNMappingRelationshipToTeam(Box), + UnparsedObject(crate::datadog::UnparsedObject), } impl<'de> Deserialize<'de> for AuthNMappingUpdateRelationships { @@ -44,39 +18,26 @@ impl<'de> Deserialize<'de> for AuthNMappingUpdateRelationships { where D: Deserializer<'de>, { - struct AuthNMappingUpdateRelationshipsVisitor; - impl<'a> Visitor<'a> for AuthNMappingUpdateRelationshipsVisitor { - type Value = AuthNMappingUpdateRelationships; - - fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { - f.write_str("a mapping") + let value: serde_json::Value = Deserialize::deserialize(deserializer)?; + if let Ok(_v) = serde_json::from_value::< + Box, + >(value.clone()) + { + if !_v._unparsed { + return Ok(AuthNMappingUpdateRelationships::AuthNMappingRelationshipToRole(_v)); } - - fn visit_map(self, mut map: M) -> Result - where - M: MapAccess<'a>, - { - let mut role: Option = None; - let mut _unparsed = false; - - while let Some((k, v)) = map.next_entry::()? { - match k.as_str() { - "role" => { - if v.is_null() { - continue; - } - role = Some(serde_json::from_value(v).map_err(M::Error::custom)?); - } - &_ => {} - } - } - - let content = AuthNMappingUpdateRelationships { role, _unparsed }; - - Ok(content) + } + if let Ok(_v) = serde_json::from_value::< + Box, + >(value.clone()) + { + if !_v._unparsed { + return Ok(AuthNMappingUpdateRelationships::AuthNMappingRelationshipToTeam(_v)); } } - deserializer.deserialize_any(AuthNMappingUpdateRelationshipsVisitor) + return Ok(AuthNMappingUpdateRelationships::UnparsedObject( + crate::datadog::UnparsedObject { value }, + )); } } diff --git a/src/datadogV2/model/model_relationship_to_team.rs b/src/datadogV2/model/model_relationship_to_team.rs new file mode 100644 index 000000000..a985095f4 --- /dev/null +++ b/src/datadogV2/model/model_relationship_to_team.rs @@ -0,0 +1,82 @@ +// 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}; + +/// Relationship to team. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RelationshipToTeam { + /// Relationship to Team object. + #[serde(rename = "data")] + pub data: Option, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RelationshipToTeam { + pub fn new() -> RelationshipToTeam { + RelationshipToTeam { + data: None, + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::RelationshipToTeamData) -> Self { + self.data = Some(value); + self + } +} + +impl Default for RelationshipToTeam { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for RelationshipToTeam { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RelationshipToTeamVisitor; + impl<'a> Visitor<'a> for RelationshipToTeamVisitor { + type Value = RelationshipToTeam; + + 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 _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)?); + } + &_ => {} + } + } + + let content = RelationshipToTeam { data, _unparsed }; + + Ok(content) + } + } + + deserializer.deserialize_any(RelationshipToTeamVisitor) + } +} diff --git a/src/datadogV2/model/model_relationship_to_team_data.rs b/src/datadogV2/model/model_relationship_to_team_data.rs new file mode 100644 index 000000000..9c0ab3705 --- /dev/null +++ b/src/datadogV2/model/model_relationship_to_team_data.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}; + +/// Relationship to Team object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RelationshipToTeamData { + /// The unique identifier of the team. + #[serde(rename = "id")] + pub id: Option, + /// Team type + #[serde(rename = "type")] + pub type_: Option, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RelationshipToTeamData { + pub fn new() -> RelationshipToTeamData { + RelationshipToTeamData { + id: None, + type_: None, + _unparsed: false, + } + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn type_(mut self, value: crate::datadogV2::model::TeamType) -> Self { + self.type_ = Some(value); + self + } +} + +impl Default for RelationshipToTeamData { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for RelationshipToTeamData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RelationshipToTeamDataVisitor; + impl<'a> Visitor<'a> for RelationshipToTeamDataVisitor { + type Value = RelationshipToTeamData; + + 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 _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + if v.is_null() { + continue; + } + id = 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)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::TeamType::UnparsedObject(_type_) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => {} + } + } + + let content = RelationshipToTeamData { + id, + type_, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RelationshipToTeamDataVisitor) + } +}