From 7ceefba4359fb9c8c69c0e7e8ab1fb2f4ca56ef1 Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 19:48:32 +0000 Subject: [PATCH] Add CSM Agents Read Endpoint (#421) Co-authored-by: ci.datadog-api-spec --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 244 ++++++++++ examples/v2_csm-agents_ListAllCSMAgents.rs | 18 + ...2_csm-agents_ListAllCSMServerlessAgents.rs | 18 + src/datadogV2/api/api_csm_agents.rs | 426 ++++++++++++++++++ src/datadogV2/api/mod.rs | 1 + src/datadogV2/mod.rs | 1 + src/datadogV2/model/mod.rs | 12 + src/datadogV2/model/model_csm_agent_data.rs | 149 ++++++ .../model/model_csm_agents_attributes.rs | 393 ++++++++++++++++ .../model/model_csm_agents_metadata.rs | 140 ++++++ .../model/model_csm_agents_response.rs | 122 +++++ src/datadogV2/model/model_csm_agents_type.rs | 48 ++ src/datadogV2/model/model_order_direction.rs | 51 +++ ...-all-CSM-Agents-returns-OK-response.frozen | 1 + ...et-all-CSM-Agents-returns-OK-response.json | 33 ++ ...rverless-Agents-returns-OK-response.frozen | 1 + ...Serverless-Agents-returns-OK-response.json | 33 ++ .../features/v2/container_images.feature | 8 +- .../scenarios/features/v2/containers.feature | 8 +- .../scenarios/features/v2/csm_agents.feature | 25 + tests/scenarios/features/v2/undo.json | 12 + tests/scenarios/function_mappings.rs | 101 +++++ 23 files changed, 1841 insertions(+), 12 deletions(-) create mode 100644 examples/v2_csm-agents_ListAllCSMAgents.rs create mode 100644 examples/v2_csm-agents_ListAllCSMServerlessAgents.rs create mode 100644 src/datadogV2/api/api_csm_agents.rs create mode 100644 src/datadogV2/model/model_csm_agent_data.rs create mode 100644 src/datadogV2/model/model_csm_agents_attributes.rs create mode 100644 src/datadogV2/model/model_csm_agents_metadata.rs create mode 100644 src/datadogV2/model/model_csm_agents_response.rs create mode 100644 src/datadogV2/model/model_csm_agents_type.rs create mode 100644 src/datadogV2/model/model_order_direction.rs create mode 100644 tests/scenarios/cassettes/v2/csm_agents/Get-all-CSM-Agents-returns-OK-response.frozen create mode 100644 tests/scenarios/cassettes/v2/csm_agents/Get-all-CSM-Agents-returns-OK-response.json create mode 100644 tests/scenarios/cassettes/v2/csm_agents/Get-all-CSM-Serverless-Agents-returns-OK-response.frozen create mode 100644 tests/scenarios/cassettes/v2/csm_agents/Get-all-CSM-Serverless-Agents-returns-OK-response.json create mode 100644 tests/scenarios/features/v2/csm_agents.feature diff --git a/.apigentools-info b/.apigentools-info index da4b0b1fd..0b8614430 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-12-16 18:27:46.210937", - "spec_repo_commit": "a179b579" + "regenerated": "2024-12-16 19:15:41.785620", + "spec_repo_commit": "162aece5" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-12-16 18:27:46.225187", - "spec_repo_commit": "a179b579" + "regenerated": "2024-12-16 19:15:41.800183", + "spec_repo_commit": "162aece5" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 3cfa378a5..5d4184e4f 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -4339,6 +4339,34 @@ components: from the other indexes type: string type: object + CSMAgentsMetadata: + description: Metadata related to the paginated response. + properties: + page_index: + description: The index of the current page in the paginated results. + example: 0 + format: int64 + type: integer + page_size: + description: The number of items per page in the paginated results. + example: 10 + format: int64 + type: integer + total_filtered: + description: Total number of items that match the filter criteria. + example: 128697 + format: int64 + type: integer + type: object + CSMAgentsType: + default: datadog_agent + description: The type of the resource. The value should always be `datadog_agent`. + enum: + - datadog_agent + example: datadog_agent + type: string + x-enum-varnames: + - DATADOG_AGENT CalculatedField: description: Calculated field. properties: @@ -6630,6 +6658,96 @@ components: nullable: true type: string type: object + CsmAgentData: + description: Single Agent Data. + properties: + attributes: + $ref: '#/components/schemas/CsmAgentsAttributes' + id: + description: The ID of the Agent. + example: fffffc5505f6a006fdf7cf5aae053653 + type: string + type: + $ref: '#/components/schemas/CSMAgentsType' + type: object + CsmAgentsAttributes: + description: A CSM Agent returned by the API. + properties: + agent_version: + description: Version of the Datadog Agent. + type: string + aws_fargate: + description: AWS Fargate details. + type: string + cluster_name: + description: List of cluster names associated with the Agent. + items: + type: string + type: array + datadog_agent: + description: Unique identifier for the Datadog Agent. + type: string + ecs_fargate_task_arn: + description: ARN of the ECS Fargate task. + type: string + envs: + description: List of environments associated with the Agent. + items: + type: string + nullable: true + type: array + host_id: + description: ID of the host. + format: int64 + type: integer + hostname: + description: Name of the host. + type: string + install_method_installer_version: + description: Version of the installer used for installing the Datadog Agent. + type: string + install_method_tool: + description: Tool used for installing the Datadog Agent. + type: string + is_csm_vm_containers_enabled: + description: Indicates if CSM VM Containers is enabled. + nullable: true + type: boolean + is_csm_vm_hosts_enabled: + description: Indicates if CSM VM Hosts is enabled. + nullable: true + type: boolean + is_cspm_enabled: + description: Indicates if CSPM is enabled. + nullable: true + type: boolean + is_cws_enabled: + description: Indicates if CWS is enabled. + nullable: true + type: boolean + is_cws_remote_configuration_enabled: + description: Indicates if CWS Remote Configuration is enabled. + nullable: true + type: boolean + is_remote_configuration_enabled: + description: Indicates if Remote Configuration is enabled. + nullable: true + type: boolean + os: + description: Operating system of the host. + type: string + type: object + CsmAgentsResponse: + description: Response object that includes a list of CSM Agents. + properties: + data: + description: A list of Agents. + items: + $ref: '#/components/schemas/CsmAgentData' + type: array + meta: + $ref: '#/components/schemas/CSMAgentsMetadata' + type: object CustomCostGetResponseMeta: description: Meta for the response from the Get Custom Costs endpoints. properties: @@ -17704,6 +17822,16 @@ components: required: - data type: object + OrderDirection: + description: The sort direction for results. + enum: + - asc + - desc + example: asc + type: string + x-enum-varnames: + - ASC + - DESC OrgConfigGetResponse: description: A response with a single Org Config. properties: @@ -30922,6 +31050,113 @@ paths: x-unstable: '**Note**: This endpoint is in public beta. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/csm/onboarding/agents: + get: + description: Get the list of all CSM Agents running on your hosts and containers. + operationId: ListAllCSMAgents + parameters: + - description: The page index for pagination (zero-based). + in: query + name: page + required: false + schema: + example: 2 + format: int32 + maximum: 1000000 + minimum: 0 + type: integer + - description: The number of items to include in a single page. + in: query + name: size + required: false + schema: + example: 12 + format: int32 + maximum: 100 + minimum: 0 + type: integer + - description: A search query string to filter results (for example, `hostname:COMP-T2H4J27423`). + in: query + name: query + required: false + schema: + example: hostname:COMP-T2H4J27423 + type: string + - description: The sort direction for results. Use `asc` for ascending or `desc` + for descending. + in: query + name: order_direction + required: false + schema: + $ref: '#/components/schemas/OrderDirection' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/CsmAgentsResponse' + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get all CSM Agents + tags: + - CSM Agents + /api/v2/csm/onboarding/serverless/agents: + get: + description: Get the list of all CSM Serverless Agents running on your hosts + and containers. + operationId: ListAllCSMServerlessAgents + parameters: + - description: The page index for pagination (zero-based). + in: query + name: page + required: false + schema: + example: 2 + format: int32 + maximum: 1000000 + minimum: 0 + type: integer + - description: The number of items to include in a single page. + in: query + name: size + required: false + schema: + example: 12 + format: int32 + maximum: 100 + minimum: 0 + type: integer + - description: A search query string to filter results (for example, `hostname:COMP-T2H4J27423`). + in: query + name: query + required: false + schema: + example: hostname:COMP-T2H4J27423 + type: string + - description: The sort direction for results. Use `asc` for ascending or `desc` + for descending. + in: query + name: order_direction + required: false + schema: + $ref: '#/components/schemas/OrderDirection' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/CsmAgentsResponse' + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get all CSM Serverless Agents + tags: + - CSM Agents /api/v2/current_user/application_keys: get: description: List all application keys available for current user @@ -44624,6 +44859,15 @@ tags: [Test Visibility in Datadog page](https://docs.datadoghq.com/tests/) for more information. name: CI Visibility Tests +- 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 Agents - 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-agents_ListAllCSMAgents.rs b/examples/v2_csm-agents_ListAllCSMAgents.rs new file mode 100644 index 000000000..953ad3e83 --- /dev/null +++ b/examples/v2_csm-agents_ListAllCSMAgents.rs @@ -0,0 +1,18 @@ +// Get all CSM Agents returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_csm_agents::CSMAgentsAPI; +use datadog_api_client::datadogV2::api_csm_agents::ListAllCSMAgentsOptionalParams; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = CSMAgentsAPI::with_config(configuration); + let resp = api + .list_all_csm_agents(ListAllCSMAgentsOptionalParams::default()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_csm-agents_ListAllCSMServerlessAgents.rs b/examples/v2_csm-agents_ListAllCSMServerlessAgents.rs new file mode 100644 index 000000000..3cb293000 --- /dev/null +++ b/examples/v2_csm-agents_ListAllCSMServerlessAgents.rs @@ -0,0 +1,18 @@ +// Get all CSM Serverless Agents returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_csm_agents::CSMAgentsAPI; +use datadog_api_client::datadogV2::api_csm_agents::ListAllCSMServerlessAgentsOptionalParams; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = CSMAgentsAPI::with_config(configuration); + let resp = api + .list_all_csm_serverless_agents(ListAllCSMServerlessAgentsOptionalParams::default()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadogV2/api/api_csm_agents.rs b/src/datadogV2/api/api_csm_agents.rs new file mode 100644 index 000000000..c4cb3a5cc --- /dev/null +++ b/src/datadogV2/api/api_csm_agents.rs @@ -0,0 +1,426 @@ +// 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}; + +/// ListAllCSMAgentsOptionalParams is a struct for passing parameters to the method [`CSMAgentsAPI::list_all_csm_agents`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct ListAllCSMAgentsOptionalParams { + /// The page index for pagination (zero-based). + pub page: Option, + /// The number of items to include in a single page. + pub size: Option, + /// A search query string to filter results (for example, `hostname:COMP-T2H4J27423`). + pub query: Option, + /// The sort direction for results. Use `asc` for ascending or `desc` for descending. + pub order_direction: Option, +} + +impl ListAllCSMAgentsOptionalParams { + /// The page index for pagination (zero-based). + pub fn page(mut self, value: i32) -> Self { + self.page = Some(value); + self + } + /// The number of items to include in a single page. + pub fn size(mut self, value: i32) -> Self { + self.size = Some(value); + self + } + /// A search query string to filter results (for example, `hostname:COMP-T2H4J27423`). + pub fn query(mut self, value: String) -> Self { + self.query = Some(value); + self + } + /// The sort direction for results. Use `asc` for ascending or `desc` for descending. + pub fn order_direction(mut self, value: crate::datadogV2::model::OrderDirection) -> Self { + self.order_direction = Some(value); + self + } +} + +/// ListAllCSMServerlessAgentsOptionalParams is a struct for passing parameters to the method [`CSMAgentsAPI::list_all_csm_serverless_agents`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct ListAllCSMServerlessAgentsOptionalParams { + /// The page index for pagination (zero-based). + pub page: Option, + /// The number of items to include in a single page. + pub size: Option, + /// A search query string to filter results (for example, `hostname:COMP-T2H4J27423`). + pub query: Option, + /// The sort direction for results. Use `asc` for ascending or `desc` for descending. + pub order_direction: Option, +} + +impl ListAllCSMServerlessAgentsOptionalParams { + /// The page index for pagination (zero-based). + pub fn page(mut self, value: i32) -> Self { + self.page = Some(value); + self + } + /// The number of items to include in a single page. + pub fn size(mut self, value: i32) -> Self { + self.size = Some(value); + self + } + /// A search query string to filter results (for example, `hostname:COMP-T2H4J27423`). + pub fn query(mut self, value: String) -> Self { + self.query = Some(value); + self + } + /// The sort direction for results. Use `asc` for ascending or `desc` for descending. + pub fn order_direction(mut self, value: crate::datadogV2::model::OrderDirection) -> Self { + self.order_direction = Some(value); + self + } +} + +/// ListAllCSMAgentsError is a struct for typed errors of method [`CSMAgentsAPI::list_all_csm_agents`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListAllCSMAgentsError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// ListAllCSMServerlessAgentsError is a struct for typed errors of method [`CSMAgentsAPI::list_all_csm_serverless_agents`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListAllCSMServerlessAgentsError { + 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 CSMAgentsAPI { + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, +} + +impl Default for CSMAgentsAPI { + fn default() -> Self { + Self::with_config(datadog::Configuration::default()) + } +} + +impl CSMAgentsAPI { + 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 list of all CSM Agents running on your hosts and containers. + pub async fn list_all_csm_agents( + &self, + params: ListAllCSMAgentsOptionalParams, + ) -> Result> + { + match self.list_all_csm_agents_with_http_info(params).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 list of all CSM Agents running on your hosts and containers. + pub async fn list_all_csm_agents_with_http_info( + &self, + params: ListAllCSMAgentsOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_all_csm_agents"; + + // unbox and build optional parameters + let page = params.page; + let size = params.size; + let query = params.query; + let order_direction = params.order_direction; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/csm/onboarding/agents", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = page { + local_req_builder = + local_req_builder.query(&[("page", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = size { + local_req_builder = + local_req_builder.query(&[("size", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = query { + local_req_builder = + local_req_builder.query(&[("query", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = order_direction { + local_req_builder = + local_req_builder.query(&[("order_direction", &local_query_param.to_string())]); + }; + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::(&local_content) + { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Get the list of all CSM Serverless Agents running on your hosts and containers. + pub async fn list_all_csm_serverless_agents( + &self, + params: ListAllCSMServerlessAgentsOptionalParams, + ) -> Result< + crate::datadogV2::model::CsmAgentsResponse, + datadog::Error, + > { + match self + .list_all_csm_serverless_agents_with_http_info(params) + .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 list of all CSM Serverless Agents running on your hosts and containers. + pub async fn list_all_csm_serverless_agents_with_http_info( + &self, + params: ListAllCSMServerlessAgentsOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_all_csm_serverless_agents"; + + // unbox and build optional parameters + let page = params.page; + let size = params.size; + let query = params.query; + let order_direction = params.order_direction; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/csm/onboarding/serverless/agents", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = page { + local_req_builder = + local_req_builder.query(&[("page", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = size { + local_req_builder = + local_req_builder.query(&[("size", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = query { + local_req_builder = + local_req_builder.query(&[("query", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = order_direction { + local_req_builder = + local_req_builder.query(&[("order_direction", &local_query_param.to_string())]); + }; + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::(&local_content) + { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } +} diff --git a/src/datadogV2/api/mod.rs b/src/datadogV2/api/mod.rs index 2eab40719..50f53757d 100644 --- a/src/datadogV2/api/mod.rs +++ b/src/datadogV2/api/mod.rs @@ -16,6 +16,7 @@ pub mod api_cloudflare_integration; pub mod api_confluent_cloud; pub mod api_container_images; pub mod api_containers; +pub mod api_csm_agents; 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 f57d3d8da..f1a57ee38 100644 --- a/src/datadogV2/mod.rs +++ b/src/datadogV2/mod.rs @@ -17,6 +17,7 @@ pub use self::api::api_cloudflare_integration; 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_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 238d684b9..7a79c7644 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -862,6 +862,18 @@ pub mod model_cost_attribution_aggregates_body; pub use self::model_cost_attribution_aggregates_body::CostAttributionAggregatesBody; pub mod model_monthly_cost_attribution_pagination; pub use self::model_monthly_cost_attribution_pagination::MonthlyCostAttributionPagination; +pub mod model_order_direction; +pub use self::model_order_direction::OrderDirection; +pub mod model_csm_agents_response; +pub use self::model_csm_agents_response::CsmAgentsResponse; +pub mod model_csm_agent_data; +pub use self::model_csm_agent_data::CsmAgentData; +pub mod model_csm_agents_attributes; +pub use self::model_csm_agents_attributes::CsmAgentsAttributes; +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_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_agent_data.rs b/src/datadogV2/model/model_csm_agent_data.rs new file mode 100644 index 000000000..9fa92834f --- /dev/null +++ b/src/datadogV2/model/model_csm_agent_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}; + +/// Single Agent Data. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CsmAgentData { + /// A CSM Agent returned by the API. + #[serde(rename = "attributes")] + pub attributes: Option, + /// The ID of the Agent. + #[serde(rename = "id")] + pub id: Option, + /// The type of the resource. The value should always be `datadog_agent`. + #[serde(rename = "type")] + pub type_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CsmAgentData { + pub fn new() -> CsmAgentData { + CsmAgentData { + attributes: None, + id: None, + type_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes(mut self, value: crate::datadogV2::model::CsmAgentsAttributes) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn type_(mut self, value: crate::datadogV2::model::CSMAgentsType) -> 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 CsmAgentData { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CsmAgentData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CsmAgentDataVisitor; + impl<'a> Visitor<'a> for CsmAgentDataVisitor { + type Value = CsmAgentData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut 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 Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::CSMAgentsType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = CsmAgentData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CsmAgentDataVisitor) + } +} diff --git a/src/datadogV2/model/model_csm_agents_attributes.rs b/src/datadogV2/model/model_csm_agents_attributes.rs new file mode 100644 index 000000000..699483adc --- /dev/null +++ b/src/datadogV2/model/model_csm_agents_attributes.rs @@ -0,0 +1,393 @@ +// 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}; + +/// A CSM Agent returned by the API. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CsmAgentsAttributes { + /// Version of the Datadog Agent. + #[serde(rename = "agent_version")] + pub agent_version: Option, + /// AWS Fargate details. + #[serde(rename = "aws_fargate")] + pub aws_fargate: Option, + /// List of cluster names associated with the Agent. + #[serde(rename = "cluster_name")] + pub cluster_name: Option>, + /// Unique identifier for the Datadog Agent. + #[serde(rename = "datadog_agent")] + pub datadog_agent: Option, + /// ARN of the ECS Fargate task. + #[serde(rename = "ecs_fargate_task_arn")] + pub ecs_fargate_task_arn: Option, + /// List of environments associated with the Agent. + #[serde(rename = "envs", default, with = "::serde_with::rust::double_option")] + pub envs: Option>>, + /// ID of the host. + #[serde(rename = "host_id")] + pub host_id: Option, + /// Name of the host. + #[serde(rename = "hostname")] + pub hostname: Option, + /// Version of the installer used for installing the Datadog Agent. + #[serde(rename = "install_method_installer_version")] + pub install_method_installer_version: Option, + /// Tool used for installing the Datadog Agent. + #[serde(rename = "install_method_tool")] + pub install_method_tool: Option, + /// Indicates if CSM VM Containers is enabled. + #[serde( + rename = "is_csm_vm_containers_enabled", + default, + with = "::serde_with::rust::double_option" + )] + pub is_csm_vm_containers_enabled: Option>, + /// Indicates if CSM VM Hosts is enabled. + #[serde( + rename = "is_csm_vm_hosts_enabled", + default, + with = "::serde_with::rust::double_option" + )] + pub is_csm_vm_hosts_enabled: Option>, + /// Indicates if CSPM is enabled. + #[serde( + rename = "is_cspm_enabled", + default, + with = "::serde_with::rust::double_option" + )] + pub is_cspm_enabled: Option>, + /// Indicates if CWS is enabled. + #[serde( + rename = "is_cws_enabled", + default, + with = "::serde_with::rust::double_option" + )] + pub is_cws_enabled: Option>, + /// Indicates if CWS Remote Configuration is enabled. + #[serde( + rename = "is_cws_remote_configuration_enabled", + default, + with = "::serde_with::rust::double_option" + )] + pub is_cws_remote_configuration_enabled: Option>, + /// Indicates if Remote Configuration is enabled. + #[serde( + rename = "is_remote_configuration_enabled", + default, + with = "::serde_with::rust::double_option" + )] + pub is_remote_configuration_enabled: Option>, + /// Operating system of the host. + #[serde(rename = "os")] + pub os: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CsmAgentsAttributes { + pub fn new() -> CsmAgentsAttributes { + CsmAgentsAttributes { + agent_version: None, + aws_fargate: None, + cluster_name: None, + datadog_agent: None, + ecs_fargate_task_arn: None, + envs: None, + host_id: None, + hostname: None, + install_method_installer_version: None, + install_method_tool: None, + is_csm_vm_containers_enabled: None, + is_csm_vm_hosts_enabled: None, + is_cspm_enabled: None, + is_cws_enabled: None, + is_cws_remote_configuration_enabled: None, + is_remote_configuration_enabled: None, + os: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn agent_version(mut self, value: String) -> Self { + self.agent_version = Some(value); + self + } + + pub fn aws_fargate(mut self, value: String) -> Self { + self.aws_fargate = Some(value); + self + } + + pub fn cluster_name(mut self, value: Vec) -> Self { + self.cluster_name = Some(value); + self + } + + pub fn datadog_agent(mut self, value: String) -> Self { + self.datadog_agent = Some(value); + self + } + + pub fn ecs_fargate_task_arn(mut self, value: String) -> Self { + self.ecs_fargate_task_arn = Some(value); + self + } + + pub fn envs(mut self, value: Option>) -> Self { + self.envs = Some(value); + self + } + + pub fn host_id(mut self, value: i64) -> Self { + self.host_id = Some(value); + self + } + + pub fn hostname(mut self, value: String) -> Self { + self.hostname = Some(value); + self + } + + pub fn install_method_installer_version(mut self, value: String) -> Self { + self.install_method_installer_version = Some(value); + self + } + + pub fn install_method_tool(mut self, value: String) -> Self { + self.install_method_tool = Some(value); + self + } + + pub fn is_csm_vm_containers_enabled(mut self, value: Option) -> Self { + self.is_csm_vm_containers_enabled = Some(value); + self + } + + pub fn is_csm_vm_hosts_enabled(mut self, value: Option) -> Self { + self.is_csm_vm_hosts_enabled = Some(value); + self + } + + pub fn is_cspm_enabled(mut self, value: Option) -> Self { + self.is_cspm_enabled = Some(value); + self + } + + pub fn is_cws_enabled(mut self, value: Option) -> Self { + self.is_cws_enabled = Some(value); + self + } + + pub fn is_cws_remote_configuration_enabled(mut self, value: Option) -> Self { + self.is_cws_remote_configuration_enabled = Some(value); + self + } + + pub fn is_remote_configuration_enabled(mut self, value: Option) -> Self { + self.is_remote_configuration_enabled = Some(value); + self + } + + pub fn os(mut self, value: String) -> Self { + self.os = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CsmAgentsAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CsmAgentsAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CsmAgentsAttributesVisitor; + impl<'a> Visitor<'a> for CsmAgentsAttributesVisitor { + type Value = CsmAgentsAttributes; + + 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 agent_version: Option = None; + let mut aws_fargate: Option = None; + let mut cluster_name: Option> = None; + let mut datadog_agent: Option = None; + let mut ecs_fargate_task_arn: Option = None; + let mut envs: Option>> = None; + let mut host_id: Option = None; + let mut hostname: Option = None; + let mut install_method_installer_version: Option = None; + let mut install_method_tool: Option = None; + let mut is_csm_vm_containers_enabled: Option> = None; + let mut is_csm_vm_hosts_enabled: Option> = None; + let mut is_cspm_enabled: Option> = None; + let mut is_cws_enabled: Option> = None; + let mut is_cws_remote_configuration_enabled: Option> = None; + let mut is_remote_configuration_enabled: Option> = None; + let mut os: 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() { + "agent_version" => { + if v.is_null() { + continue; + } + agent_version = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "aws_fargate" => { + if v.is_null() { + continue; + } + aws_fargate = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "cluster_name" => { + if v.is_null() { + continue; + } + cluster_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "datadog_agent" => { + if v.is_null() { + continue; + } + datadog_agent = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "ecs_fargate_task_arn" => { + if v.is_null() { + continue; + } + ecs_fargate_task_arn = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "envs" => { + envs = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "host_id" => { + if v.is_null() { + continue; + } + host_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "hostname" => { + if v.is_null() { + continue; + } + hostname = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "install_method_installer_version" => { + if v.is_null() { + continue; + } + install_method_installer_version = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "install_method_tool" => { + if v.is_null() { + continue; + } + install_method_tool = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "is_csm_vm_containers_enabled" => { + is_csm_vm_containers_enabled = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "is_csm_vm_hosts_enabled" => { + is_csm_vm_hosts_enabled = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "is_cspm_enabled" => { + is_cspm_enabled = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "is_cws_enabled" => { + is_cws_enabled = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "is_cws_remote_configuration_enabled" => { + is_cws_remote_configuration_enabled = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "is_remote_configuration_enabled" => { + is_remote_configuration_enabled = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "os" => { + if v.is_null() { + continue; + } + os = 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 = CsmAgentsAttributes { + agent_version, + aws_fargate, + cluster_name, + datadog_agent, + ecs_fargate_task_arn, + envs, + host_id, + hostname, + install_method_installer_version, + install_method_tool, + is_csm_vm_containers_enabled, + is_csm_vm_hosts_enabled, + is_cspm_enabled, + is_cws_enabled, + is_cws_remote_configuration_enabled, + is_remote_configuration_enabled, + os, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CsmAgentsAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_csm_agents_metadata.rs b/src/datadogV2/model/model_csm_agents_metadata.rs new file mode 100644 index 000000000..67cb2b435 --- /dev/null +++ b/src/datadogV2/model/model_csm_agents_metadata.rs @@ -0,0 +1,140 @@ +// 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}; + +/// Metadata related to the paginated response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CSMAgentsMetadata { + /// The index of the current page in the paginated results. + #[serde(rename = "page_index")] + pub page_index: Option, + /// The number of items per page in the paginated results. + #[serde(rename = "page_size")] + pub page_size: Option, + /// Total number of items that match the filter criteria. + #[serde(rename = "total_filtered")] + pub total_filtered: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CSMAgentsMetadata { + pub fn new() -> CSMAgentsMetadata { + CSMAgentsMetadata { + page_index: None, + page_size: None, + total_filtered: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn page_index(mut self, value: i64) -> Self { + self.page_index = Some(value); + self + } + + pub fn page_size(mut self, value: i64) -> Self { + self.page_size = Some(value); + self + } + + pub fn total_filtered(mut self, value: i64) -> Self { + self.total_filtered = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CSMAgentsMetadata { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CSMAgentsMetadata { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CSMAgentsMetadataVisitor; + impl<'a> Visitor<'a> for CSMAgentsMetadataVisitor { + type Value = CSMAgentsMetadata; + + 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 page_index: Option = None; + let mut page_size: Option = None; + let mut total_filtered: 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() { + "page_index" => { + if v.is_null() { + continue; + } + page_index = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "page_size" => { + if v.is_null() { + continue; + } + page_size = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "total_filtered" => { + if v.is_null() { + continue; + } + total_filtered = + 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 = CSMAgentsMetadata { + page_index, + page_size, + total_filtered, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CSMAgentsMetadataVisitor) + } +} diff --git a/src/datadogV2/model/model_csm_agents_response.rs b/src/datadogV2/model/model_csm_agents_response.rs new file mode 100644 index 000000000..0f294c140 --- /dev/null +++ b/src/datadogV2/model/model_csm_agents_response.rs @@ -0,0 +1,122 @@ +// 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 object that includes a list of CSM Agents. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CsmAgentsResponse { + /// A list of Agents. + #[serde(rename = "data")] + pub data: Option>, + /// Metadata related to the paginated response. + #[serde(rename = "meta")] + pub meta: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CsmAgentsResponse { + pub fn new() -> CsmAgentsResponse { + CsmAgentsResponse { + data: None, + meta: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: Vec) -> Self { + self.data = Some(value); + self + } + + pub fn meta(mut self, value: crate::datadogV2::model::CSMAgentsMetadata) -> Self { + self.meta = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CsmAgentsResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CsmAgentsResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CsmAgentsResponseVisitor; + impl<'a> Visitor<'a> for CsmAgentsResponseVisitor { + type Value = CsmAgentsResponse; + + 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 meta: 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)?); + } + "meta" => { + if v.is_null() { + continue; + } + meta = 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 = CsmAgentsResponse { + data, + meta, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CsmAgentsResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_csm_agents_type.rs b/src/datadogV2/model/model_csm_agents_type.rs new file mode 100644 index 000000000..0dd095e97 --- /dev/null +++ b/src/datadogV2/model/model_csm_agents_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 CSMAgentsType { + DATADOG_AGENT, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for CSMAgentsType { + fn to_string(&self) -> String { + match self { + Self::DATADOG_AGENT => String::from("datadog_agent"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for CSMAgentsType { + 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 CSMAgentsType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "datadog_agent" => Self::DATADOG_AGENT, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_order_direction.rs b/src/datadogV2/model/model_order_direction.rs new file mode 100644 index 000000000..060eb130a --- /dev/null +++ b/src/datadogV2/model/model_order_direction.rs @@ -0,0 +1,51 @@ +// 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 OrderDirection { + ASC, + DESC, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for OrderDirection { + fn to_string(&self) -> String { + match self { + Self::ASC => String::from("asc"), + Self::DESC => String::from("desc"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for OrderDirection { + 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 OrderDirection { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "asc" => Self::ASC, + "desc" => Self::DESC, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/tests/scenarios/cassettes/v2/csm_agents/Get-all-CSM-Agents-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/csm_agents/Get-all-CSM-Agents-returns-OK-response.frozen new file mode 100644 index 000000000..78ae32061 --- /dev/null +++ b/tests/scenarios/cassettes/v2/csm_agents/Get-all-CSM-Agents-returns-OK-response.frozen @@ -0,0 +1 @@ +2024-12-13T17:22:57.344Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/csm_agents/Get-all-CSM-Agents-returns-OK-response.json b/tests/scenarios/cassettes/v2/csm_agents/Get-all-CSM-Agents-returns-OK-response.json new file mode 100644 index 000000000..6af610379 --- /dev/null +++ b/tests/scenarios/cassettes/v2/csm_agents/Get-all-CSM-Agents-returns-OK-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/csm/onboarding/agents" + }, + "response": { + "body": { + "string": "{\"data\":[{\"id\":\"f3087801a44eba3c2ea706e873aee9e4\",\"type\":\"datadog_agent\",\"attributes\":{\"agent_version\":\"7.59.1\",\"aws_fargate\":\"\",\"cluster_name\":[\"\"],\"ecs_fargate_task_arn\":\"\",\"envs\":[\"pcf-vane-3512666\"],\"host_id\":29630727754,\"hostname\":\"datadog-cluster-agent-0-af63a3e6-4a25-4def-83a4-8754d185b3ef\",\"install_method_installer_version\":\"\",\"install_method_tool\":\"undefined\",\"is_csm_vm_containers_enabled\":false,\"is_csm_vm_hosts_enabled\":false,\"is_cspm_enabled\":false,\"is_cws_enabled\":false,\"is_cws_remote_configuration_enabled\":true,\"is_remote_configuration_enabled\":true,\"os\":\"GNU/Linux\"}},{\"id\":\"d66d3bc7b9d4273183431b501ef33d86\",\"type\":\"datadog_agent\",\"attributes\":{\"agent_version\":\"7.59.1\",\"aws_fargate\":\"\",\"cluster_name\":[\"\"],\"ecs_fargate_task_arn\":\"\",\"envs\":[\"pcf-vane-3512666\"],\"host_id\":29623236313,\"hostname\":\"database-0-e7b70a7b-4199-4920-a8e3-62f221819522\",\"install_method_installer_version\":\"\",\"install_method_tool\":\"undefined\",\"is_csm_vm_containers_enabled\":false,\"is_csm_vm_hosts_enabled\":false,\"is_cspm_enabled\":false,\"is_cws_enabled\":false,\"is_cws_remote_configuration_enabled\":true,\"is_remote_configuration_enabled\":true,\"os\":\"GNU/Linux\"}},{\"id\":\"c8eca433902d29dd748f93e413eb2a9d\",\"type\":\"datadog_agent\",\"attributes\":{\"agent_version\":\"7.59.1\",\"aws_fargate\":\"\",\"cluster_name\":[\"\"],\"ecs_fargate_task_arn\":\"\",\"envs\":[\"pcf-farm-3522782\"],\"host_id\":29722803807,\"hostname\":\"router-0-1bf8fdd0-bbc2-4cf3-8c7c-c1605bafa9bd\",\"install_method_installer_version\":\"\",\"install_method_tool\":\"undefined\",\"is_csm_vm_containers_enabled\":false,\"is_csm_vm_hosts_enabled\":false,\"is_cspm_enabled\":false,\"is_cws_enabled\":false,\"is_cws_remote_configuration_enabled\":true,\"is_remote_configuration_enabled\":true,\"os\":\"GNU/Linux\"}},{\"id\":\"c6009fcea425da0722eeefd58d95ae6e\",\"type\":\"datadog_agent\",\"attributes\":{\"agent_version\":\"7.59.1\",\"aws_fargate\":\"\",\"cluster_name\":[\"\"],\"ecs_fargate_task_arn\":\"\",\"envs\":[\"pcf-vane-3512666\"],\"host_id\":29623808723,\"hostname\":\"compute-0-abf8a42e-5338-44e5-8048-658415893f3c\",\"install_method_installer_version\":\"\",\"install_method_tool\":\"undefined\",\"is_csm_vm_containers_enabled\":false,\"is_csm_vm_hosts_enabled\":false,\"is_cspm_enabled\":false,\"is_cws_enabled\":false,\"is_cws_remote_configuration_enabled\":true,\"is_remote_configuration_enabled\":true,\"os\":\"GNU/Linux\"}},{\"id\":\"b5684ca6ace0e5eb757124a1bce8ad13\",\"type\":\"datadog_agent\",\"attributes\":{\"agent_version\":\"7.59.1\",\"aws_fargate\":\"\",\"cluster_name\":[\"\"],\"ecs_fargate_task_arn\":\"\",\"envs\":[\"pcf-nook-3513764\"],\"host_id\":29671027855,\"hostname\":\"database-0-805a7570-d3cf-4acc-97d8-c40ac88df896\",\"install_method_installer_version\":\"\",\"install_method_tool\":\"undefined\",\"is_csm_vm_containers_enabled\":false,\"is_csm_vm_hosts_enabled\":false,\"is_cspm_enabled\":false,\"is_cws_enabled\":false,\"is_cws_remote_configuration_enabled\":true,\"is_remote_configuration_enabled\":true,\"os\":\"GNU/Linux\"}},{\"id\":\"b2432c7f30596064f765d9f2b400299e\",\"type\":\"datadog_agent\",\"attributes\":{\"agent_version\":\"7.59.1\",\"aws_fargate\":\"\",\"cluster_name\":[\"\"],\"ecs_fargate_task_arn\":\"\",\"envs\":[\"pcf-vane-3512666\"],\"host_id\":29623289233,\"hostname\":\"blobstore-0-2d6429ae-61a4-4d6d-a1be-1e6c20711d62\",\"install_method_installer_version\":\"\",\"install_method_tool\":\"undefined\",\"is_csm_vm_containers_enabled\":false,\"is_csm_vm_hosts_enabled\":false,\"is_cspm_enabled\":false,\"is_cws_enabled\":false,\"is_cws_remote_configuration_enabled\":true,\"is_remote_configuration_enabled\":true,\"os\":\"GNU/Linux\"}},{\"id\":\"b18cbc65f97d10e2db319de9664e8136\",\"type\":\"datadog_agent\",\"attributes\":{\"agent_version\":\"7.59.1\",\"aws_fargate\":\"\",\"cluster_name\":[\"\"],\"ecs_fargate_task_arn\":\"\",\"envs\":[\"pcf-vane-3512666\"],\"host_id\":29623905136,\"hostname\":\"router-0-f84247ea-89db-459f-8db9-e19faaf118b9\",\"install_method_installer_version\":\"\",\"install_method_tool\":\"undefined\",\"is_csm_vm_containers_enabled\":false,\"is_csm_vm_hosts_enabled\":false,\"is_cspm_enabled\":false,\"is_cws_enabled\":false,\"is_cws_remote_configuration_enabled\":true,\"is_remote_configuration_enabled\":true,\"os\":\"GNU/Linux\"}},{\"id\":\"a99fccb5f6f726754282ea7ff84269c3\",\"type\":\"datadog_agent\",\"attributes\":{\"agent_version\":\"7.62.0-devel+git.319.c819811\",\"aws_fargate\":\"\",\"cluster_name\":[\"\"],\"ecs_fargate_task_arn\":\"\",\"envs\":null,\"host_id\":15240413136,\"hostname\":\"comp-xctp773fw9\",\"install_method_installer_version\":\"docker\",\"install_method_tool\":\"docker\",\"is_csm_vm_containers_enabled\":false,\"is_csm_vm_hosts_enabled\":false,\"is_cspm_enabled\":false,\"is_cws_enabled\":false,\"is_cws_remote_configuration_enabled\":true,\"is_remote_configuration_enabled\":true,\"os\":\"GNU/Linux\"}},{\"id\":\"a57d21e013a51ea0a3881ad7d4f1d7d1\",\"type\":\"datadog_agent\",\"attributes\":{\"agent_version\":\"7.59.1\",\"aws_fargate\":\"\",\"cluster_name\":[\"\"],\"ecs_fargate_task_arn\":\"\",\"envs\":[\"pcf-vane-3512666\"],\"host_id\":29630585934,\"hostname\":\"datadog-firehose-nozzle-0-d3f355d3-2839-441d-884b-9e7ee6c248a6\",\"install_method_installer_version\":\"\",\"install_method_tool\":\"undefined\",\"is_csm_vm_containers_enabled\":false,\"is_csm_vm_hosts_enabled\":false,\"is_cspm_enabled\":false,\"is_cws_enabled\":false,\"is_cws_remote_configuration_enabled\":true,\"is_remote_configuration_enabled\":true,\"os\":\"GNU/Linux\"}},{\"id\":\"a43d2a3241ca97359058507a36800089\",\"type\":\"datadog_agent\",\"attributes\":{\"agent_version\":\"7.59.1\",\"aws_fargate\":\"\",\"cluster_name\":[\"\"],\"ecs_fargate_task_arn\":\"\",\"envs\":[\"pcf-nook-3513764\"],\"host_id\":29700921282,\"hostname\":\"datadog-firehose-nozzle-0-451fe766-caa2-4fb7-9198-076d2e1ef872\",\"install_method_installer_version\":\"\",\"install_method_tool\":\"undefined\",\"is_csm_vm_containers_enabled\":false,\"is_csm_vm_hosts_enabled\":false,\"is_cspm_enabled\":false,\"is_cws_enabled\":false,\"is_cws_remote_configuration_enabled\":true,\"is_remote_configuration_enabled\":true,\"os\":\"GNU/Linux\"}}],\"meta\":{\"total_filtered\":24,\"page_index\":0,\"page_size\":10}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Fri, 13 Dec 2024 17:22:57 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/csm_agents/Get-all-CSM-Serverless-Agents-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/csm_agents/Get-all-CSM-Serverless-Agents-returns-OK-response.frozen new file mode 100644 index 000000000..3be55cc6c --- /dev/null +++ b/tests/scenarios/cassettes/v2/csm_agents/Get-all-CSM-Serverless-Agents-returns-OK-response.frozen @@ -0,0 +1 @@ +2024-12-13T17:22:57.772Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/csm_agents/Get-all-CSM-Serverless-Agents-returns-OK-response.json b/tests/scenarios/cassettes/v2/csm_agents/Get-all-CSM-Serverless-Agents-returns-OK-response.json new file mode 100644 index 000000000..d849de6ba --- /dev/null +++ b/tests/scenarios/cassettes/v2/csm_agents/Get-all-CSM-Serverless-Agents-returns-OK-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/csm/onboarding/serverless/agents" + }, + "response": { + "body": { + "string": "{\"data\":[],\"meta\":{\"total_filtered\":0,\"page_index\":0,\"page_size\":10}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Fri, 13 Dec 2024 17:22:57 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/features/v2/container_images.feature b/tests/scenarios/features/v2/container_images.feature index 8e9162526..ad6e1559b 100644 --- a/tests/scenarios/features/v2/container_images.feature +++ b/tests/scenarios/features/v2/container_images.feature @@ -10,25 +10,25 @@ Feature: Container Images And an instance of "ContainerImages" API And new "ListContainerImages" request - @replay-only @team:DataDog/container-experiences + @replay-only @team:DataDog/processes Scenario: Get all Container Image groups returns "OK" response Given request contains "group_by" parameter with value "short_image" When the request is sent Then the response status is 200 OK And the response "data[0].attributes.name" is equal to "test_name" - @generated @skip @team:DataDog/container-experiences + @generated @skip @team:DataDog/processes Scenario: Get all Container Images returns "Bad Request" response When the request is sent Then the response status is 400 Bad Request - @replay-only @team:DataDog/container-experiences + @replay-only @team:DataDog/processes Scenario: Get all Container Images returns "OK" response When the request is sent Then the response status is 200 OK And the response "data[0].attributes.name" is equal to "test_name" - @replay-only @skip-validation @team:DataDog/container-experiences @with-pagination + @replay-only @skip-validation @team:DataDog/processes @with-pagination Scenario: Get all Container Images returns "OK" response with pagination Given request contains "page[size]" parameter with value 2 When the request with pagination is sent diff --git a/tests/scenarios/features/v2/containers.feature b/tests/scenarios/features/v2/containers.feature index 1e1e84237..814931923 100644 --- a/tests/scenarios/features/v2/containers.feature +++ b/tests/scenarios/features/v2/containers.feature @@ -10,25 +10,25 @@ Feature: Containers And an instance of "Containers" API And new "ListContainers" request - @replay-only @team:DataDog/container-experiences + @replay-only @team:DataDog/processes Scenario: Get All Container groups returns "OK" response Given request contains "group_by" parameter with value "short_image" When the request is sent Then the response status is 200 OK And the response "data[0].attributes.count" is equal to 123 - @generated @skip @team:DataDog/container-experiences + @generated @skip @team:DataDog/processes Scenario: Get All Containers returns "Bad Request" response When the request is sent Then the response status is 400 Bad Request - @replay-only @team:DataDog/container-experiences + @replay-only @team:DataDog/processes Scenario: Get All Containers returns "OK" response When the request is sent Then the response status is 200 OK And the response "data[0].attributes.name" is equal to "test_name" - @replay-only @skip-validation @team:DataDog/container-experiences @with-pagination + @replay-only @skip-validation @team:DataDog/processes @with-pagination Scenario: Get All Containers returns "OK" response with pagination Given request contains "page[size]" parameter with value 2 When the request with pagination is sent diff --git a/tests/scenarios/features/v2/csm_agents.feature b/tests/scenarios/features/v2/csm_agents.feature new file mode 100644 index 000000000..49cde30aa --- /dev/null +++ b/tests/scenarios/features/v2/csm_agents.feature @@ -0,0 +1,25 @@ +@endpoint(csm-agents) @endpoint(csm-agents-v2) +Feature: CSM Agents + 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 "CSMAgents" API + + @team:DataDog/k9-cloud-security-platform + Scenario: Get all CSM Agents returns "OK" response + Given new "ListAllCSMAgents" request + When the request is sent + Then the response status is 200 OK + + @team:DataDog/k9-cloud-security-platform + Scenario: Get all CSM Serverless Agents returns "OK" response + Given new "ListAllCSMServerlessAgents" 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 9db842c40..8a00411a3 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -474,6 +474,18 @@ "type": "safe" } }, + "ListAllCSMAgents": { + "tag": "CSM Agents", + "undo": { + "type": "safe" + } + }, + "ListAllCSMServerlessAgents": { + "tag": "CSM Agents", + "undo": { + "type": "safe" + } + }, "ListCurrentUserApplicationKeys": { "tag": "Key Management", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index be3ebc194..6c1ba80e8 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -67,6 +67,7 @@ pub struct ApiInstances { pub v2_api_cloud_cost_management: Option, pub v2_api_usage_metering: Option, + pub v2_api_csm_agents: Option, pub v2_api_dashboard_lists: Option, pub v2_api_data_deletion: Option, pub v2_api_domain_allowlist: Option, @@ -542,6 +543,14 @@ pub fn initialize_api_instance(world: &mut DatadogWorld, api: String) { world.http_client.as_ref().unwrap().clone() )); } + "CSMAgents" => { + world.api_instances.v2_api_csm_agents = Some( + datadogV2::api_csm_agents::CSMAgentsAPI::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( @@ -1948,6 +1957,13 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { world .function_mappings .insert("v2.GetProjectedCost".into(), test_v2_get_projected_cost); + world + .function_mappings + .insert("v2.ListAllCSMAgents".into(), test_v2_list_all_csm_agents); + world.function_mappings.insert( + "v2.ListAllCSMServerlessAgents".into(), + test_v2_list_all_csm_serverless_agents, + ); world.function_mappings.insert( "v2.DeleteDashboardListItems".into(), test_v2_delete_dashboard_list_items, @@ -13647,6 +13663,91 @@ fn test_v2_get_projected_cost(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_csm_agents + .as_ref() + .expect("api instance not found"); + let page = _parameters + .get("page") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let size = _parameters + .get("size") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let query = _parameters + .get("query") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let order_direction = _parameters + .get("order_direction") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_csm_agents::ListAllCSMAgentsOptionalParams::default(); + params.page = page; + params.size = size; + params.query = query; + params.order_direction = order_direction; + let response = match block_on(api.list_all_csm_agents_with_http_info(params)) { + 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_all_csm_serverless_agents( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_csm_agents + .as_ref() + .expect("api instance not found"); + let page = _parameters + .get("page") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let size = _parameters + .get("size") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let query = _parameters + .get("query") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let order_direction = _parameters + .get("order_direction") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_csm_agents::ListAllCSMServerlessAgentsOptionalParams::default(); + params.page = page; + params.size = size; + params.query = query; + params.order_direction = order_direction; + let response = match block_on(api.list_all_csm_serverless_agents_with_http_info(params)) { + 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,