From ee0395e83c09a921e1480797f8625f0412ad5280 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Wed, 15 Jul 2026 17:34:47 +0000 Subject: [PATCH] Regenerate client from commit e52b06e of spec repo --- .generator/schemas/v2/openapi.yaml | 138 ++++++++++++++++ ...rg-groups_ListOrgGroupPolicySuggestions.rs | 21 +++ src/datadog/configuration.rs | 1 + src/datadogV2/api/api_org_groups.rs | 132 ++++++++++++++++ src/datadogV2/model/mod.rs | 12 ++ ..._org_group_policy_suggestion_attributes.rs | 142 +++++++++++++++++ .../model_org_group_policy_suggestion_data.rs | 149 ++++++++++++++++++ ...g_group_policy_suggestion_list_response.rs | 95 +++++++++++ ...g_group_policy_suggestion_relationships.rs | 106 +++++++++++++ ...odel_org_group_policy_suggestion_status.rs | 54 +++++++ .../model_org_group_policy_suggestion_type.rs | 48 ++++++ .../scenarios/features/v2/org_groups.feature | 16 ++ tests/scenarios/features/v2/undo.json | 6 + tests/scenarios/function_mappings.rs | 34 ++++ 14 files changed, 954 insertions(+) create mode 100644 examples/v2_org-groups_ListOrgGroupPolicySuggestions.rs create mode 100644 src/datadogV2/model/model_org_group_policy_suggestion_attributes.rs create mode 100644 src/datadogV2/model/model_org_group_policy_suggestion_data.rs create mode 100644 src/datadogV2/model/model_org_group_policy_suggestion_list_response.rs create mode 100644 src/datadogV2/model/model_org_group_policy_suggestion_relationships.rs create mode 100644 src/datadogV2/model/model_org_group_policy_suggestion_status.rs create mode 100644 src/datadogV2/model/model_org_group_policy_suggestion_type.rs diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index bf4011c155..dab9cb7af5 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -73349,6 +73349,86 @@ components: - MINUS_ID - NAME - MINUS_NAME + OrgGroupPolicySuggestionAttributes: + description: Attributes of an org group policy suggestion. + properties: + consensus_ratio: + description: The ratio of member orgs whose configuration agrees on the recommended value. + example: 0.75 + format: double + maximum: 1 + minimum: 0 + type: number + policy_name: + description: The name of the suggested policy. + example: "monitor_timezone" + type: string + recommended_value: + description: The recommended value for the policy, based on member org consensus. + example: "UTC" + status: + $ref: "#/components/schemas/OrgGroupPolicySuggestionStatus" + required: + - policy_name + - status + - consensus_ratio + - recommended_value + type: object + OrgGroupPolicySuggestionData: + description: An org group policy suggestion resource. + properties: + attributes: + $ref: "#/components/schemas/OrgGroupPolicySuggestionAttributes" + id: + description: The ID of the org group policy suggestion. + example: "1a2b3c4d-5e6f-7890-abcd-ef0123456789" + type: string + relationships: + $ref: "#/components/schemas/OrgGroupPolicySuggestionRelationships" + type: + $ref: "#/components/schemas/OrgGroupPolicySuggestionType" + required: + - id + - type + - attributes + type: object + OrgGroupPolicySuggestionListResponse: + description: Response containing a list of org group policy suggestions. + properties: + data: + description: An array of org group policy suggestions. + items: + $ref: "#/components/schemas/OrgGroupPolicySuggestionData" + type: array + required: + - data + type: object + OrgGroupPolicySuggestionRelationships: + description: Relationships of an org group policy suggestion. + properties: + org_group: + $ref: "#/components/schemas/OrgGroupRelationshipToOne" + type: object + OrgGroupPolicySuggestionStatus: + description: The status of the policy suggestion. + enum: + - pending + - accepted + - dismissed + example: pending + type: string + x-enum-varnames: + - PENDING + - ACCEPTED + - DISMISSED + OrgGroupPolicySuggestionType: + description: Org group policy suggestions resource type. + enum: + - org_group_policy_suggestions + example: org_group_policy_suggestions + type: string + x-enum-varnames: + - ORG_GROUP_POLICY_SUGGESTIONS OrgGroupPolicyType: description: Org group policies resource type. enum: @@ -164682,6 +164762,64 @@ paths: x-unstable: |- **Note**: This endpoint is in preview and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/org_group_policy_suggestions: + get: + description: List suggested organization group policies. Requires a filter on org group ID. + operationId: ListOrgGroupPolicySuggestions + parameters: + - $ref: "#/components/parameters/OrgGroupPolicyFilterOrgGroupId" + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + consensus_ratio: 0.75 + policy_name: "monitor_timezone" + recommended_value: "UTC" + status: "pending" + id: "1a2b3c4d-5e6f-7890-abcd-ef0123456789" + relationships: + org_group: + data: + id: "a1b2c3d4-e5f6-7890-abcd-ef0123456789" + type: org_groups + type: org_group_policy_suggestions + schema: + $ref: "#/components/schemas/OrgGroupPolicySuggestionListResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: List org group policy suggestions + tags: [Org Groups] + "x-permission": + operator: OR + permissions: + - org_group_read + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/org_groups: get: description: List all organization groups that the requesting organization has access to. diff --git a/examples/v2_org-groups_ListOrgGroupPolicySuggestions.rs b/examples/v2_org-groups_ListOrgGroupPolicySuggestions.rs new file mode 100644 index 0000000000..03ec08512e --- /dev/null +++ b/examples/v2_org-groups_ListOrgGroupPolicySuggestions.rs @@ -0,0 +1,21 @@ +// List org group policy suggestions returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_org_groups::OrgGroupsAPI; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.ListOrgGroupPolicySuggestions", true); + let api = OrgGroupsAPI::with_config(configuration); + let resp = api + .list_org_group_policy_suggestions( + Uuid::parse_str("a1b2c3d4-e5f6-7890-abcd-ef0123456789").expect("invalid UUID"), + ) + .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 7d27a5f6c3..0f430b0dde 100644 --- a/src/datadog/configuration.rs +++ b/src/datadog/configuration.rs @@ -728,6 +728,7 @@ impl Default for Configuration { ("v2.list_org_group_policies".to_owned(), false), ("v2.list_org_group_policy_configs".to_owned(), false), ("v2.list_org_group_policy_overrides".to_owned(), false), + ("v2.list_org_group_policy_suggestions".to_owned(), false), ("v2.list_org_groups".to_owned(), false), ("v2.update_org_group".to_owned(), false), ("v2.update_org_group_membership".to_owned(), false), diff --git a/src/datadogV2/api/api_org_groups.rs b/src/datadogV2/api/api_org_groups.rs index 803becbdc2..84b8961507 100644 --- a/src/datadogV2/api/api_org_groups.rs +++ b/src/datadogV2/api/api_org_groups.rs @@ -297,6 +297,15 @@ pub enum ListOrgGroupPolicyOverridesError { UnknownValue(serde_json::Value), } +/// ListOrgGroupPolicySuggestionsError is a struct for typed errors of method [`OrgGroupsAPI::list_org_group_policy_suggestions`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListOrgGroupPolicySuggestionsError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// ListOrgGroupsError is a struct for typed errors of method [`OrgGroupsAPI::list_org_groups`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -2390,6 +2399,129 @@ impl OrgGroupsAPI { } } + /// List suggested organization group policies. Requires a filter on org group ID. + pub async fn list_org_group_policy_suggestions( + &self, + filter_org_group_id: uuid::Uuid, + ) -> Result< + crate::datadogV2::model::OrgGroupPolicySuggestionListResponse, + datadog::Error, + > { + match self + .list_org_group_policy_suggestions_with_http_info(filter_org_group_id) + .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), + } + } + + /// List suggested organization group policies. Requires a filter on org group ID. + pub async fn list_org_group_policy_suggestions_with_http_info( + &self, + filter_org_group_id: uuid::Uuid, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_org_group_policy_suggestions"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.list_org_group_policy_suggestions' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/org_group_policy_suggestions", + 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[org_group_id]", &filter_org_group_id.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::< + crate::datadogV2::model::OrgGroupPolicySuggestionListResponse, + >(&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)) + } + } + /// List all organization groups that the requesting organization has access to. pub async fn list_org_groups( &self, diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index aece0525d8..ae077b197e 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -8574,6 +8574,18 @@ pub mod model_org_group_policy_override_update_data; pub use self::model_org_group_policy_override_update_data::OrgGroupPolicyOverrideUpdateData; pub mod model_org_group_policy_override_update_attributes; pub use self::model_org_group_policy_override_update_attributes::OrgGroupPolicyOverrideUpdateAttributes; +pub mod model_org_group_policy_suggestion_list_response; +pub use self::model_org_group_policy_suggestion_list_response::OrgGroupPolicySuggestionListResponse; +pub mod model_org_group_policy_suggestion_data; +pub use self::model_org_group_policy_suggestion_data::OrgGroupPolicySuggestionData; +pub mod model_org_group_policy_suggestion_attributes; +pub use self::model_org_group_policy_suggestion_attributes::OrgGroupPolicySuggestionAttributes; +pub mod model_org_group_policy_suggestion_status; +pub use self::model_org_group_policy_suggestion_status::OrgGroupPolicySuggestionStatus; +pub mod model_org_group_policy_suggestion_relationships; +pub use self::model_org_group_policy_suggestion_relationships::OrgGroupPolicySuggestionRelationships; +pub mod model_org_group_policy_suggestion_type; +pub use self::model_org_group_policy_suggestion_type::OrgGroupPolicySuggestionType; pub mod model_org_group_sort_option; pub use self::model_org_group_sort_option::OrgGroupSortOption; pub mod model_org_group_list_response; diff --git a/src/datadogV2/model/model_org_group_policy_suggestion_attributes.rs b/src/datadogV2/model/model_org_group_policy_suggestion_attributes.rs new file mode 100644 index 0000000000..fe2c837cb3 --- /dev/null +++ b/src/datadogV2/model/model_org_group_policy_suggestion_attributes.rs @@ -0,0 +1,142 @@ +// 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}; + +/// Attributes of an org group policy suggestion. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OrgGroupPolicySuggestionAttributes { + /// The ratio of member orgs whose configuration agrees on the recommended value. + #[serde(rename = "consensus_ratio")] + pub consensus_ratio: f64, + /// The name of the suggested policy. + #[serde(rename = "policy_name")] + pub policy_name: String, + /// The recommended value for the policy, based on member org consensus. + #[serde(rename = "recommended_value")] + pub recommended_value: serde_json::Value, + /// The status of the policy suggestion. + #[serde(rename = "status")] + pub status: crate::datadogV2::model::OrgGroupPolicySuggestionStatus, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OrgGroupPolicySuggestionAttributes { + pub fn new( + consensus_ratio: f64, + policy_name: String, + recommended_value: serde_json::Value, + status: crate::datadogV2::model::OrgGroupPolicySuggestionStatus, + ) -> OrgGroupPolicySuggestionAttributes { + OrgGroupPolicySuggestionAttributes { + consensus_ratio, + policy_name, + recommended_value, + status, + 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 OrgGroupPolicySuggestionAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OrgGroupPolicySuggestionAttributesVisitor; + impl<'a> Visitor<'a> for OrgGroupPolicySuggestionAttributesVisitor { + type Value = OrgGroupPolicySuggestionAttributes; + + 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 consensus_ratio: Option = None; + let mut policy_name: Option = None; + let mut recommended_value: Option = None; + let mut status: 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() { + "consensus_ratio" => { + consensus_ratio = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "policy_name" => { + policy_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "recommended_value" => { + recommended_value = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "status" => { + status = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _status) = status { + match _status { + crate::datadogV2::model::OrgGroupPolicySuggestionStatus::UnparsedObject(_status) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let consensus_ratio = + consensus_ratio.ok_or_else(|| M::Error::missing_field("consensus_ratio"))?; + let policy_name = + policy_name.ok_or_else(|| M::Error::missing_field("policy_name"))?; + let recommended_value = recommended_value + .ok_or_else(|| M::Error::missing_field("recommended_value"))?; + let status = status.ok_or_else(|| M::Error::missing_field("status"))?; + + let content = OrgGroupPolicySuggestionAttributes { + consensus_ratio, + policy_name, + recommended_value, + status, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OrgGroupPolicySuggestionAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_org_group_policy_suggestion_data.rs b/src/datadogV2/model/model_org_group_policy_suggestion_data.rs new file mode 100644 index 0000000000..8f17fc7117 --- /dev/null +++ b/src/datadogV2/model/model_org_group_policy_suggestion_data.rs @@ -0,0 +1,149 @@ +// 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}; + +/// An org group policy suggestion resource. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OrgGroupPolicySuggestionData { + /// Attributes of an org group policy suggestion. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::OrgGroupPolicySuggestionAttributes, + /// The ID of the org group policy suggestion. + #[serde(rename = "id")] + pub id: String, + /// Relationships of an org group policy suggestion. + #[serde(rename = "relationships")] + pub relationships: Option, + /// Org group policy suggestions resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::OrgGroupPolicySuggestionType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OrgGroupPolicySuggestionData { + pub fn new( + attributes: crate::datadogV2::model::OrgGroupPolicySuggestionAttributes, + id: String, + type_: crate::datadogV2::model::OrgGroupPolicySuggestionType, + ) -> OrgGroupPolicySuggestionData { + OrgGroupPolicySuggestionData { + attributes, + id, + relationships: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn relationships( + mut self, + value: crate::datadogV2::model::OrgGroupPolicySuggestionRelationships, + ) -> 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 OrgGroupPolicySuggestionData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OrgGroupPolicySuggestionDataVisitor; + impl<'a> Visitor<'a> for OrgGroupPolicySuggestionDataVisitor { + type Value = OrgGroupPolicySuggestionData; + + 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< + crate::datadogV2::model::OrgGroupPolicySuggestionAttributes, + > = None; + let mut id: Option = None; + let mut relationships: Option< + crate::datadogV2::model::OrgGroupPolicySuggestionRelationships, + > = 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" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + 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::OrgGroupPolicySuggestionType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = OrgGroupPolicySuggestionData { + attributes, + id, + relationships, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OrgGroupPolicySuggestionDataVisitor) + } +} diff --git a/src/datadogV2/model/model_org_group_policy_suggestion_list_response.rs b/src/datadogV2/model/model_org_group_policy_suggestion_list_response.rs new file mode 100644 index 0000000000..1a52dd86bb --- /dev/null +++ b/src/datadogV2/model/model_org_group_policy_suggestion_list_response.rs @@ -0,0 +1,95 @@ +// 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}; + +/// Response containing a list of org group policy suggestions. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OrgGroupPolicySuggestionListResponse { + /// An array of org group policy suggestions. + #[serde(rename = "data")] + pub data: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OrgGroupPolicySuggestionListResponse { + pub fn new( + data: Vec, + ) -> OrgGroupPolicySuggestionListResponse { + OrgGroupPolicySuggestionListResponse { + 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 OrgGroupPolicySuggestionListResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OrgGroupPolicySuggestionListResponseVisitor; + impl<'a> Visitor<'a> for OrgGroupPolicySuggestionListResponseVisitor { + type Value = OrgGroupPolicySuggestionListResponse; + + 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 = OrgGroupPolicySuggestionListResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OrgGroupPolicySuggestionListResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_org_group_policy_suggestion_relationships.rs b/src/datadogV2/model/model_org_group_policy_suggestion_relationships.rs new file mode 100644 index 0000000000..254a7b1a2c --- /dev/null +++ b/src/datadogV2/model/model_org_group_policy_suggestion_relationships.rs @@ -0,0 +1,106 @@ +// 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}; + +/// Relationships of an org group policy suggestion. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OrgGroupPolicySuggestionRelationships { + /// Relationship to a single org group. + #[serde(rename = "org_group")] + pub org_group: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OrgGroupPolicySuggestionRelationships { + pub fn new() -> OrgGroupPolicySuggestionRelationships { + OrgGroupPolicySuggestionRelationships { + org_group: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn org_group(mut self, value: crate::datadogV2::model::OrgGroupRelationshipToOne) -> Self { + self.org_group = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for OrgGroupPolicySuggestionRelationships { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for OrgGroupPolicySuggestionRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OrgGroupPolicySuggestionRelationshipsVisitor; + impl<'a> Visitor<'a> for OrgGroupPolicySuggestionRelationshipsVisitor { + type Value = OrgGroupPolicySuggestionRelationships; + + 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 org_group: 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() { + "org_group" => { + if v.is_null() { + continue; + } + org_group = 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 = OrgGroupPolicySuggestionRelationships { + org_group, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OrgGroupPolicySuggestionRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_org_group_policy_suggestion_status.rs b/src/datadogV2/model/model_org_group_policy_suggestion_status.rs new file mode 100644 index 0000000000..49a6445bd8 --- /dev/null +++ b/src/datadogV2/model/model_org_group_policy_suggestion_status.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 OrgGroupPolicySuggestionStatus { + PENDING, + ACCEPTED, + DISMISSED, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for OrgGroupPolicySuggestionStatus { + fn to_string(&self) -> String { + match self { + Self::PENDING => String::from("pending"), + Self::ACCEPTED => String::from("accepted"), + Self::DISMISSED => String::from("dismissed"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for OrgGroupPolicySuggestionStatus { + 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 OrgGroupPolicySuggestionStatus { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "pending" => Self::PENDING, + "accepted" => Self::ACCEPTED, + "dismissed" => Self::DISMISSED, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_org_group_policy_suggestion_type.rs b/src/datadogV2/model/model_org_group_policy_suggestion_type.rs new file mode 100644 index 0000000000..e1564c24bb --- /dev/null +++ b/src/datadogV2/model/model_org_group_policy_suggestion_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 OrgGroupPolicySuggestionType { + ORG_GROUP_POLICY_SUGGESTIONS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for OrgGroupPolicySuggestionType { + fn to_string(&self) -> String { + match self { + Self::ORG_GROUP_POLICY_SUGGESTIONS => String::from("org_group_policy_suggestions"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for OrgGroupPolicySuggestionType { + 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 OrgGroupPolicySuggestionType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "org_group_policy_suggestions" => Self::ORG_GROUP_POLICY_SUGGESTIONS, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/tests/scenarios/features/v2/org_groups.feature b/tests/scenarios/features/v2/org_groups.feature index 58065ea87f..46cd5e7d3e 100644 --- a/tests/scenarios/features/v2/org_groups.feature +++ b/tests/scenarios/features/v2/org_groups.feature @@ -325,6 +325,22 @@ Feature: Org Groups When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/org-management + Scenario: List org group policy suggestions returns "Bad Request" response + Given operation "ListOrgGroupPolicySuggestions" enabled + And new "ListOrgGroupPolicySuggestions" request + And request contains "filter[org_group_id]" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/org-management + Scenario: List org group policy suggestions returns "OK" response + Given operation "ListOrgGroupPolicySuggestions" enabled + And new "ListOrgGroupPolicySuggestions" request + And request contains "filter[org_group_id]" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/org-management Scenario: List org groups returns "Bad Request" response Given operation "ListOrgGroups" enabled diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 9261678554..bf204e203a 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -5959,6 +5959,12 @@ "type": "idempotent" } }, + "ListOrgGroupPolicySuggestions": { + "tag": "Org Groups", + "undo": { + "type": "safe" + } + }, "ListOrgGroups": { "tag": "Org Groups", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index f3d3783467..69d2ffe59b 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -6374,6 +6374,10 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.UpdateOrgGroupPolicyOverride".into(), test_v2_update_org_group_policy_override, ); + world.function_mappings.insert( + "v2.ListOrgGroupPolicySuggestions".into(), + test_v2_list_org_group_policy_suggestions, + ); world .function_mappings .insert("v2.ListOrgGroups".into(), test_v2_list_org_groups); @@ -49693,6 +49697,36 @@ fn test_v2_update_org_group_policy_override( world.response.code = response.status.as_u16(); } +fn test_v2_list_org_group_policy_suggestions( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_org_groups + .as_ref() + .expect("api instance not found"); + let filter_org_group_id = + serde_json::from_value(_parameters.get("filter[org_group_id]").unwrap().clone()).unwrap(); + let response = + match block_on(api.list_org_group_policy_suggestions_with_http_info(filter_org_group_id)) { + 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_list_org_groups(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances