diff --git a/.apigentools-info b/.apigentools-info index 7fb3e00a1..414f83940 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2025-01-16 23:13:34.260376", - "spec_repo_commit": "0ad24d9f" + "regenerated": "2025-01-17 14:23:59.744596", + "spec_repo_commit": "60205e12" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2025-01-16 23:13:34.280676", - "spec_repo_commit": "0ad24d9f" + "regenerated": "2025-01-17 14:23:59.759696", + "spec_repo_commit": "60205e12" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 763dc8027..c0f7b54f0 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -206,6 +206,13 @@ components: required: true schema: type: string + ConnectionId: + description: The ID of the action connection + in: path + name: connection_id + required: true + schema: + type: string CustomDestinationId: description: The ID of the custom destination. in: path @@ -1210,6 +1217,64 @@ components: required: - data type: object + AWSAssumeRole: + description: The definition of `AWSAssumeRole` object. + properties: + account_id: + description: AWS account the connection is created for + example: '111222333444' + pattern: ^\d{12}$ + type: string + external_id: + description: External ID used to scope which connection can be used to assume + the role + example: 33a1011635c44b38a064cf14e82e1d8f + readOnly: true + type: string + principal_id: + description: AWS account that will assume the role + example: '123456789012' + readOnly: true + type: string + role: + description: Role to assume + example: my-role + type: string + type: + $ref: '#/components/schemas/AWSAssumeRoleType' + required: + - type + - account_id + - role + type: object + AWSAssumeRoleType: + description: The definition of `AWSAssumeRoleType` object. + enum: + - AWSAssumeRole + example: AWSAssumeRole + type: string + x-enum-varnames: + - AWSASSUMEROLE + AWSAssumeRoleUpdate: + description: The definition of `AWSAssumeRoleUpdate` object. + properties: + account_id: + description: AWS account the connection is created for + example: '111222333444' + pattern: ^\d{12}$ + type: string + generate_new_external_id: + description: The `AWSAssumeRoleUpdate` `generate_new_external_id`. + type: boolean + role: + description: Role to assume + example: my-role + type: string + type: + $ref: '#/components/schemas/AWSAssumeRoleType' + required: + - type + type: object AWSAuthConfig: description: AWS Authentication config. oneOf: @@ -1248,6 +1313,43 @@ components: required: - role_name type: object + AWSCredentials: + description: The definition of `AWSCredentials` object. + oneOf: + - $ref: '#/components/schemas/AWSAssumeRole' + AWSCredentialsUpdate: + description: The definition of `AWSCredentialsUpdate` object. + oneOf: + - $ref: '#/components/schemas/AWSAssumeRoleUpdate' + AWSIntegration: + description: The definition of `AWSIntegration` object. + properties: + credentials: + $ref: '#/components/schemas/AWSCredentials' + type: + $ref: '#/components/schemas/AWSIntegrationType' + required: + - type + - credentials + type: object + AWSIntegrationType: + description: The definition of `AWSIntegrationType` object. + enum: + - AWS + example: AWS + type: string + x-enum-varnames: + - AWS + AWSIntegrationUpdate: + description: The definition of `AWSIntegrationUpdate` object. + properties: + credentials: + $ref: '#/components/schemas/AWSCredentialsUpdate' + type: + $ref: '#/components/schemas/AWSIntegrationType' + required: + - type + type: object AWSLambdaForwarderConfig: description: 'Log Autosubscription configuration for Datadog Forwarder Lambda functions. Automatically set up triggers for existing @@ -1561,6 +1663,73 @@ components: xray_services: $ref: '#/components/schemas/XRayServicesList' type: object + ActionConnectionAttributes: + description: The definition of `ActionConnectionAttributes` object. + properties: + integration: + $ref: '#/components/schemas/ActionConnectionIntegration' + name: + description: Name of the connection + example: My AWS Connection + type: string + required: + - name + - integration + type: object + ActionConnectionAttributesUpdate: + description: The definition of `ActionConnectionAttributesUpdate` object. + properties: + integration: + $ref: '#/components/schemas/ActionConnectionIntegrationUpdate' + name: + description: Name of the connection + example: My AWS Connection + type: string + type: object + ActionConnectionData: + description: Data related to the connection. + properties: + attributes: + $ref: '#/components/schemas/ActionConnectionAttributes' + id: + description: The connection identifier + readOnly: true + type: string + type: + $ref: '#/components/schemas/ActionConnectionDataType' + required: + - type + - attributes + type: object + ActionConnectionDataType: + description: The definition of `ActionConnectionDataType` object. + enum: + - action_connection + example: action_connection + type: string + x-enum-varnames: + - ACTION_CONNECTION + ActionConnectionDataUpdate: + description: Data related to the connection update. + properties: + attributes: + $ref: '#/components/schemas/ActionConnectionAttributesUpdate' + type: + $ref: '#/components/schemas/ActionConnectionDataType' + required: + - type + - attributes + type: object + ActionConnectionIntegration: + description: The definition of `ActionConnectionIntegration` object. + oneOf: + - $ref: '#/components/schemas/AWSIntegration' + - $ref: '#/components/schemas/HTTPIntegration' + ActionConnectionIntegrationUpdate: + description: The definition of `ActionConnectionIntegrationUpdate` object. + oneOf: + - $ref: '#/components/schemas/AWSIntegrationUpdate' + - $ref: '#/components/schemas/HTTPIntegrationUpdate' ActiveBillingDimensionsAttributes: description: List of active billing dimensions. properties: @@ -7020,6 +7189,20 @@ components: type: string x-enum-varnames: - COST_BY_ORG + CreateActionConnectionRequest: + description: Request used to create an action connection. + properties: + data: + $ref: '#/components/schemas/ActionConnectionData' + required: + - data + type: object + CreateActionConnectionResponse: + description: The response for a created connection + properties: + data: + $ref: '#/components/schemas/ActionConnectionData' + type: object CreateAppRequest: description: The definition of `CreateAppRequest` object. example: @@ -12230,6 +12413,12 @@ components: type: string x-enum-varnames: - GCP_SERVICE_ACCOUNT + GetActionConnectionResponse: + description: The response for found connection + properties: + data: + $ref: '#/components/schemas/ActionConnectionData' + type: object GetAppResponse: description: The definition of `GetAppResponse` object. properties: @@ -12524,6 +12713,18 @@ components: example: env:production type: string type: array + HTTPBody: + description: The definition of `HTTPBody` object. + properties: + content: + description: Serialized body content + example: '{"some-json": "with-value"}' + type: string + content_type: + description: Content type of the body + example: application/json + type: string + type: object HTTPCIAppError: description: List of errors. properties: @@ -12549,6 +12750,88 @@ components: $ref: '#/components/schemas/HTTPCIAppError' type: array type: object + HTTPCredentials: + description: The definition of `HTTPCredentials` object. + oneOf: + - $ref: '#/components/schemas/HTTPTokenAuth' + HTTPCredentialsUpdate: + description: The definition of `HTTPCredentialsUpdate` object. + oneOf: + - $ref: '#/components/schemas/HTTPTokenAuthUpdate' + HTTPHeader: + description: The definition of `HTTPHeader` object. + properties: + name: + description: The `HTTPHeader` `name`. + example: MyHttpHeader + pattern: ^[A-Za-z][A-Za-z\\d\\-\\_]*$ + type: string + value: + description: The `HTTPHeader` `value`. + example: Some header value + type: string + required: + - name + - value + type: object + HTTPHeaderUpdate: + description: The definition of `HTTPHeaderUpdate` object. + properties: + deleted: + description: Should the header be deleted. + type: boolean + name: + description: The `HTTPHeaderUpdate` `name`. + example: MyHttpHeader + pattern: ^[A-Za-z][A-Za-z\\d\\-\\_]*$ + type: string + value: + description: The `HTTPHeaderUpdate` `value`. + example: Updated Header Value + type: string + required: + - name + type: object + HTTPIntegration: + description: The definition of `HTTPIntegration` object. + properties: + base_url: + description: Base HTTP url for the integration + example: http://datadoghq.com + pattern: url + type: string + credentials: + $ref: '#/components/schemas/HTTPCredentials' + type: + $ref: '#/components/schemas/HTTPIntegrationType' + required: + - type + - base_url + - credentials + type: object + HTTPIntegrationType: + description: The definition of `HTTPIntegrationType` object. + enum: + - HTTP + example: HTTP + type: string + x-enum-varnames: + - HTTP + HTTPIntegrationUpdate: + description: The definition of `HTTPIntegrationUpdate` object. + properties: + base_url: + description: Base HTTP url for the integration + example: http://datadoghq.com + pattern: url + type: string + credentials: + $ref: '#/components/schemas/HTTPCredentialsUpdate' + type: + $ref: '#/components/schemas/HTTPIntegrationType' + required: + - type + type: object HTTPLog: description: Structured log message. items: @@ -12625,6 +12908,105 @@ components: required: - message type: object + HTTPToken: + description: The definition of `HTTPToken` object. + properties: + name: + description: The `HTTPToken` `name`. + example: MyToken + pattern: ^[A-Za-z][A-Za-z\\d]*$ + type: string + type: + $ref: '#/components/schemas/TokenType' + value: + description: The `HTTPToken` `value`. + example: Some Token Value + type: string + required: + - name + - value + - type + type: object + HTTPTokenAuth: + description: The definition of `HTTPTokenAuth` object. + properties: + body: + $ref: '#/components/schemas/HTTPBody' + headers: + description: The `HTTPTokenAuth` `headers`. + items: + $ref: '#/components/schemas/HTTPHeader' + type: array + tokens: + description: The `HTTPTokenAuth` `tokens`. + items: + $ref: '#/components/schemas/HTTPToken' + type: array + type: + $ref: '#/components/schemas/HTTPTokenAuthType' + url_parameters: + description: The `HTTPTokenAuth` `url_parameters`. + items: + $ref: '#/components/schemas/UrlParam' + type: array + required: + - type + type: object + HTTPTokenAuthType: + description: The definition of `HTTPTokenAuthType` object. + enum: + - HTTPTokenAuth + example: HTTPTokenAuth + type: string + x-enum-varnames: + - HTTPTOKENAUTH + HTTPTokenAuthUpdate: + description: The definition of `HTTPTokenAuthUpdate` object. + properties: + body: + $ref: '#/components/schemas/HTTPBody' + headers: + description: The `HTTPTokenAuthUpdate` `headers`. + items: + $ref: '#/components/schemas/HTTPHeaderUpdate' + type: array + tokens: + description: The `HTTPTokenAuthUpdate` `tokens`. + items: + $ref: '#/components/schemas/HTTPTokenUpdate' + type: array + type: + $ref: '#/components/schemas/HTTPTokenAuthType' + url_parameters: + description: The `HTTPTokenAuthUpdate` `url_parameters`. + items: + $ref: '#/components/schemas/UrlParamUpdate' + type: array + required: + - type + type: object + HTTPTokenUpdate: + description: The definition of `HTTPTokenUpdate` object. + properties: + deleted: + description: Should the header be deleted. + type: boolean + name: + description: The `HTTPToken` `name`. + example: MyToken + pattern: ^[A-Za-z][A-Za-z\\d]*$ + type: string + type: + $ref: '#/components/schemas/TokenType' + value: + description: The `HTTPToken` `value`. + example: Some Token Value + type: string + required: + - name + - type + - value + type: object HistoricalJobDataType: description: Type of payload. enum: @@ -28735,6 +29117,19 @@ components: items: $ref: '#/components/schemas/TimeseriesResponseValues' type: array + TokenName: + description: Name for tokens. + example: MyTokenName + pattern: ^[A-Za-z][A-Za-z\\d]*$ + type: string + TokenType: + description: The definition of `TokenType` object. + enum: + - SECRET + example: SECRET + type: string + x-enum-varnames: + - SECRET Unit: description: Object containing the metric unit family, scale factor, name, and short name. @@ -28763,6 +29158,20 @@ components: example: min type: string type: object + UpdateActionConnectionRequest: + description: Request used to update an action connection. + properties: + data: + $ref: '#/components/schemas/ActionConnectionDataUpdate' + required: + - data + type: object + UpdateActionConnectionResponse: + description: The response for an updated connection. + properties: + data: + $ref: '#/components/schemas/ActionConnectionData' + type: object UpdateAppRequest: description: The definition of `UpdateAppRequest` object. example: @@ -29033,6 +29442,36 @@ components: description: Upsert entity response included item. oneOf: - $ref: '#/components/schemas/EntityResponseIncludedSchema' + UrlParam: + description: The definition of `UrlParam` object. + properties: + name: + $ref: '#/components/schemas/TokenName' + example: MyUrlParameter + value: + description: The `UrlParam` `value`. + example: Some Url Parameter value + type: string + required: + - name + - value + type: object + UrlParamUpdate: + description: The definition of `UrlParamUpdate` object. + properties: + deleted: + description: Should the header be deleted. + type: boolean + name: + $ref: '#/components/schemas/TokenName' + example: MyUrlParameter + value: + description: The `UrlParamUpdate` `value`. + example: Some Url Parameter value + type: string + required: + - name + type: object UsageApplicationSecurityMonitoringResponse: description: Application Security Monitoring usage response. properties: @@ -30274,6 +30713,163 @@ info: version: '1.0' openapi: 3.0.0 paths: + /api/v2/actions/connections: + post: + description: Create a new Action Connection + operationId: CreateActionConnection + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateActionConnectionRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/CreateActionConnectionResponse' + description: Successfully created Action Connection + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '429': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Too Many Request + summary: Create a new Action Connection + tags: + - Action Connection + /api/v2/actions/connections/{connection_id}: + delete: + description: Delete an existing Action Connection + operationId: DeleteActionConnection + parameters: + - $ref: '#/components/parameters/ConnectionId' + responses: + '204': + description: The resource was deleted successfully. + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Too Many Request + summary: Delete an existing Action Connection + tags: + - Action Connection + x-permission: + operator: OR + permissions: + - connection_write + get: + description: Get an existing Action Connection + operationId: GetActionConnection + parameters: + - $ref: '#/components/parameters/ConnectionId' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/GetActionConnectionResponse' + description: Successfully get Action Connection + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Too Many Request + summary: Get an existing Action Connection + tags: + - Action Connection + patch: + description: Update an existing Action Connection + operationId: UpdateActionConnection + parameters: + - $ref: '#/components/parameters/ConnectionId' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateActionConnectionRequest' + description: Update an existing Action Connection request body + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateActionConnectionResponse' + description: Successfully updated Action Connection + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Too Many Request + summary: Update an existing Action Connection + tags: + - Action Connection /api/v2/agentless_scanning/accounts/aws: get: description: Fetches the scan options configured for AWS accounts. @@ -48218,6 +48814,17 @@ tags: externalDocs: url: https://docs.datadoghq.com/integrations/amazon_web_services/#log-collection name: AWS Logs Integration +- description: "Action connections extend your installed integrations and allow you + to take action in your third-party systems\n(e.g. AWS, GitLab, and Statuspage) + with Datadog\u2019s Workflow Automation and App Builder products.\n\nDatadog\u2019s + Integrations automatically provide authentication for Slack, Microsoft Teams, + PagerDuty, Opsgenie,\nJIRA, GitHub, and Statuspage. You do not need additional + connections in order to access these tools within\nWorkflow Automation and App + Builder.\n\nWe offer granular access control for editing and resolving connections." + externalDocs: + description: Find out more at + url: https://docs.datadoghq.com/service_management/workflows/connections/ + name: Action Connection - description: "Datadog Agentless Scanning provides visibility into risks and vulnerabilities\nwithin your hosts, running containers, and serverless functions\u2014all without\nrequiring teams to install Agents on every host or where Agents cannot be installed.\nGo diff --git a/examples/v2_action-connection_CreateActionConnection.rs b/examples/v2_action-connection_CreateActionConnection.rs new file mode 100644 index 000000000..1376df05e --- /dev/null +++ b/examples/v2_action-connection_CreateActionConnection.rs @@ -0,0 +1,40 @@ +// Create a new Action Connection returns "Successfully created Action Connection" +// response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_action_connection::ActionConnectionAPI; +use datadog_api_client::datadogV2::model::AWSAssumeRole; +use datadog_api_client::datadogV2::model::AWSAssumeRoleType; +use datadog_api_client::datadogV2::model::AWSCredentials; +use datadog_api_client::datadogV2::model::AWSIntegration; +use datadog_api_client::datadogV2::model::AWSIntegrationType; +use datadog_api_client::datadogV2::model::ActionConnectionAttributes; +use datadog_api_client::datadogV2::model::ActionConnectionData; +use datadog_api_client::datadogV2::model::ActionConnectionDataType; +use datadog_api_client::datadogV2::model::ActionConnectionIntegration; +use datadog_api_client::datadogV2::model::CreateActionConnectionRequest; + +#[tokio::main] +async fn main() { + let body = CreateActionConnectionRequest::new(ActionConnectionData::new( + ActionConnectionAttributes::new( + ActionConnectionIntegration::AWSIntegration(Box::new(AWSIntegration::new( + AWSCredentials::AWSAssumeRole(Box::new(AWSAssumeRole::new( + "123456789123".to_string(), + "MyRoleUpdated".to_string(), + AWSAssumeRoleType::AWSASSUMEROLE, + ))), + AWSIntegrationType::AWS, + ))), + "Cassette Connection DELETE_ME".to_string(), + ), + ActionConnectionDataType::ACTION_CONNECTION, + )); + let configuration = datadog::Configuration::new(); + let api = ActionConnectionAPI::with_config(configuration); + let resp = api.create_action_connection(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_action-connection_DeleteActionConnection.rs b/examples/v2_action-connection_DeleteActionConnection.rs new file mode 100644 index 000000000..eec6fae74 --- /dev/null +++ b/examples/v2_action-connection_DeleteActionConnection.rs @@ -0,0 +1,18 @@ +// Delete an existing Action Connection returns "The resource was deleted +// successfully." response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_action_connection::ActionConnectionAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = ActionConnectionAPI::with_config(configuration); + let resp = api + .delete_action_connection("connection_id".to_string()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_action-connection_DeleteActionConnection_2142905164.rs b/examples/v2_action-connection_DeleteActionConnection_2142905164.rs new file mode 100644 index 000000000..cc5a10a56 --- /dev/null +++ b/examples/v2_action-connection_DeleteActionConnection_2142905164.rs @@ -0,0 +1,20 @@ +// Delete an existing Action Connection returns "Successfully deleted Action +// Connection" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_action_connection::ActionConnectionAPI; + +#[tokio::main] +async fn main() { + // there is a valid "action_connection" in the system + let action_connection_data_id = std::env::var("ACTION_CONNECTION_DATA_ID").unwrap(); + let configuration = datadog::Configuration::new(); + let api = ActionConnectionAPI::with_config(configuration); + let resp = api + .delete_action_connection(action_connection_data_id.clone()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_action-connection_GetActionConnection.rs b/examples/v2_action-connection_GetActionConnection.rs new file mode 100644 index 000000000..79c046774 --- /dev/null +++ b/examples/v2_action-connection_GetActionConnection.rs @@ -0,0 +1,18 @@ +// Get an existing Action Connection returns "Successfully get Action Connection" +// response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_action_connection::ActionConnectionAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = ActionConnectionAPI::with_config(configuration); + let resp = api + .get_action_connection("cb460d51-3c88-4e87-adac-d47131d0423d".to_string()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_action-connection_UpdateActionConnection.rs b/examples/v2_action-connection_UpdateActionConnection.rs new file mode 100644 index 000000000..856a0c8e0 --- /dev/null +++ b/examples/v2_action-connection_UpdateActionConnection.rs @@ -0,0 +1,44 @@ +// Update an existing Action Connection returns "Successfully updated Action +// Connection" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_action_connection::ActionConnectionAPI; +use datadog_api_client::datadogV2::model::AWSAssumeRoleType; +use datadog_api_client::datadogV2::model::AWSAssumeRoleUpdate; +use datadog_api_client::datadogV2::model::AWSCredentialsUpdate; +use datadog_api_client::datadogV2::model::AWSIntegrationType; +use datadog_api_client::datadogV2::model::AWSIntegrationUpdate; +use datadog_api_client::datadogV2::model::ActionConnectionAttributesUpdate; +use datadog_api_client::datadogV2::model::ActionConnectionDataType; +use datadog_api_client::datadogV2::model::ActionConnectionDataUpdate; +use datadog_api_client::datadogV2::model::ActionConnectionIntegrationUpdate; +use datadog_api_client::datadogV2::model::UpdateActionConnectionRequest; + +#[tokio::main] +async fn main() { + let body = UpdateActionConnectionRequest::new(ActionConnectionDataUpdate::new( + ActionConnectionAttributesUpdate::new() + .integration(ActionConnectionIntegrationUpdate::AWSIntegrationUpdate( + Box::new( + AWSIntegrationUpdate::new(AWSIntegrationType::AWS).credentials( + AWSCredentialsUpdate::AWSAssumeRoleUpdate(Box::new( + AWSAssumeRoleUpdate::new(AWSAssumeRoleType::AWSASSUMEROLE) + .account_id("123456789123".to_string()) + .role("MyRoleUpdated".to_string()), + )), + ), + ), + )) + .name("Cassette Connection".to_string()), + ActionConnectionDataType::ACTION_CONNECTION, + )); + let configuration = datadog::Configuration::new(); + let api = ActionConnectionAPI::with_config(configuration); + let resp = api + .update_action_connection("cb460d51-3c88-4e87-adac-d47131d0423d".to_string(), body) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadogV2/api/api_action_connection.rs b/src/datadogV2/api/api_action_connection.rs new file mode 100644 index 000000000..27b6fb7c5 --- /dev/null +++ b/src/datadogV2/api/api_action_connection.rs @@ -0,0 +1,633 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use crate::datadog; +use flate2::{ + write::{GzEncoder, ZlibEncoder}, + Compression, +}; +use reqwest::header::{HeaderMap, HeaderValue}; +use serde::{Deserialize, Serialize}; +use std::io::Write; + +/// CreateActionConnectionError is a struct for typed errors of method [`ActionConnectionAPI::create_action_connection`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateActionConnectionError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// DeleteActionConnectionError is a struct for typed errors of method [`ActionConnectionAPI::delete_action_connection`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteActionConnectionError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GetActionConnectionError is a struct for typed errors of method [`ActionConnectionAPI::get_action_connection`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetActionConnectionError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// UpdateActionConnectionError is a struct for typed errors of method [`ActionConnectionAPI::update_action_connection`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateActionConnectionError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// Action connections extend your installed integrations and allow you to take action in your third-party systems +/// (e.g. AWS, GitLab, and Statuspage) with Datadog’s Workflow Automation and App Builder products. +/// +/// Datadog’s Integrations automatically provide authentication for Slack, Microsoft Teams, PagerDuty, Opsgenie, +/// JIRA, GitHub, and Statuspage. You do not need additional connections in order to access these tools within +/// Workflow Automation and App Builder. +/// +/// We offer granular access control for editing and resolving connections. +#[derive(Debug, Clone)] +pub struct ActionConnectionAPI { + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, +} + +impl Default for ActionConnectionAPI { + fn default() -> Self { + Self::with_config(datadog::Configuration::default()) + } +} + +impl ActionConnectionAPI { + pub fn new() -> Self { + Self::default() + } + pub fn with_config(config: datadog::Configuration) -> Self { + let mut reqwest_client_builder = reqwest::Client::builder(); + + if let Some(proxy_url) = &config.proxy_url { + let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL"); + reqwest_client_builder = reqwest_client_builder.proxy(proxy); + } + + let mut middleware_client_builder = + reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap()); + + if config.enable_retry { + struct RetryableStatus; + impl reqwest_retry::RetryableStrategy for RetryableStatus { + fn handle( + &self, + res: &Result, + ) -> Option { + match res { + Ok(success) => reqwest_retry::default_on_request_success(success), + Err(_) => None, + } + } + } + let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder() + .build_with_max_retries(config.max_retries); + + let retry_middleware = + reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy( + backoff_policy, + RetryableStatus, + ); + + middleware_client_builder = middleware_client_builder.with(retry_middleware); + } + + let client = middleware_client_builder.build(); + + Self { config, client } + } + + pub fn with_client_and_config( + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, + ) -> Self { + Self { config, client } + } + + /// Create a new Action Connection + pub async fn create_action_connection( + &self, + body: crate::datadogV2::model::CreateActionConnectionRequest, + ) -> Result< + crate::datadogV2::model::CreateActionConnectionResponse, + datadog::Error, + > { + match self.create_action_connection_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), + } + } + + /// Create a new Action Connection + pub async fn create_action_connection_with_http_info( + &self, + body: crate::datadogV2::model::CreateActionConnectionRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_action_connection"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/actions/connections", + 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, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Delete an existing Action Connection + pub async fn delete_action_connection( + &self, + connection_id: String, + ) -> Result<(), datadog::Error> { + match self + .delete_action_connection_with_http_info(connection_id) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Delete an existing Action Connection + pub async fn delete_action_connection_with_http_info( + &self, + connection_id: String, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.delete_action_connection"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/actions/connections/{connection_id}", + local_configuration.get_operation_host(operation_id), + connection_id = datadog::urlencode(connection_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // 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() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } 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 an existing Action Connection + pub async fn get_action_connection( + &self, + connection_id: String, + ) -> Result< + crate::datadogV2::model::GetActionConnectionResponse, + datadog::Error, + > { + match self + .get_action_connection_with_http_info(connection_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), + } + } + + /// Get an existing Action Connection + pub async fn get_action_connection_with_http_info( + &self, + connection_id: String, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_action_connection"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/actions/connections/{connection_id}", + local_configuration.get_operation_host(operation_id), + connection_id = datadog::urlencode(connection_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)) + } + } + + /// Update an existing Action Connection + pub async fn update_action_connection( + &self, + connection_id: String, + body: crate::datadogV2::model::UpdateActionConnectionRequest, + ) -> Result< + crate::datadogV2::model::UpdateActionConnectionResponse, + datadog::Error, + > { + match self + .update_action_connection_with_http_info(connection_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), + } + } + + /// Update an existing Action Connection + pub async fn update_action_connection_with_http_info( + &self, + connection_id: String, + body: crate::datadogV2::model::UpdateActionConnectionRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.update_action_connection"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/actions/connections/{connection_id}", + local_configuration.get_operation_host(operation_id), + connection_id = datadog::urlencode(connection_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)) + } + } +} diff --git a/src/datadogV2/api/mod.rs b/src/datadogV2/api/mod.rs index b21f39ae7..ea7416e57 100644 --- a/src/datadogV2/api/mod.rs +++ b/src/datadogV2/api/mod.rs @@ -2,6 +2,7 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2019-Present Datadog, Inc. +pub mod api_action_connection; pub mod api_agentless_scanning; pub mod api_api_management; pub mod api_apm_retention_filters; diff --git a/src/datadogV2/mod.rs b/src/datadogV2/mod.rs index f6b8e444f..e20365144 100644 --- a/src/datadogV2/mod.rs +++ b/src/datadogV2/mod.rs @@ -3,6 +3,7 @@ // Copyright 2019-Present Datadog, Inc. pub mod api; +pub use self::api::api_action_connection; pub use self::api::api_agentless_scanning; pub use self::api::api_api_management; pub use self::api::api_apm_retention_filters; diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 515e9ffb0..665554210 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -2,6 +2,84 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2019-Present Datadog, Inc. +pub mod model_create_action_connection_request; +pub use self::model_create_action_connection_request::CreateActionConnectionRequest; +pub mod model_action_connection_data; +pub use self::model_action_connection_data::ActionConnectionData; +pub mod model_action_connection_attributes; +pub use self::model_action_connection_attributes::ActionConnectionAttributes; +pub mod model_aws_integration; +pub use self::model_aws_integration::AWSIntegration; +pub mod model_aws_assume_role; +pub use self::model_aws_assume_role::AWSAssumeRole; +pub mod model_aws_assume_role_type; +pub use self::model_aws_assume_role_type::AWSAssumeRoleType; +pub mod model_aws_credentials; +pub use self::model_aws_credentials::AWSCredentials; +pub mod model_aws_integration_type; +pub use self::model_aws_integration_type::AWSIntegrationType; +pub mod model_http_integration; +pub use self::model_http_integration::HTTPIntegration; +pub mod model_http_token_auth; +pub use self::model_http_token_auth::HTTPTokenAuth; +pub mod model_http_body; +pub use self::model_http_body::HTTPBody; +pub mod model_http_header; +pub use self::model_http_header::HTTPHeader; +pub mod model_http_token; +pub use self::model_http_token::HTTPToken; +pub mod model_token_type; +pub use self::model_token_type::TokenType; +pub mod model_http_token_auth_type; +pub use self::model_http_token_auth_type::HTTPTokenAuthType; +pub mod model_url_param; +pub use self::model_url_param::UrlParam; +pub mod model_http_credentials; +pub use self::model_http_credentials::HTTPCredentials; +pub mod model_http_integration_type; +pub use self::model_http_integration_type::HTTPIntegrationType; +pub mod model_action_connection_integration; +pub use self::model_action_connection_integration::ActionConnectionIntegration; +pub mod model_action_connection_data_type; +pub use self::model_action_connection_data_type::ActionConnectionDataType; +pub mod model_create_action_connection_response; +pub use self::model_create_action_connection_response::CreateActionConnectionResponse; +pub mod model_jsonapi_error_response; +pub use self::model_jsonapi_error_response::JSONAPIErrorResponse; +pub mod model_jsonapi_error_item; +pub use self::model_jsonapi_error_item::JSONAPIErrorItem; +pub mod model_jsonapi_error_item_source; +pub use self::model_jsonapi_error_item_source::JSONAPIErrorItemSource; +pub mod model_get_action_connection_response; +pub use self::model_get_action_connection_response::GetActionConnectionResponse; +pub mod model_update_action_connection_request; +pub use self::model_update_action_connection_request::UpdateActionConnectionRequest; +pub mod model_action_connection_data_update; +pub use self::model_action_connection_data_update::ActionConnectionDataUpdate; +pub mod model_action_connection_attributes_update; +pub use self::model_action_connection_attributes_update::ActionConnectionAttributesUpdate; +pub mod model_aws_integration_update; +pub use self::model_aws_integration_update::AWSIntegrationUpdate; +pub mod model_aws_assume_role_update; +pub use self::model_aws_assume_role_update::AWSAssumeRoleUpdate; +pub mod model_aws_credentials_update; +pub use self::model_aws_credentials_update::AWSCredentialsUpdate; +pub mod model_http_integration_update; +pub use self::model_http_integration_update::HTTPIntegrationUpdate; +pub mod model_http_token_auth_update; +pub use self::model_http_token_auth_update::HTTPTokenAuthUpdate; +pub mod model_http_header_update; +pub use self::model_http_header_update::HTTPHeaderUpdate; +pub mod model_http_token_update; +pub use self::model_http_token_update::HTTPTokenUpdate; +pub mod model_url_param_update; +pub use self::model_url_param_update::UrlParamUpdate; +pub mod model_http_credentials_update; +pub use self::model_http_credentials_update::HTTPCredentialsUpdate; +pub mod model_action_connection_integration_update; +pub use self::model_action_connection_integration_update::ActionConnectionIntegrationUpdate; +pub mod model_update_action_connection_response; +pub use self::model_update_action_connection_response::UpdateActionConnectionResponse; pub mod model_aws_scan_options_response; pub use self::model_aws_scan_options_response::AwsScanOptionsResponse; pub mod model_aws_scan_options_data; @@ -96,12 +174,6 @@ pub mod model_list_apis_response_meta; pub use self::model_list_apis_response_meta::ListAPIsResponseMeta; pub mod model_list_apis_response_meta_pagination; pub use self::model_list_apis_response_meta_pagination::ListAPIsResponseMetaPagination; -pub mod model_jsonapi_error_response; -pub use self::model_jsonapi_error_response::JSONAPIErrorResponse; -pub mod model_jsonapi_error_item; -pub use self::model_jsonapi_error_item::JSONAPIErrorItem; -pub mod model_jsonapi_error_item_source; -pub use self::model_jsonapi_error_item_source::JSONAPIErrorItemSource; pub mod model_open_api_file; pub use self::model_open_api_file::OpenAPIFile; pub mod model_update_open_api_response; diff --git a/src/datadogV2/model/model_action_connection_attributes.rs b/src/datadogV2/model/model_action_connection_attributes.rs new file mode 100644 index 000000000..5b136e4d9 --- /dev/null +++ b/src/datadogV2/model/model_action_connection_attributes.rs @@ -0,0 +1,116 @@ +// 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}; + +/// The definition of `ActionConnectionAttributes` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ActionConnectionAttributes { + /// The definition of `ActionConnectionIntegration` object. + #[serde(rename = "integration")] + pub integration: crate::datadogV2::model::ActionConnectionIntegration, + /// Name of the connection + #[serde(rename = "name")] + pub name: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ActionConnectionAttributes { + pub fn new( + integration: crate::datadogV2::model::ActionConnectionIntegration, + name: String, + ) -> ActionConnectionAttributes { + ActionConnectionAttributes { + integration, + name, + 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 ActionConnectionAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ActionConnectionAttributesVisitor; + impl<'a> Visitor<'a> for ActionConnectionAttributesVisitor { + type Value = ActionConnectionAttributes; + + 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 integration: Option = + None; + let mut name: 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() { + "integration" => { + integration = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _integration) = integration { + match _integration { + crate::datadogV2::model::ActionConnectionIntegration::UnparsedObject(_integration) => { + _unparsed = true; + }, + _ => {} + } + } + } + "name" => { + name = 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 integration = + integration.ok_or_else(|| M::Error::missing_field("integration"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + + let content = ActionConnectionAttributes { + integration, + name, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ActionConnectionAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_action_connection_attributes_update.rs b/src/datadogV2/model/model_action_connection_attributes_update.rs new file mode 100644 index 000000000..54b6c955c --- /dev/null +++ b/src/datadogV2/model/model_action_connection_attributes_update.rs @@ -0,0 +1,136 @@ +// 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}; + +/// The definition of `ActionConnectionAttributesUpdate` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ActionConnectionAttributesUpdate { + /// The definition of `ActionConnectionIntegrationUpdate` object. + #[serde(rename = "integration")] + pub integration: Option, + /// Name of the connection + #[serde(rename = "name")] + pub name: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ActionConnectionAttributesUpdate { + pub fn new() -> ActionConnectionAttributesUpdate { + ActionConnectionAttributesUpdate { + integration: None, + name: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn integration( + mut self, + value: crate::datadogV2::model::ActionConnectionIntegrationUpdate, + ) -> Self { + self.integration = Some(value); + self + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ActionConnectionAttributesUpdate { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ActionConnectionAttributesUpdate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ActionConnectionAttributesUpdateVisitor; + impl<'a> Visitor<'a> for ActionConnectionAttributesUpdateVisitor { + type Value = ActionConnectionAttributesUpdate; + + 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 integration: Option< + crate::datadogV2::model::ActionConnectionIntegrationUpdate, + > = None; + let mut name: 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() { + "integration" => { + if v.is_null() { + continue; + } + integration = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _integration) = integration { + match _integration { + crate::datadogV2::model::ActionConnectionIntegrationUpdate::UnparsedObject(_integration) => { + _unparsed = true; + }, + _ => {} + } + } + } + "name" => { + if v.is_null() { + continue; + } + name = 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 = ActionConnectionAttributesUpdate { + integration, + name, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ActionConnectionAttributesUpdateVisitor) + } +} diff --git a/src/datadogV2/model/model_action_connection_data.rs b/src/datadogV2/model/model_action_connection_data.rs new file mode 100644 index 000000000..08891cc41 --- /dev/null +++ b/src/datadogV2/model/model_action_connection_data.rs @@ -0,0 +1,131 @@ +// 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}; + +/// Data related to the connection. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ActionConnectionData { + /// The definition of `ActionConnectionAttributes` object. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::ActionConnectionAttributes, + /// The connection identifier + #[serde(rename = "id")] + pub id: Option, + /// The definition of `ActionConnectionDataType` object. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::ActionConnectionDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ActionConnectionData { + pub fn new( + attributes: crate::datadogV2::model::ActionConnectionAttributes, + type_: crate::datadogV2::model::ActionConnectionDataType, + ) -> ActionConnectionData { + ActionConnectionData { + attributes, + id: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn id(mut self, value: String) -> Self { + self.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 ActionConnectionData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ActionConnectionDataVisitor; + impl<'a> Visitor<'a> for ActionConnectionDataVisitor { + type Value = ActionConnectionData; + + 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" => { + 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" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::ActionConnectionDataType::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 = ActionConnectionData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ActionConnectionDataVisitor) + } +} diff --git a/src/datadogV2/model/model_action_connection_data_type.rs b/src/datadogV2/model/model_action_connection_data_type.rs new file mode 100644 index 000000000..a1e8bc7b6 --- /dev/null +++ b/src/datadogV2/model/model_action_connection_data_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 ActionConnectionDataType { + ACTION_CONNECTION, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ActionConnectionDataType { + fn to_string(&self) -> String { + match self { + Self::ACTION_CONNECTION => String::from("action_connection"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ActionConnectionDataType { + 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 ActionConnectionDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "action_connection" => Self::ACTION_CONNECTION, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_action_connection_data_update.rs b/src/datadogV2/model/model_action_connection_data_update.rs new file mode 100644 index 000000000..5f051cc2a --- /dev/null +++ b/src/datadogV2/model/model_action_connection_data_update.rs @@ -0,0 +1,115 @@ +// 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}; + +/// Data related to the connection update. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ActionConnectionDataUpdate { + /// The definition of `ActionConnectionAttributesUpdate` object. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::ActionConnectionAttributesUpdate, + /// The definition of `ActionConnectionDataType` object. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::ActionConnectionDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ActionConnectionDataUpdate { + pub fn new( + attributes: crate::datadogV2::model::ActionConnectionAttributesUpdate, + type_: crate::datadogV2::model::ActionConnectionDataType, + ) -> ActionConnectionDataUpdate { + ActionConnectionDataUpdate { + 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 ActionConnectionDataUpdate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ActionConnectionDataUpdateVisitor; + impl<'a> Visitor<'a> for ActionConnectionDataUpdateVisitor { + type Value = ActionConnectionDataUpdate; + + 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::ActionConnectionAttributesUpdate, + > = 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::ActionConnectionDataType::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 = ActionConnectionDataUpdate { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ActionConnectionDataUpdateVisitor) + } +} diff --git a/src/datadogV2/model/model_action_connection_integration.rs b/src/datadogV2/model/model_action_connection_integration.rs new file mode 100644 index 000000000..df41811e4 --- /dev/null +++ b/src/datadogV2/model/model_action_connection_integration.rs @@ -0,0 +1,41 @@ +// 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}; + +/// The definition of `ActionConnectionIntegration` object. +#[non_exhaustive] +#[derive(Clone, Debug, PartialEq, Serialize)] +#[serde(untagged)] +pub enum ActionConnectionIntegration { + AWSIntegration(Box), + HTTPIntegration(Box), + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl<'de> Deserialize<'de> for ActionConnectionIntegration { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let value: serde_json::Value = Deserialize::deserialize(deserializer)?; + if let Ok(_v) = + serde_json::from_value::>(value.clone()) + { + if !_v._unparsed { + return Ok(ActionConnectionIntegration::AWSIntegration(_v)); + } + } + if let Ok(_v) = + serde_json::from_value::>(value.clone()) + { + if !_v._unparsed { + return Ok(ActionConnectionIntegration::HTTPIntegration(_v)); + } + } + + return Ok(ActionConnectionIntegration::UnparsedObject( + crate::datadog::UnparsedObject { value }, + )); + } +} diff --git a/src/datadogV2/model/model_action_connection_integration_update.rs b/src/datadogV2/model/model_action_connection_integration_update.rs new file mode 100644 index 000000000..2fe8cf46a --- /dev/null +++ b/src/datadogV2/model/model_action_connection_integration_update.rs @@ -0,0 +1,41 @@ +// 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}; + +/// The definition of `ActionConnectionIntegrationUpdate` object. +#[non_exhaustive] +#[derive(Clone, Debug, PartialEq, Serialize)] +#[serde(untagged)] +pub enum ActionConnectionIntegrationUpdate { + AWSIntegrationUpdate(Box), + HTTPIntegrationUpdate(Box), + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl<'de> Deserialize<'de> for ActionConnectionIntegrationUpdate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let value: serde_json::Value = Deserialize::deserialize(deserializer)?; + if let Ok(_v) = serde_json::from_value::>( + value.clone(), + ) { + if !_v._unparsed { + return Ok(ActionConnectionIntegrationUpdate::AWSIntegrationUpdate(_v)); + } + } + if let Ok(_v) = serde_json::from_value::>( + value.clone(), + ) { + if !_v._unparsed { + return Ok(ActionConnectionIntegrationUpdate::HTTPIntegrationUpdate(_v)); + } + } + + return Ok(ActionConnectionIntegrationUpdate::UnparsedObject( + crate::datadog::UnparsedObject { value }, + )); + } +} diff --git a/src/datadogV2/model/model_aws_assume_role.rs b/src/datadogV2/model/model_aws_assume_role.rs new file mode 100644 index 000000000..7cb51eb90 --- /dev/null +++ b/src/datadogV2/model/model_aws_assume_role.rs @@ -0,0 +1,162 @@ +// 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}; + +/// The definition of `AWSAssumeRole` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSAssumeRole { + /// AWS account the connection is created for + #[serde(rename = "account_id")] + pub account_id: String, + /// External ID used to scope which connection can be used to assume the role + #[serde(rename = "external_id")] + pub external_id: Option, + /// AWS account that will assume the role + #[serde(rename = "principal_id")] + pub principal_id: Option, + /// Role to assume + #[serde(rename = "role")] + pub role: String, + /// The definition of `AWSAssumeRoleType` object. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::AWSAssumeRoleType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSAssumeRole { + pub fn new( + account_id: String, + role: String, + type_: crate::datadogV2::model::AWSAssumeRoleType, + ) -> AWSAssumeRole { + AWSAssumeRole { + account_id, + external_id: None, + principal_id: None, + role, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn external_id(mut self, value: String) -> Self { + self.external_id = Some(value); + self + } + + pub fn principal_id(mut self, value: String) -> Self { + self.principal_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 AWSAssumeRole { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSAssumeRoleVisitor; + impl<'a> Visitor<'a> for AWSAssumeRoleVisitor { + type Value = AWSAssumeRole; + + 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 account_id: Option = None; + let mut external_id: Option = None; + let mut principal_id: Option = None; + let mut role: 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() { + "account_id" => { + account_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "external_id" => { + if v.is_null() { + continue; + } + external_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "principal_id" => { + if v.is_null() { + continue; + } + principal_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "role" => { + role = 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::AWSAssumeRoleType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let account_id = account_id.ok_or_else(|| M::Error::missing_field("account_id"))?; + let role = role.ok_or_else(|| M::Error::missing_field("role"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = AWSAssumeRole { + account_id, + external_id, + principal_id, + role, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSAssumeRoleVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_assume_role_type.rs b/src/datadogV2/model/model_aws_assume_role_type.rs new file mode 100644 index 000000000..a2f66f116 --- /dev/null +++ b/src/datadogV2/model/model_aws_assume_role_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 AWSAssumeRoleType { + AWSASSUMEROLE, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for AWSAssumeRoleType { + fn to_string(&self) -> String { + match self { + Self::AWSASSUMEROLE => String::from("AWSAssumeRole"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for AWSAssumeRoleType { + 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 AWSAssumeRoleType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "AWSAssumeRole" => Self::AWSASSUMEROLE, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_aws_assume_role_update.rs b/src/datadogV2/model/model_aws_assume_role_update.rs new file mode 100644 index 000000000..9ff3cd201 --- /dev/null +++ b/src/datadogV2/model/model_aws_assume_role_update.rs @@ -0,0 +1,154 @@ +// 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}; + +/// The definition of `AWSAssumeRoleUpdate` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSAssumeRoleUpdate { + /// AWS account the connection is created for + #[serde(rename = "account_id")] + pub account_id: Option, + /// The `AWSAssumeRoleUpdate` `generate_new_external_id`. + #[serde(rename = "generate_new_external_id")] + pub generate_new_external_id: Option, + /// Role to assume + #[serde(rename = "role")] + pub role: Option, + /// The definition of `AWSAssumeRoleType` object. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::AWSAssumeRoleType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSAssumeRoleUpdate { + pub fn new(type_: crate::datadogV2::model::AWSAssumeRoleType) -> AWSAssumeRoleUpdate { + AWSAssumeRoleUpdate { + account_id: None, + generate_new_external_id: None, + role: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn account_id(mut self, value: String) -> Self { + self.account_id = Some(value); + self + } + + pub fn generate_new_external_id(mut self, value: bool) -> Self { + self.generate_new_external_id = Some(value); + self + } + + pub fn role(mut self, value: String) -> Self { + self.role = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for AWSAssumeRoleUpdate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSAssumeRoleUpdateVisitor; + impl<'a> Visitor<'a> for AWSAssumeRoleUpdateVisitor { + type Value = AWSAssumeRoleUpdate; + + 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 account_id: Option = None; + let mut generate_new_external_id: Option = None; + let mut role: 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() { + "account_id" => { + if v.is_null() { + continue; + } + account_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "generate_new_external_id" => { + if v.is_null() { + continue; + } + generate_new_external_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "role" => { + if v.is_null() { + continue; + } + role = 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::AWSAssumeRoleType::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 = AWSAssumeRoleUpdate { + account_id, + generate_new_external_id, + role, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSAssumeRoleUpdateVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_credentials.rs b/src/datadogV2/model/model_aws_credentials.rs new file mode 100644 index 000000000..b9ca687d8 --- /dev/null +++ b/src/datadogV2/model/model_aws_credentials.rs @@ -0,0 +1,33 @@ +// 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}; + +/// The definition of `AWSCredentials` object. +#[non_exhaustive] +#[derive(Clone, Debug, PartialEq, Serialize)] +#[serde(untagged)] +pub enum AWSCredentials { + AWSAssumeRole(Box), + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl<'de> Deserialize<'de> for AWSCredentials { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let value: serde_json::Value = Deserialize::deserialize(deserializer)?; + if let Ok(_v) = + serde_json::from_value::>(value.clone()) + { + if !_v._unparsed { + return Ok(AWSCredentials::AWSAssumeRole(_v)); + } + } + + return Ok(AWSCredentials::UnparsedObject( + crate::datadog::UnparsedObject { value }, + )); + } +} diff --git a/src/datadogV2/model/model_aws_credentials_update.rs b/src/datadogV2/model/model_aws_credentials_update.rs new file mode 100644 index 000000000..02f6b0b06 --- /dev/null +++ b/src/datadogV2/model/model_aws_credentials_update.rs @@ -0,0 +1,33 @@ +// 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}; + +/// The definition of `AWSCredentialsUpdate` object. +#[non_exhaustive] +#[derive(Clone, Debug, PartialEq, Serialize)] +#[serde(untagged)] +pub enum AWSCredentialsUpdate { + AWSAssumeRoleUpdate(Box), + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl<'de> Deserialize<'de> for AWSCredentialsUpdate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let value: serde_json::Value = Deserialize::deserialize(deserializer)?; + if let Ok(_v) = serde_json::from_value::>( + value.clone(), + ) { + if !_v._unparsed { + return Ok(AWSCredentialsUpdate::AWSAssumeRoleUpdate(_v)); + } + } + + return Ok(AWSCredentialsUpdate::UnparsedObject( + crate::datadog::UnparsedObject { value }, + )); + } +} diff --git a/src/datadogV2/model/model_aws_integration.rs b/src/datadogV2/model/model_aws_integration.rs new file mode 100644 index 000000000..b24d5b8c6 --- /dev/null +++ b/src/datadogV2/model/model_aws_integration.rs @@ -0,0 +1,127 @@ +// 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}; + +/// The definition of `AWSIntegration` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSIntegration { + /// The definition of `AWSCredentials` object. + #[serde(rename = "credentials")] + pub credentials: crate::datadogV2::model::AWSCredentials, + /// The definition of `AWSIntegrationType` object. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::AWSIntegrationType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSIntegration { + pub fn new( + credentials: crate::datadogV2::model::AWSCredentials, + type_: crate::datadogV2::model::AWSIntegrationType, + ) -> AWSIntegration { + AWSIntegration { + credentials, + 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 AWSIntegration { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSIntegrationVisitor; + impl<'a> Visitor<'a> for AWSIntegrationVisitor { + type Value = AWSIntegration; + + 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 credentials: 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() { + "credentials" => { + credentials = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _credentials) = credentials { + match _credentials { + crate::datadogV2::model::AWSCredentials::UnparsedObject( + _credentials, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::AWSIntegrationType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let credentials = + credentials.ok_or_else(|| M::Error::missing_field("credentials"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = AWSIntegration { + credentials, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSIntegrationVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_integration_type.rs b/src/datadogV2/model/model_aws_integration_type.rs new file mode 100644 index 000000000..af2afeb4f --- /dev/null +++ b/src/datadogV2/model/model_aws_integration_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 AWSIntegrationType { + AWS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for AWSIntegrationType { + fn to_string(&self) -> String { + match self { + Self::AWS => String::from("AWS"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for AWSIntegrationType { + 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 AWSIntegrationType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "AWS" => Self::AWS, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_aws_integration_update.rs b/src/datadogV2/model/model_aws_integration_update.rs new file mode 100644 index 000000000..db194a2fb --- /dev/null +++ b/src/datadogV2/model/model_aws_integration_update.rs @@ -0,0 +1,128 @@ +// 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}; + +/// The definition of `AWSIntegrationUpdate` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSIntegrationUpdate { + /// The definition of `AWSCredentialsUpdate` object. + #[serde(rename = "credentials")] + pub credentials: Option, + /// The definition of `AWSIntegrationType` object. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::AWSIntegrationType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSIntegrationUpdate { + pub fn new(type_: crate::datadogV2::model::AWSIntegrationType) -> AWSIntegrationUpdate { + AWSIntegrationUpdate { + credentials: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn credentials(mut self, value: crate::datadogV2::model::AWSCredentialsUpdate) -> Self { + self.credentials = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for AWSIntegrationUpdate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSIntegrationUpdateVisitor; + impl<'a> Visitor<'a> for AWSIntegrationUpdateVisitor { + type Value = AWSIntegrationUpdate; + + 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 credentials: 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() { + "credentials" => { + if v.is_null() { + continue; + } + credentials = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _credentials) = credentials { + match _credentials { + crate::datadogV2::model::AWSCredentialsUpdate::UnparsedObject(_credentials) => { + _unparsed = true; + }, + _ => {} + } + } + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::AWSIntegrationType::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 = AWSIntegrationUpdate { + credentials, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSIntegrationUpdateVisitor) + } +} diff --git a/src/datadogV2/model/model_create_action_connection_request.rs b/src/datadogV2/model/model_create_action_connection_request.rs new file mode 100644 index 000000000..6e3faccb5 --- /dev/null +++ b/src/datadogV2/model/model_create_action_connection_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}; + +/// Request used to create an action connection. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateActionConnectionRequest { + /// Data related to the connection. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::ActionConnectionData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateActionConnectionRequest { + pub fn new( + data: crate::datadogV2::model::ActionConnectionData, + ) -> CreateActionConnectionRequest { + CreateActionConnectionRequest { + 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 CreateActionConnectionRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateActionConnectionRequestVisitor; + impl<'a> Visitor<'a> for CreateActionConnectionRequestVisitor { + type Value = CreateActionConnectionRequest; + + 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 = CreateActionConnectionRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateActionConnectionRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_create_action_connection_response.rs b/src/datadogV2/model/model_create_action_connection_response.rs new file mode 100644 index 000000000..07250abe6 --- /dev/null +++ b/src/datadogV2/model/model_create_action_connection_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}; + +/// The response for a created connection +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateActionConnectionResponse { + /// Data related to the connection. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateActionConnectionResponse { + pub fn new() -> CreateActionConnectionResponse { + CreateActionConnectionResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::ActionConnectionData) -> 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 CreateActionConnectionResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CreateActionConnectionResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateActionConnectionResponseVisitor; + impl<'a> Visitor<'a> for CreateActionConnectionResponseVisitor { + type Value = CreateActionConnectionResponse; + + 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 = CreateActionConnectionResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateActionConnectionResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_get_action_connection_response.rs b/src/datadogV2/model/model_get_action_connection_response.rs new file mode 100644 index 000000000..4c8b63e0d --- /dev/null +++ b/src/datadogV2/model/model_get_action_connection_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}; + +/// The response for found connection +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct GetActionConnectionResponse { + /// Data related to the connection. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl GetActionConnectionResponse { + pub fn new() -> GetActionConnectionResponse { + GetActionConnectionResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::ActionConnectionData) -> 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 GetActionConnectionResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for GetActionConnectionResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct GetActionConnectionResponseVisitor; + impl<'a> Visitor<'a> for GetActionConnectionResponseVisitor { + type Value = GetActionConnectionResponse; + + 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 = GetActionConnectionResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(GetActionConnectionResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_http_body.rs b/src/datadogV2/model/model_http_body.rs new file mode 100644 index 000000000..eee7a39c7 --- /dev/null +++ b/src/datadogV2/model/model_http_body.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}; + +/// The definition of `HTTPBody` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct HTTPBody { + /// Serialized body content + #[serde(rename = "content")] + pub content: Option, + /// Content type of the body + #[serde(rename = "content_type")] + pub content_type: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl HTTPBody { + pub fn new() -> HTTPBody { + HTTPBody { + content: None, + content_type: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn content(mut self, value: String) -> Self { + self.content = Some(value); + self + } + + pub fn content_type(mut self, value: String) -> Self { + self.content_type = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for HTTPBody { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for HTTPBody { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct HTTPBodyVisitor; + impl<'a> Visitor<'a> for HTTPBodyVisitor { + type Value = HTTPBody; + + 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 content: Option = None; + let mut content_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() { + "content" => { + if v.is_null() { + continue; + } + content = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "content_type" => { + if v.is_null() { + continue; + } + content_type = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = HTTPBody { + content, + content_type, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(HTTPBodyVisitor) + } +} diff --git a/src/datadogV2/model/model_http_credentials.rs b/src/datadogV2/model/model_http_credentials.rs new file mode 100644 index 000000000..27404b0ea --- /dev/null +++ b/src/datadogV2/model/model_http_credentials.rs @@ -0,0 +1,33 @@ +// 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}; + +/// The definition of `HTTPCredentials` object. +#[non_exhaustive] +#[derive(Clone, Debug, PartialEq, Serialize)] +#[serde(untagged)] +pub enum HTTPCredentials { + HTTPTokenAuth(Box), + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl<'de> Deserialize<'de> for HTTPCredentials { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let value: serde_json::Value = Deserialize::deserialize(deserializer)?; + if let Ok(_v) = + serde_json::from_value::>(value.clone()) + { + if !_v._unparsed { + return Ok(HTTPCredentials::HTTPTokenAuth(_v)); + } + } + + return Ok(HTTPCredentials::UnparsedObject( + crate::datadog::UnparsedObject { value }, + )); + } +} diff --git a/src/datadogV2/model/model_http_credentials_update.rs b/src/datadogV2/model/model_http_credentials_update.rs new file mode 100644 index 000000000..a2bd165d7 --- /dev/null +++ b/src/datadogV2/model/model_http_credentials_update.rs @@ -0,0 +1,33 @@ +// 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}; + +/// The definition of `HTTPCredentialsUpdate` object. +#[non_exhaustive] +#[derive(Clone, Debug, PartialEq, Serialize)] +#[serde(untagged)] +pub enum HTTPCredentialsUpdate { + HTTPTokenAuthUpdate(Box), + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl<'de> Deserialize<'de> for HTTPCredentialsUpdate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let value: serde_json::Value = Deserialize::deserialize(deserializer)?; + if let Ok(_v) = serde_json::from_value::>( + value.clone(), + ) { + if !_v._unparsed { + return Ok(HTTPCredentialsUpdate::HTTPTokenAuthUpdate(_v)); + } + } + + return Ok(HTTPCredentialsUpdate::UnparsedObject( + crate::datadog::UnparsedObject { value }, + )); + } +} diff --git a/src/datadogV2/model/model_http_header.rs b/src/datadogV2/model/model_http_header.rs new file mode 100644 index 000000000..9a71c1b93 --- /dev/null +++ b/src/datadogV2/model/model_http_header.rs @@ -0,0 +1,102 @@ +// 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}; + +/// The definition of `HTTPHeader` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct HTTPHeader { + /// The `HTTPHeader` `name`. + #[serde(rename = "name")] + pub name: String, + /// The `HTTPHeader` `value`. + #[serde(rename = "value")] + pub value: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl HTTPHeader { + pub fn new(name: String, value: String) -> HTTPHeader { + HTTPHeader { + name, + value, + 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 HTTPHeader { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct HTTPHeaderVisitor; + impl<'a> Visitor<'a> for HTTPHeaderVisitor { + type Value = HTTPHeader; + + 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 name: 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() { + "name" => { + name = 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 name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let value = value.ok_or_else(|| M::Error::missing_field("value"))?; + + let content = HTTPHeader { + name, + value, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(HTTPHeaderVisitor) + } +} diff --git a/src/datadogV2/model/model_http_header_update.rs b/src/datadogV2/model/model_http_header_update.rs new file mode 100644 index 000000000..57c9c089a --- /dev/null +++ b/src/datadogV2/model/model_http_header_update.rs @@ -0,0 +1,126 @@ +// 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}; + +/// The definition of `HTTPHeaderUpdate` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct HTTPHeaderUpdate { + /// Should the header be deleted. + #[serde(rename = "deleted")] + pub deleted: Option, + /// The `HTTPHeaderUpdate` `name`. + #[serde(rename = "name")] + pub name: String, + /// The `HTTPHeaderUpdate` `value`. + #[serde(rename = "value")] + pub value: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl HTTPHeaderUpdate { + pub fn new(name: String) -> HTTPHeaderUpdate { + HTTPHeaderUpdate { + deleted: None, + name, + value: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn deleted(mut self, value: bool) -> Self { + self.deleted = 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<'de> Deserialize<'de> for HTTPHeaderUpdate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct HTTPHeaderUpdateVisitor; + impl<'a> Visitor<'a> for HTTPHeaderUpdateVisitor { + type Value = HTTPHeaderUpdate; + + 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: Option = None; + let mut name: 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() { + "deleted" => { + if v.is_null() { + continue; + } + deleted = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = 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 name = name.ok_or_else(|| M::Error::missing_field("name"))?; + + let content = HTTPHeaderUpdate { + deleted, + name, + value, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(HTTPHeaderUpdateVisitor) + } +} diff --git a/src/datadogV2/model/model_http_integration.rs b/src/datadogV2/model/model_http_integration.rs new file mode 100644 index 000000000..b7aabd9c0 --- /dev/null +++ b/src/datadogV2/model/model_http_integration.rs @@ -0,0 +1,136 @@ +// 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}; + +/// The definition of `HTTPIntegration` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct HTTPIntegration { + /// Base HTTP url for the integration + #[serde(rename = "base_url")] + pub base_url: String, + /// The definition of `HTTPCredentials` object. + #[serde(rename = "credentials")] + pub credentials: crate::datadogV2::model::HTTPCredentials, + /// The definition of `HTTPIntegrationType` object. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::HTTPIntegrationType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl HTTPIntegration { + pub fn new( + base_url: String, + credentials: crate::datadogV2::model::HTTPCredentials, + type_: crate::datadogV2::model::HTTPIntegrationType, + ) -> HTTPIntegration { + HTTPIntegration { + base_url, + credentials, + 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 HTTPIntegration { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct HTTPIntegrationVisitor; + impl<'a> Visitor<'a> for HTTPIntegrationVisitor { + type Value = HTTPIntegration; + + 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 base_url: Option = None; + let mut credentials: 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() { + "base_url" => { + base_url = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "credentials" => { + credentials = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _credentials) = credentials { + match _credentials { + crate::datadogV2::model::HTTPCredentials::UnparsedObject( + _credentials, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::HTTPIntegrationType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let base_url = base_url.ok_or_else(|| M::Error::missing_field("base_url"))?; + let credentials = + credentials.ok_or_else(|| M::Error::missing_field("credentials"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = HTTPIntegration { + base_url, + credentials, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(HTTPIntegrationVisitor) + } +} diff --git a/src/datadogV2/model/model_http_integration_type.rs b/src/datadogV2/model/model_http_integration_type.rs new file mode 100644 index 000000000..a56ac10fc --- /dev/null +++ b/src/datadogV2/model/model_http_integration_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 HTTPIntegrationType { + HTTP, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for HTTPIntegrationType { + fn to_string(&self) -> String { + match self { + Self::HTTP => String::from("HTTP"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for HTTPIntegrationType { + 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 HTTPIntegrationType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "HTTP" => Self::HTTP, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_http_integration_update.rs b/src/datadogV2/model/model_http_integration_update.rs new file mode 100644 index 000000000..db2cdfc43 --- /dev/null +++ b/src/datadogV2/model/model_http_integration_update.rs @@ -0,0 +1,143 @@ +// 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}; + +/// The definition of `HTTPIntegrationUpdate` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct HTTPIntegrationUpdate { + /// Base HTTP url for the integration + #[serde(rename = "base_url")] + pub base_url: Option, + /// The definition of `HTTPCredentialsUpdate` object. + #[serde(rename = "credentials")] + pub credentials: Option, + /// The definition of `HTTPIntegrationType` object. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::HTTPIntegrationType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl HTTPIntegrationUpdate { + pub fn new(type_: crate::datadogV2::model::HTTPIntegrationType) -> HTTPIntegrationUpdate { + HTTPIntegrationUpdate { + base_url: None, + credentials: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn base_url(mut self, value: String) -> Self { + self.base_url = Some(value); + self + } + + pub fn credentials(mut self, value: crate::datadogV2::model::HTTPCredentialsUpdate) -> Self { + self.credentials = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for HTTPIntegrationUpdate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct HTTPIntegrationUpdateVisitor; + impl<'a> Visitor<'a> for HTTPIntegrationUpdateVisitor { + type Value = HTTPIntegrationUpdate; + + 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 base_url: Option = None; + let mut credentials: 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() { + "base_url" => { + if v.is_null() { + continue; + } + base_url = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "credentials" => { + if v.is_null() { + continue; + } + credentials = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _credentials) = credentials { + match _credentials { + crate::datadogV2::model::HTTPCredentialsUpdate::UnparsedObject(_credentials) => { + _unparsed = true; + }, + _ => {} + } + } + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::HTTPIntegrationType::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 = HTTPIntegrationUpdate { + base_url, + credentials, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(HTTPIntegrationUpdateVisitor) + } +} diff --git a/src/datadogV2/model/model_http_token.rs b/src/datadogV2/model/model_http_token.rs new file mode 100644 index 000000000..2f429a5a1 --- /dev/null +++ b/src/datadogV2/model/model_http_token.rs @@ -0,0 +1,124 @@ +// 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}; + +/// The definition of `HTTPToken` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct HTTPToken { + /// The `HTTPToken` `name`. + #[serde(rename = "name")] + pub name: String, + /// The definition of `TokenType` object. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::TokenType, + /// The `HTTPToken` `value`. + #[serde(rename = "value")] + pub value: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl HTTPToken { + pub fn new( + name: String, + type_: crate::datadogV2::model::TokenType, + value: String, + ) -> HTTPToken { + HTTPToken { + name, + type_, + value, + 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 HTTPToken { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct HTTPTokenVisitor; + impl<'a> Visitor<'a> for HTTPTokenVisitor { + type Value = HTTPToken; + + 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 name: Option = None; + 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() { + "name" => { + name = 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::TokenType::UnparsedObject(_type_) => { + _unparsed = true; + } + _ => {} + } + } + } + "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 name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + let value = value.ok_or_else(|| M::Error::missing_field("value"))?; + + let content = HTTPToken { + name, + type_, + value, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(HTTPTokenVisitor) + } +} diff --git a/src/datadogV2/model/model_http_token_auth.rs b/src/datadogV2/model/model_http_token_auth.rs new file mode 100644 index 000000000..8d9a771ca --- /dev/null +++ b/src/datadogV2/model/model_http_token_auth.rs @@ -0,0 +1,171 @@ +// 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}; + +/// The definition of `HTTPTokenAuth` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct HTTPTokenAuth { + /// The definition of `HTTPBody` object. + #[serde(rename = "body")] + pub body: Option, + /// The `HTTPTokenAuth` `headers`. + #[serde(rename = "headers")] + pub headers: Option>, + /// The `HTTPTokenAuth` `tokens`. + #[serde(rename = "tokens")] + pub tokens: Option>, + /// The definition of `HTTPTokenAuthType` object. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::HTTPTokenAuthType, + /// The `HTTPTokenAuth` `url_parameters`. + #[serde(rename = "url_parameters")] + pub url_parameters: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl HTTPTokenAuth { + pub fn new(type_: crate::datadogV2::model::HTTPTokenAuthType) -> HTTPTokenAuth { + HTTPTokenAuth { + body: None, + headers: None, + tokens: None, + type_, + url_parameters: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn body(mut self, value: crate::datadogV2::model::HTTPBody) -> Self { + self.body = Some(value); + self + } + + pub fn headers(mut self, value: Vec) -> Self { + self.headers = Some(value); + self + } + + pub fn tokens(mut self, value: Vec) -> Self { + self.tokens = Some(value); + self + } + + pub fn url_parameters(mut self, value: Vec) -> Self { + self.url_parameters = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for HTTPTokenAuth { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct HTTPTokenAuthVisitor; + impl<'a> Visitor<'a> for HTTPTokenAuthVisitor { + type Value = HTTPTokenAuth; + + 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 body: Option = None; + let mut headers: Option> = None; + let mut tokens: Option> = None; + let mut type_: Option = None; + let mut url_parameters: 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() { + "body" => { + if v.is_null() { + continue; + } + body = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "headers" => { + if v.is_null() { + continue; + } + headers = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "tokens" => { + if v.is_null() { + continue; + } + tokens = 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::HTTPTokenAuthType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "url_parameters" => { + if v.is_null() { + continue; + } + url_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 type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = HTTPTokenAuth { + body, + headers, + tokens, + type_, + url_parameters, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(HTTPTokenAuthVisitor) + } +} diff --git a/src/datadogV2/model/model_http_token_auth_type.rs b/src/datadogV2/model/model_http_token_auth_type.rs new file mode 100644 index 000000000..d0cb66461 --- /dev/null +++ b/src/datadogV2/model/model_http_token_auth_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 HTTPTokenAuthType { + HTTPTOKENAUTH, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for HTTPTokenAuthType { + fn to_string(&self) -> String { + match self { + Self::HTTPTOKENAUTH => String::from("HTTPTokenAuth"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for HTTPTokenAuthType { + 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 HTTPTokenAuthType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "HTTPTokenAuth" => Self::HTTPTOKENAUTH, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_http_token_auth_update.rs b/src/datadogV2/model/model_http_token_auth_update.rs new file mode 100644 index 000000000..636f2801b --- /dev/null +++ b/src/datadogV2/model/model_http_token_auth_update.rs @@ -0,0 +1,171 @@ +// 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}; + +/// The definition of `HTTPTokenAuthUpdate` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct HTTPTokenAuthUpdate { + /// The definition of `HTTPBody` object. + #[serde(rename = "body")] + pub body: Option, + /// The `HTTPTokenAuthUpdate` `headers`. + #[serde(rename = "headers")] + pub headers: Option>, + /// The `HTTPTokenAuthUpdate` `tokens`. + #[serde(rename = "tokens")] + pub tokens: Option>, + /// The definition of `HTTPTokenAuthType` object. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::HTTPTokenAuthType, + /// The `HTTPTokenAuthUpdate` `url_parameters`. + #[serde(rename = "url_parameters")] + pub url_parameters: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl HTTPTokenAuthUpdate { + pub fn new(type_: crate::datadogV2::model::HTTPTokenAuthType) -> HTTPTokenAuthUpdate { + HTTPTokenAuthUpdate { + body: None, + headers: None, + tokens: None, + type_, + url_parameters: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn body(mut self, value: crate::datadogV2::model::HTTPBody) -> Self { + self.body = Some(value); + self + } + + pub fn headers(mut self, value: Vec) -> Self { + self.headers = Some(value); + self + } + + pub fn tokens(mut self, value: Vec) -> Self { + self.tokens = Some(value); + self + } + + pub fn url_parameters(mut self, value: Vec) -> Self { + self.url_parameters = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for HTTPTokenAuthUpdate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct HTTPTokenAuthUpdateVisitor; + impl<'a> Visitor<'a> for HTTPTokenAuthUpdateVisitor { + type Value = HTTPTokenAuthUpdate; + + 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 body: Option = None; + let mut headers: Option> = None; + let mut tokens: Option> = None; + let mut type_: Option = None; + let mut url_parameters: 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() { + "body" => { + if v.is_null() { + continue; + } + body = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "headers" => { + if v.is_null() { + continue; + } + headers = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "tokens" => { + if v.is_null() { + continue; + } + tokens = 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::HTTPTokenAuthType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "url_parameters" => { + if v.is_null() { + continue; + } + url_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 type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = HTTPTokenAuthUpdate { + body, + headers, + tokens, + type_, + url_parameters, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(HTTPTokenAuthUpdateVisitor) + } +} diff --git a/src/datadogV2/model/model_http_token_update.rs b/src/datadogV2/model/model_http_token_update.rs new file mode 100644 index 000000000..2e7a8ac8b --- /dev/null +++ b/src/datadogV2/model/model_http_token_update.rs @@ -0,0 +1,141 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `HTTPTokenUpdate` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct HTTPTokenUpdate { + /// Should the header be deleted. + #[serde(rename = "deleted")] + pub deleted: Option, + /// The `HTTPToken` `name`. + #[serde(rename = "name")] + pub name: String, + /// The definition of `TokenType` object. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::TokenType, + /// The `HTTPToken` `value`. + #[serde(rename = "value")] + pub value: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl HTTPTokenUpdate { + pub fn new( + name: String, + type_: crate::datadogV2::model::TokenType, + value: String, + ) -> HTTPTokenUpdate { + HTTPTokenUpdate { + deleted: None, + name, + type_, + value, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn deleted(mut self, value: bool) -> Self { + self.deleted = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for HTTPTokenUpdate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct HTTPTokenUpdateVisitor; + impl<'a> Visitor<'a> for HTTPTokenUpdateVisitor { + type Value = HTTPTokenUpdate; + + 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: Option = None; + let mut name: Option = None; + 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() { + "deleted" => { + if v.is_null() { + continue; + } + deleted = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = 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::TokenType::UnparsedObject(_type_) => { + _unparsed = true; + } + _ => {} + } + } + } + "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 name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + let value = value.ok_or_else(|| M::Error::missing_field("value"))?; + + let content = HTTPTokenUpdate { + deleted, + name, + type_, + value, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(HTTPTokenUpdateVisitor) + } +} diff --git a/src/datadogV2/model/model_token_type.rs b/src/datadogV2/model/model_token_type.rs new file mode 100644 index 000000000..d285d59d3 --- /dev/null +++ b/src/datadogV2/model/model_token_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 TokenType { + SECRET, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for TokenType { + fn to_string(&self) -> String { + match self { + Self::SECRET => String::from("SECRET"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for TokenType { + 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 TokenType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "SECRET" => Self::SECRET, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_update_action_connection_request.rs b/src/datadogV2/model/model_update_action_connection_request.rs new file mode 100644 index 000000000..b584009b5 --- /dev/null +++ b/src/datadogV2/model/model_update_action_connection_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}; + +/// Request used to update an action connection. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct UpdateActionConnectionRequest { + /// Data related to the connection update. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::ActionConnectionDataUpdate, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl UpdateActionConnectionRequest { + pub fn new( + data: crate::datadogV2::model::ActionConnectionDataUpdate, + ) -> UpdateActionConnectionRequest { + UpdateActionConnectionRequest { + 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 UpdateActionConnectionRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct UpdateActionConnectionRequestVisitor; + impl<'a> Visitor<'a> for UpdateActionConnectionRequestVisitor { + type Value = UpdateActionConnectionRequest; + + 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 = UpdateActionConnectionRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(UpdateActionConnectionRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_update_action_connection_response.rs b/src/datadogV2/model/model_update_action_connection_response.rs new file mode 100644 index 000000000..580fe1853 --- /dev/null +++ b/src/datadogV2/model/model_update_action_connection_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}; + +/// The response for an updated connection. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct UpdateActionConnectionResponse { + /// Data related to the connection. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl UpdateActionConnectionResponse { + pub fn new() -> UpdateActionConnectionResponse { + UpdateActionConnectionResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::ActionConnectionData) -> 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 UpdateActionConnectionResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for UpdateActionConnectionResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct UpdateActionConnectionResponseVisitor; + impl<'a> Visitor<'a> for UpdateActionConnectionResponseVisitor { + type Value = UpdateActionConnectionResponse; + + 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 = UpdateActionConnectionResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(UpdateActionConnectionResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_url_param.rs b/src/datadogV2/model/model_url_param.rs new file mode 100644 index 000000000..0da578a7b --- /dev/null +++ b/src/datadogV2/model/model_url_param.rs @@ -0,0 +1,102 @@ +// 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}; + +/// The definition of `UrlParam` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct UrlParam { + /// Name for tokens. + #[serde(rename = "name")] + pub name: String, + /// The `UrlParam` `value`. + #[serde(rename = "value")] + pub value: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl UrlParam { + pub fn new(name: String, value: String) -> UrlParam { + UrlParam { + name, + value, + 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 UrlParam { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct UrlParamVisitor; + impl<'a> Visitor<'a> for UrlParamVisitor { + type Value = UrlParam; + + 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 name: 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() { + "name" => { + name = 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 name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let value = value.ok_or_else(|| M::Error::missing_field("value"))?; + + let content = UrlParam { + name, + value, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(UrlParamVisitor) + } +} diff --git a/src/datadogV2/model/model_url_param_update.rs b/src/datadogV2/model/model_url_param_update.rs new file mode 100644 index 000000000..1a9a2d44f --- /dev/null +++ b/src/datadogV2/model/model_url_param_update.rs @@ -0,0 +1,126 @@ +// 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}; + +/// The definition of `UrlParamUpdate` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct UrlParamUpdate { + /// Should the header be deleted. + #[serde(rename = "deleted")] + pub deleted: Option, + /// Name for tokens. + #[serde(rename = "name")] + pub name: String, + /// The `UrlParamUpdate` `value`. + #[serde(rename = "value")] + pub value: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl UrlParamUpdate { + pub fn new(name: String) -> UrlParamUpdate { + UrlParamUpdate { + deleted: None, + name, + value: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn deleted(mut self, value: bool) -> Self { + self.deleted = 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<'de> Deserialize<'de> for UrlParamUpdate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct UrlParamUpdateVisitor; + impl<'a> Visitor<'a> for UrlParamUpdateVisitor { + type Value = UrlParamUpdate; + + 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: Option = None; + let mut name: 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() { + "deleted" => { + if v.is_null() { + continue; + } + deleted = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = 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 name = name.ok_or_else(|| M::Error::missing_field("name"))?; + + let content = UrlParamUpdate { + deleted, + name, + value, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(UrlParamUpdateVisitor) + } +} diff --git a/tests/scenarios/cassettes/v2/action_connection/Create-a-new-Action-Connection-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/action_connection/Create-a-new-Action-Connection-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..43f3dbf1f --- /dev/null +++ b/tests/scenarios/cassettes/v2/action_connection/Create-a-new-Action-Connection-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-01-06T22:02:35.383Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/action_connection/Create-a-new-Action-Connection-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/action_connection/Create-a-new-Action-Connection-returns-Bad-Request-response.json new file mode 100644 index 000000000..8b7b8ab7f --- /dev/null +++ b/tests/scenarios/cassettes/v2/action_connection/Create-a-new-Action-Connection-returns-Bad-Request-response.json @@ -0,0 +1,39 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"integration\":{\"credentials\":{\"account_id\":\"1\",\"role\":\"MyRoleUpdated\",\"type\":\"AWSAssumeRole\"},\"type\":\"AWS\"},\"name\":\"Cassette Connection\"},\"type\":\"action_connection\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/actions/connections" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"error creating connection: rpc error: code = InvalidArgument desc = multiple errors: 1 error occurred:\\n\\t* [error_code=8]: invalid CreateCustomConnectionRequest.Data: embedded message failed validation | caused by: invalid CustomConnectionData.Aws: embedded message failed validation | caused by: invalid CustomConnectionData_AwsAuthData.AssumeRole: embedded message failed validation | caused by: invalid CustomConnectionData_AwsAuthData_AssumeRole.AccountId: value does not match regex pattern \\\"^\\\\\\\\d{12}$\\\"\\n\\n\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Mon, 06 Jan 2025 22:02:35 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/action_connection/Create-a-new-Action-Connection-returns-Successfully-created-Action-Connection-response.frozen b/tests/scenarios/cassettes/v2/action_connection/Create-a-new-Action-Connection-returns-Successfully-created-Action-Connection-response.frozen new file mode 100644 index 000000000..e63d0f654 --- /dev/null +++ b/tests/scenarios/cassettes/v2/action_connection/Create-a-new-Action-Connection-returns-Successfully-created-Action-Connection-response.frozen @@ -0,0 +1 @@ +2025-01-06T22:02:35.598Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/action_connection/Create-a-new-Action-Connection-returns-Successfully-created-Action-Connection-response.json b/tests/scenarios/cassettes/v2/action_connection/Create-a-new-Action-Connection-returns-Successfully-created-Action-Connection-response.json new file mode 100644 index 000000000..dca1abbe8 --- /dev/null +++ b/tests/scenarios/cassettes/v2/action_connection/Create-a-new-Action-Connection-returns-Successfully-created-Action-Connection-response.json @@ -0,0 +1,63 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"integration\":{\"credentials\":{\"account_id\":\"123456789123\",\"role\":\"MyRoleUpdated\",\"type\":\"AWSAssumeRole\"},\"type\":\"AWS\"},\"name\":\"Cassette Connection DELETE_ME\"},\"type\":\"action_connection\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/actions/connections" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"db41b6cb-ef93-45bd-9857-548e9474737c\",\"type\":\"action_connection\",\"attributes\":{\"integration\":{\"credentials\":{\"account_id\":\"123456789123\",\"role\":\"MyRoleUpdated\",\"external_id\":\"c6f62d439f14423b963e4dd4246af4a7\",\"principal_id\":\"464622532012\",\"type\":\"AWSAssumeRole\"},\"type\":\"AWS\"},\"name\":\"Cassette Connection DELETE_ME\"}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Mon, 06 Jan 2025 22:02:35 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/actions/connections/db41b6cb-ef93-45bd-9857-548e9474737c" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 06 Jan 2025 22:02:35 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/action_connection/Delete-an-existing-Action-Connection-returns-Not-Found-response.frozen b/tests/scenarios/cassettes/v2/action_connection/Delete-an-existing-Action-Connection-returns-Not-Found-response.frozen new file mode 100644 index 000000000..2dc54861f --- /dev/null +++ b/tests/scenarios/cassettes/v2/action_connection/Delete-an-existing-Action-Connection-returns-Not-Found-response.frozen @@ -0,0 +1 @@ +2025-01-06T22:02:36.467Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/action_connection/Delete-an-existing-Action-Connection-returns-Not-Found-response.json b/tests/scenarios/cassettes/v2/action_connection/Delete-an-existing-Action-Connection-returns-Not-Found-response.json new file mode 100644 index 000000000..302f48afd --- /dev/null +++ b/tests/scenarios/cassettes/v2/action_connection/Delete-an-existing-Action-Connection-returns-Not-Found-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/actions/connections/aaa11111-aa11-aa11-aaaa-aaaaaa111111" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"error deleting connection: rpc error: code = NotFound desc = connection not found\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Mon, 06 Jan 2025 22:02:36 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/action_connection/Delete-an-existing-Action-Connection-returns-Successfully-deleted-Action-Connection-response.frozen b/tests/scenarios/cassettes/v2/action_connection/Delete-an-existing-Action-Connection-returns-Successfully-deleted-Action-Connection-response.frozen new file mode 100644 index 000000000..0ea80a169 --- /dev/null +++ b/tests/scenarios/cassettes/v2/action_connection/Delete-an-existing-Action-Connection-returns-Successfully-deleted-Action-Connection-response.frozen @@ -0,0 +1 @@ +2025-01-06T22:02:36.636Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/action_connection/Delete-an-existing-Action-Connection-returns-Successfully-deleted-Action-Connection-response.json b/tests/scenarios/cassettes/v2/action_connection/Delete-an-existing-Action-Connection-returns-Successfully-deleted-Action-Connection-response.json new file mode 100644 index 000000000..fd4bdfacd --- /dev/null +++ b/tests/scenarios/cassettes/v2/action_connection/Delete-an-existing-Action-Connection-returns-Successfully-deleted-Action-Connection-response.json @@ -0,0 +1,91 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"integration\":{\"credentials\":{\"account_id\":\"123456789123\",\"role\":\"MyRole\",\"type\":\"AWSAssumeRole\"},\"type\":\"AWS\"},\"name\":\"Cassette Connection DELETE\"},\"type\":\"action_connection\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/actions/connections" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"4b60345a-85b2-4417-94b2-72a9528b4060\",\"type\":\"action_connection\",\"attributes\":{\"integration\":{\"credentials\":{\"account_id\":\"123456789123\",\"role\":\"MyRole\",\"external_id\":\"3bceadebe70c4df7b8ec6abb789e08c0\",\"principal_id\":\"464622532012\",\"type\":\"AWSAssumeRole\"},\"type\":\"AWS\"},\"name\":\"Cassette Connection DELETE\"}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Mon, 06 Jan 2025 22:02:36 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/actions/connections/4b60345a-85b2-4417-94b2-72a9528b4060" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 06 Jan 2025 22:02:36 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/actions/connections/4b60345a-85b2-4417-94b2-72a9528b4060" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"error deleting connection: rpc error: code = NotFound desc = connection not found\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Mon, 06 Jan 2025 22:02:36 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/action_connection/Get-an-existing-Action-Connection-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/action_connection/Get-an-existing-Action-Connection-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..aa65c8678 --- /dev/null +++ b/tests/scenarios/cassettes/v2/action_connection/Get-an-existing-Action-Connection-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-01-06T22:02:37.403Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/action_connection/Get-an-existing-Action-Connection-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/action_connection/Get-an-existing-Action-Connection-returns-Bad-Request-response.json new file mode 100644 index 000000000..21ca5113f --- /dev/null +++ b/tests/scenarios/cassettes/v2/action_connection/Get-an-existing-Action-Connection-returns-Bad-Request-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/actions/connections/bad-format" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"error connectionId not a valid UUID\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Mon, 06 Jan 2025 22:02:37 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/action_connection/Get-an-existing-Action-Connection-returns-Not-Found-response.frozen b/tests/scenarios/cassettes/v2/action_connection/Get-an-existing-Action-Connection-returns-Not-Found-response.frozen new file mode 100644 index 000000000..b2ef94934 --- /dev/null +++ b/tests/scenarios/cassettes/v2/action_connection/Get-an-existing-Action-Connection-returns-Not-Found-response.frozen @@ -0,0 +1 @@ +2025-01-06T22:02:37.563Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/action_connection/Get-an-existing-Action-Connection-returns-Not-Found-response.json b/tests/scenarios/cassettes/v2/action_connection/Get-an-existing-Action-Connection-returns-Not-Found-response.json new file mode 100644 index 000000000..d4e02ad5e --- /dev/null +++ b/tests/scenarios/cassettes/v2/action_connection/Get-an-existing-Action-Connection-returns-Not-Found-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/actions/connections/aaa11111-aa11-aa11-aaaa-aaaaaa111111" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"error getting connection: rpc error: code = NotFound desc = connection not found\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Mon, 06 Jan 2025 22:02:37 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/action_connection/Get-an-existing-Action-Connection-returns-Successfully-get-Action-Connection-response.frozen b/tests/scenarios/cassettes/v2/action_connection/Get-an-existing-Action-Connection-returns-Successfully-get-Action-Connection-response.frozen new file mode 100644 index 000000000..4b2a54697 --- /dev/null +++ b/tests/scenarios/cassettes/v2/action_connection/Get-an-existing-Action-Connection-returns-Successfully-get-Action-Connection-response.frozen @@ -0,0 +1 @@ +2025-01-06T22:02:37.743Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/action_connection/Get-an-existing-Action-Connection-returns-Successfully-get-Action-Connection-response.json b/tests/scenarios/cassettes/v2/action_connection/Get-an-existing-Action-Connection-returns-Successfully-get-Action-Connection-response.json new file mode 100644 index 000000000..9e666bee4 --- /dev/null +++ b/tests/scenarios/cassettes/v2/action_connection/Get-an-existing-Action-Connection-returns-Successfully-get-Action-Connection-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/actions/connections/cb460d51-3c88-4e87-adac-d47131d0423d" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"cb460d51-3c88-4e87-adac-d47131d0423d\",\"type\":\"action_connection\",\"attributes\":{\"integration\":{\"credentials\":{\"account_id\":\"123456789123\",\"role\":\"MyRoleUpdated\",\"external_id\":\"909b33b1242748cfbef42f20011e2fa0\",\"principal_id\":\"464622532012\",\"type\":\"AWSAssumeRole\"},\"type\":\"AWS\"},\"name\":\"Cassette Connection\"}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Mon, 06 Jan 2025 22:02:37 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/action_connection/Update-an-existing-Action-Connection-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/action_connection/Update-an-existing-Action-Connection-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..fe27ab93a --- /dev/null +++ b/tests/scenarios/cassettes/v2/action_connection/Update-an-existing-Action-Connection-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-01-06T22:02:38.001Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/action_connection/Update-an-existing-Action-Connection-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/action_connection/Update-an-existing-Action-Connection-returns-Bad-Request-response.json new file mode 100644 index 000000000..b8eb59904 --- /dev/null +++ b/tests/scenarios/cassettes/v2/action_connection/Update-an-existing-Action-Connection-returns-Bad-Request-response.json @@ -0,0 +1,39 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"integration\":{\"credentials\":{\"account_id\":\"1\",\"role\":\"MyRoleUpdated\",\"type\":\"AWSAssumeRole\"},\"type\":\"AWS\"},\"name\":\"Cassette Connection\"},\"type\":\"action_connection\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "patch", + "uri": "https://api.datadoghq.com/api/v2/actions/connections/cb460d51-3c88-4e87-adac-d47131d0423d" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"error creating connection: rpc error: code = InvalidArgument desc = multiple errors: 1 error occurred:\\n\\t* [error_code=8]: invalid UpdateCustomConnectionRequest.DataUpdate: embedded message failed validation | caused by: invalid CustomConnectionDataUpdate.Aws: embedded message failed validation | caused by: invalid CustomConnectionDataUpdate_AwsAuth.AssumeRole: embedded message failed validation | caused by: invalid CustomConnectionDataUpdate_AwsAuth_AssumeRole.AccountId: value does not match regex pattern \\\"^\\\\\\\\d{12}$\\\"\\n\\n\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Mon, 06 Jan 2025 22:02:38 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/action_connection/Update-an-existing-Action-Connection-returns-Not-Found-response.frozen b/tests/scenarios/cassettes/v2/action_connection/Update-an-existing-Action-Connection-returns-Not-Found-response.frozen new file mode 100644 index 000000000..c89c4afae --- /dev/null +++ b/tests/scenarios/cassettes/v2/action_connection/Update-an-existing-Action-Connection-returns-Not-Found-response.frozen @@ -0,0 +1 @@ +2025-01-06T22:02:38.092Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/action_connection/Update-an-existing-Action-Connection-returns-Not-Found-response.json b/tests/scenarios/cassettes/v2/action_connection/Update-an-existing-Action-Connection-returns-Not-Found-response.json new file mode 100644 index 000000000..4e1d13e0f --- /dev/null +++ b/tests/scenarios/cassettes/v2/action_connection/Update-an-existing-Action-Connection-returns-Not-Found-response.json @@ -0,0 +1,39 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"integration\":{\"credentials\":{\"account_id\":\"123456789123\",\"role\":\"MyRoleUpdated\",\"type\":\"AWSAssumeRole\"},\"type\":\"AWS\"},\"name\":\"Cassette Connection\"},\"type\":\"action_connection\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "patch", + "uri": "https://api.datadoghq.com/api/v2/actions/connections/aaa11111-aa11-aa11-aaaa-aaaaaa111111" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"error creating connection: rpc error: code = NotFound desc = connection not found\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Mon, 06 Jan 2025 22:02:38 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/action_connection/Update-an-existing-Action-Connection-returns-Successfully-updated-Action-Connection-response.frozen b/tests/scenarios/cassettes/v2/action_connection/Update-an-existing-Action-Connection-returns-Successfully-updated-Action-Connection-response.frozen new file mode 100644 index 000000000..b602ce06d --- /dev/null +++ b/tests/scenarios/cassettes/v2/action_connection/Update-an-existing-Action-Connection-returns-Successfully-updated-Action-Connection-response.frozen @@ -0,0 +1 @@ +2025-01-06T22:02:38.186Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/action_connection/Update-an-existing-Action-Connection-returns-Successfully-updated-Action-Connection-response.json b/tests/scenarios/cassettes/v2/action_connection/Update-an-existing-Action-Connection-returns-Successfully-updated-Action-Connection-response.json new file mode 100644 index 000000000..2d0746a76 --- /dev/null +++ b/tests/scenarios/cassettes/v2/action_connection/Update-an-existing-Action-Connection-returns-Successfully-updated-Action-Connection-response.json @@ -0,0 +1,39 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"integration\":{\"credentials\":{\"account_id\":\"123456789123\",\"role\":\"MyRoleUpdated\",\"type\":\"AWSAssumeRole\"},\"type\":\"AWS\"},\"name\":\"Cassette Connection\"},\"type\":\"action_connection\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "patch", + "uri": "https://api.datadoghq.com/api/v2/actions/connections/cb460d51-3c88-4e87-adac-d47131d0423d" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"cb460d51-3c88-4e87-adac-d47131d0423d\",\"type\":\"action_connection\",\"attributes\":{\"integration\":{\"credentials\":{\"account_id\":\"123456789123\",\"role\":\"MyRoleUpdated\",\"external_id\":\"909b33b1242748cfbef42f20011e2fa0\",\"principal_id\":\"464622532012\",\"type\":\"AWSAssumeRole\"},\"type\":\"AWS\"},\"name\":\"Cassette Connection\"}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Mon, 06 Jan 2025 22:02:38 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/features/v2/action_connection.feature b/tests/scenarios/features/v2/action_connection.feature new file mode 100644 index 000000000..f379fc1a0 --- /dev/null +++ b/tests/scenarios/features/v2/action_connection.feature @@ -0,0 +1,96 @@ +@endpoint(action-connection) @endpoint(action-connection-v2) +Feature: Action Connection + Action connections extend your installed integrations and allow you to + take action in your third-party systems (e.g. AWS, GitLab, and Statuspage) + with Datadog’s Workflow Automation and App Builder products. Datadog’s + Integrations automatically provide authentication for Slack, Microsoft + Teams, PagerDuty, Opsgenie, JIRA, GitHub, and Statuspage. You do not need + additional connections in order to access these tools within Workflow + Automation and App Builder. We offer granular access control for editing + and resolving connections. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "ActionConnection" API + + @team:DataDog/workflow-automation-dev + Scenario: Create a new Action Connection returns "Bad Request" response + Given new "CreateActionConnection" request + And body with value {"data":{"type":"action_connection","attributes":{"name":"Cassette Connection","integration":{"type":"AWS","credentials":{"type":"AWSAssumeRole","role":"MyRoleUpdated","account_id":"1"}}}}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/workflow-automation-dev + Scenario: Create a new Action Connection returns "Successfully created Action Connection" response + Given new "CreateActionConnection" request + And body with value {"data":{"type":"action_connection","attributes":{"name":"Cassette Connection DELETE_ME","integration":{"type":"AWS","credentials":{"type":"AWSAssumeRole","role":"MyRoleUpdated","account_id":"123456789123"}}}}} + When the request is sent + Then the response status is 201 Successfully created Action Connection + + @team:DataDog/workflow-automation-dev + Scenario: Delete an existing Action Connection returns "Not Found" response + Given new "DeleteActionConnection" request + And request contains "connection_id" parameter with value "aaa11111-aa11-aa11-aaaa-aaaaaa111111" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/workflow-automation-dev + Scenario: Delete an existing Action Connection returns "Successfully deleted Action Connection" response + Given there is a valid "action_connection" in the system + And new "DeleteActionConnection" request + And request contains "connection_id" parameter from "action_connection.data.id" + When the request is sent + Then the response status is 204 The resource was deleted successfully. + + @generated @skip @team:DataDog/workflow-automation-dev + Scenario: Delete an existing Action Connection returns "The resource was deleted successfully." response + Given new "DeleteActionConnection" request + And request contains "connection_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 The resource was deleted successfully. + + @team:DataDog/workflow-automation-dev + Scenario: Get an existing Action Connection returns "Bad Request" response + Given new "GetActionConnection" request + And request contains "connection_id" parameter with value "bad-format" + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/workflow-automation-dev + Scenario: Get an existing Action Connection returns "Not Found" response + Given new "GetActionConnection" request + And request contains "connection_id" parameter with value "aaa11111-aa11-aa11-aaaa-aaaaaa111111" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/workflow-automation-dev + Scenario: Get an existing Action Connection returns "Successfully get Action Connection" response + Given new "GetActionConnection" request + And request contains "connection_id" parameter with value "cb460d51-3c88-4e87-adac-d47131d0423d" + When the request is sent + Then the response status is 200 Successfully get Action Connection + + @team:DataDog/workflow-automation-dev + Scenario: Update an existing Action Connection returns "Bad Request" response + Given new "UpdateActionConnection" request + And request contains "connection_id" parameter with value "cb460d51-3c88-4e87-adac-d47131d0423d" + And body with value {"data":{"type":"action_connection","attributes":{"name":"Cassette Connection","integration":{"type":"AWS","credentials":{"type":"AWSAssumeRole","role":"MyRoleUpdated","account_id":"1"}}}}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/workflow-automation-dev + Scenario: Update an existing Action Connection returns "Not Found" response + Given new "UpdateActionConnection" request + And request contains "connection_id" parameter with value "aaa11111-aa11-aa11-aaaa-aaaaaa111111" + And body with value {"data":{"type":"action_connection","attributes":{"name":"Cassette Connection","integration":{"type":"AWS","credentials":{"type":"AWSAssumeRole","role":"MyRoleUpdated","account_id":"123456789123"}}}}} + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/workflow-automation-dev + Scenario: Update an existing Action Connection returns "Successfully updated Action Connection" response + Given new "UpdateActionConnection" request + And request contains "connection_id" parameter with value "cb460d51-3c88-4e87-adac-d47131d0423d" + And body with value {"data":{"type":"action_connection","attributes":{"name":"Cassette Connection","integration":{"type":"AWS","credentials":{"type":"AWSAssumeRole","role":"MyRoleUpdated","account_id":"123456789123"}}}}} + When the request is sent + Then the response status is 200 Successfully updated Action Connection diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 3c9e42793..2af5f560d 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -1,4 +1,16 @@ [ + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"action_connection\",\n \"attributes\": {\n \"name\": \"Cassette Connection DELETE\",\n \"integration\": {\n \"type\": \"AWS\",\n \"credentials\": {\n \"type\": \"AWSAssumeRole\",\n \"role\": \"MyRole\",\n \"account_id\": \"123456789123\"\n }\n }\n }\n }\n}" + } + ], + "step": "there is a valid \"action_connection\" in the system", + "key": "action_connection", + "tag": "Action Connection", + "operationId": "CreateActionConnection" + }, { "parameters": [ { diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index d6c6e9de8..d1258a8d9 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1,4 +1,35 @@ { + "CreateActionConnection": { + "tag": "Action Connection", + "undo": { + "operationId": "DeleteActionConnection", + "parameters": [ + { + "name": "connection_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteActionConnection": { + "tag": "Action Connection", + "undo": { + "type": "idempotent" + } + }, + "GetActionConnection": { + "tag": "Action Connection", + "undo": { + "type": "safe" + } + }, + "UpdateActionConnection": { + "tag": "Action Connection", + "undo": { + "type": "idempotent" + } + }, "ListAwsScanOptions": { "tag": "Agentless Scanning", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 2439673c5..a272093eb 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -49,6 +49,7 @@ pub struct ApiInstances { pub v1_api_tags: Option, pub v1_api_users: Option, pub v1_api_authentication: Option, + pub v2_api_action_connection: Option, pub v2_api_agentless_scanning: Option, pub v2_api_key_management: Option, pub v2_api_api_management: Option, @@ -458,6 +459,14 @@ pub fn initialize_api_instance(world: &mut DatadogWorld, api: String) { ), ); } + "ActionConnection" => { + world.api_instances.v2_api_action_connection = Some( + datadogV2::api_action_connection::ActionConnectionAPI::with_client_and_config( + world.config.clone(), + world.http_client.as_ref().unwrap().clone(), + ), + ); + } "AgentlessScanning" => { world.api_instances.v2_api_agentless_scanning = Some( datadogV2::api_agentless_scanning::AgentlessScanningAPI::with_client_and_config( @@ -1643,6 +1652,22 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { world .function_mappings .insert("v1.Validate".into(), test_v1_validate); + world.function_mappings.insert( + "v2.CreateActionConnection".into(), + test_v2_create_action_connection, + ); + world.function_mappings.insert( + "v2.DeleteActionConnection".into(), + test_v2_delete_action_connection, + ); + world.function_mappings.insert( + "v2.GetActionConnection".into(), + test_v2_get_action_connection, + ); + world.function_mappings.insert( + "v2.UpdateActionConnection".into(), + test_v2_update_action_connection, + ); world.function_mappings.insert( "v2.ListAwsScanOptions".into(), test_v2_list_aws_scan_options, @@ -10413,6 +10438,120 @@ fn test_v1_validate(world: &mut DatadogWorld, _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_action_connection + .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_action_connection_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_action_connection( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_action_connection + .as_ref() + .expect("api instance not found"); + let connection_id = + serde_json::from_value(_parameters.get("connection_id").unwrap().clone()).unwrap(); + let response = match block_on(api.delete_action_connection_with_http_info(connection_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_get_action_connection(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_action_connection + .as_ref() + .expect("api instance not found"); + let connection_id = + serde_json::from_value(_parameters.get("connection_id").unwrap().clone()).unwrap(); + let response = match block_on(api.get_action_connection_with_http_info(connection_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_update_action_connection( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_action_connection + .as_ref() + .expect("api instance not found"); + let connection_id = + serde_json::from_value(_parameters.get("connection_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.update_action_connection_with_http_info(connection_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_aws_scan_options(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances