diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 34829870a..35ebab5e5 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -16842,6 +16842,78 @@ components: required: - data type: object + DeletedSuiteResponseData: + properties: + attributes: + $ref: '#/components/schemas/DeletedSuiteResponseDataAttributes' + id: + type: string + type: + $ref: '#/components/schemas/DeletedSuiteType' + type: object + DeletedSuiteResponseDataAttributes: + properties: + deleted_at: + description: Deletion timestamp of the Synthetic suite ID. + type: string + public_id: + description: The Synthetic suite ID deleted. + type: string + type: object + DeletedSuiteType: + default: suites + enum: + - suites + example: suites + type: string + x-enum-varnames: + - SUITES + DeletedSuitesRequestDelete: + properties: + attributes: + $ref: '#/components/schemas/DeletedSuitesRequestDeleteAttributes' + id: + type: string + type: + $ref: '#/components/schemas/DeletedSuitesRequestType' + required: + - attributes + type: object + DeletedSuitesRequestDeleteAttributes: + properties: + force_delete_dependencies: + type: boolean + public_ids: + example: + - '' + items: + type: string + type: array + required: + - public_ids + type: object + DeletedSuitesRequestDeleteRequest: + properties: + data: + $ref: '#/components/schemas/DeletedSuitesRequestDelete' + required: + - data + type: object + DeletedSuitesRequestType: + default: delete_suites_request + enum: + - delete_suites_request + example: delete_suites_request + type: string + x-enum-varnames: + - DELETE_SUITES_REQUEST + DeletedSuitesResponse: + properties: + data: + items: + $ref: '#/components/schemas/DeletedSuiteResponseData' + type: array + type: object DependencyLocation: description: Static library vulnerability location. properties: @@ -52614,6 +52686,153 @@ components: format: double type: number type: object + SuiteCreateEdit: + properties: + attributes: + $ref: '#/components/schemas/SyntheticsSuite' + type: + $ref: '#/components/schemas/SyntheticsSuiteType' + required: + - attributes + - type + type: object + SuiteCreateEditRequest: + properties: + data: + $ref: '#/components/schemas/SuiteCreateEdit' + required: + - data + type: object + SuiteSearchResponseType: + default: suites_search + enum: + - suites_search + example: suites_search + type: string + x-enum-varnames: + - SUITES_SEARCH + SyntheticsSuite: + description: Object containing details about a Synthetic suite. + properties: + message: + description: Notification message associated with the suite. + example: Notification message + type: string + name: + description: Name of the suite. + example: Example suite name + type: string + options: + $ref: '#/components/schemas/SyntheticsSuiteOptions' + public_id: + description: The public ID for the test. + example: 123-abc-456 + readOnly: true + type: string + tags: + description: Array of tags attached to the suite. + example: + - env:production + items: + description: A tag attached to the suite. + type: string + type: array + tests: + items: + $ref: '#/components/schemas/SyntheticsSuiteTest' + type: array + type: + $ref: '#/components/schemas/SyntheticsSuiteType' + required: + - name + - message + - type + - tests + - options + type: object + SyntheticsSuiteOptions: + description: Object describing the extra options for a Synthetic suite. + properties: + alerting_threshold: + description: Percentage of critical tests failure needed for a suite to + fail. + format: double + maximum: 1 + minimum: 0 + type: number + type: object + SyntheticsSuiteResponse: + description: Synthetics suite response + properties: + data: + $ref: '#/components/schemas/SyntheticsSuiteResponseData' + type: object + SyntheticsSuiteResponseData: + description: Synthetics suite response data + properties: + attributes: + $ref: '#/components/schemas/SyntheticsSuite' + type: object + SyntheticsSuiteSearchResponse: + description: Synthetics suite search response + properties: + data: + $ref: '#/components/schemas/SyntheticsSuiteSearchResponseData' + type: object + SyntheticsSuiteSearchResponseData: + description: Synthetics suite search response data + properties: + attributes: + $ref: '#/components/schemas/SyntheticsSuiteSearchResponseDataAttributes' + id: + format: uuid + type: string + type: + $ref: '#/components/schemas/SuiteSearchResponseType' + type: object + SyntheticsSuiteSearchResponseDataAttributes: + description: Synthetics suite search response data attributes + properties: + suites: + items: + $ref: '#/components/schemas/SyntheticsSuite' + type: array + total: + format: int32 + maximum: 2147483647 + type: integer + type: object + SyntheticsSuiteTest: + description: Object containing details about a Synthetic test included in a + Synthetic suite. + properties: + alerting_criticality: + $ref: '#/components/schemas/SyntheticsSuiteTestAlertingCriticality' + public_id: + example: '' + type: string + required: + - public_id + type: object + SyntheticsSuiteTestAlertingCriticality: + description: Alerting criticality for each the test. + enum: + - ignore + - critical + example: critical + type: string + x-enum-varnames: + - IGNORE + - CRITICAL + SyntheticsSuiteType: + default: suite + description: Type of the Synthetic suite, `suite`. + enum: + - suite + example: suite + type: string + x-enum-varnames: + - SUITE TableResultV2: description: A reference table resource containing its full configuration and state. @@ -84170,6 +84389,227 @@ paths: operator: OR permissions: - billing_edit + /api/v2/synthetics/suites: + post: + operationId: CreateSyntheticsSuite + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SuiteCreateEditRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/SyntheticsSuiteResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: API error response. + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - synthetics_write + summary: 'Synthetics: Create a test suite' + tags: + - Synthetics + x-permission: + operator: OR + permissions: + - synthetics_write + - synthetics_create_edit_trigger + /api/v2/synthetics/suites/bulk-delete: + post: + operationId: DeleteSyntheticsSuites + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/DeletedSuitesRequestDeleteRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/DeletedSuitesResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: API error response. + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - synthetics_write + summary: 'Synthetics: Bulk delete suites' + tags: + - Synthetics + x-permission: + operator: OR + permissions: + - synthetics_write + /api/v2/synthetics/suites/search: + get: + description: Search for Synthetics suites. + operationId: SearchSuites + parameters: + - description: The search query. + in: query + name: query + required: false + schema: + type: string + - description: The sort order for the results (e.g., `name,asc` or `name,desc`). + in: query + name: sort + required: false + schema: + default: name,asc + type: string + - description: If true, return only facets instead of full test details. + in: query + name: facets_only + required: false + schema: + default: false + type: boolean + - description: The offset from which to start returning results. + in: query + name: start + required: false + schema: + default: 0 + format: int64 + type: integer + - description: The maximum number of results to return. + in: query + name: count + required: false + schema: + default: 50 + format: int64 + type: integer + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/SyntheticsSuiteSearchResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: API error response. + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - synthetics_read + summary: Search Synthetics suites + tags: + - Synthetics + x-permission: + operator: OR + permissions: + - synthetics_read + /api/v2/synthetics/suites/{public_id}: + get: + operationId: GetSyntheticsSuite + parameters: + - description: The public ID of the suite to get details from. + in: path + name: public_id + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/SyntheticsSuiteResponse' + description: OK + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: API error response. + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - synthetics_read + summary: 'Synthetics: Get a suite' + tags: + - Synthetics + x-permission: + operator: OR + permissions: + - synthetics_read + put: + operationId: EditSyntheticsSuite + parameters: + - description: The public ID of the suite to edit. + in: path + name: public_id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SuiteCreateEditRequest' + description: New suite details to be saved. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/SyntheticsSuiteResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: API error response. + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - synthetics_write + summary: 'Synthetics: edit a test suite' + tags: + - Synthetics + x-permission: + operator: OR + permissions: + - synthetics_write /api/v2/tags/enrichment: get: description: List all tag pipeline rulesets - Retrieve a list of all tag pipeline diff --git a/examples/v2_synthetics_CreateSyntheticsSuite.rs b/examples/v2_synthetics_CreateSyntheticsSuite.rs new file mode 100644 index 000000000..7bf52272d --- /dev/null +++ b/examples/v2_synthetics_CreateSyntheticsSuite.rs @@ -0,0 +1,31 @@ +// Synthetics: Create a test suite returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_synthetics::SyntheticsAPI; +use datadog_api_client::datadogV2::model::SuiteCreateEdit; +use datadog_api_client::datadogV2::model::SuiteCreateEditRequest; +use datadog_api_client::datadogV2::model::SyntheticsSuite; +use datadog_api_client::datadogV2::model::SyntheticsSuiteOptions; +use datadog_api_client::datadogV2::model::SyntheticsSuiteType; + +#[tokio::main] +async fn main() { + let body = SuiteCreateEditRequest::new(SuiteCreateEdit::new( + SyntheticsSuite::new( + "Notification message".to_string(), + "Example suite name".to_string(), + SyntheticsSuiteOptions::new(), + vec![], + SyntheticsSuiteType::SUITE, + ) + .tags(vec!["env:production".to_string()]), + SyntheticsSuiteType::SUITE, + )); + let configuration = datadog::Configuration::new(); + let api = SyntheticsAPI::with_config(configuration); + let resp = api.create_synthetics_suite(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_synthetics_DeleteSyntheticsSuites.rs b/examples/v2_synthetics_DeleteSyntheticsSuites.rs new file mode 100644 index 000000000..06e8de8b7 --- /dev/null +++ b/examples/v2_synthetics_DeleteSyntheticsSuites.rs @@ -0,0 +1,25 @@ +// Synthetics: Bulk delete suites returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_synthetics::SyntheticsAPI; +use datadog_api_client::datadogV2::model::DeletedSuitesRequestDelete; +use datadog_api_client::datadogV2::model::DeletedSuitesRequestDeleteAttributes; +use datadog_api_client::datadogV2::model::DeletedSuitesRequestDeleteRequest; +use datadog_api_client::datadogV2::model::DeletedSuitesRequestType; + +#[tokio::main] +async fn main() { + let body = DeletedSuitesRequestDeleteRequest::new( + DeletedSuitesRequestDelete::new(DeletedSuitesRequestDeleteAttributes::new(vec![ + "".to_string() + ])) + .type_(DeletedSuitesRequestType::DELETE_SUITES_REQUEST), + ); + let configuration = datadog::Configuration::new(); + let api = SyntheticsAPI::with_config(configuration); + let resp = api.delete_synthetics_suites(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_synthetics_EditSyntheticsSuite.rs b/examples/v2_synthetics_EditSyntheticsSuite.rs new file mode 100644 index 000000000..cbf5ce187 --- /dev/null +++ b/examples/v2_synthetics_EditSyntheticsSuite.rs @@ -0,0 +1,36 @@ +// Synthetics: edit a test suite returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_synthetics::SyntheticsAPI; +use datadog_api_client::datadogV2::model::SuiteCreateEdit; +use datadog_api_client::datadogV2::model::SuiteCreateEditRequest; +use datadog_api_client::datadogV2::model::SyntheticsSuite; +use datadog_api_client::datadogV2::model::SyntheticsSuiteOptions; +use datadog_api_client::datadogV2::model::SyntheticsSuiteTest; +use datadog_api_client::datadogV2::model::SyntheticsSuiteTestAlertingCriticality; +use datadog_api_client::datadogV2::model::SyntheticsSuiteType; + +#[tokio::main] +async fn main() { + let body = SuiteCreateEditRequest::new(SuiteCreateEdit::new( + SyntheticsSuite::new( + "Notification message".to_string(), + "Example suite name".to_string(), + SyntheticsSuiteOptions::new(), + vec![SyntheticsSuiteTest::new("".to_string()) + .alerting_criticality(SyntheticsSuiteTestAlertingCriticality::CRITICAL)], + SyntheticsSuiteType::SUITE, + ) + .tags(vec!["env:production".to_string()]), + SyntheticsSuiteType::SUITE, + )); + let configuration = datadog::Configuration::new(); + let api = SyntheticsAPI::with_config(configuration); + let resp = api + .edit_synthetics_suite("public_id".to_string(), body) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_synthetics_GetSyntheticsSuite.rs b/examples/v2_synthetics_GetSyntheticsSuite.rs new file mode 100644 index 000000000..b8bee3b74 --- /dev/null +++ b/examples/v2_synthetics_GetSyntheticsSuite.rs @@ -0,0 +1,15 @@ +// Synthetics: Get a suite returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_synthetics::SyntheticsAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = SyntheticsAPI::with_config(configuration); + let resp = api.get_synthetics_suite("public_id".to_string()).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_synthetics_SearchSuites.rs b/examples/v2_synthetics_SearchSuites.rs new file mode 100644 index 000000000..cee51134b --- /dev/null +++ b/examples/v2_synthetics_SearchSuites.rs @@ -0,0 +1,18 @@ +// Search Synthetics suites returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_synthetics::SearchSuitesOptionalParams; +use datadog_api_client::datadogV2::api_synthetics::SyntheticsAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = SyntheticsAPI::with_config(configuration); + let resp = api + .search_suites(SearchSuitesOptionalParams::default()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadogV2/api/api_synthetics.rs b/src/datadogV2/api/api_synthetics.rs index ad52dd80f..9c9729541 100644 --- a/src/datadogV2/api/api_synthetics.rs +++ b/src/datadogV2/api/api_synthetics.rs @@ -10,6 +10,74 @@ use reqwest::header::{HeaderMap, HeaderValue}; use serde::{Deserialize, Serialize}; use std::io::Write; +/// SearchSuitesOptionalParams is a struct for passing parameters to the method [`SyntheticsAPI::search_suites`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct SearchSuitesOptionalParams { + /// The search query. + pub query: Option, + /// The sort order for the results (e.g., `name,asc` or `name,desc`). + pub sort: Option, + /// If true, return only facets instead of full test details. + pub facets_only: Option, + /// The offset from which to start returning results. + pub start: Option, + /// The maximum number of results to return. + pub count: Option, +} + +impl SearchSuitesOptionalParams { + /// The search query. + pub fn query(mut self, value: String) -> Self { + self.query = Some(value); + self + } + /// The sort order for the results (e.g., `name,asc` or `name,desc`). + pub fn sort(mut self, value: String) -> Self { + self.sort = Some(value); + self + } + /// If true, return only facets instead of full test details. + pub fn facets_only(mut self, value: bool) -> Self { + self.facets_only = Some(value); + self + } + /// The offset from which to start returning results. + pub fn start(mut self, value: i64) -> Self { + self.start = Some(value); + self + } + /// The maximum number of results to return. + pub fn count(mut self, value: i64) -> Self { + self.count = Some(value); + self + } +} + +/// CreateSyntheticsSuiteError is a struct for typed errors of method [`SyntheticsAPI::create_synthetics_suite`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateSyntheticsSuiteError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// DeleteSyntheticsSuitesError is a struct for typed errors of method [`SyntheticsAPI::delete_synthetics_suites`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteSyntheticsSuitesError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// EditSyntheticsSuiteError is a struct for typed errors of method [`SyntheticsAPI::edit_synthetics_suite`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum EditSyntheticsSuiteError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// GetOnDemandConcurrencyCapError is a struct for typed errors of method [`SyntheticsAPI::get_on_demand_concurrency_cap`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -18,6 +86,22 @@ pub enum GetOnDemandConcurrencyCapError { UnknownValue(serde_json::Value), } +/// GetSyntheticsSuiteError is a struct for typed errors of method [`SyntheticsAPI::get_synthetics_suite`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetSyntheticsSuiteError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// SearchSuitesError is a struct for typed errors of method [`SyntheticsAPI::search_suites`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SearchSuitesError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// SetOnDemandConcurrencyCapError is a struct for typed errors of method [`SyntheticsAPI::set_on_demand_concurrency_cap`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -97,14 +181,14 @@ impl SyntheticsAPI { Self { config, client } } - /// Get the on-demand concurrency cap. - pub async fn get_on_demand_concurrency_cap( + pub async fn create_synthetics_suite( &self, + body: crate::datadogV2::model::SuiteCreateEditRequest, ) -> Result< - crate::datadogV2::model::OnDemandConcurrencyCapResponse, - datadog::Error, + crate::datadogV2::model::SyntheticsSuiteResponse, + datadog::Error, > { - match self.get_on_demand_concurrency_cap_with_http_info().await { + match self.create_synthetics_suite_with_http_info(body).await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -118,27 +202,28 @@ impl SyntheticsAPI { } } - /// Get the on-demand concurrency cap. - pub async fn get_on_demand_concurrency_cap_with_http_info( + pub async fn create_synthetics_suite_with_http_info( &self, + body: crate::datadogV2::model::SuiteCreateEditRequest, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.get_on_demand_concurrency_cap"; + let operation_id = "v2.create_synthetics_suite"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/synthetics/settings/on_demand_concurrency_cap", + "{}/api/v2/synthetics/suites", local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = - local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); // build headers let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); headers.insert("Accept", HeaderValue::from_static("application/json")); // build user agent @@ -169,6 +254,51 @@ impl SyntheticsAPI { ); }; + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + local_req_builder = local_req_builder.headers(headers); let local_req = local_req_builder.build()?; log::debug!("request content: {:?}", local_req.body()); @@ -179,7 +309,7 @@ impl SyntheticsAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( + match serde_json::from_str::( &local_content, ) { Ok(e) => { @@ -192,7 +322,159 @@ impl SyntheticsAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + 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)) + } + } + + pub async fn delete_synthetics_suites( + &self, + body: crate::datadogV2::model::DeletedSuitesRequestDeleteRequest, + ) -> Result< + crate::datadogV2::model::DeletedSuitesResponse, + datadog::Error, + > { + match self.delete_synthetics_suites_with_http_info(body).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), + } + } + + pub async fn delete_synthetics_suites_with_http_info( + &self, + body: crate::datadogV2::model::DeletedSuitesRequestDeleteRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.delete_synthetics_suites"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/synthetics/suites/bulk-delete", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + 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"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + 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, @@ -203,6 +485,512 @@ impl SyntheticsAPI { } } + pub async fn edit_synthetics_suite( + &self, + public_id: String, + body: crate::datadogV2::model::SuiteCreateEditRequest, + ) -> Result< + crate::datadogV2::model::SyntheticsSuiteResponse, + datadog::Error, + > { + match self + .edit_synthetics_suite_with_http_info(public_id, body) + .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), + } + } + + pub async fn edit_synthetics_suite_with_http_info( + &self, + public_id: String, + body: crate::datadogV2::model::SuiteCreateEditRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.edit_synthetics_suite"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/synthetics/suites/{public_id}", + local_configuration.get_operation_host(operation_id), + public_id = datadog::urlencode(public_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::PUT, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + 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"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + 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 on-demand concurrency cap. + pub async fn get_on_demand_concurrency_cap( + &self, + ) -> Result< + crate::datadogV2::model::OnDemandConcurrencyCapResponse, + datadog::Error, + > { + match self.get_on_demand_concurrency_cap_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 on-demand concurrency cap. + pub async fn get_on_demand_concurrency_cap_with_http_info( + &self, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_on_demand_concurrency_cap"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/synthetics/settings/on_demand_concurrency_cap", + 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::( + &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)) + } + } + + pub async fn get_synthetics_suite( + &self, + public_id: String, + ) -> Result< + crate::datadogV2::model::SyntheticsSuiteResponse, + datadog::Error, + > { + match self.get_synthetics_suite_with_http_info(public_id).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + pub async fn get_synthetics_suite_with_http_info( + &self, + public_id: String, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_synthetics_suite"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/synthetics/suites/{public_id}", + local_configuration.get_operation_host(operation_id), + public_id = datadog::urlencode(public_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::( + &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)) + } + } + + /// Search for Synthetics suites. + pub async fn search_suites( + &self, + params: SearchSuitesOptionalParams, + ) -> Result< + crate::datadogV2::model::SyntheticsSuiteSearchResponse, + datadog::Error, + > { + match self.search_suites_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), + } + } + + /// Search for Synthetics suites. + pub async fn search_suites_with_http_info( + &self, + params: SearchSuitesOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.search_suites"; + + // unbox and build optional parameters + let query = params.query; + let sort = params.sort; + let facets_only = params.facets_only; + let start = params.start; + let count = params.count; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/synthetics/suites/search", + 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) = query { + local_req_builder = + local_req_builder.query(&[("query", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = sort { + local_req_builder = + local_req_builder.query(&[("sort", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = facets_only { + local_req_builder = + local_req_builder.query(&[("facets_only", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = start { + local_req_builder = + local_req_builder.query(&[("start", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = count { + local_req_builder = + local_req_builder.query(&[("count", &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)) + } + } + /// Save new value for on-demand concurrency cap. pub async fn set_on_demand_concurrency_cap( &self, diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 2278040e0..6640a3c83 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -6682,6 +6682,48 @@ pub mod model_on_demand_concurrency_cap_attributes; pub use self::model_on_demand_concurrency_cap_attributes::OnDemandConcurrencyCapAttributes; pub mod model_on_demand_concurrency_cap_type; pub use self::model_on_demand_concurrency_cap_type::OnDemandConcurrencyCapType; +pub mod model_suite_create_edit_request; +pub use self::model_suite_create_edit_request::SuiteCreateEditRequest; +pub mod model_suite_create_edit; +pub use self::model_suite_create_edit::SuiteCreateEdit; +pub mod model_synthetics_suite; +pub use self::model_synthetics_suite::SyntheticsSuite; +pub mod model_synthetics_suite_options; +pub use self::model_synthetics_suite_options::SyntheticsSuiteOptions; +pub mod model_synthetics_suite_test; +pub use self::model_synthetics_suite_test::SyntheticsSuiteTest; +pub mod model_synthetics_suite_test_alerting_criticality; +pub use self::model_synthetics_suite_test_alerting_criticality::SyntheticsSuiteTestAlertingCriticality; +pub mod model_synthetics_suite_type; +pub use self::model_synthetics_suite_type::SyntheticsSuiteType; +pub mod model_synthetics_suite_response; +pub use self::model_synthetics_suite_response::SyntheticsSuiteResponse; +pub mod model_synthetics_suite_response_data; +pub use self::model_synthetics_suite_response_data::SyntheticsSuiteResponseData; +pub mod model_deleted_suites_request_delete_request; +pub use self::model_deleted_suites_request_delete_request::DeletedSuitesRequestDeleteRequest; +pub mod model_deleted_suites_request_delete; +pub use self::model_deleted_suites_request_delete::DeletedSuitesRequestDelete; +pub mod model_deleted_suites_request_delete_attributes; +pub use self::model_deleted_suites_request_delete_attributes::DeletedSuitesRequestDeleteAttributes; +pub mod model_deleted_suites_request_type; +pub use self::model_deleted_suites_request_type::DeletedSuitesRequestType; +pub mod model_deleted_suites_response; +pub use self::model_deleted_suites_response::DeletedSuitesResponse; +pub mod model_deleted_suite_response_data; +pub use self::model_deleted_suite_response_data::DeletedSuiteResponseData; +pub mod model_deleted_suite_response_data_attributes; +pub use self::model_deleted_suite_response_data_attributes::DeletedSuiteResponseDataAttributes; +pub mod model_deleted_suite_type; +pub use self::model_deleted_suite_type::DeletedSuiteType; +pub mod model_synthetics_suite_search_response; +pub use self::model_synthetics_suite_search_response::SyntheticsSuiteSearchResponse; +pub mod model_synthetics_suite_search_response_data; +pub use self::model_synthetics_suite_search_response_data::SyntheticsSuiteSearchResponseData; +pub mod model_synthetics_suite_search_response_data_attributes; +pub use self::model_synthetics_suite_search_response_data_attributes::SyntheticsSuiteSearchResponseDataAttributes; +pub mod model_suite_search_response_type; +pub use self::model_suite_search_response_type::SuiteSearchResponseType; pub mod model_ruleset_resp_array; pub use self::model_ruleset_resp_array::RulesetRespArray; pub mod model_ruleset_resp_data; diff --git a/src/datadogV2/model/model_deleted_suite_response_data.rs b/src/datadogV2/model/model_deleted_suite_response_data.rs new file mode 100644 index 000000000..f619ab71a --- /dev/null +++ b/src/datadogV2/model/model_deleted_suite_response_data.rs @@ -0,0 +1,150 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DeletedSuiteResponseData { + #[serde(rename = "attributes")] + pub attributes: Option, + #[serde(rename = "id")] + pub id: Option, + #[serde(rename = "type")] + pub type_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DeletedSuiteResponseData { + pub fn new() -> DeletedSuiteResponseData { + DeletedSuiteResponseData { + attributes: None, + id: None, + type_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::DeletedSuiteResponseDataAttributes, + ) -> 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::DeletedSuiteType) -> 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 DeletedSuiteResponseData { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for DeletedSuiteResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DeletedSuiteResponseDataVisitor; + impl<'a> Visitor<'a> for DeletedSuiteResponseDataVisitor { + type Value = DeletedSuiteResponseData; + + 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::DeletedSuiteResponseDataAttributes, + > = 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::DeletedSuiteType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = DeletedSuiteResponseData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DeletedSuiteResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_deleted_suite_response_data_attributes.rs b/src/datadogV2/model/model_deleted_suite_response_data_attributes.rs new file mode 100644 index 000000000..4532e2654 --- /dev/null +++ b/src/datadogV2/model/model_deleted_suite_response_data_attributes.rs @@ -0,0 +1,121 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DeletedSuiteResponseDataAttributes { + /// Deletion timestamp of the Synthetic suite ID. + #[serde(rename = "deleted_at")] + pub deleted_at: Option, + /// The Synthetic suite ID deleted. + #[serde(rename = "public_id")] + pub public_id: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DeletedSuiteResponseDataAttributes { + pub fn new() -> DeletedSuiteResponseDataAttributes { + DeletedSuiteResponseDataAttributes { + deleted_at: None, + public_id: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn deleted_at(mut self, value: String) -> Self { + self.deleted_at = Some(value); + self + } + + pub fn public_id(mut self, value: String) -> Self { + self.public_id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for DeletedSuiteResponseDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for DeletedSuiteResponseDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DeletedSuiteResponseDataAttributesVisitor; + impl<'a> Visitor<'a> for DeletedSuiteResponseDataAttributesVisitor { + type Value = DeletedSuiteResponseDataAttributes; + + 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 deleted_at: Option = None; + let mut public_id: 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() { + "deleted_at" => { + if v.is_null() { + continue; + } + deleted_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "public_id" => { + if v.is_null() { + continue; + } + public_id = 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 = DeletedSuiteResponseDataAttributes { + deleted_at, + public_id, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DeletedSuiteResponseDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_deleted_suite_type.rs b/src/datadogV2/model/model_deleted_suite_type.rs new file mode 100644 index 000000000..c882cf806 --- /dev/null +++ b/src/datadogV2/model/model_deleted_suite_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 DeletedSuiteType { + SUITES, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for DeletedSuiteType { + fn to_string(&self) -> String { + match self { + Self::SUITES => String::from("suites"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for DeletedSuiteType { + 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 DeletedSuiteType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "suites" => Self::SUITES, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_deleted_suites_request_delete.rs b/src/datadogV2/model/model_deleted_suites_request_delete.rs new file mode 100644 index 000000000..229695259 --- /dev/null +++ b/src/datadogV2/model/model_deleted_suites_request_delete.rs @@ -0,0 +1,134 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DeletedSuitesRequestDelete { + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::DeletedSuitesRequestDeleteAttributes, + #[serde(rename = "id")] + pub id: Option, + #[serde(rename = "type")] + pub type_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DeletedSuitesRequestDelete { + pub fn new( + attributes: crate::datadogV2::model::DeletedSuitesRequestDeleteAttributes, + ) -> DeletedSuitesRequestDelete { + DeletedSuitesRequestDelete { + attributes, + id: None, + type_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn type_(mut self, value: crate::datadogV2::model::DeletedSuitesRequestType) -> Self { + self.type_ = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DeletedSuitesRequestDelete { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DeletedSuitesRequestDeleteVisitor; + impl<'a> Visitor<'a> for DeletedSuitesRequestDeleteVisitor { + type Value = DeletedSuitesRequestDelete; + + 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::DeletedSuitesRequestDeleteAttributes, + > = 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" => { + 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::DeletedSuitesRequestType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + + let content = DeletedSuitesRequestDelete { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DeletedSuitesRequestDeleteVisitor) + } +} diff --git a/src/datadogV2/model/model_deleted_suites_request_delete_attributes.rs b/src/datadogV2/model/model_deleted_suites_request_delete_attributes.rs new file mode 100644 index 000000000..9d1770057 --- /dev/null +++ b/src/datadogV2/model/model_deleted_suites_request_delete_attributes.rs @@ -0,0 +1,107 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DeletedSuitesRequestDeleteAttributes { + #[serde(rename = "force_delete_dependencies")] + pub force_delete_dependencies: Option, + #[serde(rename = "public_ids")] + pub public_ids: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DeletedSuitesRequestDeleteAttributes { + pub fn new(public_ids: Vec) -> DeletedSuitesRequestDeleteAttributes { + DeletedSuitesRequestDeleteAttributes { + force_delete_dependencies: None, + public_ids, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn force_delete_dependencies(mut self, value: bool) -> Self { + self.force_delete_dependencies = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DeletedSuitesRequestDeleteAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DeletedSuitesRequestDeleteAttributesVisitor; + impl<'a> Visitor<'a> for DeletedSuitesRequestDeleteAttributesVisitor { + type Value = DeletedSuitesRequestDeleteAttributes; + + 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 force_delete_dependencies: Option = None; + let mut public_ids: 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() { + "force_delete_dependencies" => { + if v.is_null() { + continue; + } + force_delete_dependencies = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "public_ids" => { + public_ids = 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 public_ids = public_ids.ok_or_else(|| M::Error::missing_field("public_ids"))?; + + let content = DeletedSuitesRequestDeleteAttributes { + force_delete_dependencies, + public_ids, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DeletedSuitesRequestDeleteAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_deleted_suites_request_delete_request.rs b/src/datadogV2/model/model_deleted_suites_request_delete_request.rs new file mode 100644 index 000000000..23c522701 --- /dev/null +++ b/src/datadogV2/model/model_deleted_suites_request_delete_request.rs @@ -0,0 +1,92 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DeletedSuitesRequestDeleteRequest { + #[serde(rename = "data")] + pub data: crate::datadogV2::model::DeletedSuitesRequestDelete, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DeletedSuitesRequestDeleteRequest { + pub fn new( + data: crate::datadogV2::model::DeletedSuitesRequestDelete, + ) -> DeletedSuitesRequestDeleteRequest { + DeletedSuitesRequestDeleteRequest { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DeletedSuitesRequestDeleteRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DeletedSuitesRequestDeleteRequestVisitor; + impl<'a> Visitor<'a> for DeletedSuitesRequestDeleteRequestVisitor { + type Value = DeletedSuitesRequestDeleteRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = DeletedSuitesRequestDeleteRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DeletedSuitesRequestDeleteRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_deleted_suites_request_type.rs b/src/datadogV2/model/model_deleted_suites_request_type.rs new file mode 100644 index 000000000..dcbb0049a --- /dev/null +++ b/src/datadogV2/model/model_deleted_suites_request_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 DeletedSuitesRequestType { + DELETE_SUITES_REQUEST, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for DeletedSuitesRequestType { + fn to_string(&self) -> String { + match self { + Self::DELETE_SUITES_REQUEST => String::from("delete_suites_request"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for DeletedSuitesRequestType { + 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 DeletedSuitesRequestType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "delete_suites_request" => Self::DELETE_SUITES_REQUEST, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_deleted_suites_response.rs b/src/datadogV2/model/model_deleted_suites_response.rs new file mode 100644 index 000000000..ce22e83c6 --- /dev/null +++ b/src/datadogV2/model/model_deleted_suites_response.rs @@ -0,0 +1,103 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DeletedSuitesResponse { + #[serde(rename = "data")] + pub data: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DeletedSuitesResponse { + pub fn new() -> DeletedSuitesResponse { + DeletedSuitesResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: Vec) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for DeletedSuitesResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for DeletedSuitesResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DeletedSuitesResponseVisitor; + impl<'a> Visitor<'a> for DeletedSuitesResponseVisitor { + type Value = DeletedSuitesResponse; + + 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 = DeletedSuitesResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DeletedSuitesResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_suite_create_edit.rs b/src/datadogV2/model/model_suite_create_edit.rs new file mode 100644 index 000000000..5b63571ed --- /dev/null +++ b/src/datadogV2/model/model_suite_create_edit.rs @@ -0,0 +1,112 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SuiteCreateEdit { + /// Object containing details about a Synthetic suite. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::SyntheticsSuite, + /// Type of the Synthetic suite, `suite`. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::SyntheticsSuiteType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SuiteCreateEdit { + pub fn new( + attributes: crate::datadogV2::model::SyntheticsSuite, + type_: crate::datadogV2::model::SyntheticsSuiteType, + ) -> SuiteCreateEdit { + SuiteCreateEdit { + attributes, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for SuiteCreateEdit { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SuiteCreateEditVisitor; + impl<'a> Visitor<'a> for SuiteCreateEditVisitor { + type Value = SuiteCreateEdit; + + 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 type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::SyntheticsSuiteType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = SuiteCreateEdit { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SuiteCreateEditVisitor) + } +} diff --git a/src/datadogV2/model/model_suite_create_edit_request.rs b/src/datadogV2/model/model_suite_create_edit_request.rs new file mode 100644 index 000000000..7cb61e581 --- /dev/null +++ b/src/datadogV2/model/model_suite_create_edit_request.rs @@ -0,0 +1,90 @@ +// 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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SuiteCreateEditRequest { + #[serde(rename = "data")] + pub data: crate::datadogV2::model::SuiteCreateEdit, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SuiteCreateEditRequest { + pub fn new(data: crate::datadogV2::model::SuiteCreateEdit) -> SuiteCreateEditRequest { + SuiteCreateEditRequest { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for SuiteCreateEditRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SuiteCreateEditRequestVisitor; + impl<'a> Visitor<'a> for SuiteCreateEditRequestVisitor { + type Value = SuiteCreateEditRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = SuiteCreateEditRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SuiteCreateEditRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_suite_search_response_type.rs b/src/datadogV2/model/model_suite_search_response_type.rs new file mode 100644 index 000000000..eb7c097cd --- /dev/null +++ b/src/datadogV2/model/model_suite_search_response_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 SuiteSearchResponseType { + SUITES_SEARCH, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for SuiteSearchResponseType { + fn to_string(&self) -> String { + match self { + Self::SUITES_SEARCH => String::from("suites_search"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for SuiteSearchResponseType { + 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 SuiteSearchResponseType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "suites_search" => Self::SUITES_SEARCH, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_synthetics_suite.rs b/src/datadogV2/model/model_synthetics_suite.rs new file mode 100644 index 000000000..f043d3fb7 --- /dev/null +++ b/src/datadogV2/model/model_synthetics_suite.rs @@ -0,0 +1,179 @@ +// 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}; + +/// Object containing details about a Synthetic suite. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SyntheticsSuite { + /// Notification message associated with the suite. + #[serde(rename = "message")] + pub message: String, + /// Name of the suite. + #[serde(rename = "name")] + pub name: String, + /// Object describing the extra options for a Synthetic suite. + #[serde(rename = "options")] + pub options: crate::datadogV2::model::SyntheticsSuiteOptions, + /// The public ID for the test. + #[serde(rename = "public_id")] + pub public_id: Option, + /// Array of tags attached to the suite. + #[serde(rename = "tags")] + pub tags: Option>, + #[serde(rename = "tests")] + pub tests: Vec, + /// Type of the Synthetic suite, `suite`. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::SyntheticsSuiteType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SyntheticsSuite { + pub fn new( + message: String, + name: String, + options: crate::datadogV2::model::SyntheticsSuiteOptions, + tests: Vec, + type_: crate::datadogV2::model::SyntheticsSuiteType, + ) -> SyntheticsSuite { + SyntheticsSuite { + message, + name, + options, + public_id: None, + tags: None, + tests, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn public_id(mut self, value: String) -> Self { + self.public_id = Some(value); + self + } + + pub fn tags(mut self, value: Vec) -> Self { + self.tags = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for SyntheticsSuite { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SyntheticsSuiteVisitor; + impl<'a> Visitor<'a> for SyntheticsSuiteVisitor { + type Value = SyntheticsSuite; + + 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 message: Option = None; + let mut name: Option = None; + let mut options: Option = None; + let mut public_id: Option = None; + let mut tags: Option> = None; + let mut tests: 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() { + "message" => { + message = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "options" => { + options = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "public_id" => { + if v.is_null() { + continue; + } + public_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "tags" => { + if v.is_null() { + continue; + } + tags = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "tests" => { + tests = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::SyntheticsSuiteType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let message = message.ok_or_else(|| M::Error::missing_field("message"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let options = options.ok_or_else(|| M::Error::missing_field("options"))?; + let tests = tests.ok_or_else(|| M::Error::missing_field("tests"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = SyntheticsSuite { + message, + name, + options, + public_id, + tags, + tests, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SyntheticsSuiteVisitor) + } +} diff --git a/src/datadogV2/model/model_synthetics_suite_options.rs b/src/datadogV2/model/model_synthetics_suite_options.rs new file mode 100644 index 000000000..d1665c6b5 --- /dev/null +++ b/src/datadogV2/model/model_synthetics_suite_options.rs @@ -0,0 +1,106 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Object describing the extra options for a Synthetic suite. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SyntheticsSuiteOptions { + /// Percentage of critical tests failure needed for a suite to fail. + #[serde(rename = "alerting_threshold")] + pub alerting_threshold: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SyntheticsSuiteOptions { + pub fn new() -> SyntheticsSuiteOptions { + SyntheticsSuiteOptions { + alerting_threshold: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn alerting_threshold(mut self, value: f64) -> Self { + self.alerting_threshold = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for SyntheticsSuiteOptions { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for SyntheticsSuiteOptions { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SyntheticsSuiteOptionsVisitor; + impl<'a> Visitor<'a> for SyntheticsSuiteOptionsVisitor { + type Value = SyntheticsSuiteOptions; + + 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 alerting_threshold: 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() { + "alerting_threshold" => { + if v.is_null() { + continue; + } + alerting_threshold = + 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 = SyntheticsSuiteOptions { + alerting_threshold, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SyntheticsSuiteOptionsVisitor) + } +} diff --git a/src/datadogV2/model/model_synthetics_suite_response.rs b/src/datadogV2/model/model_synthetics_suite_response.rs new file mode 100644 index 000000000..d641dcc77 --- /dev/null +++ b/src/datadogV2/model/model_synthetics_suite_response.rs @@ -0,0 +1,105 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Synthetics suite response +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SyntheticsSuiteResponse { + /// Synthetics suite response data + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SyntheticsSuiteResponse { + pub fn new() -> SyntheticsSuiteResponse { + SyntheticsSuiteResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::SyntheticsSuiteResponseData) -> 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 SyntheticsSuiteResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for SyntheticsSuiteResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SyntheticsSuiteResponseVisitor; + impl<'a> Visitor<'a> for SyntheticsSuiteResponseVisitor { + type Value = SyntheticsSuiteResponse; + + 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 = SyntheticsSuiteResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SyntheticsSuiteResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_synthetics_suite_response_data.rs b/src/datadogV2/model/model_synthetics_suite_response_data.rs new file mode 100644 index 000000000..c0f4127e0 --- /dev/null +++ b/src/datadogV2/model/model_synthetics_suite_response_data.rs @@ -0,0 +1,105 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Synthetics suite response data +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SyntheticsSuiteResponseData { + /// Object containing details about a Synthetic suite. + #[serde(rename = "attributes")] + pub attributes: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SyntheticsSuiteResponseData { + pub fn new() -> SyntheticsSuiteResponseData { + SyntheticsSuiteResponseData { + attributes: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes(mut self, value: crate::datadogV2::model::SyntheticsSuite) -> Self { + self.attributes = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for SyntheticsSuiteResponseData { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for SyntheticsSuiteResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SyntheticsSuiteResponseDataVisitor; + impl<'a> Visitor<'a> for SyntheticsSuiteResponseDataVisitor { + type Value = SyntheticsSuiteResponseData; + + 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 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)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = SyntheticsSuiteResponseData { + attributes, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SyntheticsSuiteResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_synthetics_suite_search_response.rs b/src/datadogV2/model/model_synthetics_suite_search_response.rs new file mode 100644 index 000000000..d4f6169f5 --- /dev/null +++ b/src/datadogV2/model/model_synthetics_suite_search_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}; + +/// Synthetics suite search response +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SyntheticsSuiteSearchResponse { + /// Synthetics suite search response data + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SyntheticsSuiteSearchResponse { + pub fn new() -> SyntheticsSuiteSearchResponse { + SyntheticsSuiteSearchResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: crate::datadogV2::model::SyntheticsSuiteSearchResponseData, + ) -> 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 SyntheticsSuiteSearchResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for SyntheticsSuiteSearchResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SyntheticsSuiteSearchResponseVisitor; + impl<'a> Visitor<'a> for SyntheticsSuiteSearchResponseVisitor { + type Value = SyntheticsSuiteSearchResponse; + + 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 = SyntheticsSuiteSearchResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SyntheticsSuiteSearchResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_synthetics_suite_search_response_data.rs b/src/datadogV2/model/model_synthetics_suite_search_response_data.rs new file mode 100644 index 000000000..3a7429851 --- /dev/null +++ b/src/datadogV2/model/model_synthetics_suite_search_response_data.rs @@ -0,0 +1,150 @@ +// 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}; + +/// Synthetics suite search response data +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SyntheticsSuiteSearchResponseData { + /// Synthetics suite search response data attributes + #[serde(rename = "attributes")] + pub attributes: Option, + #[serde(rename = "id")] + pub id: Option, + #[serde(rename = "type")] + pub type_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SyntheticsSuiteSearchResponseData { + pub fn new() -> SyntheticsSuiteSearchResponseData { + SyntheticsSuiteSearchResponseData { + attributes: None, + id: None, + type_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::SyntheticsSuiteSearchResponseDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: uuid::Uuid) -> Self { + self.id = Some(value); + self + } + + pub fn type_(mut self, value: crate::datadogV2::model::SuiteSearchResponseType) -> 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 SyntheticsSuiteSearchResponseData { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for SyntheticsSuiteSearchResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SyntheticsSuiteSearchResponseDataVisitor; + impl<'a> Visitor<'a> for SyntheticsSuiteSearchResponseDataVisitor { + type Value = SyntheticsSuiteSearchResponseData; + + 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::SyntheticsSuiteSearchResponseDataAttributes, + > = 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::SuiteSearchResponseType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = SyntheticsSuiteSearchResponseData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SyntheticsSuiteSearchResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_synthetics_suite_search_response_data_attributes.rs b/src/datadogV2/model/model_synthetics_suite_search_response_data_attributes.rs new file mode 100644 index 000000000..3e19f16b7 --- /dev/null +++ b/src/datadogV2/model/model_synthetics_suite_search_response_data_attributes.rs @@ -0,0 +1,120 @@ +// 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}; + +/// Synthetics suite search response data attributes +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SyntheticsSuiteSearchResponseDataAttributes { + #[serde(rename = "suites")] + pub suites: Option>, + #[serde(rename = "total")] + pub total: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SyntheticsSuiteSearchResponseDataAttributes { + pub fn new() -> SyntheticsSuiteSearchResponseDataAttributes { + SyntheticsSuiteSearchResponseDataAttributes { + suites: None, + total: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn suites(mut self, value: Vec) -> Self { + self.suites = Some(value); + self + } + + pub fn total(mut self, value: i32) -> Self { + self.total = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for SyntheticsSuiteSearchResponseDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for SyntheticsSuiteSearchResponseDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SyntheticsSuiteSearchResponseDataAttributesVisitor; + impl<'a> Visitor<'a> for SyntheticsSuiteSearchResponseDataAttributesVisitor { + type Value = SyntheticsSuiteSearchResponseDataAttributes; + + 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 suites: Option> = None; + let mut total: 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() { + "suites" => { + if v.is_null() { + continue; + } + suites = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "total" => { + if v.is_null() { + continue; + } + total = 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 = SyntheticsSuiteSearchResponseDataAttributes { + suites, + total, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SyntheticsSuiteSearchResponseDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_synthetics_suite_test.rs b/src/datadogV2/model/model_synthetics_suite_test.rs new file mode 100644 index 000000000..e1da92381 --- /dev/null +++ b/src/datadogV2/model/model_synthetics_suite_test.rs @@ -0,0 +1,123 @@ +// 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}; + +/// Object containing details about a Synthetic test included in a Synthetic suite. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SyntheticsSuiteTest { + /// Alerting criticality for each the test. + #[serde(rename = "alerting_criticality")] + pub alerting_criticality: + Option, + #[serde(rename = "public_id")] + pub public_id: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SyntheticsSuiteTest { + pub fn new(public_id: String) -> SyntheticsSuiteTest { + SyntheticsSuiteTest { + alerting_criticality: None, + public_id, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn alerting_criticality( + mut self, + value: crate::datadogV2::model::SyntheticsSuiteTestAlertingCriticality, + ) -> Self { + self.alerting_criticality = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for SyntheticsSuiteTest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SyntheticsSuiteTestVisitor; + impl<'a> Visitor<'a> for SyntheticsSuiteTestVisitor { + type Value = SyntheticsSuiteTest; + + 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 alerting_criticality: Option< + crate::datadogV2::model::SyntheticsSuiteTestAlertingCriticality, + > = None; + let mut public_id: 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() { + "alerting_criticality" => { + if v.is_null() { + continue; + } + alerting_criticality = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _alerting_criticality) = alerting_criticality { + match _alerting_criticality { + crate::datadogV2::model::SyntheticsSuiteTestAlertingCriticality::UnparsedObject(_alerting_criticality) => { + _unparsed = true; + }, + _ => {} + } + } + } + "public_id" => { + public_id = 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 public_id = public_id.ok_or_else(|| M::Error::missing_field("public_id"))?; + + let content = SyntheticsSuiteTest { + alerting_criticality, + public_id, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SyntheticsSuiteTestVisitor) + } +} diff --git a/src/datadogV2/model/model_synthetics_suite_test_alerting_criticality.rs b/src/datadogV2/model/model_synthetics_suite_test_alerting_criticality.rs new file mode 100644 index 000000000..997120048 --- /dev/null +++ b/src/datadogV2/model/model_synthetics_suite_test_alerting_criticality.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 SyntheticsSuiteTestAlertingCriticality { + IGNORE, + CRITICAL, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for SyntheticsSuiteTestAlertingCriticality { + fn to_string(&self) -> String { + match self { + Self::IGNORE => String::from("ignore"), + Self::CRITICAL => String::from("critical"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for SyntheticsSuiteTestAlertingCriticality { + 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 SyntheticsSuiteTestAlertingCriticality { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "ignore" => Self::IGNORE, + "critical" => Self::CRITICAL, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_synthetics_suite_type.rs b/src/datadogV2/model/model_synthetics_suite_type.rs new file mode 100644 index 000000000..a75fd0e20 --- /dev/null +++ b/src/datadogV2/model/model_synthetics_suite_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 SyntheticsSuiteType { + SUITE, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for SyntheticsSuiteType { + fn to_string(&self) -> String { + match self { + Self::SUITE => String::from("suite"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for SyntheticsSuiteType { + 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 SyntheticsSuiteType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "suite" => Self::SUITE, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/tests/scenarios/features/v2/synthetics.feature b/tests/scenarios/features/v2/synthetics.feature index 73efa73ec..4df8a547f 100644 --- a/tests/scenarios/features/v2/synthetics.feature +++ b/tests/scenarios/features/v2/synthetics.feature @@ -27,3 +27,73 @@ Feature: Synthetics When the request is sent Then the response status is 200 OK And the response "data.attributes.on_demand_concurrency_cap" is equal to 20 + + @generated @skip @team:DataDog/synthetics-managing + Scenario: Search Synthetics suites returns "API error response." response + Given new "SearchSuites" request + When the request is sent + Then the response status is 400 API error response. + + @team:DataDog/synthetics-managing + Scenario: Search Synthetics suites returns "OK" response + Given new "SearchSuites" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/synthetics-managing + Scenario: Synthetics: Bulk delete suites returns "API error response." response + Given new "DeleteSyntheticsSuites" request + And body with value {"data": {"attributes": {"public_ids": [""]}, "type": "delete_suites_request"}} + When the request is sent + Then the response status is 400 API error response. + + @generated @skip @team:DataDog/synthetics-managing + Scenario: Synthetics: Bulk delete suites returns "OK" response + Given new "DeleteSyntheticsSuites" request + And body with value {"data": {"attributes": {"public_ids": [""]}, "type": "delete_suites_request"}} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/synthetics-managing + Scenario: Synthetics: Create a test suite returns "API error response." response + Given new "CreateSyntheticsSuite" request + And body with value {"data": {"attributes": {"message": "Notification message", "name": "Example suite name", "options": {}, "tags": ["env:production"], "tests": [{"alerting_criticality": "critical", "public_id": ""}], "type": "suite"}, "type": "suite"}} + When the request is sent + Then the response status is 400 API error response. + + @team:DataDog/synthetics-managing + Scenario: Synthetics: Create a test suite returns "OK" response + Given new "CreateSyntheticsSuite" request + And body with value {"data": {"attributes": {"message": "Notification message", "name": "Example suite name", "options": {}, "tags": ["env:production"], "tests": [], "type": "suite"}, "type": "suite"}} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/synthetics-managing + Scenario: Synthetics: Get a suite returns "API error response." response + Given new "GetSyntheticsSuite" request + And request contains "public_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 API error response. + + @generated @skip @team:DataDog/synthetics-managing + Scenario: Synthetics: Get a suite returns "OK" response + Given new "GetSyntheticsSuite" request + And request contains "public_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/synthetics-managing + Scenario: Synthetics: edit a test suite returns "API error response." response + Given new "EditSyntheticsSuite" request + And request contains "public_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"message": "Notification message", "name": "Example suite name", "options": {}, "tags": ["env:production"], "tests": [{"alerting_criticality": "critical", "public_id": ""}], "type": "suite"}, "type": "suite"}} + When the request is sent + Then the response status is 400 API error response. + + @generated @skip @team:DataDog/synthetics-managing + Scenario: Synthetics: edit a test suite returns "OK" response + Given new "EditSyntheticsSuite" request + And request contains "public_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"message": "Notification message", "name": "Example suite name", "options": {}, "tags": ["env:production"], "tests": [{"alerting_criticality": "critical", "public_id": ""}], "type": "suite"}, "type": "suite"}} + 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 98885927f..1fbea5365 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -4413,6 +4413,43 @@ "type": "safe" } }, + "CreateSyntheticsSuite": { + "tag": "Synthetics", + "undo": { + "operationId": "DeleteSyntheticsSuites", + "parameters": [ + { + "name": "body", + "template": "{\"data\": {\"type\": \"delete_suites_request\", \"attributes\": {\"public_ids\": [\"{{ public_id }}\"]}}" + } + ], + "type": "unsafe" + } + }, + "DeleteSyntheticsSuites": { + "tag": "Synthetics", + "undo": { + "type": "idempotent" + } + }, + "SearchSuites": { + "tag": "Synthetics", + "undo": { + "type": "safe" + } + }, + "GetSyntheticsSuite": { + "tag": "Synthetics", + "undo": { + "type": "safe" + } + }, + "EditSyntheticsSuite": { + "tag": "Synthetics", + "undo": { + "type": "idempotent" + } + }, "ListTagPipelinesRulesets": { "tag": "Cloud Cost Management", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 2326eee6c..c577c45b8 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -4307,6 +4307,24 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.SetOnDemandConcurrencyCap".into(), test_v2_set_on_demand_concurrency_cap, ); + world.function_mappings.insert( + "v2.CreateSyntheticsSuite".into(), + test_v2_create_synthetics_suite, + ); + world.function_mappings.insert( + "v2.DeleteSyntheticsSuites".into(), + test_v2_delete_synthetics_suites, + ); + world + .function_mappings + .insert("v2.SearchSuites".into(), test_v2_search_suites); + world + .function_mappings + .insert("v2.GetSyntheticsSuite".into(), test_v2_get_synthetics_suite); + world.function_mappings.insert( + "v2.EditSyntheticsSuite".into(), + test_v2_edit_synthetics_suite, + ); world .function_mappings .insert("v2.ListTeams".into(), test_v2_list_teams); @@ -33215,6 +33233,155 @@ fn test_v2_set_on_demand_concurrency_cap( world.response.code = response.status.as_u16(); } +fn test_v2_create_synthetics_suite(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_synthetics + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.create_synthetics_suite_with_http_info(body)) { + 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_synthetics_suites( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_synthetics + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.delete_synthetics_suites_with_http_info(body)) { + 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_search_suites(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_synthetics + .as_ref() + .expect("api instance not found"); + let query = _parameters + .get("query") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let sort = _parameters + .get("sort") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let facets_only = _parameters + .get("facets_only") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let start = _parameters + .get("start") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let count = _parameters + .get("count") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_synthetics::SearchSuitesOptionalParams::default(); + params.query = query; + params.sort = sort; + params.facets_only = facets_only; + params.start = start; + params.count = count; + let response = match block_on(api.search_suites_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_get_synthetics_suite(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_synthetics + .as_ref() + .expect("api instance not found"); + let public_id = serde_json::from_value(_parameters.get("public_id").unwrap().clone()).unwrap(); + let response = match block_on(api.get_synthetics_suite_with_http_info(public_id)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_edit_synthetics_suite(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_synthetics + .as_ref() + .expect("api instance not found"); + let public_id = serde_json::from_value(_parameters.get("public_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.edit_synthetics_suite_with_http_info(public_id, body)) { + 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_teams(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances