diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 42ec940d0..9a4d9f05e 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -27888,6 +27888,7 @@ paths: - aws_configuration_read /api/v1/integration/aws/event_bridge: delete: + deprecated: true description: Delete an Amazon EventBridge source. operationId: DeleteAWSEventBridgeSource requestBody: @@ -27928,6 +27929,7 @@ paths: permissions: - manage_integrations get: + deprecated: true description: Get all Amazon EventBridge sources. operationId: ListAWSEventBridgeSources parameters: [] @@ -27959,6 +27961,7 @@ paths: operator: OPEN permissions: [] post: + deprecated: true description: Create an Amazon EventBridge source. operationId: CreateAWSEventBridgeSource requestBody: diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index c31c76079..e44adfced 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1428,7 +1428,9 @@ components: AWSAccountConfigID: description: 'Unique Datadog ID of the AWS Account Integration Config. - To get the config ID for an account, use the [List all AWS integrations](https://docs.datadoghq.com/api/latest/aws-integration/#list-all-aws-integrations) + To get the config ID for an account, use the + + [List all AWS integrations](https://docs.datadoghq.com/api/latest/aws-integration/#list-all-aws-integrations) endpoint and query by AWS Account ID.' example: 00000000-abcd-0001-0000-000000000000 @@ -1486,6 +1488,7 @@ components: description: 'AWS partition your AWS account is scoped to. Defaults to `aws`. See [Partitions](https://docs.aws.amazon.com/whitepapers/latest/aws-fault-isolation-boundaries/partitions.html) + in the AWS documentation for more information.' enum: - aws @@ -1730,6 +1733,269 @@ components: description: The definition of `AWSCredentialsUpdate` object. oneOf: - $ref: '#/components/schemas/AWSAssumeRoleUpdate' + AWSEventBridgeAccountConfiguration: + description: The EventBridge configuration for one AWS account. + properties: + account_id: + description: Your AWS Account ID without dashes. + example: '123456789012' + type: string + event_hubs: + description: Array of AWS event sources associated with this account. + items: + $ref: '#/components/schemas/AWSEventBridgeSource' + type: array + tags: + description: 'Array of tags (in the form `key:value`) which are added to + all hosts + + and metrics reporting through the main AWS integration.' + example: + - $KEY:$VALUE + items: + description: The list of the host_tags. + type: string + type: array + type: object + AWSEventBridgeCreateRequest: + description: Amazon EventBridge create request body. + properties: + data: + $ref: '#/components/schemas/AWSEventBridgeCreateRequestData' + required: + - data + type: object + AWSEventBridgeCreateRequestAttributes: + description: The EventBridge source to be created. + properties: + account_id: + $ref: '#/components/schemas/AWSAccountID' + create_event_bus: + description: 'Set to true if Datadog should create the event bus in addition + to the event + + source. Requires the `events:CreateEventBus` permission.' + example: true + type: boolean + event_generator_name: + description: 'The given part of the event source name, which is then combined + with an + + assigned suffix to form the full name.' + example: app-alerts + type: string + region: + description: 'The event source''s + + [AWS region](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints).' + example: us-east-1 + type: string + required: + - account_id + - event_generator_name + - region + type: object + AWSEventBridgeCreateRequestData: + description: Amazon EventBridge create request data. + properties: + attributes: + $ref: '#/components/schemas/AWSEventBridgeCreateRequestAttributes' + type: + $ref: '#/components/schemas/AWSEventBridgeType' + required: + - attributes + - type + type: object + AWSEventBridgeCreateResponse: + description: Amazon EventBridge create response body. + properties: + data: + $ref: '#/components/schemas/AWSEventBridgeCreateResponseData' + required: + - data + type: object + AWSEventBridgeCreateResponseAttributes: + description: A created EventBridge source. + properties: + event_source_name: + description: The event source name. + example: app-alerts-zyxw3210 + type: string + has_bus: + description: True if the event bus was created in addition to the source. + example: true + type: boolean + region: + description: 'The event source''s + + [AWS region](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints).' + example: us-east-1 + type: string + status: + $ref: '#/components/schemas/AWSEventBridgeCreateStatus' + type: object + AWSEventBridgeCreateResponseData: + description: Amazon EventBridge create response data. + properties: + attributes: + $ref: '#/components/schemas/AWSEventBridgeCreateResponseAttributes' + id: + default: create_event_bridge + description: The ID of the Amazon EventBridge create response data. + example: create_event_bridge + type: string + type: + $ref: '#/components/schemas/AWSEventBridgeType' + required: + - attributes + - type + type: object + AWSEventBridgeCreateStatus: + description: The event source status "created". + enum: + - created + example: created + type: string + x-enum-varnames: + - CREATED + AWSEventBridgeDeleteRequest: + description: Amazon EventBridge delete request body. + properties: + data: + $ref: '#/components/schemas/AWSEventBridgeDeleteRequestData' + required: + - data + type: object + AWSEventBridgeDeleteRequestAttributes: + description: The EventBridge source to be deleted. + properties: + account_id: + $ref: '#/components/schemas/AWSAccountID' + event_generator_name: + description: The event source name. + example: app-alerts-zyxw3210 + type: string + region: + description: 'The event source''s + + [AWS region](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints).' + example: us-east-1 + type: string + required: + - account_id + - event_generator_name + - region + type: object + AWSEventBridgeDeleteRequestData: + description: Amazon EventBridge delete request data. + properties: + attributes: + $ref: '#/components/schemas/AWSEventBridgeDeleteRequestAttributes' + type: + $ref: '#/components/schemas/AWSEventBridgeType' + required: + - attributes + - type + type: object + AWSEventBridgeDeleteResponse: + description: Amazon EventBridge delete response body. + properties: + data: + $ref: '#/components/schemas/AWSEventBridgeDeleteResponseData' + required: + - data + type: object + AWSEventBridgeDeleteResponseAttributes: + description: The EventBridge source delete response attributes. + properties: + status: + $ref: '#/components/schemas/AWSEventBridgeDeleteStatus' + type: object + AWSEventBridgeDeleteResponseData: + description: Amazon EventBridge delete response data. + properties: + attributes: + $ref: '#/components/schemas/AWSEventBridgeDeleteResponseAttributes' + id: + default: delete_event_bridge + description: The ID of the Amazon EventBridge list response data. + example: delete_event_bridge + type: string + type: + $ref: '#/components/schemas/AWSEventBridgeType' + required: + - attributes + - type + type: object + AWSEventBridgeDeleteStatus: + description: The event source status "empty". + enum: + - empty + example: empty + type: string + x-enum-varnames: + - EMPTY + AWSEventBridgeListResponse: + description: Amazon EventBridge list response body. + properties: + data: + $ref: '#/components/schemas/AWSEventBridgeListResponseData' + required: + - data + type: object + AWSEventBridgeListResponseAttributes: + description: An object describing the EventBridge configuration for multiple + accounts. + properties: + accounts: + description: List of accounts with their event sources. + items: + $ref: '#/components/schemas/AWSEventBridgeAccountConfiguration' + type: array + is_installed: + description: True if the EventBridge integration is enabled for your organization. + type: boolean + type: object + AWSEventBridgeListResponseData: + description: Amazon EventBridge list response data. + properties: + attributes: + $ref: '#/components/schemas/AWSEventBridgeListResponseAttributes' + id: + default: get_event_bridge + description: The ID of the Amazon EventBridge list response data. + example: get_event_bridge + type: string + type: + $ref: '#/components/schemas/AWSEventBridgeType' + required: + - attributes + - id + - type + type: object + AWSEventBridgeSource: + description: An EventBridge source. + properties: + name: + description: The event source name. + example: app-alerts-zyxw3210 + type: string + region: + description: 'The event source''s + + [AWS region](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints).' + example: us-east-1 + type: string + type: object + AWSEventBridgeType: + default: event_bridge + description: Amazon EventBridge resource type. + enum: + - event_bridge + example: event_bridge + type: string + x-enum-varnames: + - EVENT_BRIDGE AWSIntegration: description: The definition of `AWSIntegration` object. properties: @@ -1809,10 +2075,12 @@ components: type: object AWSLambdaForwarderConfig: description: 'Log Autosubscription configuration for Datadog Forwarder Lambda - functions. Automatically set up triggers for existing + functions. - and new logs for some services, ensuring no logs from new resources are missed - and saving time spent on manual configuration.' + Automatically set up triggers for existing and new logs for some services, + + ensuring no logs from new resources are missed and saving time spent on manual + configuration.' properties: lambdas: description: List of Datadog Lambda Log Forwarder ARNs in your AWS account. @@ -1825,9 +2093,11 @@ components: $ref: '#/components/schemas/AWSLambdaForwarderConfigLogSourceConfig' sources: description: 'List of service IDs set to enable automatic log collection. + Discover the list of available services with the [Get list of AWS log ready services](https://docs.datadoghq.com/api/latest/aws-logs-integration/#get-list-of-aws-log-ready-services) + endpoint.' items: example: s3 @@ -1847,14 +2117,20 @@ components: description: 'AWS log source tag filter list. Defaults to `[]`. Array of log source to AWS resource tag mappings. Each mapping contains a - log source and its associated AWS resource tags (in `key:value` format) used - to filter logs submitted to Datadog. + log source and its + + associated AWS resource tags (in `key:value` format) used to filter logs submitted + to Datadog. Tag filters are applied for tags on the AWS resource emitting logs; tags associated - with the log storage entity (such as a CloudWatch Log Group or S3 Bucket) - are not considered. + with the + + log storage entity (such as a CloudWatch Log Group or S3 Bucket) are not considered. + + For more information on resource tag filter syntax, + + [see AWS resource exclusion](https://docs.datadoghq.com/account_management/billing/aws/#aws-resource-exclusion) - For more information on resource tag filter syntax, [see AWS resource exclusion](https://docs.datadoghq.com/account_management/billing/aws/#aws-resource-exclusion) in the AWS integration billing page.' properties: source: @@ -1958,17 +2234,21 @@ components: - $ref: '#/components/schemas/AWSNamespaceFiltersExcludeOnly' - $ref: '#/components/schemas/AWSNamespaceFiltersIncludeOnly' AWSNamespaceFiltersExcludeOnly: - description: 'Exclude only these namespaces from metrics collection. Defaults - to `["AWS/SQS", "AWS/ElasticMapReduce", "AWS/Usage"]`. + description: 'Exclude only these namespaces from metrics collection. + + Defaults to `["AWS/SQS", "AWS/ElasticMapReduce", "AWS/Usage"]`. `AWS/SQS`, `AWS/ElasticMapReduce`, and `AWS/Usage` are excluded by default + to reduce your AWS CloudWatch costs from `GetMetricData` API calls.' properties: exclude_only: - description: 'Exclude only these namespaces from metrics collection. Defaults - to `["AWS/SQS", "AWS/ElasticMapReduce", "AWS/Usage"]`. + description: 'Exclude only these namespaces from metrics collection. + + Defaults to `["AWS/SQS", "AWS/ElasticMapReduce", "AWS/Usage"]`. `AWS/SQS`, `AWS/ElasticMapReduce`, and `AWS/Usage` are excluded by default + to reduce your AWS CloudWatch costs from `GetMetricData` API calls.' example: - AWS/SQS @@ -1999,15 +2279,18 @@ components: description: 'AWS Metrics Collection tag filters list. Defaults to `[]`. The array of custom AWS resource tags (in the form `key:value`) defines a - filter that Datadog uses when collecting metrics from a specified service. + filter that Datadog uses + + when collecting metrics from a specified service. Wildcards, such as `?` (match a single character) and `*` (match multiple - characters), and exclusion using `!` before the tag are supported. + characters), + + and exclusion using `!` before the tag are supported. - For EC2, only hosts that match one of the defined tags will be imported into - Datadog. The rest will be ignored. + For EC2, only hosts that match one of the defined tags are imported into Datadog. - For example, `env:production,instance-type:c?.*,!region:us-east-1`.' + The rest are ignored. For example, `env:production,instance-type:c?.*,!region:us-east-1`.' properties: namespace: description: The AWS service for which the tag filters defined in `tags` @@ -2147,15 +2430,19 @@ components: description: AWS Resources Collection config. properties: cloud_security_posture_management_collection: - description: Enable Cloud Security Management to scan AWS resources for - vulnerabilities, misconfigurations, identity risks, and compliance violations. - Defaults to `false`. Requires `extended_collection` to be set to `true`. + description: 'Enable Cloud Security Management to scan AWS resources for + vulnerabilities, misconfigurations, + + identity risks, and compliance violations. Defaults to `false`. + + Requires `extended_collection` to be set to `true`.' example: false type: boolean extended_collection: - description: Whether Datadog collects additional attributes and configuration - information about the resources in your AWS account. Defaults to `true`. - Required for `cloud_security_posture_management_collection`. + description: 'Whether Datadog collects additional attributes and configuration + information about the resources + + in your AWS account. Defaults to `true`. Required for `cloud_security_posture_management_collection`.' example: true type: boolean type: object @@ -63553,8 +63840,9 @@ paths: description: Get a list of AWS Account Integration Configs. operationId: ListAWSAccounts parameters: - - description: Optional query parameter to filter accounts by AWS Account ID. - If not provided, all accounts are returned. + - description: 'Optional query parameter to filter accounts by AWS Account ID. + + If not provided, all accounts are returned.' example: '123456789012' in: query name: aws_account_id @@ -63719,6 +64007,96 @@ paths: operator: OR permissions: - aws_configuration_read + /api/v2/integration/aws/event_bridge: + delete: + description: Delete an Amazon EventBridge source. + operationId: DeleteAWSEventBridgeSource + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/AWSEventBridgeDeleteRequest' + description: Delete the Amazon EventBridge source with the given name, region, + and associated AWS account. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/AWSEventBridgeDeleteResponse' + description: Amazon EventBridge source deleted. + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Delete an Amazon EventBridge source + tags: + - AWS Integration + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - manage_integrations + get: + description: Get all Amazon EventBridge sources. + operationId: ListAWSEventBridgeSources + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/AWSEventBridgeListResponse' + description: Amazon EventBridge sources list. + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get all Amazon EventBridge sources + tags: + - AWS Integration + x-permission: + operator: OR + permissions: + - integrations_read + post: + description: Create an Amazon EventBridge source. + operationId: CreateAWSEventBridgeSource + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/AWSEventBridgeCreateRequest' + description: Create an Amazon EventBridge source for an AWS account with a + given name and region. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/AWSEventBridgeCreateResponse' + description: Amazon EventBridge source created. + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '409': + $ref: '#/components/responses/ConflictResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Create an Amazon EventBridge source + tags: + - AWS Integration + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - manage_integrations /api/v2/integration/aws/generate_new_external_id: post: description: Generate a new external ID for AWS role-based authentication. diff --git a/LICENSE-3rdparty.csv b/LICENSE-3rdparty.csv index 94e543c7e..2468006c5 100644 --- a/LICENSE-3rdparty.csv +++ b/LICENSE-3rdparty.csv @@ -161,7 +161,6 @@ want,https://github.com/seanmonstar/want,MIT,Sean McArthur , } impl ListAWSAccountsOptionalParams { - /// Optional query parameter to filter accounts by AWS Account ID. If not provided, all accounts are returned. + /// Optional query parameter to filter accounts by AWS Account ID. + /// If not provided, all accounts are returned. pub fn aws_account_id(mut self, value: String) -> Self { self.aws_account_id = Some(value); self @@ -34,6 +36,14 @@ pub enum CreateAWSAccountError { UnknownValue(serde_json::Value), } +/// CreateAWSEventBridgeSourceError is a struct for typed errors of method [`AWSIntegrationAPI::create_aws_event_bridge_source`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateAWSEventBridgeSourceError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// CreateNewAWSExternalIDError is a struct for typed errors of method [`AWSIntegrationAPI::create_new_aws_external_id`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -50,6 +60,14 @@ pub enum DeleteAWSAccountError { UnknownValue(serde_json::Value), } +/// DeleteAWSEventBridgeSourceError is a struct for typed errors of method [`AWSIntegrationAPI::delete_aws_event_bridge_source`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteAWSEventBridgeSourceError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// GetAWSAccountError is a struct for typed errors of method [`AWSIntegrationAPI::get_aws_account`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -90,6 +108,14 @@ pub enum ListAWSAccountsError { UnknownValue(serde_json::Value), } +/// ListAWSEventBridgeSourcesError is a struct for typed errors of method [`AWSIntegrationAPI::list_aws_event_bridge_sources`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListAWSEventBridgeSourcesError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// ListAWSNamespacesError is a struct for typed errors of method [`AWSIntegrationAPI::list_aws_namespaces`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -324,6 +350,163 @@ impl AWSIntegrationAPI { } } + /// Create an Amazon EventBridge source. + pub async fn create_aws_event_bridge_source( + &self, + body: crate::datadogV2::model::AWSEventBridgeCreateRequest, + ) -> Result< + crate::datadogV2::model::AWSEventBridgeCreateResponse, + datadog::Error, + > { + match self + .create_aws_event_bridge_source_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 an Amazon EventBridge source. + pub async fn create_aws_event_bridge_source_with_http_info( + &self, + body: crate::datadogV2::model::AWSEventBridgeCreateRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_aws_event_bridge_source"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/integration/aws/event_bridge", + 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)) + } + } + /// Generate a new external ID for AWS role-based authentication. pub async fn create_new_aws_external_id( &self, @@ -521,6 +704,163 @@ impl AWSIntegrationAPI { } } + /// Delete an Amazon EventBridge source. + pub async fn delete_aws_event_bridge_source( + &self, + body: crate::datadogV2::model::AWSEventBridgeDeleteRequest, + ) -> Result< + crate::datadogV2::model::AWSEventBridgeDeleteResponse, + datadog::Error, + > { + match self + .delete_aws_event_bridge_source_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), + } + } + + /// Delete an Amazon EventBridge source. + pub async fn delete_aws_event_bridge_source_with_http_info( + &self, + body: crate::datadogV2::model::AWSEventBridgeDeleteRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.delete_aws_event_bridge_source"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/integration/aws/event_bridge", + local_configuration.get_operation_host(operation_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("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + /// Get an AWS Account Integration Config by config ID. pub async fn get_aws_account( &self, @@ -1075,6 +1415,112 @@ impl AWSIntegrationAPI { } } + /// Get all Amazon EventBridge sources. + pub async fn list_aws_event_bridge_sources( + &self, + ) -> Result< + crate::datadogV2::model::AWSEventBridgeListResponse, + datadog::Error, + > { + match self.list_aws_event_bridge_sources_with_http_info().await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get all Amazon EventBridge sources. + pub async fn list_aws_event_bridge_sources_with_http_info( + &self, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_aws_event_bridge_sources"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/integration/aws/event_bridge", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + /// Get a list of available AWS CloudWatch namespaces that can send metrics to Datadog. pub async fn list_aws_namespaces( &self, diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 4c01be1ab..f4718fced 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -2866,6 +2866,46 @@ pub mod model_aws_namespaces_response_attributes; pub use self::model_aws_namespaces_response_attributes::AWSNamespacesResponseAttributes; pub mod model_aws_namespaces_response_data_type; pub use self::model_aws_namespaces_response_data_type::AWSNamespacesResponseDataType; +pub mod model_aws_event_bridge_delete_request; +pub use self::model_aws_event_bridge_delete_request::AWSEventBridgeDeleteRequest; +pub mod model_aws_event_bridge_delete_request_data; +pub use self::model_aws_event_bridge_delete_request_data::AWSEventBridgeDeleteRequestData; +pub mod model_aws_event_bridge_delete_request_attributes; +pub use self::model_aws_event_bridge_delete_request_attributes::AWSEventBridgeDeleteRequestAttributes; +pub mod model_aws_event_bridge_type; +pub use self::model_aws_event_bridge_type::AWSEventBridgeType; +pub mod model_aws_event_bridge_delete_response; +pub use self::model_aws_event_bridge_delete_response::AWSEventBridgeDeleteResponse; +pub mod model_aws_event_bridge_delete_response_data; +pub use self::model_aws_event_bridge_delete_response_data::AWSEventBridgeDeleteResponseData; +pub mod model_aws_event_bridge_delete_response_attributes; +pub use self::model_aws_event_bridge_delete_response_attributes::AWSEventBridgeDeleteResponseAttributes; +pub mod model_aws_event_bridge_delete_status; +pub use self::model_aws_event_bridge_delete_status::AWSEventBridgeDeleteStatus; +pub mod model_aws_event_bridge_list_response; +pub use self::model_aws_event_bridge_list_response::AWSEventBridgeListResponse; +pub mod model_aws_event_bridge_list_response_data; +pub use self::model_aws_event_bridge_list_response_data::AWSEventBridgeListResponseData; +pub mod model_aws_event_bridge_list_response_attributes; +pub use self::model_aws_event_bridge_list_response_attributes::AWSEventBridgeListResponseAttributes; +pub mod model_aws_event_bridge_account_configuration; +pub use self::model_aws_event_bridge_account_configuration::AWSEventBridgeAccountConfiguration; +pub mod model_aws_event_bridge_source; +pub use self::model_aws_event_bridge_source::AWSEventBridgeSource; +pub mod model_aws_event_bridge_create_request; +pub use self::model_aws_event_bridge_create_request::AWSEventBridgeCreateRequest; +pub mod model_aws_event_bridge_create_request_data; +pub use self::model_aws_event_bridge_create_request_data::AWSEventBridgeCreateRequestData; +pub mod model_aws_event_bridge_create_request_attributes; +pub use self::model_aws_event_bridge_create_request_attributes::AWSEventBridgeCreateRequestAttributes; +pub mod model_aws_event_bridge_create_response; +pub use self::model_aws_event_bridge_create_response::AWSEventBridgeCreateResponse; +pub mod model_aws_event_bridge_create_response_data; +pub use self::model_aws_event_bridge_create_response_data::AWSEventBridgeCreateResponseData; +pub mod model_aws_event_bridge_create_response_attributes; +pub use self::model_aws_event_bridge_create_response_attributes::AWSEventBridgeCreateResponseAttributes; +pub mod model_aws_event_bridge_create_status; +pub use self::model_aws_event_bridge_create_status::AWSEventBridgeCreateStatus; pub mod model_aws_new_external_id_response; pub use self::model_aws_new_external_id_response::AWSNewExternalIDResponse; pub mod model_aws_new_external_id_response_data; diff --git a/src/datadogV2/model/model_aws_account_create_request_attributes.rs b/src/datadogV2/model/model_aws_account_create_request_attributes.rs index 4757b4546..5547335ef 100644 --- a/src/datadogV2/model/model_aws_account_create_request_attributes.rs +++ b/src/datadogV2/model/model_aws_account_create_request_attributes.rs @@ -25,7 +25,8 @@ pub struct AWSAccountCreateRequestAttributes { #[serde(rename = "aws_account_id")] pub aws_account_id: String, /// AWS partition your AWS account is scoped to. Defaults to `aws`. - /// See [Partitions]() in the AWS documentation for more information. + /// See [Partitions]() + /// in the AWS documentation for more information. #[serde(rename = "aws_partition")] pub aws_partition: crate::datadogV2::model::AWSAccountPartition, /// AWS Regions to collect data from. Defaults to `include_all`. diff --git a/src/datadogV2/model/model_aws_account_response_attributes.rs b/src/datadogV2/model/model_aws_account_response_attributes.rs index 7cd431402..37aafd977 100644 --- a/src/datadogV2/model/model_aws_account_response_attributes.rs +++ b/src/datadogV2/model/model_aws_account_response_attributes.rs @@ -25,7 +25,8 @@ pub struct AWSAccountResponseAttributes { #[serde(rename = "aws_account_id")] pub aws_account_id: String, /// AWS partition your AWS account is scoped to. Defaults to `aws`. - /// See [Partitions]() in the AWS documentation for more information. + /// See [Partitions]() + /// in the AWS documentation for more information. #[serde(rename = "aws_partition")] pub aws_partition: Option, /// AWS Regions to collect data from. Defaults to `include_all`. diff --git a/src/datadogV2/model/model_aws_account_response_data.rs b/src/datadogV2/model/model_aws_account_response_data.rs index 6f625ddfc..653787067 100644 --- a/src/datadogV2/model/model_aws_account_response_data.rs +++ b/src/datadogV2/model/model_aws_account_response_data.rs @@ -15,7 +15,8 @@ pub struct AWSAccountResponseData { #[serde(rename = "attributes")] pub attributes: Option, /// Unique Datadog ID of the AWS Account Integration Config. - /// To get the config ID for an account, use the [List all AWS integrations]() + /// To get the config ID for an account, use the + /// [List all AWS integrations]() /// endpoint and query by AWS Account ID. #[serde(rename = "id")] pub id: String, diff --git a/src/datadogV2/model/model_aws_account_update_request_attributes.rs b/src/datadogV2/model/model_aws_account_update_request_attributes.rs index 8717cafbe..a1bb45d15 100644 --- a/src/datadogV2/model/model_aws_account_update_request_attributes.rs +++ b/src/datadogV2/model/model_aws_account_update_request_attributes.rs @@ -25,7 +25,8 @@ pub struct AWSAccountUpdateRequestAttributes { #[serde(rename = "aws_account_id")] pub aws_account_id: String, /// AWS partition your AWS account is scoped to. Defaults to `aws`. - /// See [Partitions]() in the AWS documentation for more information. + /// See [Partitions]() + /// in the AWS documentation for more information. #[serde(rename = "aws_partition")] pub aws_partition: Option, /// AWS Regions to collect data from. Defaults to `include_all`. diff --git a/src/datadogV2/model/model_aws_account_update_request_data.rs b/src/datadogV2/model/model_aws_account_update_request_data.rs index 20ac31886..fd3bf8e2b 100644 --- a/src/datadogV2/model/model_aws_account_update_request_data.rs +++ b/src/datadogV2/model/model_aws_account_update_request_data.rs @@ -15,7 +15,8 @@ pub struct AWSAccountUpdateRequestData { #[serde(rename = "attributes")] pub attributes: crate::datadogV2::model::AWSAccountUpdateRequestAttributes, /// Unique Datadog ID of the AWS Account Integration Config. - /// To get the config ID for an account, use the [List all AWS integrations]() + /// To get the config ID for an account, use the + /// [List all AWS integrations]() /// endpoint and query by AWS Account ID. #[serde(rename = "id")] pub id: Option, diff --git a/src/datadogV2/model/model_aws_event_bridge_account_configuration.rs b/src/datadogV2/model/model_aws_event_bridge_account_configuration.rs new file mode 100644 index 000000000..81bf21e5e --- /dev/null +++ b/src/datadogV2/model/model_aws_event_bridge_account_configuration.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 EventBridge configuration for one AWS account. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSEventBridgeAccountConfiguration { + /// Your AWS Account ID without dashes. + #[serde(rename = "account_id")] + pub account_id: Option, + /// Array of AWS event sources associated with this account. + #[serde(rename = "event_hubs")] + pub event_hubs: Option>, + /// Array of tags (in the form `key:value`) which are added to all hosts + /// and metrics reporting through the main AWS integration. + #[serde(rename = "tags")] + pub tags: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSEventBridgeAccountConfiguration { + pub fn new() -> AWSEventBridgeAccountConfiguration { + AWSEventBridgeAccountConfiguration { + account_id: None, + event_hubs: None, + tags: None, + 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 event_hubs(mut self, value: Vec) -> Self { + self.event_hubs = Some(value); + self + } + + pub fn tags(mut self, value: Vec) -> Self { + self.tags = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for AWSEventBridgeAccountConfiguration { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for AWSEventBridgeAccountConfiguration { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSEventBridgeAccountConfigurationVisitor; + impl<'a> Visitor<'a> for AWSEventBridgeAccountConfigurationVisitor { + type Value = AWSEventBridgeAccountConfiguration; + + 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 event_hubs: Option> = + None; + let mut tags: 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)?); + } + "event_hubs" => { + if v.is_null() { + continue; + } + event_hubs = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "tags" => { + if v.is_null() { + continue; + } + tags = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = AWSEventBridgeAccountConfiguration { + account_id, + event_hubs, + tags, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSEventBridgeAccountConfigurationVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_event_bridge_create_request.rs b/src/datadogV2/model/model_aws_event_bridge_create_request.rs new file mode 100644 index 000000000..53341b32d --- /dev/null +++ b/src/datadogV2/model/model_aws_event_bridge_create_request.rs @@ -0,0 +1,95 @@ +// 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}; + +/// Amazon EventBridge create request body. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSEventBridgeCreateRequest { + /// Amazon EventBridge create request data. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::AWSEventBridgeCreateRequestData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSEventBridgeCreateRequest { + pub fn new( + data: crate::datadogV2::model::AWSEventBridgeCreateRequestData, + ) -> AWSEventBridgeCreateRequest { + AWSEventBridgeCreateRequest { + 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 AWSEventBridgeCreateRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSEventBridgeCreateRequestVisitor; + impl<'a> Visitor<'a> for AWSEventBridgeCreateRequestVisitor { + type Value = AWSEventBridgeCreateRequest; + + 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 = AWSEventBridgeCreateRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSEventBridgeCreateRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_event_bridge_create_request_attributes.rs b/src/datadogV2/model/model_aws_event_bridge_create_request_attributes.rs new file mode 100644 index 000000000..aa33ddfa8 --- /dev/null +++ b/src/datadogV2/model/model_aws_event_bridge_create_request_attributes.rs @@ -0,0 +1,139 @@ +// 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 EventBridge source to be created. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSEventBridgeCreateRequestAttributes { + /// AWS Account ID. + #[serde(rename = "account_id")] + pub account_id: String, + /// Set to true if Datadog should create the event bus in addition to the event + /// source. Requires the `events:CreateEventBus` permission. + #[serde(rename = "create_event_bus")] + pub create_event_bus: Option, + /// The given part of the event source name, which is then combined with an + /// assigned suffix to form the full name. + #[serde(rename = "event_generator_name")] + pub event_generator_name: String, + /// The event source's + /// [AWS region](). + #[serde(rename = "region")] + pub region: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSEventBridgeCreateRequestAttributes { + pub fn new( + account_id: String, + event_generator_name: String, + region: String, + ) -> AWSEventBridgeCreateRequestAttributes { + AWSEventBridgeCreateRequestAttributes { + account_id, + create_event_bus: None, + event_generator_name, + region, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn create_event_bus(mut self, value: bool) -> Self { + self.create_event_bus = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for AWSEventBridgeCreateRequestAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSEventBridgeCreateRequestAttributesVisitor; + impl<'a> Visitor<'a> for AWSEventBridgeCreateRequestAttributesVisitor { + type Value = AWSEventBridgeCreateRequestAttributes; + + 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 create_event_bus: Option = None; + let mut event_generator_name: Option = None; + let mut region: 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)?); + } + "create_event_bus" => { + if v.is_null() { + continue; + } + create_event_bus = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "event_generator_name" => { + event_generator_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "region" => { + region = 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 account_id = account_id.ok_or_else(|| M::Error::missing_field("account_id"))?; + let event_generator_name = event_generator_name + .ok_or_else(|| M::Error::missing_field("event_generator_name"))?; + let region = region.ok_or_else(|| M::Error::missing_field("region"))?; + + let content = AWSEventBridgeCreateRequestAttributes { + account_id, + create_event_bus, + event_generator_name, + region, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSEventBridgeCreateRequestAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_event_bridge_create_request_data.rs b/src/datadogV2/model/model_aws_event_bridge_create_request_data.rs new file mode 100644 index 000000000..c142e0f69 --- /dev/null +++ b/src/datadogV2/model/model_aws_event_bridge_create_request_data.rs @@ -0,0 +1,117 @@ +// 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}; + +/// Amazon EventBridge create request data. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSEventBridgeCreateRequestData { + /// The EventBridge source to be created. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::AWSEventBridgeCreateRequestAttributes, + /// Amazon EventBridge resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::AWSEventBridgeType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSEventBridgeCreateRequestData { + pub fn new( + attributes: crate::datadogV2::model::AWSEventBridgeCreateRequestAttributes, + type_: crate::datadogV2::model::AWSEventBridgeType, + ) -> AWSEventBridgeCreateRequestData { + AWSEventBridgeCreateRequestData { + 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 AWSEventBridgeCreateRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSEventBridgeCreateRequestDataVisitor; + impl<'a> Visitor<'a> for AWSEventBridgeCreateRequestDataVisitor { + type Value = AWSEventBridgeCreateRequestData; + + 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::AWSEventBridgeCreateRequestAttributes, + > = 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::AWSEventBridgeType::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 = AWSEventBridgeCreateRequestData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSEventBridgeCreateRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_event_bridge_create_response.rs b/src/datadogV2/model/model_aws_event_bridge_create_response.rs new file mode 100644 index 000000000..7ea04d40b --- /dev/null +++ b/src/datadogV2/model/model_aws_event_bridge_create_response.rs @@ -0,0 +1,95 @@ +// 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}; + +/// Amazon EventBridge create response body. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSEventBridgeCreateResponse { + /// Amazon EventBridge create response data. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::AWSEventBridgeCreateResponseData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSEventBridgeCreateResponse { + pub fn new( + data: crate::datadogV2::model::AWSEventBridgeCreateResponseData, + ) -> AWSEventBridgeCreateResponse { + AWSEventBridgeCreateResponse { + 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 AWSEventBridgeCreateResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSEventBridgeCreateResponseVisitor; + impl<'a> Visitor<'a> for AWSEventBridgeCreateResponseVisitor { + type Value = AWSEventBridgeCreateResponse; + + 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 = AWSEventBridgeCreateResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSEventBridgeCreateResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_event_bridge_create_response_attributes.rs b/src/datadogV2/model/model_aws_event_bridge_create_response_attributes.rs new file mode 100644 index 000000000..ab08d7cf6 --- /dev/null +++ b/src/datadogV2/model/model_aws_event_bridge_create_response_attributes.rs @@ -0,0 +1,166 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// A created EventBridge source. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSEventBridgeCreateResponseAttributes { + /// The event source name. + #[serde(rename = "event_source_name")] + pub event_source_name: Option, + /// True if the event bus was created in addition to the source. + #[serde(rename = "has_bus")] + pub has_bus: Option, + /// The event source's + /// [AWS region](). + #[serde(rename = "region")] + pub region: Option, + /// The event source status "created". + #[serde(rename = "status")] + pub status: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSEventBridgeCreateResponseAttributes { + pub fn new() -> AWSEventBridgeCreateResponseAttributes { + AWSEventBridgeCreateResponseAttributes { + event_source_name: None, + has_bus: None, + region: None, + status: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn event_source_name(mut self, value: String) -> Self { + self.event_source_name = Some(value); + self + } + + pub fn has_bus(mut self, value: bool) -> Self { + self.has_bus = Some(value); + self + } + + pub fn region(mut self, value: String) -> Self { + self.region = Some(value); + self + } + + pub fn status(mut self, value: crate::datadogV2::model::AWSEventBridgeCreateStatus) -> Self { + self.status = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for AWSEventBridgeCreateResponseAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for AWSEventBridgeCreateResponseAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSEventBridgeCreateResponseAttributesVisitor; + impl<'a> Visitor<'a> for AWSEventBridgeCreateResponseAttributesVisitor { + type Value = AWSEventBridgeCreateResponseAttributes; + + 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 event_source_name: Option = None; + let mut has_bus: Option = None; + let mut region: Option = None; + let mut status: 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() { + "event_source_name" => { + if v.is_null() { + continue; + } + event_source_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "has_bus" => { + if v.is_null() { + continue; + } + has_bus = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "region" => { + if v.is_null() { + continue; + } + region = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "status" => { + if v.is_null() { + continue; + } + status = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _status) = status { + match _status { + crate::datadogV2::model::AWSEventBridgeCreateStatus::UnparsedObject(_status) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = AWSEventBridgeCreateResponseAttributes { + event_source_name, + has_bus, + region, + status, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSEventBridgeCreateResponseAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_event_bridge_create_response_data.rs b/src/datadogV2/model/model_aws_event_bridge_create_response_data.rs new file mode 100644 index 000000000..c4dd13c37 --- /dev/null +++ b/src/datadogV2/model/model_aws_event_bridge_create_response_data.rs @@ -0,0 +1,134 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Amazon EventBridge create response data. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSEventBridgeCreateResponseData { + /// A created EventBridge source. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::AWSEventBridgeCreateResponseAttributes, + /// The ID of the Amazon EventBridge create response data. + #[serde(rename = "id")] + pub id: Option, + /// Amazon EventBridge resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::AWSEventBridgeType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSEventBridgeCreateResponseData { + pub fn new( + attributes: crate::datadogV2::model::AWSEventBridgeCreateResponseAttributes, + type_: crate::datadogV2::model::AWSEventBridgeType, + ) -> AWSEventBridgeCreateResponseData { + AWSEventBridgeCreateResponseData { + 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 AWSEventBridgeCreateResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSEventBridgeCreateResponseDataVisitor; + impl<'a> Visitor<'a> for AWSEventBridgeCreateResponseDataVisitor { + type Value = AWSEventBridgeCreateResponseData; + + 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::AWSEventBridgeCreateResponseAttributes, + > = 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::AWSEventBridgeType::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 = AWSEventBridgeCreateResponseData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSEventBridgeCreateResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_event_bridge_create_status.rs b/src/datadogV2/model/model_aws_event_bridge_create_status.rs new file mode 100644 index 000000000..4d42f3495 --- /dev/null +++ b/src/datadogV2/model/model_aws_event_bridge_create_status.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 AWSEventBridgeCreateStatus { + CREATED, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for AWSEventBridgeCreateStatus { + fn to_string(&self) -> String { + match self { + Self::CREATED => String::from("created"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for AWSEventBridgeCreateStatus { + 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 AWSEventBridgeCreateStatus { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "created" => Self::CREATED, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_aws_event_bridge_delete_request.rs b/src/datadogV2/model/model_aws_event_bridge_delete_request.rs new file mode 100644 index 000000000..54706620d --- /dev/null +++ b/src/datadogV2/model/model_aws_event_bridge_delete_request.rs @@ -0,0 +1,95 @@ +// 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}; + +/// Amazon EventBridge delete request body. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSEventBridgeDeleteRequest { + /// Amazon EventBridge delete request data. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::AWSEventBridgeDeleteRequestData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSEventBridgeDeleteRequest { + pub fn new( + data: crate::datadogV2::model::AWSEventBridgeDeleteRequestData, + ) -> AWSEventBridgeDeleteRequest { + AWSEventBridgeDeleteRequest { + 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 AWSEventBridgeDeleteRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSEventBridgeDeleteRequestVisitor; + impl<'a> Visitor<'a> for AWSEventBridgeDeleteRequestVisitor { + type Value = AWSEventBridgeDeleteRequest; + + 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 = AWSEventBridgeDeleteRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSEventBridgeDeleteRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_event_bridge_delete_request_attributes.rs b/src/datadogV2/model/model_aws_event_bridge_delete_request_attributes.rs new file mode 100644 index 000000000..7c32dc9ca --- /dev/null +++ b/src/datadogV2/model/model_aws_event_bridge_delete_request_attributes.rs @@ -0,0 +1,119 @@ +// 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 EventBridge source to be deleted. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSEventBridgeDeleteRequestAttributes { + /// AWS Account ID. + #[serde(rename = "account_id")] + pub account_id: String, + /// The event source name. + #[serde(rename = "event_generator_name")] + pub event_generator_name: String, + /// The event source's + /// [AWS region](). + #[serde(rename = "region")] + pub region: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSEventBridgeDeleteRequestAttributes { + pub fn new( + account_id: String, + event_generator_name: String, + region: String, + ) -> AWSEventBridgeDeleteRequestAttributes { + AWSEventBridgeDeleteRequestAttributes { + account_id, + event_generator_name, + region, + 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 AWSEventBridgeDeleteRequestAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSEventBridgeDeleteRequestAttributesVisitor; + impl<'a> Visitor<'a> for AWSEventBridgeDeleteRequestAttributesVisitor { + type Value = AWSEventBridgeDeleteRequestAttributes; + + 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 event_generator_name: Option = None; + let mut region: 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)?); + } + "event_generator_name" => { + event_generator_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "region" => { + region = 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 account_id = account_id.ok_or_else(|| M::Error::missing_field("account_id"))?; + let event_generator_name = event_generator_name + .ok_or_else(|| M::Error::missing_field("event_generator_name"))?; + let region = region.ok_or_else(|| M::Error::missing_field("region"))?; + + let content = AWSEventBridgeDeleteRequestAttributes { + account_id, + event_generator_name, + region, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSEventBridgeDeleteRequestAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_event_bridge_delete_request_data.rs b/src/datadogV2/model/model_aws_event_bridge_delete_request_data.rs new file mode 100644 index 000000000..5d93a3303 --- /dev/null +++ b/src/datadogV2/model/model_aws_event_bridge_delete_request_data.rs @@ -0,0 +1,117 @@ +// 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}; + +/// Amazon EventBridge delete request data. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSEventBridgeDeleteRequestData { + /// The EventBridge source to be deleted. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::AWSEventBridgeDeleteRequestAttributes, + /// Amazon EventBridge resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::AWSEventBridgeType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSEventBridgeDeleteRequestData { + pub fn new( + attributes: crate::datadogV2::model::AWSEventBridgeDeleteRequestAttributes, + type_: crate::datadogV2::model::AWSEventBridgeType, + ) -> AWSEventBridgeDeleteRequestData { + AWSEventBridgeDeleteRequestData { + 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 AWSEventBridgeDeleteRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSEventBridgeDeleteRequestDataVisitor; + impl<'a> Visitor<'a> for AWSEventBridgeDeleteRequestDataVisitor { + type Value = AWSEventBridgeDeleteRequestData; + + 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::AWSEventBridgeDeleteRequestAttributes, + > = 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::AWSEventBridgeType::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 = AWSEventBridgeDeleteRequestData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSEventBridgeDeleteRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_event_bridge_delete_response.rs b/src/datadogV2/model/model_aws_event_bridge_delete_response.rs new file mode 100644 index 000000000..6c3f66b5b --- /dev/null +++ b/src/datadogV2/model/model_aws_event_bridge_delete_response.rs @@ -0,0 +1,95 @@ +// 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}; + +/// Amazon EventBridge delete response body. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSEventBridgeDeleteResponse { + /// Amazon EventBridge delete response data. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::AWSEventBridgeDeleteResponseData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSEventBridgeDeleteResponse { + pub fn new( + data: crate::datadogV2::model::AWSEventBridgeDeleteResponseData, + ) -> AWSEventBridgeDeleteResponse { + AWSEventBridgeDeleteResponse { + 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 AWSEventBridgeDeleteResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSEventBridgeDeleteResponseVisitor; + impl<'a> Visitor<'a> for AWSEventBridgeDeleteResponseVisitor { + type Value = AWSEventBridgeDeleteResponse; + + 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 = AWSEventBridgeDeleteResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSEventBridgeDeleteResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_event_bridge_delete_response_attributes.rs b/src/datadogV2/model/model_aws_event_bridge_delete_response_attributes.rs new file mode 100644 index 000000000..ab8fe5c20 --- /dev/null +++ b/src/datadogV2/model/model_aws_event_bridge_delete_response_attributes.rs @@ -0,0 +1,113 @@ +// 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 EventBridge source delete response attributes. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSEventBridgeDeleteResponseAttributes { + /// The event source status "empty". + #[serde(rename = "status")] + pub status: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSEventBridgeDeleteResponseAttributes { + pub fn new() -> AWSEventBridgeDeleteResponseAttributes { + AWSEventBridgeDeleteResponseAttributes { + status: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn status(mut self, value: crate::datadogV2::model::AWSEventBridgeDeleteStatus) -> Self { + self.status = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for AWSEventBridgeDeleteResponseAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for AWSEventBridgeDeleteResponseAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSEventBridgeDeleteResponseAttributesVisitor; + impl<'a> Visitor<'a> for AWSEventBridgeDeleteResponseAttributesVisitor { + type Value = AWSEventBridgeDeleteResponseAttributes; + + 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 status: 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() { + "status" => { + if v.is_null() { + continue; + } + status = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _status) = status { + match _status { + crate::datadogV2::model::AWSEventBridgeDeleteStatus::UnparsedObject(_status) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = AWSEventBridgeDeleteResponseAttributes { + status, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSEventBridgeDeleteResponseAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_event_bridge_delete_response_data.rs b/src/datadogV2/model/model_aws_event_bridge_delete_response_data.rs new file mode 100644 index 000000000..19a1f221a --- /dev/null +++ b/src/datadogV2/model/model_aws_event_bridge_delete_response_data.rs @@ -0,0 +1,134 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Amazon EventBridge delete response data. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSEventBridgeDeleteResponseData { + /// The EventBridge source delete response attributes. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::AWSEventBridgeDeleteResponseAttributes, + /// The ID of the Amazon EventBridge list response data. + #[serde(rename = "id")] + pub id: Option, + /// Amazon EventBridge resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::AWSEventBridgeType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSEventBridgeDeleteResponseData { + pub fn new( + attributes: crate::datadogV2::model::AWSEventBridgeDeleteResponseAttributes, + type_: crate::datadogV2::model::AWSEventBridgeType, + ) -> AWSEventBridgeDeleteResponseData { + AWSEventBridgeDeleteResponseData { + 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 AWSEventBridgeDeleteResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSEventBridgeDeleteResponseDataVisitor; + impl<'a> Visitor<'a> for AWSEventBridgeDeleteResponseDataVisitor { + type Value = AWSEventBridgeDeleteResponseData; + + 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::AWSEventBridgeDeleteResponseAttributes, + > = 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::AWSEventBridgeType::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 = AWSEventBridgeDeleteResponseData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSEventBridgeDeleteResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_event_bridge_delete_status.rs b/src/datadogV2/model/model_aws_event_bridge_delete_status.rs new file mode 100644 index 000000000..cfca94451 --- /dev/null +++ b/src/datadogV2/model/model_aws_event_bridge_delete_status.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 AWSEventBridgeDeleteStatus { + EMPTY, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for AWSEventBridgeDeleteStatus { + fn to_string(&self) -> String { + match self { + Self::EMPTY => String::from("empty"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for AWSEventBridgeDeleteStatus { + 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 AWSEventBridgeDeleteStatus { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "empty" => Self::EMPTY, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_aws_event_bridge_list_response.rs b/src/datadogV2/model/model_aws_event_bridge_list_response.rs new file mode 100644 index 000000000..7aa7a700a --- /dev/null +++ b/src/datadogV2/model/model_aws_event_bridge_list_response.rs @@ -0,0 +1,95 @@ +// 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}; + +/// Amazon EventBridge list response body. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSEventBridgeListResponse { + /// Amazon EventBridge list response data. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::AWSEventBridgeListResponseData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSEventBridgeListResponse { + pub fn new( + data: crate::datadogV2::model::AWSEventBridgeListResponseData, + ) -> AWSEventBridgeListResponse { + AWSEventBridgeListResponse { + 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 AWSEventBridgeListResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSEventBridgeListResponseVisitor; + impl<'a> Visitor<'a> for AWSEventBridgeListResponseVisitor { + type Value = AWSEventBridgeListResponse; + + 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 = AWSEventBridgeListResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSEventBridgeListResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_event_bridge_list_response_attributes.rs b/src/datadogV2/model/model_aws_event_bridge_list_response_attributes.rs new file mode 100644 index 000000000..99f2981a1 --- /dev/null +++ b/src/datadogV2/model/model_aws_event_bridge_list_response_attributes.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}; + +/// An object describing the EventBridge configuration for multiple accounts. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSEventBridgeListResponseAttributes { + /// List of accounts with their event sources. + #[serde(rename = "accounts")] + pub accounts: Option>, + /// True if the EventBridge integration is enabled for your organization. + #[serde(rename = "is_installed")] + pub is_installed: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSEventBridgeListResponseAttributes { + pub fn new() -> AWSEventBridgeListResponseAttributes { + AWSEventBridgeListResponseAttributes { + accounts: None, + is_installed: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn accounts( + mut self, + value: Vec, + ) -> Self { + self.accounts = Some(value); + self + } + + pub fn is_installed(mut self, value: bool) -> Self { + self.is_installed = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for AWSEventBridgeListResponseAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for AWSEventBridgeListResponseAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSEventBridgeListResponseAttributesVisitor; + impl<'a> Visitor<'a> for AWSEventBridgeListResponseAttributesVisitor { + type Value = AWSEventBridgeListResponseAttributes; + + 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 accounts: Option< + Vec, + > = None; + let mut is_installed: 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() { + "accounts" => { + if v.is_null() { + continue; + } + accounts = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "is_installed" => { + if v.is_null() { + continue; + } + is_installed = + 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 = AWSEventBridgeListResponseAttributes { + accounts, + is_installed, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSEventBridgeListResponseAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_event_bridge_list_response_data.rs b/src/datadogV2/model/model_aws_event_bridge_list_response_data.rs new file mode 100644 index 000000000..0ca978ef5 --- /dev/null +++ b/src/datadogV2/model/model_aws_event_bridge_list_response_data.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}; + +/// Amazon EventBridge list response data. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSEventBridgeListResponseData { + /// An object describing the EventBridge configuration for multiple accounts. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::AWSEventBridgeListResponseAttributes, + /// The ID of the Amazon EventBridge list response data. + #[serde(rename = "id")] + pub id: String, + /// Amazon EventBridge resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::AWSEventBridgeType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSEventBridgeListResponseData { + pub fn new( + attributes: crate::datadogV2::model::AWSEventBridgeListResponseAttributes, + id: String, + type_: crate::datadogV2::model::AWSEventBridgeType, + ) -> AWSEventBridgeListResponseData { + AWSEventBridgeListResponseData { + attributes, + id, + 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 AWSEventBridgeListResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSEventBridgeListResponseDataVisitor; + impl<'a> Visitor<'a> for AWSEventBridgeListResponseDataVisitor { + type Value = AWSEventBridgeListResponseData; + + 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::AWSEventBridgeListResponseAttributes, + > = 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" => { + 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::AWSEventBridgeType::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 id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = AWSEventBridgeListResponseData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSEventBridgeListResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_event_bridge_source.rs b/src/datadogV2/model/model_aws_event_bridge_source.rs new file mode 100644 index 000000000..463bae44c --- /dev/null +++ b/src/datadogV2/model/model_aws_event_bridge_source.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}; + +/// An EventBridge source. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSEventBridgeSource { + /// The event source name. + #[serde(rename = "name")] + pub name: Option, + /// The event source's + /// [AWS region](). + #[serde(rename = "region")] + pub region: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSEventBridgeSource { + pub fn new() -> AWSEventBridgeSource { + AWSEventBridgeSource { + name: None, + region: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn region(mut self, value: String) -> Self { + self.region = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for AWSEventBridgeSource { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for AWSEventBridgeSource { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSEventBridgeSourceVisitor; + impl<'a> Visitor<'a> for AWSEventBridgeSourceVisitor { + type Value = AWSEventBridgeSource; + + 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 region: 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" => { + if v.is_null() { + continue; + } + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "region" => { + if v.is_null() { + continue; + } + region = 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 = AWSEventBridgeSource { + name, + region, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSEventBridgeSourceVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_event_bridge_type.rs b/src/datadogV2/model/model_aws_event_bridge_type.rs new file mode 100644 index 000000000..ea9bbf544 --- /dev/null +++ b/src/datadogV2/model/model_aws_event_bridge_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 AWSEventBridgeType { + EVENT_BRIDGE, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for AWSEventBridgeType { + fn to_string(&self) -> String { + match self { + Self::EVENT_BRIDGE => String::from("event_bridge"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for AWSEventBridgeType { + 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 AWSEventBridgeType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "event_bridge" => Self::EVENT_BRIDGE, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_aws_lambda_forwarder_config.rs b/src/datadogV2/model/model_aws_lambda_forwarder_config.rs index 1c4733400..3a61fb113 100644 --- a/src/datadogV2/model/model_aws_lambda_forwarder_config.rs +++ b/src/datadogV2/model/model_aws_lambda_forwarder_config.rs @@ -6,8 +6,9 @@ use serde::{Deserialize, Deserializer, Serialize}; use serde_with::skip_serializing_none; use std::fmt::{self, Formatter}; -/// Log Autosubscription configuration for Datadog Forwarder Lambda functions. Automatically set up triggers for existing -/// and new logs for some services, ensuring no logs from new resources are missed and saving time spent on manual configuration. +/// Log Autosubscription configuration for Datadog Forwarder Lambda functions. +/// Automatically set up triggers for existing and new logs for some services, +/// ensuring no logs from new resources are missed and saving time spent on manual configuration. #[non_exhaustive] #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] @@ -18,8 +19,10 @@ pub struct AWSLambdaForwarderConfig { /// Log source configuration. #[serde(rename = "log_source_config")] pub log_source_config: Option, - /// List of service IDs set to enable automatic log collection. Discover the list of available services with the - /// [Get list of AWS log ready services]() endpoint. + /// List of service IDs set to enable automatic log collection. + /// Discover the list of available services with the + /// [Get list of AWS log ready services]() + /// endpoint. #[serde(rename = "sources")] pub sources: Option>, #[serde(flatten)] diff --git a/src/datadogV2/model/model_aws_log_source_tag_filter.rs b/src/datadogV2/model/model_aws_log_source_tag_filter.rs index c5c0c38b2..50aebfcdd 100644 --- a/src/datadogV2/model/model_aws_log_source_tag_filter.rs +++ b/src/datadogV2/model/model_aws_log_source_tag_filter.rs @@ -7,9 +7,13 @@ use serde_with::skip_serializing_none; use std::fmt::{self, Formatter}; /// AWS log source tag filter list. Defaults to `[]`. -/// Array of log source to AWS resource tag mappings. Each mapping contains a log source and its associated AWS resource tags (in `key:value` format) used to filter logs submitted to Datadog. -/// Tag filters are applied for tags on the AWS resource emitting logs; tags associated with the log storage entity (such as a CloudWatch Log Group or S3 Bucket) are not considered. -/// For more information on resource tag filter syntax, [see AWS resource exclusion]() in the AWS integration billing page. +/// Array of log source to AWS resource tag mappings. Each mapping contains a log source and its +/// associated AWS resource tags (in `key:value` format) used to filter logs submitted to Datadog. +/// Tag filters are applied for tags on the AWS resource emitting logs; tags associated with the +/// log storage entity (such as a CloudWatch Log Group or S3 Bucket) are not considered. +/// For more information on resource tag filter syntax, +/// [see AWS resource exclusion]() +/// in the AWS integration billing page. #[non_exhaustive] #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] diff --git a/src/datadogV2/model/model_aws_logs_config.rs b/src/datadogV2/model/model_aws_logs_config.rs index 6437e178d..ed5005d93 100644 --- a/src/datadogV2/model/model_aws_logs_config.rs +++ b/src/datadogV2/model/model_aws_logs_config.rs @@ -11,8 +11,9 @@ use std::fmt::{self, Formatter}; #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] pub struct AWSLogsConfig { - /// Log Autosubscription configuration for Datadog Forwarder Lambda functions. Automatically set up triggers for existing - /// and new logs for some services, ensuring no logs from new resources are missed and saving time spent on manual configuration. + /// Log Autosubscription configuration for Datadog Forwarder Lambda functions. + /// Automatically set up triggers for existing and new logs for some services, + /// ensuring no logs from new resources are missed and saving time spent on manual configuration. #[serde(rename = "lambda_forwarder")] pub lambda_forwarder: Option, #[serde(flatten)] diff --git a/src/datadogV2/model/model_aws_namespace_filters_exclude_only.rs b/src/datadogV2/model/model_aws_namespace_filters_exclude_only.rs index 0d37f3161..08829ab5d 100644 --- a/src/datadogV2/model/model_aws_namespace_filters_exclude_only.rs +++ b/src/datadogV2/model/model_aws_namespace_filters_exclude_only.rs @@ -6,14 +6,18 @@ use serde::{Deserialize, Deserializer, Serialize}; use serde_with::skip_serializing_none; use std::fmt::{self, Formatter}; -/// Exclude only these namespaces from metrics collection. Defaults to `["AWS/SQS", "AWS/ElasticMapReduce", "AWS/Usage"]`. -/// `AWS/SQS`, `AWS/ElasticMapReduce`, and `AWS/Usage` are excluded by default to reduce your AWS CloudWatch costs from `GetMetricData` API calls. +/// Exclude only these namespaces from metrics collection. +/// Defaults to `["AWS/SQS", "AWS/ElasticMapReduce", "AWS/Usage"]`. +/// `AWS/SQS`, `AWS/ElasticMapReduce`, and `AWS/Usage` are excluded by default +/// to reduce your AWS CloudWatch costs from `GetMetricData` API calls. #[non_exhaustive] #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] pub struct AWSNamespaceFiltersExcludeOnly { - /// Exclude only these namespaces from metrics collection. Defaults to `["AWS/SQS", "AWS/ElasticMapReduce", "AWS/Usage"]`. - /// `AWS/SQS`, `AWS/ElasticMapReduce`, and `AWS/Usage` are excluded by default to reduce your AWS CloudWatch costs from `GetMetricData` API calls. + /// Exclude only these namespaces from metrics collection. + /// Defaults to `["AWS/SQS", "AWS/ElasticMapReduce", "AWS/Usage"]`. + /// `AWS/SQS`, `AWS/ElasticMapReduce`, and `AWS/Usage` are excluded by default + /// to reduce your AWS CloudWatch costs from `GetMetricData` API calls. #[serde(rename = "exclude_only")] pub exclude_only: Vec, #[serde(flatten)] diff --git a/src/datadogV2/model/model_aws_namespace_tag_filter.rs b/src/datadogV2/model/model_aws_namespace_tag_filter.rs index f5d519a1c..f7ae3036a 100644 --- a/src/datadogV2/model/model_aws_namespace_tag_filter.rs +++ b/src/datadogV2/model/model_aws_namespace_tag_filter.rs @@ -7,10 +7,12 @@ use serde_with::skip_serializing_none; use std::fmt::{self, Formatter}; /// AWS Metrics Collection tag filters list. Defaults to `[]`. -/// The array of custom AWS resource tags (in the form `key:value`) defines a filter that Datadog uses when collecting metrics from a specified service. -/// Wildcards, such as `?` (match a single character) and `*` (match multiple characters), and exclusion using `!` before the tag are supported. -/// For EC2, only hosts that match one of the defined tags will be imported into Datadog. The rest will be ignored. -/// For example, `env:production,instance-type:c?.*,!region:us-east-1`. +/// The array of custom AWS resource tags (in the form `key:value`) defines a filter that Datadog uses +/// when collecting metrics from a specified service. +/// Wildcards, such as `?` (match a single character) and `*` (match multiple characters), +/// and exclusion using `!` before the tag are supported. +/// For EC2, only hosts that match one of the defined tags are imported into Datadog. +/// The rest are ignored. For example, `env:production,instance-type:c?.*,!region:us-east-1`. #[non_exhaustive] #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] diff --git a/src/datadogV2/model/model_aws_resources_config.rs b/src/datadogV2/model/model_aws_resources_config.rs index 3f1748a03..70fdfae95 100644 --- a/src/datadogV2/model/model_aws_resources_config.rs +++ b/src/datadogV2/model/model_aws_resources_config.rs @@ -11,10 +11,13 @@ use std::fmt::{self, Formatter}; #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] pub struct AWSResourcesConfig { - /// Enable Cloud Security Management to scan AWS resources for vulnerabilities, misconfigurations, identity risks, and compliance violations. Defaults to `false`. Requires `extended_collection` to be set to `true`. + /// Enable Cloud Security Management to scan AWS resources for vulnerabilities, misconfigurations, + /// identity risks, and compliance violations. Defaults to `false`. + /// Requires `extended_collection` to be set to `true`. #[serde(rename = "cloud_security_posture_management_collection")] pub cloud_security_posture_management_collection: Option, - /// Whether Datadog collects additional attributes and configuration information about the resources in your AWS account. Defaults to `true`. Required for `cloud_security_posture_management_collection`. + /// Whether Datadog collects additional attributes and configuration information about the resources + /// in your AWS account. Defaults to `true`. Required for `cloud_security_posture_management_collection`. #[serde(rename = "extended_collection")] pub extended_collection: Option, #[serde(flatten)] diff --git a/tests/scenarios/features/v2/aws_integration.feature b/tests/scenarios/features/v2/aws_integration.feature index 16522a97c..30ded64d7 100644 --- a/tests/scenarios/features/v2/aws_integration.feature +++ b/tests/scenarios/features/v2/aws_integration.feature @@ -38,6 +38,27 @@ Feature: AWS Integration When the request is sent Then the response status is 409 Conflict + @generated @skip @team:DataDog/aws-integrations + Scenario: Create an Amazon EventBridge source returns "Amazon EventBridge source created." response + Given new "CreateAWSEventBridgeSource" request + And body with value {"data": {"attributes": {"account_id": "123456789012", "create_event_bus": true, "event_generator_name": "app-alerts", "region": "us-east-1"}, "type": "event_bridge"}} + When the request is sent + Then the response status is 200 Amazon EventBridge source created. + + @generated @skip @team:DataDog/aws-integrations + Scenario: Create an Amazon EventBridge source returns "Bad Request" response + Given new "CreateAWSEventBridgeSource" request + And body with value {"data": {"attributes": {"account_id": "123456789012", "create_event_bus": true, "event_generator_name": "app-alerts", "region": "us-east-1"}, "type": "event_bridge"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/aws-integrations + Scenario: Create an Amazon EventBridge source returns "Conflict" response + Given new "CreateAWSEventBridgeSource" request + And body with value {"data": {"attributes": {"account_id": "123456789012", "create_event_bus": true, "event_generator_name": "app-alerts", "region": "us-east-1"}, "type": "event_bridge"}} + When the request is sent + Then the response status is 409 Conflict + @team:DataDog/aws-integrations Scenario: Delete an AWS integration returns "Bad Request" response Given new "DeleteAWSAccount" request @@ -61,6 +82,20 @@ Feature: AWS Integration When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/aws-integrations + Scenario: Delete an Amazon EventBridge source returns "Amazon EventBridge source deleted." response + Given new "DeleteAWSEventBridgeSource" request + And body with value {"data": {"attributes": {"account_id": "123456789012", "event_generator_name": "app-alerts-zyxw3210", "region": "us-east-1"}, "type": "event_bridge"}} + When the request is sent + Then the response status is 200 Amazon EventBridge source deleted. + + @generated @skip @team:DataDog/aws-integrations + Scenario: Delete an Amazon EventBridge source returns "Bad Request" response + Given new "DeleteAWSEventBridgeSource" request + And body with value {"data": {"attributes": {"account_id": "123456789012", "event_generator_name": "app-alerts-zyxw3210", "region": "us-east-1"}, "type": "event_bridge"}} + When the request is sent + Then the response status is 400 Bad Request + @team:DataDog/aws-integrations Scenario: Generate a new external ID returns "AWS External ID object" response Given new "CreateNewAWSExternalID" request @@ -91,6 +126,18 @@ Feature: AWS Integration When the request is sent Then the response status is 200 AWS integration standard IAM permissions. + @generated @skip @team:DataDog/aws-integrations + Scenario: Get all Amazon EventBridge sources returns "Amazon EventBridge sources list." response + Given new "ListAWSEventBridgeSources" request + When the request is sent + Then the response status is 200 Amazon EventBridge sources list. + + @generated @skip @team:DataDog/aws-integrations + Scenario: Get all Amazon EventBridge sources returns "Bad Request" response + Given new "ListAWSEventBridgeSources" request + When the request is sent + Then the response status is 400 Bad Request + @team:DataDog/aws-integrations Scenario: Get an AWS integration by config ID returns "AWS Account object" response Given there is a valid "aws_account_v2" in the system diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index eb1380ab6..ec7eca2cf 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1712,6 +1712,26 @@ "type": "safe" } }, + "DeleteAWSEventBridgeSource": { + "tag": "AWS Integration", + "undo": { + "type": "idempotent" + } + }, + "ListAWSEventBridgeSources": { + "tag": "AWS Integration", + "undo": { + "type": "safe" + } + }, + "CreateAWSEventBridgeSource": { + "tag": "AWS Integration", + "undo": { + "operationId": "DeleteAWSEventBridgeSource", + "parameters": [], + "type": "unsafe" + } + }, "CreateNewAWSExternalID": { "tag": "AWS Integration", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index baca98d96..138f8fa03 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -3059,6 +3059,18 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { world .function_mappings .insert("v2.ListAWSNamespaces".into(), test_v2_list_aws_namespaces); + world.function_mappings.insert( + "v2.DeleteAWSEventBridgeSource".into(), + test_v2_delete_aws_event_bridge_source, + ); + world.function_mappings.insert( + "v2.ListAWSEventBridgeSources".into(), + test_v2_list_aws_event_bridge_sources, + ); + world.function_mappings.insert( + "v2.CreateAWSEventBridgeSource".into(), + test_v2_create_aws_event_bridge_source, + ); world.function_mappings.insert( "v2.CreateNewAWSExternalID".into(), test_v2_create_new_aws_external_id, @@ -22876,6 +22888,89 @@ fn test_v2_list_aws_namespaces(world: &mut DatadogWorld, _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_aws_integration + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.delete_aws_event_bridge_source_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_list_aws_event_bridge_sources( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_aws_integration + .as_ref() + .expect("api instance not found"); + let response = match block_on(api.list_aws_event_bridge_sources_with_http_info()) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_create_aws_event_bridge_source( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_aws_integration + .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_aws_event_bridge_source_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_create_new_aws_external_id( world: &mut DatadogWorld, _parameters: &HashMap,