diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 642bfd742..2b877f268 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -52263,14 +52263,31 @@ components: TeamSyncAttributes: description: Team sync attributes. properties: + frequency: + $ref: '#/components/schemas/TeamSyncAttributesFrequency' source: $ref: '#/components/schemas/TeamSyncAttributesSource' + sync_membership: + $ref: '#/components/schemas/TeamSyncAttributesSyncMembership' type: $ref: '#/components/schemas/TeamSyncAttributesType' required: - source - type type: object + TeamSyncAttributesFrequency: + description: How often the sync process should be run. Defaults to `once` when + not provided. + enum: + - once + - continuously + - paused + example: once + type: string + x-enum-varnames: + - ONCE + - CONTINUOUSLY + - PAUSED TeamSyncAttributesSource: description: The external source platform for team synchronization. Only "github" is supported. @@ -52280,15 +52297,22 @@ components: type: string x-enum-varnames: - GITHUB + TeamSyncAttributesSyncMembership: + description: Whether to sync members from the external team to the Datadog team. + Defaults to `false` when not provided. + example: true + type: boolean TeamSyncAttributesType: - description: The type of synchronization operation. Only "link" is supported, - which links existing teams by matching names. + description: The type of synchronization operation. "link" connects teams by + matching names. "provision" creates new teams when no match is found. enum: - link + - provision example: link type: string x-enum-varnames: - LINK + - PROVISION TeamSyncBulkType: description: Team sync bulk type. enum: @@ -52298,10 +52322,15 @@ components: x-enum-varnames: - TEAM_SYNC_BULK TeamSyncData: - description: Team sync data. + description: A configuration governing syncing between Datadog teams and teams + from an external system. properties: attributes: $ref: '#/components/schemas/TeamSyncAttributes' + id: + description: The sync's identifier + example: aeadc05e-98a8-11ec-ac2c-da7ad0900001 + type: string type: $ref: '#/components/schemas/TeamSyncBulkType' required: @@ -52322,6 +52351,15 @@ components: required: - data type: object + TeamSyncResponse: + description: Team sync configurations response. + properties: + data: + description: List of team sync configurations + items: + $ref: '#/components/schemas/TeamSyncData' + type: array + type: object TeamTarget: description: Represents a team target for an escalation policy step, including the team's ID and resource type. @@ -81182,6 +81220,52 @@ paths: If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/team/sync: + get: + description: 'Get all team synchronization configurations. + + Returns a list of configurations used for linking or provisioning teams with + external sources like GitHub.' + operationId: GetTeamSync + parameters: + - description: Filter by the external source platform for team synchronization + in: query + name: filter[source] + required: true + schema: + $ref: '#/components/schemas/TeamSyncAttributesSource' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/TeamSyncResponse' + description: OK + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Team sync configurations not found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - teams_read + summary: Get team sync configurations + tags: + - Teams + x-permission: + operator: OR + permissions: + - teams_read + x-unstable: '**Note**: This endpoint is in Preview. To request access, fill + out this [form](https://www.datadoghq.com/product-preview/github-integration-for-teams/). + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' post: description: 'This endpoint attempts to link your existing Datadog teams with GitHub teams by matching their names. @@ -81208,7 +81292,8 @@ paths: using a normalized exact match; case is ignored and spaces are removed. No modifications are made - to teams in GitHub. This will not create new Teams in Datadog.' + to teams in GitHub. This only creates new teams in Datadog when type is set + to `provision`.' operationId: SyncTeams requestBody: content: diff --git a/examples/v2_teams_GetTeamSync.rs b/examples/v2_teams_GetTeamSync.rs new file mode 100644 index 000000000..911870715 --- /dev/null +++ b/examples/v2_teams_GetTeamSync.rs @@ -0,0 +1,17 @@ +// Get team sync configurations returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_teams::TeamsAPI; +use datadog_api_client::datadogV2::model::TeamSyncAttributesSource; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.GetTeamSync", true); + let api = TeamsAPI::with_config(configuration); + let resp = api.get_team_sync(TeamSyncAttributesSource::GITHUB).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadog/configuration.rs b/src/datadog/configuration.rs index 47202ecab..90d90ee11 100644 --- a/src/datadog/configuration.rs +++ b/src/datadog/configuration.rs @@ -256,6 +256,7 @@ impl Default for Configuration { ("v2.create_sca_resolve_vulnerable_symbols".to_owned(), false), ("v2.create_sca_result".to_owned(), false), ("v2.add_member_team".to_owned(), false), + ("v2.get_team_sync".to_owned(), false), ("v2.list_member_teams".to_owned(), false), ("v2.remove_member_team".to_owned(), false), ("v2.sync_teams".to_owned(), false), diff --git a/src/datadogV2/api/api_teams.rs b/src/datadogV2/api/api_teams.rs index a912bdf59..edad90efc 100644 --- a/src/datadogV2/api/api_teams.rs +++ b/src/datadogV2/api/api_teams.rs @@ -234,6 +234,14 @@ pub enum GetTeamPermissionSettingsError { UnknownValue(serde_json::Value), } +/// GetTeamSyncError is a struct for typed errors of method [`TeamsAPI::get_team_sync`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTeamSyncError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// GetUserMembershipsError is a struct for typed errors of method [`TeamsAPI::get_user_memberships`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -1848,6 +1856,122 @@ impl TeamsAPI { } } + /// Get all team synchronization configurations. + /// Returns a list of configurations used for linking or provisioning teams with external sources like GitHub. + pub async fn get_team_sync( + &self, + filter_source: crate::datadogV2::model::TeamSyncAttributesSource, + ) -> Result> { + match self.get_team_sync_with_http_info(filter_source).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), + } + } + + /// Get all team synchronization configurations. + /// Returns a list of configurations used for linking or provisioning teams with external sources like GitHub. + pub async fn get_team_sync_with_http_info( + &self, + filter_source: crate::datadogV2::model::TeamSyncAttributesSource, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_team_sync"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.get_team_sync' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/team/sync", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + local_req_builder = + local_req_builder.query(&[("filter[source]", &filter_source.to_string())]); + + // 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)) + } + } + /// Get a list of memberships for a user pub async fn get_user_memberships( &self, @@ -2426,7 +2550,7 @@ impl TeamsAPI { /// [A GitHub organization must be connected to your Datadog account](), /// and the GitHub App integrated with Datadog must have the `Members Read` permission. Matching is performed by comparing the Datadog team handle to the GitHub team slug /// using a normalized exact match; case is ignored and spaces are removed. No modifications are made - /// to teams in GitHub. This will not create new Teams in Datadog. + /// to teams in GitHub. This only creates new teams in Datadog when type is set to `provision`. pub async fn sync_teams( &self, body: crate::datadogV2::model::TeamSyncRequest, @@ -2447,7 +2571,7 @@ impl TeamsAPI { /// [A GitHub organization must be connected to your Datadog account](), /// and the GitHub App integrated with Datadog must have the `Members Read` permission. Matching is performed by comparing the Datadog team handle to the GitHub team slug /// using a normalized exact match; case is ignored and spaces are removed. No modifications are made - /// to teams in GitHub. This will not create new Teams in Datadog. + /// to teams in GitHub. This only creates new teams in Datadog when type is set to `provision`. pub async fn sync_teams_with_http_info( &self, body: crate::datadogV2::model::TeamSyncRequest, diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index b6c7891bb..1878768c9 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -6630,18 +6630,22 @@ pub mod model_team_connection_create_request; pub use self::model_team_connection_create_request::TeamConnectionCreateRequest; pub mod model_team_connection_create_data; pub use self::model_team_connection_create_data::TeamConnectionCreateData; -pub mod model_team_sync_request; -pub use self::model_team_sync_request::TeamSyncRequest; +pub mod model_team_sync_attributes_source; +pub use self::model_team_sync_attributes_source::TeamSyncAttributesSource; +pub mod model_team_sync_response; +pub use self::model_team_sync_response::TeamSyncResponse; pub mod model_team_sync_data; pub use self::model_team_sync_data::TeamSyncData; pub mod model_team_sync_attributes; pub use self::model_team_sync_attributes::TeamSyncAttributes; -pub mod model_team_sync_attributes_source; -pub use self::model_team_sync_attributes_source::TeamSyncAttributesSource; +pub mod model_team_sync_attributes_frequency; +pub use self::model_team_sync_attributes_frequency::TeamSyncAttributesFrequency; pub mod model_team_sync_attributes_type; pub use self::model_team_sync_attributes_type::TeamSyncAttributesType; pub mod model_team_sync_bulk_type; pub use self::model_team_sync_bulk_type::TeamSyncBulkType; +pub mod model_team_sync_request; +pub use self::model_team_sync_request::TeamSyncRequest; pub mod model_add_member_team_request; pub use self::model_add_member_team_request::AddMemberTeamRequest; pub mod model_member_team; diff --git a/src/datadogV2/model/model_team_sync_attributes.rs b/src/datadogV2/model/model_team_sync_attributes.rs index e143c4348..942eae3aa 100644 --- a/src/datadogV2/model/model_team_sync_attributes.rs +++ b/src/datadogV2/model/model_team_sync_attributes.rs @@ -11,10 +11,16 @@ use std::fmt::{self, Formatter}; #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] pub struct TeamSyncAttributes { + /// How often the sync process should be run. Defaults to `once` when not provided. + #[serde(rename = "frequency")] + pub frequency: Option, /// The external source platform for team synchronization. Only "github" is supported. #[serde(rename = "source")] pub source: crate::datadogV2::model::TeamSyncAttributesSource, - /// The type of synchronization operation. Only "link" is supported, which links existing teams by matching names. + /// Whether to sync members from the external team to the Datadog team. Defaults to `false` when not provided. + #[serde(rename = "sync_membership")] + pub sync_membership: Option, + /// The type of synchronization operation. "link" connects teams by matching names. "provision" creates new teams when no match is found. #[serde(rename = "type")] pub type_: crate::datadogV2::model::TeamSyncAttributesType, #[serde(flatten)] @@ -30,13 +36,28 @@ impl TeamSyncAttributes { type_: crate::datadogV2::model::TeamSyncAttributesType, ) -> TeamSyncAttributes { TeamSyncAttributes { + frequency: None, source, + sync_membership: None, type_, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } } + pub fn frequency( + mut self, + value: crate::datadogV2::model::TeamSyncAttributesFrequency, + ) -> Self { + self.frequency = Some(value); + self + } + + pub fn sync_membership(mut self, value: bool) -> Self { + self.sync_membership = Some(value); + self + } + pub fn additional_properties( mut self, value: std::collections::BTreeMap, @@ -63,7 +84,10 @@ impl<'de> Deserialize<'de> for TeamSyncAttributes { where M: MapAccess<'a>, { + let mut frequency: Option = + None; let mut source: Option = None; + let mut sync_membership: Option = None; let mut type_: Option = None; let mut additional_properties: std::collections::BTreeMap< String, @@ -73,6 +97,20 @@ impl<'de> Deserialize<'de> for TeamSyncAttributes { while let Some((k, v)) = map.next_entry::()? { match k.as_str() { + "frequency" => { + if v.is_null() { + continue; + } + frequency = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _frequency) = frequency { + match _frequency { + crate::datadogV2::model::TeamSyncAttributesFrequency::UnparsedObject(_frequency) => { + _unparsed = true; + }, + _ => {} + } + } + } "source" => { source = Some(serde_json::from_value(v).map_err(M::Error::custom)?); if let Some(ref _source) = source { @@ -84,6 +122,13 @@ impl<'de> Deserialize<'de> for TeamSyncAttributes { } } } + "sync_membership" => { + if v.is_null() { + continue; + } + sync_membership = + 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_ { @@ -106,7 +151,9 @@ impl<'de> Deserialize<'de> for TeamSyncAttributes { let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; let content = TeamSyncAttributes { + frequency, source, + sync_membership, type_, additional_properties, _unparsed, diff --git a/src/datadogV2/model/model_team_sync_attributes_frequency.rs b/src/datadogV2/model/model_team_sync_attributes_frequency.rs new file mode 100644 index 000000000..4ac378850 --- /dev/null +++ b/src/datadogV2/model/model_team_sync_attributes_frequency.rs @@ -0,0 +1,54 @@ +// 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 TeamSyncAttributesFrequency { + ONCE, + CONTINUOUSLY, + PAUSED, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for TeamSyncAttributesFrequency { + fn to_string(&self) -> String { + match self { + Self::ONCE => String::from("once"), + Self::CONTINUOUSLY => String::from("continuously"), + Self::PAUSED => String::from("paused"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for TeamSyncAttributesFrequency { + 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 TeamSyncAttributesFrequency { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "once" => Self::ONCE, + "continuously" => Self::CONTINUOUSLY, + "paused" => Self::PAUSED, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_team_sync_attributes_type.rs b/src/datadogV2/model/model_team_sync_attributes_type.rs index 227518b85..5a24fa069 100644 --- a/src/datadogV2/model/model_team_sync_attributes_type.rs +++ b/src/datadogV2/model/model_team_sync_attributes_type.rs @@ -8,6 +8,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; #[derive(Clone, Debug, Eq, PartialEq)] pub enum TeamSyncAttributesType { LINK, + PROVISION, UnparsedObject(crate::datadog::UnparsedObject), } @@ -15,6 +16,7 @@ impl ToString for TeamSyncAttributesType { fn to_string(&self) -> String { match self { Self::LINK => String::from("link"), + Self::PROVISION => String::from("provision"), Self::UnparsedObject(v) => v.value.to_string(), } } @@ -40,6 +42,7 @@ impl<'de> Deserialize<'de> for TeamSyncAttributesType { let s: String = String::deserialize(deserializer)?; Ok(match s.as_str() { "link" => Self::LINK, + "provision" => Self::PROVISION, _ => Self::UnparsedObject(crate::datadog::UnparsedObject { value: serde_json::Value::String(s.into()), }), diff --git a/src/datadogV2/model/model_team_sync_data.rs b/src/datadogV2/model/model_team_sync_data.rs index d8c514634..c37d92946 100644 --- a/src/datadogV2/model/model_team_sync_data.rs +++ b/src/datadogV2/model/model_team_sync_data.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Deserializer, Serialize}; use serde_with::skip_serializing_none; use std::fmt::{self, Formatter}; -/// Team sync data. +/// A configuration governing syncing between Datadog teams and teams from an external system. #[non_exhaustive] #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] @@ -14,6 +14,9 @@ pub struct TeamSyncData { /// Team sync attributes. #[serde(rename = "attributes")] pub attributes: crate::datadogV2::model::TeamSyncAttributes, + /// The sync's identifier + #[serde(rename = "id")] + pub id: Option, /// Team sync bulk type. #[serde(rename = "type")] pub type_: crate::datadogV2::model::TeamSyncBulkType, @@ -31,12 +34,18 @@ impl TeamSyncData { ) -> TeamSyncData { TeamSyncData { attributes, + id: None, type_, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } } + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + pub fn additional_properties( mut self, value: std::collections::BTreeMap, @@ -64,6 +73,7 @@ impl<'de> Deserialize<'de> for TeamSyncData { M: MapAccess<'a>, { let mut attributes: Option = None; + let mut id: Option = None; let mut type_: Option = None; let mut additional_properties: std::collections::BTreeMap< String, @@ -76,6 +86,12 @@ impl<'de> Deserialize<'de> for TeamSyncData { "attributes" => { 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" => { type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); if let Some(ref _type_) = type_ { @@ -101,6 +117,7 @@ impl<'de> Deserialize<'de> for TeamSyncData { let content = TeamSyncData { attributes, + id, type_, additional_properties, _unparsed, diff --git a/src/datadogV2/model/model_team_sync_request.rs b/src/datadogV2/model/model_team_sync_request.rs index c46499c04..4d99fe668 100644 --- a/src/datadogV2/model/model_team_sync_request.rs +++ b/src/datadogV2/model/model_team_sync_request.rs @@ -11,7 +11,7 @@ use std::fmt::{self, Formatter}; #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] pub struct TeamSyncRequest { - /// Team sync data. + /// A configuration governing syncing between Datadog teams and teams from an external system. #[serde(rename = "data")] pub data: crate::datadogV2::model::TeamSyncData, #[serde(flatten)] diff --git a/src/datadogV2/model/model_team_sync_response.rs b/src/datadogV2/model/model_team_sync_response.rs new file mode 100644 index 000000000..4f64e1f5d --- /dev/null +++ b/src/datadogV2/model/model_team_sync_response.rs @@ -0,0 +1,105 @@ +// 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 sync configurations response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamSyncResponse { + /// List of team sync configurations + #[serde(rename = "data")] + pub data: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamSyncResponse { + pub fn new() -> TeamSyncResponse { + TeamSyncResponse { + 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 TeamSyncResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TeamSyncResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamSyncResponseVisitor; + impl<'a> Visitor<'a> for TeamSyncResponseVisitor { + type Value = TeamSyncResponse; + + 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 = TeamSyncResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamSyncResponseVisitor) + } +} diff --git a/tests/scenarios/features/v2/teams.feature b/tests/scenarios/features/v2/teams.feature index 5ba9294a1..bf11bd031 100644 --- a/tests/scenarios/features/v2/teams.feature +++ b/tests/scenarios/features/v2/teams.feature @@ -235,6 +235,22 @@ Feature: Teams Then the response status is 200 OK And the response has 3 items + @generated @skip @team:DataDog/aaa-omg + Scenario: Get team sync configurations returns "OK" response + Given operation "GetTeamSync" enabled + And new "GetTeamSync" request + And request contains "filter[source]" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/aaa-omg + Scenario: Get team sync configurations returns "Team sync configurations not found" response + Given operation "GetTeamSync" enabled + And new "GetTeamSync" request + And request contains "filter[source]" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Team sync configurations not found + @generated @skip @team:DataDog/aaa-omg Scenario: Get user memberships returns "API error response." response Given new "GetUserMemberships" request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index d25ca0a4d..dba9a5e29 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -4287,6 +4287,12 @@ "type": "unsafe" } }, + "GetTeamSync": { + "tag": "Teams", + "undo": { + "type": "safe" + } + }, "SyncTeams": { "tag": "Teams", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index e04382cb2..09a3ab6f6 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -4214,6 +4214,9 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { world .function_mappings .insert("v2.CreateTeam".into(), test_v2_create_team); + world + .function_mappings + .insert("v2.GetTeamSync".into(), test_v2_get_team_sync); world .function_mappings .insert("v2.SyncTeams".into(), test_v2_sync_teams); @@ -32478,6 +32481,32 @@ fn test_v2_create_team(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_teams + .as_ref() + .expect("api instance not found"); + let filter_source = + serde_json::from_value(_parameters.get("filter[source]").unwrap().clone()).unwrap(); + let response = match block_on(api.get_team_sync_with_http_info(filter_source)) { + 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_sync_teams(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances