From dc6a885acd31737db7c15b30d0793ca38cd6e7e8 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 21 Nov 2025 13:02:29 +0000 Subject: [PATCH] Regenerate client from commit 73f2ad5 of spec repo --- .generator/schemas/v2/openapi.yaml | 315 ++++++++++++++++++ examples/v2_synthetics_PatchGlobalVariable.rs | 32 ++ src/datadogV2/api/api_synthetics.rs | 182 ++++++++++ src/datadogV2/model/mod.rs | 36 ++ .../model/model_global_variable_data.rs | 150 +++++++++ ...odel_global_variable_json_patch_request.rs | 94 ++++++ ...global_variable_json_patch_request_data.rs | 133 ++++++++ ...able_json_patch_request_data_attributes.rs | 104 ++++++ .../model_global_variable_json_patch_type.rs | 48 +++ .../model/model_global_variable_response.rs | 105 ++++++ .../model/model_global_variable_type.rs | 48 +++ .../model/model_json_patch_operation.rs | 130 ++++++++ .../model/model_json_patch_operation_op.rs | 63 ++++ .../model/model_synthetics_global_variable.rs | 245 ++++++++++++++ ...l_synthetics_global_variable_attributes.rs | 106 ++++++ ...odel_synthetics_global_variable_options.rs | 111 ++++++ ...tics_global_variable_parse_test_options.rs | 156 +++++++++ ...global_variable_parse_test_options_type.rs | 57 ++++ ..._synthetics_global_variable_parser_type.rs | 57 ++++ ...thetics_global_variable_totp_parameters.rs | 123 +++++++ .../model_synthetics_global_variable_value.rs | 144 ++++++++ .../model/model_synthetics_variable_parser.rs | 120 +++++++ .../scenarios/features/v2/synthetics.feature | 24 ++ tests/scenarios/features/v2/undo.json | 6 + tests/scenarios/function_mappings.rs | 31 ++ 25 files changed, 2620 insertions(+) create mode 100644 examples/v2_synthetics_PatchGlobalVariable.rs create mode 100644 src/datadogV2/model/model_global_variable_data.rs create mode 100644 src/datadogV2/model/model_global_variable_json_patch_request.rs create mode 100644 src/datadogV2/model/model_global_variable_json_patch_request_data.rs create mode 100644 src/datadogV2/model/model_global_variable_json_patch_request_data_attributes.rs create mode 100644 src/datadogV2/model/model_global_variable_json_patch_type.rs create mode 100644 src/datadogV2/model/model_global_variable_response.rs create mode 100644 src/datadogV2/model/model_global_variable_type.rs create mode 100644 src/datadogV2/model/model_json_patch_operation.rs create mode 100644 src/datadogV2/model/model_json_patch_operation_op.rs create mode 100644 src/datadogV2/model/model_synthetics_global_variable.rs create mode 100644 src/datadogV2/model/model_synthetics_global_variable_attributes.rs create mode 100644 src/datadogV2/model/model_synthetics_global_variable_options.rs create mode 100644 src/datadogV2/model/model_synthetics_global_variable_parse_test_options.rs create mode 100644 src/datadogV2/model/model_synthetics_global_variable_parse_test_options_type.rs create mode 100644 src/datadogV2/model/model_synthetics_global_variable_parser_type.rs create mode 100644 src/datadogV2/model/model_synthetics_global_variable_totp_parameters.rs create mode 100644 src/datadogV2/model/model_synthetics_global_variable_value.rs create mode 100644 src/datadogV2/model/model_synthetics_variable_parser.rs diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 9bceb7154..1fe0e1f16 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -23651,6 +23651,61 @@ components: required: - type type: object + GlobalVariableData: + description: Synthetics global variable data. Wrapper around the global variable + object. + properties: + attributes: + $ref: '#/components/schemas/SyntheticsGlobalVariable' + id: + description: Global variable identifier. + type: string + type: + $ref: '#/components/schemas/GlobalVariableType' + type: object + GlobalVariableJsonPatchRequest: + description: JSON Patch request for global variable. + properties: + data: + $ref: '#/components/schemas/GlobalVariableJsonPatchRequestData' + required: + - data + type: object + GlobalVariableJsonPatchRequestData: + properties: + attributes: + $ref: '#/components/schemas/GlobalVariableJsonPatchRequestDataAttributes' + type: + $ref: '#/components/schemas/GlobalVariableJsonPatchType' + type: object + GlobalVariableJsonPatchRequestDataAttributes: + properties: + json_patch: + description: JSON Patch operations following RFC 6902. + items: + $ref: '#/components/schemas/JsonPatchOperation' + type: array + type: object + GlobalVariableJsonPatchType: + description: Global variable JSON Patch type. + enum: + - global_variables_json_patch + type: string + x-enum-varnames: + - GLOBAL_VARIABLES_JSON_PATCH + GlobalVariableResponse: + description: Global variable response. + properties: + data: + $ref: '#/components/schemas/GlobalVariableData' + type: object + GlobalVariableType: + description: Global variable type. + enum: + - global_variables + type: string + x-enum-varnames: + - GLOBAL_VARIABLES GoogleMeetConfigurationReference: description: A reference to a Google Meet Configuration resource. nullable: true @@ -28404,6 +28459,40 @@ components: - to - index type: object + JsonPatchOperation: + description: A JSON Patch operation as per RFC 6902. + properties: + op: + $ref: '#/components/schemas/JsonPatchOperationOp' + path: + description: A JSON Pointer path (e.g., "/name", "/value/secure"). + example: /name + type: string + value: + description: The value to use for the operation (not applicable for "remove" + and "test" operations). + required: + - op + - path + type: object + JsonPatchOperationOp: + description: The operation to perform. + enum: + - add + - remove + - replace + - move + - copy + - test + example: add + type: string + x-enum-varnames: + - ADD + - REMOVE + - REPLACE + - MOVE + - COPY + - TEST KindAttributes: description: Kind attributes. properties: @@ -51322,6 +51411,178 @@ components: format: double type: number type: object + SyntheticsGlobalVariable: + description: Synthetic global variable. + properties: + attributes: + $ref: '#/components/schemas/SyntheticsGlobalVariableAttributes' + description: + description: Description of the global variable. + example: Example description + type: string + id: + description: Unique identifier of the global variable. + readOnly: true + type: string + is_fido: + description: Determines if the global variable is a FIDO variable. + type: boolean + is_totp: + description: Determines if the global variable is a TOTP/MFA variable. + type: boolean + name: + description: Name of the global variable. Unique across Synthetic global + variables. + example: MY_VARIABLE + type: string + parse_test_options: + $ref: '#/components/schemas/SyntheticsGlobalVariableParseTestOptions' + parse_test_public_id: + description: A Synthetic test ID to use as a test to generate the variable + value. + example: abc-def-123 + type: string + tags: + description: Tags of the global variable. + example: + - team:front + - test:workflow-1 + items: + description: Tag name. + type: string + type: array + value: + $ref: '#/components/schemas/SyntheticsGlobalVariableValue' + required: + - description + - name + - tags + - value + type: object + SyntheticsGlobalVariableAttributes: + description: Attributes of the global variable. + properties: + restricted_roles: + $ref: '#/components/schemas/SyntheticsRestrictedRoles' + type: object + SyntheticsGlobalVariableOptions: + description: Options for the Global Variable for MFA. + properties: + totp_parameters: + $ref: '#/components/schemas/SyntheticsGlobalVariableTOTPParameters' + type: object + SyntheticsGlobalVariableParseTestOptions: + description: Parser options to use for retrieving a Synthetic global variable + from a Synthetic test. Used in conjunction with `parse_test_public_id`. + properties: + field: + description: When type is `http_header`, name of the header to use to extract + the value. + example: content-type + type: string + localVariableName: + description: When type is `local_variable`, name of the local variable to + use to extract the value. + example: LOCAL_VARIABLE + type: string + parser: + $ref: '#/components/schemas/SyntheticsVariableParser' + type: + $ref: '#/components/schemas/SyntheticsGlobalVariableParseTestOptionsType' + required: + - type + type: object + SyntheticsGlobalVariableParseTestOptionsType: + description: Type of value to extract from a test for a Synthetic global variable. + enum: + - http_body + - http_header + - http_status_code + - local_variable + example: http_body + type: string + x-enum-varnames: + - HTTP_BODY + - HTTP_HEADER + - HTTP_STATUS_CODE + - LOCAL_VARIABLE + SyntheticsGlobalVariableParserType: + description: Type of parser for a Synthetic global variable from a synthetics + test. + enum: + - raw + - json_path + - regex + - x_path + example: raw + type: string + x-enum-varnames: + - RAW + - JSON_PATH + - REGEX + - X_PATH + SyntheticsGlobalVariableTOTPParameters: + description: Parameters for the TOTP/MFA variable + properties: + digits: + description: Number of digits for the OTP code. + example: 6 + format: int32 + maximum: 10 + minimum: 4 + type: integer + refresh_interval: + description: Interval for which to refresh the token (in seconds). + example: 30 + format: int32 + maximum: 999 + minimum: 0 + type: integer + type: object + SyntheticsGlobalVariableValue: + description: Value of the global variable. + example: + secure: true + value: value + properties: + options: + $ref: '#/components/schemas/SyntheticsGlobalVariableOptions' + secure: + description: Determines if the value of the variable is hidden. + type: boolean + value: + description: 'Value of the global variable. When reading a global variable, + + the value will not be present if the variable is hidden with the `secure` + property.' + example: example-value + type: string + type: object + SyntheticsRestrictedRoles: + description: A list of role identifiers that can be pulled from the Roles API, + for restricting read and write access. + example: + - xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + items: + description: UUID for a role. + example: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + type: string + type: array + SyntheticsVariableParser: + description: Details of the parser to use for the global variable. + example: + type: regex + value: .* + properties: + type: + $ref: '#/components/schemas/SyntheticsGlobalVariableParserType' + value: + description: Regex or JSON path used for the parser. Not used with type + `raw`. + type: string + required: + - type + type: object TableResultV2: description: A reference table resource containing its full configuration and state. @@ -81694,6 +81955,60 @@ paths: operator: OR permissions: - billing_edit + /api/v2/synthetics/variables/{variable_id}/jsonpatch: + patch: + description: 'Patch a global variable using JSON Patch (RFC 6902). + + This endpoint allows partial updates to a global variable by specifying only + the fields to modify. + + + Common operations include: + + - Replace field values: `{"op": "replace", "path": "/name", "value": "new_name"}` + + - Update nested values: `{"op": "replace", "path": "/value/value", "value": + "new_value"}` + + - Add/update tags: `{"op": "add", "path": "/tags/-", "value": "new_tag"}` + + - Remove fields: `{"op": "remove", "path": "/description"}`' + operationId: PatchGlobalVariable + parameters: + - description: The ID of the global variable. + in: path + name: variable_id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/GlobalVariableJsonPatchRequest' + description: JSON Patch document with operations to apply. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/GlobalVariableResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Patch a global variable + tags: + - Synthetics + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - synthetics_global_variable_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_PatchGlobalVariable.rs b/examples/v2_synthetics_PatchGlobalVariable.rs new file mode 100644 index 000000000..bed8cfcb3 --- /dev/null +++ b/examples/v2_synthetics_PatchGlobalVariable.rs @@ -0,0 +1,32 @@ +// Patch a global variable returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_synthetics::SyntheticsAPI; +use datadog_api_client::datadogV2::model::GlobalVariableJsonPatchRequest; +use datadog_api_client::datadogV2::model::GlobalVariableJsonPatchRequestData; +use datadog_api_client::datadogV2::model::GlobalVariableJsonPatchRequestDataAttributes; +use datadog_api_client::datadogV2::model::GlobalVariableJsonPatchType; +use datadog_api_client::datadogV2::model::JsonPatchOperation; +use datadog_api_client::datadogV2::model::JsonPatchOperationOp; + +#[tokio::main] +async fn main() { + let body = GlobalVariableJsonPatchRequest::new( + GlobalVariableJsonPatchRequestData::new() + .attributes( + GlobalVariableJsonPatchRequestDataAttributes::new().json_patch(vec![ + JsonPatchOperation::new(JsonPatchOperationOp::ADD, "/name".to_string()), + ]), + ) + .type_(GlobalVariableJsonPatchType::GLOBAL_VARIABLES_JSON_PATCH), + ); + let configuration = datadog::Configuration::new(); + let api = SyntheticsAPI::with_config(configuration); + let resp = api + .patch_global_variable("variable_id".to_string(), body) + .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..221410968 100644 --- a/src/datadogV2/api/api_synthetics.rs +++ b/src/datadogV2/api/api_synthetics.rs @@ -18,6 +18,14 @@ pub enum GetOnDemandConcurrencyCapError { UnknownValue(serde_json::Value), } +/// PatchGlobalVariableError is a struct for typed errors of method [`SyntheticsAPI::patch_global_variable`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PatchGlobalVariableError { + 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)] @@ -203,6 +211,180 @@ impl SyntheticsAPI { } } + /// Patch a global variable using JSON Patch (RFC 6902). + /// This endpoint allows partial updates to a global variable by specifying only the fields to modify. + /// + /// Common operations include: + /// - Replace field values: `{"op": "replace", "path": "/name", "value": "new_name"}` + /// - Update nested values: `{"op": "replace", "path": "/value/value", "value": "new_value"}` + /// - Add/update tags: `{"op": "add", "path": "/tags/-", "value": "new_tag"}` + /// - Remove fields: `{"op": "remove", "path": "/description"}` + pub async fn patch_global_variable( + &self, + variable_id: String, + body: crate::datadogV2::model::GlobalVariableJsonPatchRequest, + ) -> Result< + crate::datadogV2::model::GlobalVariableResponse, + datadog::Error, + > { + match self + .patch_global_variable_with_http_info(variable_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), + } + } + + /// Patch a global variable using JSON Patch (RFC 6902). + /// This endpoint allows partial updates to a global variable by specifying only the fields to modify. + /// + /// Common operations include: + /// - Replace field values: `{"op": "replace", "path": "/name", "value": "new_name"}` + /// - Update nested values: `{"op": "replace", "path": "/value/value", "value": "new_value"}` + /// - Add/update tags: `{"op": "add", "path": "/tags/-", "value": "new_tag"}` + /// - Remove fields: `{"op": "remove", "path": "/description"}` + pub async fn patch_global_variable_with_http_info( + &self, + variable_id: String, + body: crate::datadogV2::model::GlobalVariableJsonPatchRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.patch_global_variable"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/synthetics/variables/{variable_id}/jsonpatch", + local_configuration.get_operation_host(operation_id), + variable_id = datadog::urlencode(variable_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::PATCH, 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)) + } + } + /// 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 19b16a61f..7743ca322 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -6522,6 +6522,42 @@ 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_global_variable_json_patch_request; +pub use self::model_global_variable_json_patch_request::GlobalVariableJsonPatchRequest; +pub mod model_global_variable_json_patch_request_data; +pub use self::model_global_variable_json_patch_request_data::GlobalVariableJsonPatchRequestData; +pub mod model_global_variable_json_patch_request_data_attributes; +pub use self::model_global_variable_json_patch_request_data_attributes::GlobalVariableJsonPatchRequestDataAttributes; +pub mod model_json_patch_operation; +pub use self::model_json_patch_operation::JsonPatchOperation; +pub mod model_json_patch_operation_op; +pub use self::model_json_patch_operation_op::JsonPatchOperationOp; +pub mod model_global_variable_json_patch_type; +pub use self::model_global_variable_json_patch_type::GlobalVariableJsonPatchType; +pub mod model_global_variable_response; +pub use self::model_global_variable_response::GlobalVariableResponse; +pub mod model_global_variable_data; +pub use self::model_global_variable_data::GlobalVariableData; +pub mod model_synthetics_global_variable; +pub use self::model_synthetics_global_variable::SyntheticsGlobalVariable; +pub mod model_synthetics_global_variable_attributes; +pub use self::model_synthetics_global_variable_attributes::SyntheticsGlobalVariableAttributes; +pub mod model_synthetics_global_variable_parse_test_options; +pub use self::model_synthetics_global_variable_parse_test_options::SyntheticsGlobalVariableParseTestOptions; +pub mod model_synthetics_variable_parser; +pub use self::model_synthetics_variable_parser::SyntheticsVariableParser; +pub mod model_synthetics_global_variable_parser_type; +pub use self::model_synthetics_global_variable_parser_type::SyntheticsGlobalVariableParserType; +pub mod model_synthetics_global_variable_parse_test_options_type; +pub use self::model_synthetics_global_variable_parse_test_options_type::SyntheticsGlobalVariableParseTestOptionsType; +pub mod model_synthetics_global_variable_value; +pub use self::model_synthetics_global_variable_value::SyntheticsGlobalVariableValue; +pub mod model_synthetics_global_variable_options; +pub use self::model_synthetics_global_variable_options::SyntheticsGlobalVariableOptions; +pub mod model_synthetics_global_variable_totp_parameters; +pub use self::model_synthetics_global_variable_totp_parameters::SyntheticsGlobalVariableTOTPParameters; +pub mod model_global_variable_type; +pub use self::model_global_variable_type::GlobalVariableType; 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_global_variable_data.rs b/src/datadogV2/model/model_global_variable_data.rs new file mode 100644 index 000000000..8c961802a --- /dev/null +++ b/src/datadogV2/model/model_global_variable_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 global variable data. Wrapper around the global variable object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct GlobalVariableData { + /// Synthetic global variable. + #[serde(rename = "attributes")] + pub attributes: Option, + /// Global variable identifier. + #[serde(rename = "id")] + pub id: Option, + /// Global variable type. + #[serde(rename = "type")] + pub type_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl GlobalVariableData { + pub fn new() -> GlobalVariableData { + GlobalVariableData { + attributes: None, + id: None, + type_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes(mut self, value: crate::datadogV2::model::SyntheticsGlobalVariable) -> 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::GlobalVariableType) -> 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 GlobalVariableData { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for GlobalVariableData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct GlobalVariableDataVisitor; + impl<'a> Visitor<'a> for GlobalVariableDataVisitor { + type Value = GlobalVariableData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = + None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + if v.is_null() { + continue; + } + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::GlobalVariableType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = GlobalVariableData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(GlobalVariableDataVisitor) + } +} diff --git a/src/datadogV2/model/model_global_variable_json_patch_request.rs b/src/datadogV2/model/model_global_variable_json_patch_request.rs new file mode 100644 index 000000000..0561e0eb5 --- /dev/null +++ b/src/datadogV2/model/model_global_variable_json_patch_request.rs @@ -0,0 +1,94 @@ +// 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}; + +/// JSON Patch request for global variable. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct GlobalVariableJsonPatchRequest { + #[serde(rename = "data")] + pub data: crate::datadogV2::model::GlobalVariableJsonPatchRequestData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl GlobalVariableJsonPatchRequest { + pub fn new( + data: crate::datadogV2::model::GlobalVariableJsonPatchRequestData, + ) -> GlobalVariableJsonPatchRequest { + GlobalVariableJsonPatchRequest { + 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 GlobalVariableJsonPatchRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct GlobalVariableJsonPatchRequestVisitor; + impl<'a> Visitor<'a> for GlobalVariableJsonPatchRequestVisitor { + type Value = GlobalVariableJsonPatchRequest; + + 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 = GlobalVariableJsonPatchRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(GlobalVariableJsonPatchRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_global_variable_json_patch_request_data.rs b/src/datadogV2/model/model_global_variable_json_patch_request_data.rs new file mode 100644 index 000000000..6ba745e0f --- /dev/null +++ b/src/datadogV2/model/model_global_variable_json_patch_request_data.rs @@ -0,0 +1,133 @@ +// 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 GlobalVariableJsonPatchRequestData { + #[serde(rename = "attributes")] + pub attributes: Option, + /// Global variable JSON Patch type. + #[serde(rename = "type")] + pub type_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl GlobalVariableJsonPatchRequestData { + pub fn new() -> GlobalVariableJsonPatchRequestData { + GlobalVariableJsonPatchRequestData { + attributes: None, + type_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::GlobalVariableJsonPatchRequestDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn type_(mut self, value: crate::datadogV2::model::GlobalVariableJsonPatchType) -> 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 GlobalVariableJsonPatchRequestData { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for GlobalVariableJsonPatchRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct GlobalVariableJsonPatchRequestDataVisitor; + impl<'a> Visitor<'a> for GlobalVariableJsonPatchRequestDataVisitor { + type Value = GlobalVariableJsonPatchRequestData; + + 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::GlobalVariableJsonPatchRequestDataAttributes, + > = 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)?); + } + "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::GlobalVariableJsonPatchType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = GlobalVariableJsonPatchRequestData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(GlobalVariableJsonPatchRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_global_variable_json_patch_request_data_attributes.rs b/src/datadogV2/model/model_global_variable_json_patch_request_data_attributes.rs new file mode 100644 index 000000000..b0b7afdeb --- /dev/null +++ b/src/datadogV2/model/model_global_variable_json_patch_request_data_attributes.rs @@ -0,0 +1,104 @@ +// 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 GlobalVariableJsonPatchRequestDataAttributes { + /// JSON Patch operations following RFC 6902. + #[serde(rename = "json_patch")] + pub json_patch: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl GlobalVariableJsonPatchRequestDataAttributes { + pub fn new() -> GlobalVariableJsonPatchRequestDataAttributes { + GlobalVariableJsonPatchRequestDataAttributes { + json_patch: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn json_patch(mut self, value: Vec) -> Self { + self.json_patch = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for GlobalVariableJsonPatchRequestDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for GlobalVariableJsonPatchRequestDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct GlobalVariableJsonPatchRequestDataAttributesVisitor; + impl<'a> Visitor<'a> for GlobalVariableJsonPatchRequestDataAttributesVisitor { + type Value = GlobalVariableJsonPatchRequestDataAttributes; + + 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 json_patch: 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() { + "json_patch" => { + if v.is_null() { + continue; + } + json_patch = 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 = GlobalVariableJsonPatchRequestDataAttributes { + json_patch, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(GlobalVariableJsonPatchRequestDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_global_variable_json_patch_type.rs b/src/datadogV2/model/model_global_variable_json_patch_type.rs new file mode 100644 index 000000000..2eef76c1e --- /dev/null +++ b/src/datadogV2/model/model_global_variable_json_patch_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 GlobalVariableJsonPatchType { + GLOBAL_VARIABLES_JSON_PATCH, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for GlobalVariableJsonPatchType { + fn to_string(&self) -> String { + match self { + Self::GLOBAL_VARIABLES_JSON_PATCH => String::from("global_variables_json_patch"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for GlobalVariableJsonPatchType { + 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 GlobalVariableJsonPatchType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "global_variables_json_patch" => Self::GLOBAL_VARIABLES_JSON_PATCH, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_global_variable_response.rs b/src/datadogV2/model/model_global_variable_response.rs new file mode 100644 index 000000000..082b9d860 --- /dev/null +++ b/src/datadogV2/model/model_global_variable_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}; + +/// Global variable response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct GlobalVariableResponse { + /// Synthetics global variable data. Wrapper around the global variable object. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl GlobalVariableResponse { + pub fn new() -> GlobalVariableResponse { + GlobalVariableResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::GlobalVariableData) -> 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 GlobalVariableResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for GlobalVariableResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct GlobalVariableResponseVisitor; + impl<'a> Visitor<'a> for GlobalVariableResponseVisitor { + type Value = GlobalVariableResponse; + + 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 = GlobalVariableResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(GlobalVariableResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_global_variable_type.rs b/src/datadogV2/model/model_global_variable_type.rs new file mode 100644 index 000000000..b2bbc2b5f --- /dev/null +++ b/src/datadogV2/model/model_global_variable_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 GlobalVariableType { + GLOBAL_VARIABLES, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for GlobalVariableType { + fn to_string(&self) -> String { + match self { + Self::GLOBAL_VARIABLES => String::from("global_variables"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for GlobalVariableType { + 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 GlobalVariableType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "global_variables" => Self::GLOBAL_VARIABLES, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_json_patch_operation.rs b/src/datadogV2/model/model_json_patch_operation.rs new file mode 100644 index 000000000..93696df1a --- /dev/null +++ b/src/datadogV2/model/model_json_patch_operation.rs @@ -0,0 +1,130 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// A JSON Patch operation as per RFC 6902. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct JsonPatchOperation { + /// The operation to perform. + #[serde(rename = "op")] + pub op: crate::datadogV2::model::JsonPatchOperationOp, + /// A JSON Pointer path (e.g., "/name", "/value/secure"). + #[serde(rename = "path")] + pub path: String, + /// The value to use for the operation (not applicable for "remove" and "test" operations). + #[serde(rename = "value")] + pub value: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl JsonPatchOperation { + pub fn new( + op: crate::datadogV2::model::JsonPatchOperationOp, + path: String, + ) -> JsonPatchOperation { + JsonPatchOperation { + op, + path, + value: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn value(mut self, value: serde_json::Value) -> Self { + self.value = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for JsonPatchOperation { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct JsonPatchOperationVisitor; + impl<'a> Visitor<'a> for JsonPatchOperationVisitor { + type Value = JsonPatchOperation; + + 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 op: Option = None; + let mut path: Option = None; + let mut value: 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() { + "op" => { + op = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _op) = op { + match _op { + crate::datadogV2::model::JsonPatchOperationOp::UnparsedObject(_op) => { + _unparsed = true; + }, + _ => {} + } + } + } + "path" => { + path = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "value" => { + if v.is_null() { + continue; + } + value = 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 op = op.ok_or_else(|| M::Error::missing_field("op"))?; + let path = path.ok_or_else(|| M::Error::missing_field("path"))?; + + let content = JsonPatchOperation { + op, + path, + value, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(JsonPatchOperationVisitor) + } +} diff --git a/src/datadogV2/model/model_json_patch_operation_op.rs b/src/datadogV2/model/model_json_patch_operation_op.rs new file mode 100644 index 000000000..d19706a35 --- /dev/null +++ b/src/datadogV2/model/model_json_patch_operation_op.rs @@ -0,0 +1,63 @@ +// 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 JsonPatchOperationOp { + ADD, + REMOVE, + REPLACE, + MOVE, + COPY, + TEST, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for JsonPatchOperationOp { + fn to_string(&self) -> String { + match self { + Self::ADD => String::from("add"), + Self::REMOVE => String::from("remove"), + Self::REPLACE => String::from("replace"), + Self::MOVE => String::from("move"), + Self::COPY => String::from("copy"), + Self::TEST => String::from("test"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for JsonPatchOperationOp { + 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 JsonPatchOperationOp { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "add" => Self::ADD, + "remove" => Self::REMOVE, + "replace" => Self::REPLACE, + "move" => Self::MOVE, + "copy" => Self::COPY, + "test" => Self::TEST, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_synthetics_global_variable.rs b/src/datadogV2/model/model_synthetics_global_variable.rs new file mode 100644 index 000000000..ebc54dcd3 --- /dev/null +++ b/src/datadogV2/model/model_synthetics_global_variable.rs @@ -0,0 +1,245 @@ +// 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}; + +/// Synthetic global variable. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SyntheticsGlobalVariable { + /// Attributes of the global variable. + #[serde(rename = "attributes")] + pub attributes: Option, + /// Description of the global variable. + #[serde(rename = "description")] + pub description: String, + /// Unique identifier of the global variable. + #[serde(rename = "id")] + pub id: Option, + /// Determines if the global variable is a FIDO variable. + #[serde(rename = "is_fido")] + pub is_fido: Option, + /// Determines if the global variable is a TOTP/MFA variable. + #[serde(rename = "is_totp")] + pub is_totp: Option, + /// Name of the global variable. Unique across Synthetic global variables. + #[serde(rename = "name")] + pub name: String, + /// Parser options to use for retrieving a Synthetic global variable from a Synthetic test. Used in conjunction with `parse_test_public_id`. + #[serde(rename = "parse_test_options")] + pub parse_test_options: + Option, + /// A Synthetic test ID to use as a test to generate the variable value. + #[serde(rename = "parse_test_public_id")] + pub parse_test_public_id: Option, + /// Tags of the global variable. + #[serde(rename = "tags")] + pub tags: Vec, + /// Value of the global variable. + #[serde(rename = "value")] + pub value: crate::datadogV2::model::SyntheticsGlobalVariableValue, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SyntheticsGlobalVariable { + pub fn new( + description: String, + name: String, + tags: Vec, + value: crate::datadogV2::model::SyntheticsGlobalVariableValue, + ) -> SyntheticsGlobalVariable { + SyntheticsGlobalVariable { + attributes: None, + description, + id: None, + is_fido: None, + is_totp: None, + name, + parse_test_options: None, + parse_test_public_id: None, + tags, + value, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::SyntheticsGlobalVariableAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn is_fido(mut self, value: bool) -> Self { + self.is_fido = Some(value); + self + } + + pub fn is_totp(mut self, value: bool) -> Self { + self.is_totp = Some(value); + self + } + + pub fn parse_test_options( + mut self, + value: crate::datadogV2::model::SyntheticsGlobalVariableParseTestOptions, + ) -> Self { + self.parse_test_options = Some(value); + self + } + + pub fn parse_test_public_id(mut self, value: String) -> Self { + self.parse_test_public_id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for SyntheticsGlobalVariable { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SyntheticsGlobalVariableVisitor; + impl<'a> Visitor<'a> for SyntheticsGlobalVariableVisitor { + type Value = SyntheticsGlobalVariable; + + 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::SyntheticsGlobalVariableAttributes, + > = None; + let mut description: Option = None; + let mut id: Option = None; + let mut is_fido: Option = None; + let mut is_totp: Option = None; + let mut name: Option = None; + let mut parse_test_options: Option< + crate::datadogV2::model::SyntheticsGlobalVariableParseTestOptions, + > = None; + let mut parse_test_public_id: Option = None; + let mut tags: Option> = None; + let mut value: 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)?); + } + "description" => { + description = + 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)?); + } + "is_fido" => { + if v.is_null() { + continue; + } + is_fido = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "is_totp" => { + if v.is_null() { + continue; + } + is_totp = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "parse_test_options" => { + if v.is_null() { + continue; + } + parse_test_options = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "parse_test_public_id" => { + if v.is_null() { + continue; + } + parse_test_public_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "tags" => { + tags = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "value" => { + value = 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 description = + description.ok_or_else(|| M::Error::missing_field("description"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let tags = tags.ok_or_else(|| M::Error::missing_field("tags"))?; + let value = value.ok_or_else(|| M::Error::missing_field("value"))?; + + let content = SyntheticsGlobalVariable { + attributes, + description, + id, + is_fido, + is_totp, + name, + parse_test_options, + parse_test_public_id, + tags, + value, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SyntheticsGlobalVariableVisitor) + } +} diff --git a/src/datadogV2/model/model_synthetics_global_variable_attributes.rs b/src/datadogV2/model/model_synthetics_global_variable_attributes.rs new file mode 100644 index 000000000..16bf7515c --- /dev/null +++ b/src/datadogV2/model/model_synthetics_global_variable_attributes.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}; + +/// Attributes of the global variable. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SyntheticsGlobalVariableAttributes { + /// A list of role identifiers that can be pulled from the Roles API, for restricting read and write access. + #[serde(rename = "restricted_roles")] + pub restricted_roles: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SyntheticsGlobalVariableAttributes { + pub fn new() -> SyntheticsGlobalVariableAttributes { + SyntheticsGlobalVariableAttributes { + restricted_roles: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn restricted_roles(mut self, value: Vec) -> Self { + self.restricted_roles = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for SyntheticsGlobalVariableAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for SyntheticsGlobalVariableAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SyntheticsGlobalVariableAttributesVisitor; + impl<'a> Visitor<'a> for SyntheticsGlobalVariableAttributesVisitor { + type Value = SyntheticsGlobalVariableAttributes; + + 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 restricted_roles: 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() { + "restricted_roles" => { + if v.is_null() { + continue; + } + restricted_roles = + 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 = SyntheticsGlobalVariableAttributes { + restricted_roles, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SyntheticsGlobalVariableAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_synthetics_global_variable_options.rs b/src/datadogV2/model/model_synthetics_global_variable_options.rs new file mode 100644 index 000000000..a5d7d68d4 --- /dev/null +++ b/src/datadogV2/model/model_synthetics_global_variable_options.rs @@ -0,0 +1,111 @@ +// 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}; + +/// Options for the Global Variable for MFA. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SyntheticsGlobalVariableOptions { + /// Parameters for the TOTP/MFA variable + #[serde(rename = "totp_parameters")] + pub totp_parameters: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SyntheticsGlobalVariableOptions { + pub fn new() -> SyntheticsGlobalVariableOptions { + SyntheticsGlobalVariableOptions { + totp_parameters: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn totp_parameters( + mut self, + value: crate::datadogV2::model::SyntheticsGlobalVariableTOTPParameters, + ) -> Self { + self.totp_parameters = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for SyntheticsGlobalVariableOptions { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for SyntheticsGlobalVariableOptions { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SyntheticsGlobalVariableOptionsVisitor; + impl<'a> Visitor<'a> for SyntheticsGlobalVariableOptionsVisitor { + type Value = SyntheticsGlobalVariableOptions; + + 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 totp_parameters: Option< + crate::datadogV2::model::SyntheticsGlobalVariableTOTPParameters, + > = 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() { + "totp_parameters" => { + if v.is_null() { + continue; + } + totp_parameters = + 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 = SyntheticsGlobalVariableOptions { + totp_parameters, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SyntheticsGlobalVariableOptionsVisitor) + } +} diff --git a/src/datadogV2/model/model_synthetics_global_variable_parse_test_options.rs b/src/datadogV2/model/model_synthetics_global_variable_parse_test_options.rs new file mode 100644 index 000000000..5133a3db5 --- /dev/null +++ b/src/datadogV2/model/model_synthetics_global_variable_parse_test_options.rs @@ -0,0 +1,156 @@ +// 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}; + +/// Parser options to use for retrieving a Synthetic global variable from a Synthetic test. Used in conjunction with `parse_test_public_id`. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SyntheticsGlobalVariableParseTestOptions { + /// When type is `http_header`, name of the header to use to extract the value. + #[serde(rename = "field")] + pub field: Option, + /// When type is `local_variable`, name of the local variable to use to extract the value. + #[serde(rename = "localVariableName")] + pub local_variable_name: Option, + /// Details of the parser to use for the global variable. + #[serde(rename = "parser")] + pub parser: Option, + /// Type of value to extract from a test for a Synthetic global variable. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::SyntheticsGlobalVariableParseTestOptionsType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SyntheticsGlobalVariableParseTestOptions { + pub fn new( + type_: crate::datadogV2::model::SyntheticsGlobalVariableParseTestOptionsType, + ) -> SyntheticsGlobalVariableParseTestOptions { + SyntheticsGlobalVariableParseTestOptions { + field: None, + local_variable_name: None, + parser: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn field(mut self, value: String) -> Self { + self.field = Some(value); + self + } + + pub fn local_variable_name(mut self, value: String) -> Self { + self.local_variable_name = Some(value); + self + } + + pub fn parser(mut self, value: crate::datadogV2::model::SyntheticsVariableParser) -> Self { + self.parser = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for SyntheticsGlobalVariableParseTestOptions { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SyntheticsGlobalVariableParseTestOptionsVisitor; + impl<'a> Visitor<'a> for SyntheticsGlobalVariableParseTestOptionsVisitor { + type Value = SyntheticsGlobalVariableParseTestOptions; + + 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 field: Option = None; + let mut local_variable_name: Option = None; + let mut parser: Option = None; + let mut type_: Option< + crate::datadogV2::model::SyntheticsGlobalVariableParseTestOptionsType, + > = 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() { + "field" => { + if v.is_null() { + continue; + } + field = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "localVariableName" => { + if v.is_null() { + continue; + } + local_variable_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "parser" => { + if v.is_null() { + continue; + } + parser = 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::SyntheticsGlobalVariableParseTestOptionsType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = SyntheticsGlobalVariableParseTestOptions { + field, + local_variable_name, + parser, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SyntheticsGlobalVariableParseTestOptionsVisitor) + } +} diff --git a/src/datadogV2/model/model_synthetics_global_variable_parse_test_options_type.rs b/src/datadogV2/model/model_synthetics_global_variable_parse_test_options_type.rs new file mode 100644 index 000000000..c71af62ab --- /dev/null +++ b/src/datadogV2/model/model_synthetics_global_variable_parse_test_options_type.rs @@ -0,0 +1,57 @@ +// 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 SyntheticsGlobalVariableParseTestOptionsType { + HTTP_BODY, + HTTP_HEADER, + HTTP_STATUS_CODE, + LOCAL_VARIABLE, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for SyntheticsGlobalVariableParseTestOptionsType { + fn to_string(&self) -> String { + match self { + Self::HTTP_BODY => String::from("http_body"), + Self::HTTP_HEADER => String::from("http_header"), + Self::HTTP_STATUS_CODE => String::from("http_status_code"), + Self::LOCAL_VARIABLE => String::from("local_variable"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for SyntheticsGlobalVariableParseTestOptionsType { + 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 SyntheticsGlobalVariableParseTestOptionsType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "http_body" => Self::HTTP_BODY, + "http_header" => Self::HTTP_HEADER, + "http_status_code" => Self::HTTP_STATUS_CODE, + "local_variable" => Self::LOCAL_VARIABLE, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_synthetics_global_variable_parser_type.rs b/src/datadogV2/model/model_synthetics_global_variable_parser_type.rs new file mode 100644 index 000000000..a14ec507a --- /dev/null +++ b/src/datadogV2/model/model_synthetics_global_variable_parser_type.rs @@ -0,0 +1,57 @@ +// 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 SyntheticsGlobalVariableParserType { + RAW, + JSON_PATH, + REGEX, + X_PATH, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for SyntheticsGlobalVariableParserType { + fn to_string(&self) -> String { + match self { + Self::RAW => String::from("raw"), + Self::JSON_PATH => String::from("json_path"), + Self::REGEX => String::from("regex"), + Self::X_PATH => String::from("x_path"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for SyntheticsGlobalVariableParserType { + 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 SyntheticsGlobalVariableParserType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "raw" => Self::RAW, + "json_path" => Self::JSON_PATH, + "regex" => Self::REGEX, + "x_path" => Self::X_PATH, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_synthetics_global_variable_totp_parameters.rs b/src/datadogV2/model/model_synthetics_global_variable_totp_parameters.rs new file mode 100644 index 000000000..f01156df8 --- /dev/null +++ b/src/datadogV2/model/model_synthetics_global_variable_totp_parameters.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}; + +/// Parameters for the TOTP/MFA variable +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SyntheticsGlobalVariableTOTPParameters { + /// Number of digits for the OTP code. + #[serde(rename = "digits")] + pub digits: Option, + /// Interval for which to refresh the token (in seconds). + #[serde(rename = "refresh_interval")] + pub refresh_interval: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SyntheticsGlobalVariableTOTPParameters { + pub fn new() -> SyntheticsGlobalVariableTOTPParameters { + SyntheticsGlobalVariableTOTPParameters { + digits: None, + refresh_interval: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn digits(mut self, value: i32) -> Self { + self.digits = Some(value); + self + } + + pub fn refresh_interval(mut self, value: i32) -> Self { + self.refresh_interval = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for SyntheticsGlobalVariableTOTPParameters { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for SyntheticsGlobalVariableTOTPParameters { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SyntheticsGlobalVariableTOTPParametersVisitor; + impl<'a> Visitor<'a> for SyntheticsGlobalVariableTOTPParametersVisitor { + type Value = SyntheticsGlobalVariableTOTPParameters; + + 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 digits: Option = None; + let mut refresh_interval: 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() { + "digits" => { + if v.is_null() { + continue; + } + digits = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "refresh_interval" => { + if v.is_null() { + continue; + } + refresh_interval = + 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 = SyntheticsGlobalVariableTOTPParameters { + digits, + refresh_interval, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SyntheticsGlobalVariableTOTPParametersVisitor) + } +} diff --git a/src/datadogV2/model/model_synthetics_global_variable_value.rs b/src/datadogV2/model/model_synthetics_global_variable_value.rs new file mode 100644 index 000000000..0cbabf9ce --- /dev/null +++ b/src/datadogV2/model/model_synthetics_global_variable_value.rs @@ -0,0 +1,144 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Value of the global variable. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SyntheticsGlobalVariableValue { + /// Options for the Global Variable for MFA. + #[serde(rename = "options")] + pub options: Option, + /// Determines if the value of the variable is hidden. + #[serde(rename = "secure")] + pub secure: Option, + /// Value of the global variable. When reading a global variable, + /// the value will not be present if the variable is hidden with the `secure` property. + #[serde(rename = "value")] + pub value: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SyntheticsGlobalVariableValue { + pub fn new() -> SyntheticsGlobalVariableValue { + SyntheticsGlobalVariableValue { + options: None, + secure: None, + value: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn options( + mut self, + value: crate::datadogV2::model::SyntheticsGlobalVariableOptions, + ) -> Self { + self.options = Some(value); + self + } + + pub fn secure(mut self, value: bool) -> Self { + self.secure = Some(value); + self + } + + pub fn value(mut self, value: String) -> Self { + self.value = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for SyntheticsGlobalVariableValue { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for SyntheticsGlobalVariableValue { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SyntheticsGlobalVariableValueVisitor; + impl<'a> Visitor<'a> for SyntheticsGlobalVariableValueVisitor { + type Value = SyntheticsGlobalVariableValue; + + 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 options: Option = + None; + let mut secure: Option = None; + let mut value: 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() { + "options" => { + if v.is_null() { + continue; + } + options = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "secure" => { + if v.is_null() { + continue; + } + secure = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "value" => { + if v.is_null() { + continue; + } + value = 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 = SyntheticsGlobalVariableValue { + options, + secure, + value, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SyntheticsGlobalVariableValueVisitor) + } +} diff --git a/src/datadogV2/model/model_synthetics_variable_parser.rs b/src/datadogV2/model/model_synthetics_variable_parser.rs new file mode 100644 index 000000000..8ca1ec5ea --- /dev/null +++ b/src/datadogV2/model/model_synthetics_variable_parser.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}; + +/// Details of the parser to use for the global variable. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SyntheticsVariableParser { + /// Type of parser for a Synthetic global variable from a synthetics test. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::SyntheticsGlobalVariableParserType, + /// Regex or JSON path used for the parser. Not used with type `raw`. + #[serde(rename = "value")] + pub value: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SyntheticsVariableParser { + pub fn new( + type_: crate::datadogV2::model::SyntheticsGlobalVariableParserType, + ) -> SyntheticsVariableParser { + SyntheticsVariableParser { + type_, + value: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn value(mut self, value: String) -> Self { + self.value = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for SyntheticsVariableParser { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SyntheticsVariableParserVisitor; + impl<'a> Visitor<'a> for SyntheticsVariableParserVisitor { + type Value = SyntheticsVariableParser; + + 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 type_: Option = + None; + let mut value: 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() { + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::SyntheticsGlobalVariableParserType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + "value" => { + if v.is_null() { + continue; + } + value = 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 type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = SyntheticsVariableParser { + type_, + value, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SyntheticsVariableParserVisitor) + } +} diff --git a/tests/scenarios/features/v2/synthetics.feature b/tests/scenarios/features/v2/synthetics.feature index 73efa73ec..133993b11 100644 --- a/tests/scenarios/features/v2/synthetics.feature +++ b/tests/scenarios/features/v2/synthetics.feature @@ -20,6 +20,30 @@ Feature: Synthetics When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/synthetics-managing + Scenario: Patch a global variable returns "Bad Request" response + Given new "PatchGlobalVariable" request + And request contains "variable_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"json_patch": [{"op": "add", "path": "/name"}]}, "type": "global_variables_json_patch"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/synthetics-managing + Scenario: Patch a global variable returns "Not Found" response + Given new "PatchGlobalVariable" request + And request contains "variable_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"json_patch": [{"op": "add", "path": "/name"}]}, "type": "global_variables_json_patch"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/synthetics-managing + Scenario: Patch a global variable returns "OK" response + Given new "PatchGlobalVariable" request + And request contains "variable_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"json_patch": [{"op": "add", "path": "/name"}]}, "type": "global_variables_json_patch"}} + When the request is sent + Then the response status is 200 OK + @team:DataDog/synthetics-managing Scenario: Save new value for on-demand concurrency cap returns "OK" response Given new "SetOnDemandConcurrencyCap" request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 3799e64e6..f4cbbb2ba 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -4284,6 +4284,12 @@ "type": "safe" } }, + "PatchGlobalVariable": { + "tag": "Synthetics", + "undo": { + "type": "safe" + } + }, "ListTagPipelinesRulesets": { "tag": "Cloud Cost Management", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 4f9cae93a..80809c62b 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -4243,6 +4243,10 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.SetOnDemandConcurrencyCap".into(), test_v2_set_on_demand_concurrency_cap, ); + world.function_mappings.insert( + "v2.PatchGlobalVariable".into(), + test_v2_patch_global_variable, + ); world .function_mappings .insert("v2.ListTeams".into(), test_v2_list_teams); @@ -32583,6 +32587,33 @@ fn test_v2_set_on_demand_concurrency_cap( world.response.code = response.status.as_u16(); } +fn test_v2_patch_global_variable(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_synthetics + .as_ref() + .expect("api instance not found"); + let variable_id = + serde_json::from_value(_parameters.get("variable_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.patch_global_variable_with_http_info(variable_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