diff --git a/.apigentools-info b/.apigentools-info index 94393347e..79608751c 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-12-19 07:26:20.419256", - "spec_repo_commit": "5dd2cbe4" + "regenerated": "2024-12-19 17:18:34.019012", + "spec_repo_commit": "061160d5" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-12-19 07:26:20.435562", - "spec_repo_commit": "5dd2cbe4" + "regenerated": "2024-12-19 17:18:34.033878", + "spec_repo_commit": "061160d5" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 3480f9db3..f8565ef66 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -7159,6 +7159,140 @@ components: meta: $ref: '#/components/schemas/CSMAgentsMetadata' type: object + CsmCloudAccountsCoverageAnalysisAttributes: + description: CSM Cloud Accounts Coverage Analysis attributes. + properties: + aws_coverage: + $ref: '#/components/schemas/CsmCoverageAnalysis' + azure_coverage: + $ref: '#/components/schemas/CsmCoverageAnalysis' + gcp_coverage: + $ref: '#/components/schemas/CsmCoverageAnalysis' + org_id: + description: The ID of your organization. + example: 123456 + format: int64 + type: integer + total_coverage: + $ref: '#/components/schemas/CsmCoverageAnalysis' + type: object + CsmCloudAccountsCoverageAnalysisData: + description: CSM Cloud Accounts Coverage Analysis data. + properties: + attributes: + $ref: '#/components/schemas/CsmCloudAccountsCoverageAnalysisAttributes' + id: + description: The ID of your organization. + example: 66b3c6b5-5c9a-457e-b1c3-f247ca23afa3 + type: string + type: + default: get_cloud_accounts_coverage_analysis_response_public_v0 + description: The type of the resource. The value should always be `get_cloud_accounts_coverage_analysis_response_public_v0`. + example: get_cloud_accounts_coverage_analysis_response_public_v0 + type: string + type: object + CsmCloudAccountsCoverageAnalysisResponse: + description: CSM Cloud Accounts Coverage Analysis response. + properties: + data: + $ref: '#/components/schemas/CsmCloudAccountsCoverageAnalysisData' + type: object + CsmCoverageAnalysis: + description: CSM Coverage Analysis. + properties: + configured_resources_count: + description: The number of fully configured resources. + example: 8 + format: int64 + type: integer + coverage: + description: The coverage percentage. + example: 0.8 + format: double + type: number + partially_configured_resources_count: + description: The number of partially configured resources. + example: 0 + format: int64 + type: integer + total_resources_count: + description: The total number of resources. + example: 10 + format: int64 + type: integer + type: object + CsmHostsAndContainersCoverageAnalysisAttributes: + description: CSM Hosts and Containers Coverage Analysis attributes. + properties: + cspm_coverage: + $ref: '#/components/schemas/CsmCoverageAnalysis' + cws_coverage: + $ref: '#/components/schemas/CsmCoverageAnalysis' + org_id: + description: The ID of your organization. + example: 123456 + format: int64 + type: integer + total_coverage: + $ref: '#/components/schemas/CsmCoverageAnalysis' + vm_coverage: + $ref: '#/components/schemas/CsmCoverageAnalysis' + type: object + CsmHostsAndContainersCoverageAnalysisData: + description: CSM Hosts and Containers Coverage Analysis data. + properties: + attributes: + $ref: '#/components/schemas/CsmHostsAndContainersCoverageAnalysisAttributes' + id: + description: The ID of your organization. + example: 66b3c6b5-5c9a-457e-b1c3-f247ca23afa3 + type: string + type: + default: get_hosts_and_containers_coverage_analysis_response_public_v0 + description: The type of the resource. The value should always be `get_hosts_and_containers_coverage_analysis_response_public_v0`. + example: get_hosts_and_containers_coverage_analysis_response_public_v0 + type: string + type: object + CsmHostsAndContainersCoverageAnalysisResponse: + description: CSM Hosts and Containers Coverage Analysis response. + properties: + data: + $ref: '#/components/schemas/CsmHostsAndContainersCoverageAnalysisData' + type: object + CsmServerlessCoverageAnalysisAttributes: + description: CSM Serverless Resources Coverage Analysis attributes. + properties: + cws_coverage: + $ref: '#/components/schemas/CsmCoverageAnalysis' + org_id: + description: The ID of your organization. + example: 123456 + format: int64 + type: integer + total_coverage: + $ref: '#/components/schemas/CsmCoverageAnalysis' + type: object + CsmServerlessCoverageAnalysisData: + description: CSM Serverless Resources Coverage Analysis data. + properties: + attributes: + $ref: '#/components/schemas/CsmServerlessCoverageAnalysisAttributes' + id: + description: The ID of your organization. + example: 66b3c6b5-5c9a-457e-b1c3-f247ca23afa3 + type: string + type: + default: get_serverless_coverage_analysis_response_public_v0 + description: The type of the resource. The value should always be `get_serverless_coverage_analysis_response_public_v0`. + example: get_serverless_coverage_analysis_response_public_v0 + type: string + type: object + CsmServerlessCoverageAnalysisResponse: + description: CSM Serverless Resources Coverage Analysis response. + properties: + data: + $ref: '#/components/schemas/CsmServerlessCoverageAnalysisData' + type: object CustomConnection: description: The definition of `CustomConnection` object. properties: @@ -32844,6 +32978,72 @@ paths: summary: Get all CSM Agents tags: - CSM Agents + /api/v2/csm/onboarding/coverage_analysis/cloud_accounts: + get: + description: 'Get the CSM Coverage Analysis of your Cloud Accounts. + + This is calculated based on the number of your Cloud Accounts that are + + scanned for security issues.' + operationId: GetCSMCloudAccountsCoverageAnalysis + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/CsmCloudAccountsCoverageAnalysisResponse' + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get the CSM Cloud Accounts Coverage Analysis + tags: + - CSM Coverage Analysis + /api/v2/csm/onboarding/coverage_analysis/hosts_and_containers: + get: + description: 'Get the CSM Coverage Analysis of your Hosts and Containers. + + This is calculated based on the number of agents running on your Hosts + + and Containers with CSM feature(s) enabled.' + operationId: GetCSMHostsAndContainersCoverageAnalysis + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/CsmHostsAndContainersCoverageAnalysisResponse' + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get the CSM Hosts and Containers Coverage Analysis + tags: + - CSM Coverage Analysis + /api/v2/csm/onboarding/coverage_analysis/serverless: + get: + description: 'Get the CSM Coverage Analysis of your Serverless Resources. + + This is calculated based on the number of agents running on your Serverless + + Resources with CSM feature(s) enabled.' + operationId: GetCSMServerlessCoverageAnalysis + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/CsmServerlessCoverageAnalysisResponse' + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get the CSM Serverless Coverage Analysis + tags: + - CSM Coverage Analysis /api/v2/csm/onboarding/serverless/agents: get: description: Get the list of all CSM Serverless Agents running on your hosts @@ -46613,6 +46813,15 @@ tags: Go to https://docs.datadoghq.com/security/cloud_security_management to learn more' name: CSM Agents +- description: 'Datadog Cloud Security Management (CSM) delivers real-time threat + detection + + and continuous configuration audits across your entire cloud infrastructure, + + all in a unified view for seamless collaboration and faster remediation. + + Go to https://docs.datadoghq.com/security/cloud_security_management to learn more.' + name: CSM Coverage Analysis - description: Cloud Security Management Threats (CSM Threats) monitors file, network, and process activity across your environment to detect real-time threats to your infrastructure. See [Cloud Security Management Threats](https://docs.datadoghq.com/security/threats/) diff --git a/examples/v2_csm-coverage-analysis_GetCSMCloudAccountsCoverageAnalysis.rs b/examples/v2_csm-coverage-analysis_GetCSMCloudAccountsCoverageAnalysis.rs new file mode 100644 index 000000000..dc4532365 --- /dev/null +++ b/examples/v2_csm-coverage-analysis_GetCSMCloudAccountsCoverageAnalysis.rs @@ -0,0 +1,15 @@ +// Get the CSM Cloud Accounts Coverage Analysis returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_csm_coverage_analysis::CSMCoverageAnalysisAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = CSMCoverageAnalysisAPI::with_config(configuration); + let resp = api.get_csm_cloud_accounts_coverage_analysis().await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_csm-coverage-analysis_GetCSMHostsAndContainersCoverageAnalysis.rs b/examples/v2_csm-coverage-analysis_GetCSMHostsAndContainersCoverageAnalysis.rs new file mode 100644 index 000000000..ef8e0d334 --- /dev/null +++ b/examples/v2_csm-coverage-analysis_GetCSMHostsAndContainersCoverageAnalysis.rs @@ -0,0 +1,15 @@ +// Get the CSM Hosts and Containers Coverage Analysis returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_csm_coverage_analysis::CSMCoverageAnalysisAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = CSMCoverageAnalysisAPI::with_config(configuration); + let resp = api.get_csm_hosts_and_containers_coverage_analysis().await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_csm-coverage-analysis_GetCSMServerlessCoverageAnalysis.rs b/examples/v2_csm-coverage-analysis_GetCSMServerlessCoverageAnalysis.rs new file mode 100644 index 000000000..b218c930f --- /dev/null +++ b/examples/v2_csm-coverage-analysis_GetCSMServerlessCoverageAnalysis.rs @@ -0,0 +1,15 @@ +// Get the CSM Serverless Coverage Analysis returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_csm_coverage_analysis::CSMCoverageAnalysisAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = CSMCoverageAnalysisAPI::with_config(configuration); + let resp = api.get_csm_serverless_coverage_analysis().await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadogV2/api/api_csm_coverage_analysis.rs b/src/datadogV2/api/api_csm_coverage_analysis.rs new file mode 100644 index 000000000..249cd2129 --- /dev/null +++ b/src/datadogV2/api/api_csm_coverage_analysis.rs @@ -0,0 +1,443 @@ +// 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 crate::datadog; +use reqwest::header::{HeaderMap, HeaderValue}; +use serde::{Deserialize, Serialize}; + +/// GetCSMCloudAccountsCoverageAnalysisError is a struct for typed errors of method [`CSMCoverageAnalysisAPI::get_csm_cloud_accounts_coverage_analysis`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetCSMCloudAccountsCoverageAnalysisError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GetCSMHostsAndContainersCoverageAnalysisError is a struct for typed errors of method [`CSMCoverageAnalysisAPI::get_csm_hosts_and_containers_coverage_analysis`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetCSMHostsAndContainersCoverageAnalysisError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GetCSMServerlessCoverageAnalysisError is a struct for typed errors of method [`CSMCoverageAnalysisAPI::get_csm_serverless_coverage_analysis`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetCSMServerlessCoverageAnalysisError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// Datadog Cloud Security Management (CSM) delivers real-time threat detection +/// and continuous configuration audits across your entire cloud infrastructure, +/// all in a unified view for seamless collaboration and faster remediation. +/// Go to to learn more. +#[derive(Debug, Clone)] +pub struct CSMCoverageAnalysisAPI { + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, +} + +impl Default for CSMCoverageAnalysisAPI { + fn default() -> Self { + Self::with_config(datadog::Configuration::default()) + } +} + +impl CSMCoverageAnalysisAPI { + pub fn new() -> Self { + Self::default() + } + pub fn with_config(config: datadog::Configuration) -> Self { + let mut reqwest_client_builder = reqwest::Client::builder(); + + if let Some(proxy_url) = &config.proxy_url { + let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL"); + reqwest_client_builder = reqwest_client_builder.proxy(proxy); + } + + let mut middleware_client_builder = + reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap()); + + if config.enable_retry { + struct RetryableStatus; + impl reqwest_retry::RetryableStrategy for RetryableStatus { + fn handle( + &self, + res: &Result, + ) -> Option { + match res { + Ok(success) => reqwest_retry::default_on_request_success(success), + Err(_) => None, + } + } + } + let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder() + .build_with_max_retries(config.max_retries); + + let retry_middleware = + reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy( + backoff_policy, + RetryableStatus, + ); + + middleware_client_builder = middleware_client_builder.with(retry_middleware); + } + + let client = middleware_client_builder.build(); + + Self { config, client } + } + + pub fn with_client_and_config( + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, + ) -> Self { + Self { config, client } + } + + /// Get the CSM Coverage Analysis of your Cloud Accounts. + /// This is calculated based on the number of your Cloud Accounts that are + /// scanned for security issues. + pub async fn get_csm_cloud_accounts_coverage_analysis( + &self, + ) -> Result< + crate::datadogV2::model::CsmCloudAccountsCoverageAnalysisResponse, + datadog::Error, + > { + match self + .get_csm_cloud_accounts_coverage_analysis_with_http_info() + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get the CSM Coverage Analysis of your Cloud Accounts. + /// This is calculated based on the number of your Cloud Accounts that are + /// scanned for security issues. + pub async fn get_csm_cloud_accounts_coverage_analysis_with_http_info( + &self, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_csm_cloud_accounts_coverage_analysis"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/csm/onboarding/coverage_analysis/cloud_accounts", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::< + crate::datadogV2::model::CsmCloudAccountsCoverageAnalysisResponse, + >(&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 the CSM Coverage Analysis of your Hosts and Containers. + /// This is calculated based on the number of agents running on your Hosts + /// and Containers with CSM feature(s) enabled. + pub async fn get_csm_hosts_and_containers_coverage_analysis( + &self, + ) -> Result< + crate::datadogV2::model::CsmHostsAndContainersCoverageAnalysisResponse, + datadog::Error, + > { + match self + .get_csm_hosts_and_containers_coverage_analysis_with_http_info() + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get the CSM Coverage Analysis of your Hosts and Containers. + /// This is calculated based on the number of agents running on your Hosts + /// and Containers with CSM feature(s) enabled. + pub async fn get_csm_hosts_and_containers_coverage_analysis_with_http_info( + &self, + ) -> Result< + datadog::ResponseContent< + crate::datadogV2::model::CsmHostsAndContainersCoverageAnalysisResponse, + >, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_csm_hosts_and_containers_coverage_analysis"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/csm/onboarding/coverage_analysis/hosts_and_containers", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::< + crate::datadogV2::model::CsmHostsAndContainersCoverageAnalysisResponse, + >(&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 the CSM Coverage Analysis of your Serverless Resources. + /// This is calculated based on the number of agents running on your Serverless + /// Resources with CSM feature(s) enabled. + pub async fn get_csm_serverless_coverage_analysis( + &self, + ) -> Result< + crate::datadogV2::model::CsmServerlessCoverageAnalysisResponse, + datadog::Error, + > { + match self + .get_csm_serverless_coverage_analysis_with_http_info() + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get the CSM Coverage Analysis of your Serverless Resources. + /// This is calculated based on the number of agents running on your Serverless + /// Resources with CSM feature(s) enabled. + pub async fn get_csm_serverless_coverage_analysis_with_http_info( + &self, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_csm_serverless_coverage_analysis"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/csm/onboarding/coverage_analysis/serverless", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::< + crate::datadogV2::model::CsmServerlessCoverageAnalysisResponse, + >(&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)) + } + } +} diff --git a/src/datadogV2/api/mod.rs b/src/datadogV2/api/mod.rs index f69132c08..f6752767e 100644 --- a/src/datadogV2/api/mod.rs +++ b/src/datadogV2/api/mod.rs @@ -19,6 +19,7 @@ pub mod api_confluent_cloud; pub mod api_container_images; pub mod api_containers; pub mod api_csm_agents; +pub mod api_csm_coverage_analysis; pub mod api_csm_threats; pub mod api_dashboard_lists; pub mod api_data_deletion; diff --git a/src/datadogV2/mod.rs b/src/datadogV2/mod.rs index a8ca64c41..83a6b8937 100644 --- a/src/datadogV2/mod.rs +++ b/src/datadogV2/mod.rs @@ -20,6 +20,7 @@ pub use self::api::api_confluent_cloud; pub use self::api::api_container_images; pub use self::api::api_containers; pub use self::api::api_csm_agents; +pub use self::api::api_csm_coverage_analysis; pub use self::api::api_csm_threats; pub use self::api::api_dashboard_lists; pub use self::api::api_data_deletion; diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 909d05007..ec4d2ccd4 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -1048,6 +1048,26 @@ pub mod model_csm_agents_type; pub use self::model_csm_agents_type::CSMAgentsType; pub mod model_csm_agents_metadata; pub use self::model_csm_agents_metadata::CSMAgentsMetadata; +pub mod model_csm_cloud_accounts_coverage_analysis_response; +pub use self::model_csm_cloud_accounts_coverage_analysis_response::CsmCloudAccountsCoverageAnalysisResponse; +pub mod model_csm_cloud_accounts_coverage_analysis_data; +pub use self::model_csm_cloud_accounts_coverage_analysis_data::CsmCloudAccountsCoverageAnalysisData; +pub mod model_csm_cloud_accounts_coverage_analysis_attributes; +pub use self::model_csm_cloud_accounts_coverage_analysis_attributes::CsmCloudAccountsCoverageAnalysisAttributes; +pub mod model_csm_coverage_analysis; +pub use self::model_csm_coverage_analysis::CsmCoverageAnalysis; +pub mod model_csm_hosts_and_containers_coverage_analysis_response; +pub use self::model_csm_hosts_and_containers_coverage_analysis_response::CsmHostsAndContainersCoverageAnalysisResponse; +pub mod model_csm_hosts_and_containers_coverage_analysis_data; +pub use self::model_csm_hosts_and_containers_coverage_analysis_data::CsmHostsAndContainersCoverageAnalysisData; +pub mod model_csm_hosts_and_containers_coverage_analysis_attributes; +pub use self::model_csm_hosts_and_containers_coverage_analysis_attributes::CsmHostsAndContainersCoverageAnalysisAttributes; +pub mod model_csm_serverless_coverage_analysis_response; +pub use self::model_csm_serverless_coverage_analysis_response::CsmServerlessCoverageAnalysisResponse; +pub mod model_csm_serverless_coverage_analysis_data; +pub use self::model_csm_serverless_coverage_analysis_data::CsmServerlessCoverageAnalysisData; +pub mod model_csm_serverless_coverage_analysis_attributes; +pub use self::model_csm_serverless_coverage_analysis_attributes::CsmServerlessCoverageAnalysisAttributes; pub mod model_application_key_create_request; pub use self::model_application_key_create_request::ApplicationKeyCreateRequest; pub mod model_application_key_create_data; diff --git a/src/datadogV2/model/model_csm_cloud_accounts_coverage_analysis_attributes.rs b/src/datadogV2/model/model_csm_cloud_accounts_coverage_analysis_attributes.rs new file mode 100644 index 000000000..e673ef87a --- /dev/null +++ b/src/datadogV2/model/model_csm_cloud_accounts_coverage_analysis_attributes.rs @@ -0,0 +1,177 @@ +// 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}; + +/// CSM Cloud Accounts Coverage Analysis attributes. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CsmCloudAccountsCoverageAnalysisAttributes { + /// CSM Coverage Analysis. + #[serde(rename = "aws_coverage")] + pub aws_coverage: Option, + /// CSM Coverage Analysis. + #[serde(rename = "azure_coverage")] + pub azure_coverage: Option, + /// CSM Coverage Analysis. + #[serde(rename = "gcp_coverage")] + pub gcp_coverage: Option, + /// The ID of your organization. + #[serde(rename = "org_id")] + pub org_id: Option, + /// CSM Coverage Analysis. + #[serde(rename = "total_coverage")] + pub total_coverage: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CsmCloudAccountsCoverageAnalysisAttributes { + pub fn new() -> CsmCloudAccountsCoverageAnalysisAttributes { + CsmCloudAccountsCoverageAnalysisAttributes { + aws_coverage: None, + azure_coverage: None, + gcp_coverage: None, + org_id: None, + total_coverage: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn aws_coverage(mut self, value: crate::datadogV2::model::CsmCoverageAnalysis) -> Self { + self.aws_coverage = Some(value); + self + } + + pub fn azure_coverage(mut self, value: crate::datadogV2::model::CsmCoverageAnalysis) -> Self { + self.azure_coverage = Some(value); + self + } + + pub fn gcp_coverage(mut self, value: crate::datadogV2::model::CsmCoverageAnalysis) -> Self { + self.gcp_coverage = Some(value); + self + } + + pub fn org_id(mut self, value: i64) -> Self { + self.org_id = Some(value); + self + } + + pub fn total_coverage(mut self, value: crate::datadogV2::model::CsmCoverageAnalysis) -> Self { + self.total_coverage = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CsmCloudAccountsCoverageAnalysisAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CsmCloudAccountsCoverageAnalysisAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CsmCloudAccountsCoverageAnalysisAttributesVisitor; + impl<'a> Visitor<'a> for CsmCloudAccountsCoverageAnalysisAttributesVisitor { + type Value = CsmCloudAccountsCoverageAnalysisAttributes; + + 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 aws_coverage: Option = None; + let mut azure_coverage: Option = None; + let mut gcp_coverage: Option = None; + let mut org_id: Option = None; + let mut total_coverage: 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() { + "aws_coverage" => { + if v.is_null() { + continue; + } + aws_coverage = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "azure_coverage" => { + if v.is_null() { + continue; + } + azure_coverage = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "gcp_coverage" => { + if v.is_null() { + continue; + } + gcp_coverage = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "org_id" => { + if v.is_null() { + continue; + } + org_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "total_coverage" => { + if v.is_null() { + continue; + } + total_coverage = + 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 = CsmCloudAccountsCoverageAnalysisAttributes { + aws_coverage, + azure_coverage, + gcp_coverage, + org_id, + total_coverage, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CsmCloudAccountsCoverageAnalysisAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_csm_cloud_accounts_coverage_analysis_data.rs b/src/datadogV2/model/model_csm_cloud_accounts_coverage_analysis_data.rs new file mode 100644 index 000000000..093668ed6 --- /dev/null +++ b/src/datadogV2/model/model_csm_cloud_accounts_coverage_analysis_data.rs @@ -0,0 +1,144 @@ +// 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}; + +/// CSM Cloud Accounts Coverage Analysis data. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CsmCloudAccountsCoverageAnalysisData { + /// CSM Cloud Accounts Coverage Analysis attributes. + #[serde(rename = "attributes")] + pub attributes: Option, + /// The ID of your organization. + #[serde(rename = "id")] + pub id: Option, + /// The type of the resource. The value should always be `get_cloud_accounts_coverage_analysis_response_public_v0`. + #[serde(rename = "type")] + pub type_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CsmCloudAccountsCoverageAnalysisData { + pub fn new() -> CsmCloudAccountsCoverageAnalysisData { + CsmCloudAccountsCoverageAnalysisData { + attributes: None, + id: None, + type_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::CsmCloudAccountsCoverageAnalysisAttributes, + ) -> 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: String) -> Self { + self.type_ = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CsmCloudAccountsCoverageAnalysisData { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CsmCloudAccountsCoverageAnalysisData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CsmCloudAccountsCoverageAnalysisDataVisitor; + impl<'a> Visitor<'a> for CsmCloudAccountsCoverageAnalysisDataVisitor { + type Value = CsmCloudAccountsCoverageAnalysisData; + + 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::CsmCloudAccountsCoverageAnalysisAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "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 Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = CsmCloudAccountsCoverageAnalysisData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CsmCloudAccountsCoverageAnalysisDataVisitor) + } +} diff --git a/src/datadogV2/model/model_csm_cloud_accounts_coverage_analysis_response.rs b/src/datadogV2/model/model_csm_cloud_accounts_coverage_analysis_response.rs new file mode 100644 index 000000000..dd30fb663 --- /dev/null +++ b/src/datadogV2/model/model_csm_cloud_accounts_coverage_analysis_response.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}; + +/// CSM Cloud Accounts Coverage Analysis response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CsmCloudAccountsCoverageAnalysisResponse { + /// CSM Cloud Accounts Coverage Analysis data. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CsmCloudAccountsCoverageAnalysisResponse { + pub fn new() -> CsmCloudAccountsCoverageAnalysisResponse { + CsmCloudAccountsCoverageAnalysisResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: crate::datadogV2::model::CsmCloudAccountsCoverageAnalysisData, + ) -> 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 CsmCloudAccountsCoverageAnalysisResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CsmCloudAccountsCoverageAnalysisResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CsmCloudAccountsCoverageAnalysisResponseVisitor; + impl<'a> Visitor<'a> for CsmCloudAccountsCoverageAnalysisResponseVisitor { + type Value = CsmCloudAccountsCoverageAnalysisResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option< + crate::datadogV2::model::CsmCloudAccountsCoverageAnalysisData, + > = 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 = CsmCloudAccountsCoverageAnalysisResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CsmCloudAccountsCoverageAnalysisResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_csm_coverage_analysis.rs b/src/datadogV2/model/model_csm_coverage_analysis.rs new file mode 100644 index 000000000..9716a2de6 --- /dev/null +++ b/src/datadogV2/model/model_csm_coverage_analysis.rs @@ -0,0 +1,159 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// CSM Coverage Analysis. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CsmCoverageAnalysis { + /// The number of fully configured resources. + #[serde(rename = "configured_resources_count")] + pub configured_resources_count: Option, + /// The coverage percentage. + #[serde(rename = "coverage")] + pub coverage: Option, + /// The number of partially configured resources. + #[serde(rename = "partially_configured_resources_count")] + pub partially_configured_resources_count: Option, + /// The total number of resources. + #[serde(rename = "total_resources_count")] + pub total_resources_count: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CsmCoverageAnalysis { + pub fn new() -> CsmCoverageAnalysis { + CsmCoverageAnalysis { + configured_resources_count: None, + coverage: None, + partially_configured_resources_count: None, + total_resources_count: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn configured_resources_count(mut self, value: i64) -> Self { + self.configured_resources_count = Some(value); + self + } + + pub fn coverage(mut self, value: f64) -> Self { + self.coverage = Some(value); + self + } + + pub fn partially_configured_resources_count(mut self, value: i64) -> Self { + self.partially_configured_resources_count = Some(value); + self + } + + pub fn total_resources_count(mut self, value: i64) -> Self { + self.total_resources_count = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CsmCoverageAnalysis { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CsmCoverageAnalysis { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CsmCoverageAnalysisVisitor; + impl<'a> Visitor<'a> for CsmCoverageAnalysisVisitor { + type Value = CsmCoverageAnalysis; + + 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 configured_resources_count: Option = None; + let mut coverage: Option = None; + let mut partially_configured_resources_count: Option = None; + let mut total_resources_count: 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() { + "configured_resources_count" => { + if v.is_null() { + continue; + } + configured_resources_count = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "coverage" => { + if v.is_null() { + continue; + } + coverage = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "partially_configured_resources_count" => { + if v.is_null() { + continue; + } + partially_configured_resources_count = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "total_resources_count" => { + if v.is_null() { + continue; + } + total_resources_count = + 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 = CsmCoverageAnalysis { + configured_resources_count, + coverage, + partially_configured_resources_count, + total_resources_count, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CsmCoverageAnalysisVisitor) + } +} diff --git a/src/datadogV2/model/model_csm_hosts_and_containers_coverage_analysis_attributes.rs b/src/datadogV2/model/model_csm_hosts_and_containers_coverage_analysis_attributes.rs new file mode 100644 index 000000000..3fcfcd322 --- /dev/null +++ b/src/datadogV2/model/model_csm_hosts_and_containers_coverage_analysis_attributes.rs @@ -0,0 +1,177 @@ +// 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}; + +/// CSM Hosts and Containers Coverage Analysis attributes. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CsmHostsAndContainersCoverageAnalysisAttributes { + /// CSM Coverage Analysis. + #[serde(rename = "cspm_coverage")] + pub cspm_coverage: Option, + /// CSM Coverage Analysis. + #[serde(rename = "cws_coverage")] + pub cws_coverage: Option, + /// The ID of your organization. + #[serde(rename = "org_id")] + pub org_id: Option, + /// CSM Coverage Analysis. + #[serde(rename = "total_coverage")] + pub total_coverage: Option, + /// CSM Coverage Analysis. + #[serde(rename = "vm_coverage")] + pub vm_coverage: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CsmHostsAndContainersCoverageAnalysisAttributes { + pub fn new() -> CsmHostsAndContainersCoverageAnalysisAttributes { + CsmHostsAndContainersCoverageAnalysisAttributes { + cspm_coverage: None, + cws_coverage: None, + org_id: None, + total_coverage: None, + vm_coverage: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn cspm_coverage(mut self, value: crate::datadogV2::model::CsmCoverageAnalysis) -> Self { + self.cspm_coverage = Some(value); + self + } + + pub fn cws_coverage(mut self, value: crate::datadogV2::model::CsmCoverageAnalysis) -> Self { + self.cws_coverage = Some(value); + self + } + + pub fn org_id(mut self, value: i64) -> Self { + self.org_id = Some(value); + self + } + + pub fn total_coverage(mut self, value: crate::datadogV2::model::CsmCoverageAnalysis) -> Self { + self.total_coverage = Some(value); + self + } + + pub fn vm_coverage(mut self, value: crate::datadogV2::model::CsmCoverageAnalysis) -> Self { + self.vm_coverage = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CsmHostsAndContainersCoverageAnalysisAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CsmHostsAndContainersCoverageAnalysisAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CsmHostsAndContainersCoverageAnalysisAttributesVisitor; + impl<'a> Visitor<'a> for CsmHostsAndContainersCoverageAnalysisAttributesVisitor { + type Value = CsmHostsAndContainersCoverageAnalysisAttributes; + + 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 cspm_coverage: Option = None; + let mut cws_coverage: Option = None; + let mut org_id: Option = None; + let mut total_coverage: Option = None; + let mut vm_coverage: 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() { + "cspm_coverage" => { + if v.is_null() { + continue; + } + cspm_coverage = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "cws_coverage" => { + if v.is_null() { + continue; + } + cws_coverage = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "org_id" => { + if v.is_null() { + continue; + } + org_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "total_coverage" => { + if v.is_null() { + continue; + } + total_coverage = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "vm_coverage" => { + if v.is_null() { + continue; + } + vm_coverage = + 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 = CsmHostsAndContainersCoverageAnalysisAttributes { + cspm_coverage, + cws_coverage, + org_id, + total_coverage, + vm_coverage, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CsmHostsAndContainersCoverageAnalysisAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_csm_hosts_and_containers_coverage_analysis_data.rs b/src/datadogV2/model/model_csm_hosts_and_containers_coverage_analysis_data.rs new file mode 100644 index 000000000..e9a729982 --- /dev/null +++ b/src/datadogV2/model/model_csm_hosts_and_containers_coverage_analysis_data.rs @@ -0,0 +1,145 @@ +// 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}; + +/// CSM Hosts and Containers Coverage Analysis data. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CsmHostsAndContainersCoverageAnalysisData { + /// CSM Hosts and Containers Coverage Analysis attributes. + #[serde(rename = "attributes")] + pub attributes: + Option, + /// The ID of your organization. + #[serde(rename = "id")] + pub id: Option, + /// The type of the resource. The value should always be `get_hosts_and_containers_coverage_analysis_response_public_v0`. + #[serde(rename = "type")] + pub type_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CsmHostsAndContainersCoverageAnalysisData { + pub fn new() -> CsmHostsAndContainersCoverageAnalysisData { + CsmHostsAndContainersCoverageAnalysisData { + attributes: None, + id: None, + type_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::CsmHostsAndContainersCoverageAnalysisAttributes, + ) -> 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: String) -> Self { + self.type_ = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CsmHostsAndContainersCoverageAnalysisData { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CsmHostsAndContainersCoverageAnalysisData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CsmHostsAndContainersCoverageAnalysisDataVisitor; + impl<'a> Visitor<'a> for CsmHostsAndContainersCoverageAnalysisDataVisitor { + type Value = CsmHostsAndContainersCoverageAnalysisData; + + 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::CsmHostsAndContainersCoverageAnalysisAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "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 Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = CsmHostsAndContainersCoverageAnalysisData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CsmHostsAndContainersCoverageAnalysisDataVisitor) + } +} diff --git a/src/datadogV2/model/model_csm_hosts_and_containers_coverage_analysis_response.rs b/src/datadogV2/model/model_csm_hosts_and_containers_coverage_analysis_response.rs new file mode 100644 index 000000000..4be5fe159 --- /dev/null +++ b/src/datadogV2/model/model_csm_hosts_and_containers_coverage_analysis_response.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}; + +/// CSM Hosts and Containers Coverage Analysis response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CsmHostsAndContainersCoverageAnalysisResponse { + /// CSM Hosts and Containers Coverage Analysis data. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CsmHostsAndContainersCoverageAnalysisResponse { + pub fn new() -> CsmHostsAndContainersCoverageAnalysisResponse { + CsmHostsAndContainersCoverageAnalysisResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: crate::datadogV2::model::CsmHostsAndContainersCoverageAnalysisData, + ) -> 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 CsmHostsAndContainersCoverageAnalysisResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CsmHostsAndContainersCoverageAnalysisResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CsmHostsAndContainersCoverageAnalysisResponseVisitor; + impl<'a> Visitor<'a> for CsmHostsAndContainersCoverageAnalysisResponseVisitor { + type Value = CsmHostsAndContainersCoverageAnalysisResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option< + crate::datadogV2::model::CsmHostsAndContainersCoverageAnalysisData, + > = 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 = CsmHostsAndContainersCoverageAnalysisResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CsmHostsAndContainersCoverageAnalysisResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_csm_serverless_coverage_analysis_attributes.rs b/src/datadogV2/model/model_csm_serverless_coverage_analysis_attributes.rs new file mode 100644 index 000000000..927fc59e8 --- /dev/null +++ b/src/datadogV2/model/model_csm_serverless_coverage_analysis_attributes.rs @@ -0,0 +1,141 @@ +// 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}; + +/// CSM Serverless Resources Coverage Analysis attributes. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CsmServerlessCoverageAnalysisAttributes { + /// CSM Coverage Analysis. + #[serde(rename = "cws_coverage")] + pub cws_coverage: Option, + /// The ID of your organization. + #[serde(rename = "org_id")] + pub org_id: Option, + /// CSM Coverage Analysis. + #[serde(rename = "total_coverage")] + pub total_coverage: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CsmServerlessCoverageAnalysisAttributes { + pub fn new() -> CsmServerlessCoverageAnalysisAttributes { + CsmServerlessCoverageAnalysisAttributes { + cws_coverage: None, + org_id: None, + total_coverage: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn cws_coverage(mut self, value: crate::datadogV2::model::CsmCoverageAnalysis) -> Self { + self.cws_coverage = Some(value); + self + } + + pub fn org_id(mut self, value: i64) -> Self { + self.org_id = Some(value); + self + } + + pub fn total_coverage(mut self, value: crate::datadogV2::model::CsmCoverageAnalysis) -> Self { + self.total_coverage = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CsmServerlessCoverageAnalysisAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CsmServerlessCoverageAnalysisAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CsmServerlessCoverageAnalysisAttributesVisitor; + impl<'a> Visitor<'a> for CsmServerlessCoverageAnalysisAttributesVisitor { + type Value = CsmServerlessCoverageAnalysisAttributes; + + 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 cws_coverage: Option = None; + let mut org_id: Option = None; + let mut total_coverage: 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() { + "cws_coverage" => { + if v.is_null() { + continue; + } + cws_coverage = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "org_id" => { + if v.is_null() { + continue; + } + org_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "total_coverage" => { + if v.is_null() { + continue; + } + total_coverage = + 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 = CsmServerlessCoverageAnalysisAttributes { + cws_coverage, + org_id, + total_coverage, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CsmServerlessCoverageAnalysisAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_csm_serverless_coverage_analysis_data.rs b/src/datadogV2/model/model_csm_serverless_coverage_analysis_data.rs new file mode 100644 index 000000000..747e95606 --- /dev/null +++ b/src/datadogV2/model/model_csm_serverless_coverage_analysis_data.rs @@ -0,0 +1,144 @@ +// 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}; + +/// CSM Serverless Resources Coverage Analysis data. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CsmServerlessCoverageAnalysisData { + /// CSM Serverless Resources Coverage Analysis attributes. + #[serde(rename = "attributes")] + pub attributes: Option, + /// The ID of your organization. + #[serde(rename = "id")] + pub id: Option, + /// The type of the resource. The value should always be `get_serverless_coverage_analysis_response_public_v0`. + #[serde(rename = "type")] + pub type_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CsmServerlessCoverageAnalysisData { + pub fn new() -> CsmServerlessCoverageAnalysisData { + CsmServerlessCoverageAnalysisData { + attributes: None, + id: None, + type_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::CsmServerlessCoverageAnalysisAttributes, + ) -> 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: String) -> Self { + self.type_ = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CsmServerlessCoverageAnalysisData { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CsmServerlessCoverageAnalysisData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CsmServerlessCoverageAnalysisDataVisitor; + impl<'a> Visitor<'a> for CsmServerlessCoverageAnalysisDataVisitor { + type Value = CsmServerlessCoverageAnalysisData; + + 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::CsmServerlessCoverageAnalysisAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "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 Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = CsmServerlessCoverageAnalysisData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CsmServerlessCoverageAnalysisDataVisitor) + } +} diff --git a/src/datadogV2/model/model_csm_serverless_coverage_analysis_response.rs b/src/datadogV2/model/model_csm_serverless_coverage_analysis_response.rs new file mode 100644 index 000000000..e53e336a3 --- /dev/null +++ b/src/datadogV2/model/model_csm_serverless_coverage_analysis_response.rs @@ -0,0 +1,109 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// CSM Serverless Resources Coverage Analysis response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CsmServerlessCoverageAnalysisResponse { + /// CSM Serverless Resources Coverage Analysis data. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CsmServerlessCoverageAnalysisResponse { + pub fn new() -> CsmServerlessCoverageAnalysisResponse { + CsmServerlessCoverageAnalysisResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: crate::datadogV2::model::CsmServerlessCoverageAnalysisData, + ) -> 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 CsmServerlessCoverageAnalysisResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CsmServerlessCoverageAnalysisResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CsmServerlessCoverageAnalysisResponseVisitor; + impl<'a> Visitor<'a> for CsmServerlessCoverageAnalysisResponseVisitor { + type Value = CsmServerlessCoverageAnalysisResponse; + + 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 = CsmServerlessCoverageAnalysisResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CsmServerlessCoverageAnalysisResponseVisitor) + } +} diff --git a/tests/scenarios/features/v2/csm_coverage_analysis.feature b/tests/scenarios/features/v2/csm_coverage_analysis.feature new file mode 100644 index 000000000..8c3689dbf --- /dev/null +++ b/tests/scenarios/features/v2/csm_coverage_analysis.feature @@ -0,0 +1,31 @@ +@endpoint(csm-coverage-analysis) @endpoint(csm-coverage-analysis-v2) +Feature: CSM Coverage Analysis + Datadog Cloud Security Management (CSM) delivers real-time threat + detection and continuous configuration audits across your entire cloud + infrastructure, all in a unified view for seamless collaboration and + faster remediation. Go to + https://docs.datadoghq.com/security/cloud_security_management to learn + more. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "CSMCoverageAnalysis" API + + @team:DataDog/k9-cloud-security-platform + Scenario: Get the CSM Cloud Accounts Coverage Analysis returns "OK" response + Given new "GetCSMCloudAccountsCoverageAnalysis" request + When the request is sent + Then the response status is 200 OK + + @team:DataDog/k9-cloud-security-platform + Scenario: Get the CSM Hosts and Containers Coverage Analysis returns "OK" response + Given new "GetCSMHostsAndContainersCoverageAnalysis" request + When the request is sent + Then the response status is 200 OK + + @team:DataDog/k9-cloud-security-platform + Scenario: Get the CSM Serverless Coverage Analysis returns "OK" response + Given new "GetCSMServerlessCoverageAnalysis" request + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index b1ed2db69..de5bae742 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -535,6 +535,24 @@ "type": "safe" } }, + "GetCSMCloudAccountsCoverageAnalysis": { + "tag": "CSM Coverage Analysis", + "undo": { + "type": "safe" + } + }, + "GetCSMHostsAndContainersCoverageAnalysis": { + "tag": "CSM Coverage Analysis", + "undo": { + "type": "safe" + } + }, + "GetCSMServerlessCoverageAnalysis": { + "tag": "CSM Coverage Analysis", + "undo": { + "type": "safe" + } + }, "ListAllCSMServerlessAgents": { "tag": "CSM Agents", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 43ad48ae7..956447a75 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -70,6 +70,8 @@ pub struct ApiInstances { Option, pub v2_api_usage_metering: Option, pub v2_api_csm_agents: Option, + pub v2_api_csm_coverage_analysis: + Option, pub v2_api_dashboard_lists: Option, pub v2_api_data_deletion: Option, pub v2_api_domain_allowlist: Option, @@ -568,6 +570,12 @@ pub fn initialize_api_instance(world: &mut DatadogWorld, api: String) { ), ); } + "CSMCoverageAnalysis" => { + world.api_instances.v2_api_csm_coverage_analysis = Some(datadogV2::api_csm_coverage_analysis::CSMCoverageAnalysisAPI::with_client_and_config( + world.config.clone(), + world.http_client.as_ref().unwrap().clone() + )); + } "DataDeletion" => { world.api_instances.v2_api_data_deletion = Some( datadogV2::api_data_deletion::DataDeletionAPI::with_client_and_config( @@ -2005,6 +2013,18 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.ListAllCSMServerlessAgents".into(), test_v2_list_all_csm_serverless_agents, ); + world.function_mappings.insert( + "v2.GetCSMCloudAccountsCoverageAnalysis".into(), + test_v2_get_csm_cloud_accounts_coverage_analysis, + ); + world.function_mappings.insert( + "v2.GetCSMHostsAndContainersCoverageAnalysis".into(), + test_v2_get_csm_hosts_and_containers_coverage_analysis, + ); + world.function_mappings.insert( + "v2.GetCSMServerlessCoverageAnalysis".into(), + test_v2_get_csm_serverless_coverage_analysis, + ); world.function_mappings.insert( "v2.DeleteDashboardListItems".into(), test_v2_delete_dashboard_list_items, @@ -14030,6 +14050,88 @@ fn test_v2_list_all_csm_serverless_agents( world.response.code = response.status.as_u16(); } +fn test_v2_get_csm_cloud_accounts_coverage_analysis( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_csm_coverage_analysis + .as_ref() + .expect("api instance not found"); + let response = match block_on(api.get_csm_cloud_accounts_coverage_analysis_with_http_info()) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_get_csm_hosts_and_containers_coverage_analysis( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_csm_coverage_analysis + .as_ref() + .expect("api instance not found"); + let response = + match block_on(api.get_csm_hosts_and_containers_coverage_analysis_with_http_info()) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_get_csm_serverless_coverage_analysis( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_csm_coverage_analysis + .as_ref() + .expect("api instance not found"); + let response = match block_on(api.get_csm_serverless_coverage_analysis_with_http_info()) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + fn test_v2_delete_dashboard_list_items( world: &mut DatadogWorld, _parameters: &HashMap,