diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 5b151db2a..af90ad1cb 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -23771,6 +23771,299 @@ components: the default subdomain. type: string type: object + EventEmailAddressAlertType: + description: The alert type of events generated from the email address. + enum: + - info + - warn + - error + - success + example: info + type: string + x-enum-varnames: + - INFO + - WARN + - ERROR + - SUCCESS + EventEmailAddressCreateAttributes: + description: Attributes for creating an event email address. + properties: + alert_type: + $ref: '#/components/schemas/EventEmailAddressAlertType' + description: + description: A description of the event email address. + example: Email address for production alerts. + maxLength: 1024 + type: string + format: + $ref: '#/components/schemas/EventEmailAddressFormat' + notify_handles: + $ref: '#/components/schemas/EventEmailAddressNotifyHandles' + tags: + $ref: '#/components/schemas/EventEmailAddressTags' + required: + - format + type: object + EventEmailAddressCreateData: + description: Data for creating an event email address. + properties: + attributes: + $ref: '#/components/schemas/EventEmailAddressCreateAttributes' + type: + $ref: '#/components/schemas/EventEmailAddressResourceType' + required: + - type + - attributes + type: object + EventEmailAddressCreateRequest: + description: Request body for creating an event email address. + properties: + data: + $ref: '#/components/schemas/EventEmailAddressCreateData' + required: + - data + type: object + EventEmailAddressCreatedByRelationship: + description: Relationship to the user who created the email address. + properties: + data: + $ref: '#/components/schemas/EventEmailAddressUserData' + required: + - data + type: object + EventEmailAddressData: + description: A single event email address resource. + properties: + attributes: + $ref: '#/components/schemas/EventEmailAddressResponseAttributes' + id: + description: The UUID of the event email address. + example: 00000000-0000-0000-0000-000000000001 + type: string + relationships: + $ref: '#/components/schemas/EventEmailAddressRelationships' + type: + $ref: '#/components/schemas/EventEmailAddressResourceType' + required: + - type + - id + - attributes + - relationships + type: object + EventEmailAddressFormat: + description: The format of events ingested through the email address. + enum: + - json + - plain-text + example: json + type: string + x-enum-varnames: + - JSON + - PLAIN_TEXT + EventEmailAddressIncludedUser: + description: An included user resource in an event email address response. + properties: + attributes: + $ref: '#/components/schemas/EventEmailAddressIncludedUserAttributes' + id: + description: The UUID of the user. + example: 00000000-0000-0000-0000-000000000001 + type: string + type: + description: The type of the resource. + example: users + type: string + required: + - type + - id + - attributes + type: object + EventEmailAddressIncludedUserAttributes: + description: Attributes of an included user resource. + properties: + name: + description: The name of the user. + example: John Doe + type: string + required: + - name + type: object + EventEmailAddressNotifyHandles: + description: A list of handles to notify when an email is received. + example: + - '@slack-my-channel' + items: + description: A notification handle. + maxLength: 256 + minLength: 1 + type: string + maxItems: 10 + type: array + EventEmailAddressRelationships: + description: Relationships associated with an event email address resource. + properties: + created_by: + $ref: '#/components/schemas/EventEmailAddressCreatedByRelationship' + revoked_by: + $ref: '#/components/schemas/EventEmailAddressRevokedByRelationship' + required: + - created_by + type: object + EventEmailAddressResourceType: + description: The type of the resource. Must be `event_emails`. + enum: + - event_emails + example: event_emails + type: string + x-enum-varnames: + - EVENT_EMAILS + EventEmailAddressResponseAttributes: + description: Attributes of an event email address resource. + properties: + alert_type: + $ref: '#/components/schemas/EventEmailAddressAlertType' + created_at: + description: The timestamp of when the event email address was created. + example: '2025-04-11T13:58:07Z' + format: date-time + type: string + description: + description: A description of the event email address. + example: Email address for production alerts. + maxLength: 1024 + nullable: true + type: string + email: + description: The generated email address for ingesting events. + example: api-abc12345@event-intake.datadoghq.com + type: string + format: + $ref: '#/components/schemas/EventEmailAddressFormat' + last_used_at: + description: The timestamp of when the event email address was last used. + example: null + format: date-time + nullable: true + type: string + notify_handles: + $ref: '#/components/schemas/EventEmailAddressNotifyHandles' + revoked_at: + description: The timestamp of when the event email address was revoked. + example: null + format: date-time + nullable: true + type: string + tags: + $ref: '#/components/schemas/EventEmailAddressTags' + required: + - email + - format + - created_at + type: object + EventEmailAddressRevokedByRelationship: + description: Relationship to the user who revoked the email address. + example: null + nullable: true + properties: + data: + $ref: '#/components/schemas/EventEmailAddressUserData' + type: object + EventEmailAddressSingleResponse: + description: Response containing a single event email address. + properties: + data: + $ref: '#/components/schemas/EventEmailAddressData' + included: + description: Related resources included in the response. + items: + $ref: '#/components/schemas/EventEmailAddressIncludedUser' + type: array + required: + - data + type: object + EventEmailAddressTags: + description: A list of tags to apply to events generated from the email address. + example: + - env:production + - team:my-team + items: + description: A tag. + maxLength: 200 + minLength: 1 + type: string + maxItems: 20 + type: array + EventEmailAddressUpdateAttributes: + description: Attributes for updating an event email address. + properties: + alert_type: + $ref: '#/components/schemas/EventEmailAddressAlertType' + description: + description: A description of the event email address. + example: Updated description for the email address. + maxLength: 1024 + nullable: true + type: string + notify_handles: + $ref: '#/components/schemas/EventEmailAddressNotifyHandles' + tags: + $ref: '#/components/schemas/EventEmailAddressTags' + required: + - description + - alert_type + - tags + - notify_handles + type: object + EventEmailAddressUpdateData: + description: Data for updating an event email address. + properties: + attributes: + $ref: '#/components/schemas/EventEmailAddressUpdateAttributes' + type: + $ref: '#/components/schemas/EventEmailAddressResourceType' + required: + - type + - attributes + type: object + EventEmailAddressUpdateRequest: + description: Request body for updating an event email address. + properties: + data: + $ref: '#/components/schemas/EventEmailAddressUpdateData' + required: + - data + type: object + EventEmailAddressUserData: + description: A user data reference in a relationship. + properties: + id: + description: The UUID of the user. + example: 00000000-0000-0000-0000-000000000001 + type: string + type: + description: The type of the resource. + example: users + type: string + required: + - type + - id + type: object + EventEmailAddressesResponse: + description: Response containing a list of event email addresses. + properties: + data: + description: A list of event email address resources. + items: + $ref: '#/components/schemas/EventEmailAddressData' + type: array + included: + description: Related resources included in the response. + items: + $ref: '#/components/schemas/EventEmailAddressIncludedUser' + type: array + required: + - data + type: object EventPayload: additionalProperties: false description: Event attributes. @@ -45607,6 +45900,50 @@ components: required: - type type: object + OnCallEventEmailAddressCreateAttributes: + description: Attributes for creating an on-call event email address. + properties: + alert_type: + $ref: '#/components/schemas/EventEmailAddressAlertType' + description: + description: A description of the on-call event email address. + example: On-call email address for my team. + maxLength: 1024 + type: string + format: + $ref: '#/components/schemas/EventEmailAddressFormat' + tags: + $ref: '#/components/schemas/EventEmailAddressTags' + team_handle: + description: 'The team handle associated with the on-call email address. + + Must contain only alphanumeric characters, hyphens, and underscores.' + example: my-team + maxLength: 195 + type: string + required: + - format + - team_handle + type: object + OnCallEventEmailAddressCreateData: + description: Data for creating an on-call event email address. + properties: + attributes: + $ref: '#/components/schemas/OnCallEventEmailAddressCreateAttributes' + type: + $ref: '#/components/schemas/EventEmailAddressResourceType' + required: + - type + - attributes + type: object + OnCallEventEmailAddressCreateRequest: + description: Request body for creating an on-call event email address. + properties: + data: + $ref: '#/components/schemas/OnCallEventEmailAddressCreateData' + required: + - data + type: object OnCallNotificationRule: description: A top-level wrapper for a notification rule example: @@ -82017,6 +82354,371 @@ paths: tags: - Events x-codegen-request-body-name: body + /api/v2/events/mail: + get: + description: List all API email addresses for your organization. + operationId: ListEventEmailAddresses + parameters: + - description: When set to `true`, returns only active (non-revoked) email addresses. + in: query + name: active + required: false + schema: + type: boolean + - description: 'Comma-separated list of related resources to include in the + response. + + Supported values are `created_by` and `revoked_by`.' + in: query + name: include + required: false + schema: + example: created_by,revoked_by + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/EventEmailAddressesResponse' + description: OK + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: List event email addresses + tags: + - Events + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + post: + description: Create a new API email address to use in an event email integration + rule. + operationId: CreateEventEmailAddress + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/EventEmailAddressCreateRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/EventEmailAddressSingleResponse' + description: Created + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '405': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Method Not Allowed + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Create an event email address + tags: + - Events + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/events/mail/on-call: + get: + description: List all on-call event email addresses for a given team handle. + operationId: ListOnCallEventEmailAddresses + parameters: + - description: The team handle to filter on-call event email addresses. + in: query + name: filter[team_handle] + required: true + schema: + example: my-team + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/EventEmailAddressesResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: List on-call event email addresses + tags: + - Events + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + post: + description: Create a new on-call event email address associated with a team + handle. + operationId: CreateOnCallEventEmailAddress + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OnCallEventEmailAddressCreateRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/EventEmailAddressSingleResponse' + description: Created + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Create an on-call event email address + tags: + - Events + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/events/mail/on-call/{id}: + delete: + description: Revoke an existing on-call event email address in your organization. + operationId: DeleteOnCallEventEmailAddress + parameters: + - description: The UUID of the on-call event email address. + in: path + name: id + required: true + schema: + example: 00000000-0000-0000-0000-000000000001 + format: uuid + type: string + responses: + '204': + description: No Content + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Revoke an on-call event email address + tags: + - Events + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/events/mail/{email_uuid}: + delete: + description: Revoke an existing API email address in your organization. + operationId: DeleteEventEmailAddress + parameters: + - description: The UUID of the event email address. + in: path + name: email_uuid + required: true + schema: + example: 00000000-0000-0000-0000-000000000001 + format: uuid + type: string + responses: + '204': + description: No Content + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Revoke an event email address + tags: + - Events + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + get: + description: Get a single API email address for your organization. + operationId: GetEventEmailAddress + parameters: + - description: The UUID of the event email address. + in: path + name: email_uuid + required: true + schema: + example: 00000000-0000-0000-0000-000000000001 + format: uuid + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/EventEmailAddressSingleResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Get an event email address + tags: + - Events + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + patch: + description: Update an existing API email address in your organization. + operationId: UpdateEventEmailAddress + parameters: + - description: The UUID of the event email address. + in: path + name: email_uuid + required: true + schema: + example: 00000000-0000-0000-0000-000000000001 + format: uuid + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/EventEmailAddressUpdateRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/EventEmailAddressSingleResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Update an event email address + tags: + - Events + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/events/search: post: description: 'List endpoint returns events that match an events search query. diff --git a/examples/v2_events_CreateEventEmailAddress.rs b/examples/v2_events_CreateEventEmailAddress.rs new file mode 100644 index 000000000..4ca5b545f --- /dev/null +++ b/examples/v2_events_CreateEventEmailAddress.rs @@ -0,0 +1,33 @@ +// Create an event email address returns "Created" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_events::EventsAPI; +use datadog_api_client::datadogV2::model::EventEmailAddressAlertType; +use datadog_api_client::datadogV2::model::EventEmailAddressCreateAttributes; +use datadog_api_client::datadogV2::model::EventEmailAddressCreateData; +use datadog_api_client::datadogV2::model::EventEmailAddressCreateRequest; +use datadog_api_client::datadogV2::model::EventEmailAddressFormat; +use datadog_api_client::datadogV2::model::EventEmailAddressResourceType; + +#[tokio::main] +async fn main() { + let body = EventEmailAddressCreateRequest::new(EventEmailAddressCreateData::new( + EventEmailAddressCreateAttributes::new(EventEmailAddressFormat::JSON) + .alert_type(EventEmailAddressAlertType::INFO) + .description("Email address for production alerts.".to_string()) + .notify_handles(vec!["@slack-my-channel".to_string()]) + .tags(vec![ + "env:production".to_string(), + "team:my-team".to_string(), + ]), + EventEmailAddressResourceType::EVENT_EMAILS, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.CreateEventEmailAddress", true); + let api = EventsAPI::with_config(configuration); + let resp = api.create_event_email_address(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_events_CreateOnCallEventEmailAddress.rs b/examples/v2_events_CreateOnCallEventEmailAddress.rs new file mode 100644 index 000000000..20bb7fc36 --- /dev/null +++ b/examples/v2_events_CreateOnCallEventEmailAddress.rs @@ -0,0 +1,35 @@ +// Create an on-call event email address returns "Created" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_events::EventsAPI; +use datadog_api_client::datadogV2::model::EventEmailAddressAlertType; +use datadog_api_client::datadogV2::model::EventEmailAddressFormat; +use datadog_api_client::datadogV2::model::EventEmailAddressResourceType; +use datadog_api_client::datadogV2::model::OnCallEventEmailAddressCreateAttributes; +use datadog_api_client::datadogV2::model::OnCallEventEmailAddressCreateData; +use datadog_api_client::datadogV2::model::OnCallEventEmailAddressCreateRequest; + +#[tokio::main] +async fn main() { + let body = OnCallEventEmailAddressCreateRequest::new(OnCallEventEmailAddressCreateData::new( + OnCallEventEmailAddressCreateAttributes::new( + EventEmailAddressFormat::JSON, + "my-team".to_string(), + ) + .alert_type(EventEmailAddressAlertType::INFO) + .description("On-call email address for my team.".to_string()) + .tags(vec![ + "env:production".to_string(), + "team:my-team".to_string(), + ]), + EventEmailAddressResourceType::EVENT_EMAILS, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.CreateOnCallEventEmailAddress", true); + let api = EventsAPI::with_config(configuration); + let resp = api.create_on_call_event_email_address(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_events_DeleteEventEmailAddress.rs b/examples/v2_events_DeleteEventEmailAddress.rs new file mode 100644 index 000000000..02e8261d9 --- /dev/null +++ b/examples/v2_events_DeleteEventEmailAddress.rs @@ -0,0 +1,21 @@ +// Revoke an event email address returns "No Content" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_events::EventsAPI; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.DeleteEventEmailAddress", true); + let api = EventsAPI::with_config(configuration); + let resp = api + .delete_event_email_address( + Uuid::parse_str("00000000-0000-0000-0000-000000000001").expect("invalid UUID"), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_events_DeleteOnCallEventEmailAddress.rs b/examples/v2_events_DeleteOnCallEventEmailAddress.rs new file mode 100644 index 000000000..9209d115e --- /dev/null +++ b/examples/v2_events_DeleteOnCallEventEmailAddress.rs @@ -0,0 +1,21 @@ +// Revoke an on-call event email address returns "No Content" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_events::EventsAPI; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.DeleteOnCallEventEmailAddress", true); + let api = EventsAPI::with_config(configuration); + let resp = api + .delete_on_call_event_email_address( + Uuid::parse_str("00000000-0000-0000-0000-000000000001").expect("invalid UUID"), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_events_GetEventEmailAddress.rs b/examples/v2_events_GetEventEmailAddress.rs new file mode 100644 index 000000000..0ce9c2e01 --- /dev/null +++ b/examples/v2_events_GetEventEmailAddress.rs @@ -0,0 +1,21 @@ +// Get an event email address returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_events::EventsAPI; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.GetEventEmailAddress", true); + let api = EventsAPI::with_config(configuration); + let resp = api + .get_event_email_address( + Uuid::parse_str("00000000-0000-0000-0000-000000000001").expect("invalid UUID"), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_events_ListEventEmailAddresses.rs b/examples/v2_events_ListEventEmailAddresses.rs new file mode 100644 index 000000000..e2bdeb7a0 --- /dev/null +++ b/examples/v2_events_ListEventEmailAddresses.rs @@ -0,0 +1,19 @@ +// List event email addresses returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_events::EventsAPI; +use datadog_api_client::datadogV2::api_events::ListEventEmailAddressesOptionalParams; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.ListEventEmailAddresses", true); + let api = EventsAPI::with_config(configuration); + let resp = api + .list_event_email_addresses(ListEventEmailAddressesOptionalParams::default()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_events_ListOnCallEventEmailAddresses.rs b/examples/v2_events_ListOnCallEventEmailAddresses.rs new file mode 100644 index 000000000..43e51dfb4 --- /dev/null +++ b/examples/v2_events_ListOnCallEventEmailAddresses.rs @@ -0,0 +1,18 @@ +// List on-call event email addresses returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_events::EventsAPI; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.ListOnCallEventEmailAddresses", true); + let api = EventsAPI::with_config(configuration); + let resp = api + .list_on_call_event_email_addresses("my-team".to_string()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_events_UpdateEventEmailAddress.rs b/examples/v2_events_UpdateEventEmailAddress.rs new file mode 100644 index 000000000..06474b34e --- /dev/null +++ b/examples/v2_events_UpdateEventEmailAddress.rs @@ -0,0 +1,36 @@ +// Update an event email address returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_events::EventsAPI; +use datadog_api_client::datadogV2::model::EventEmailAddressAlertType; +use datadog_api_client::datadogV2::model::EventEmailAddressResourceType; +use datadog_api_client::datadogV2::model::EventEmailAddressUpdateAttributes; +use datadog_api_client::datadogV2::model::EventEmailAddressUpdateData; +use datadog_api_client::datadogV2::model::EventEmailAddressUpdateRequest; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let body = EventEmailAddressUpdateRequest::new(EventEmailAddressUpdateData::new( + EventEmailAddressUpdateAttributes::new( + EventEmailAddressAlertType::INFO, + Some("Updated description for the email address.".to_string()), + vec!["@slack-my-channel".to_string()], + vec!["env:production".to_string(), "team:my-team".to_string()], + ), + EventEmailAddressResourceType::EVENT_EMAILS, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.UpdateEventEmailAddress", true); + let api = EventsAPI::with_config(configuration); + let resp = api + .update_event_email_address( + Uuid::parse_str("00000000-0000-0000-0000-000000000001").expect("invalid UUID"), + body, + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadog/configuration.rs b/src/datadog/configuration.rs index cb1af6230..b5b098c4d 100644 --- a/src/datadog/configuration.rs +++ b/src/datadog/configuration.rs @@ -205,6 +205,14 @@ impl Default for Configuration { ("v2.get_deployment_rule".to_owned(), false), ("v2.update_deployment_gate".to_owned(), false), ("v2.update_deployment_rule".to_owned(), false), + ("v2.create_event_email_address".to_owned(), false), + ("v2.create_on_call_event_email_address".to_owned(), false), + ("v2.delete_event_email_address".to_owned(), false), + ("v2.delete_on_call_event_email_address".to_owned(), false), + ("v2.get_event_email_address".to_owned(), false), + ("v2.list_event_email_addresses".to_owned(), false), + ("v2.list_on_call_event_email_addresses".to_owned(), false), + ("v2.update_event_email_address".to_owned(), false), ("v2.create_hamr_org_connection".to_owned(), false), ("v2.get_hamr_org_connection".to_owned(), false), ("v2.create_global_incident_handle".to_owned(), false), diff --git a/src/datadogV2/api/api_events.rs b/src/datadogV2/api/api_events.rs index 62cf2f36b..fa258879f 100644 --- a/src/datadogV2/api/api_events.rs +++ b/src/datadogV2/api/api_events.rs @@ -8,10 +8,36 @@ use flate2::{ Compression, }; use futures_core::stream::Stream; +use log::warn; use reqwest::header::{HeaderMap, HeaderValue}; use serde::{Deserialize, Serialize}; use std::io::Write; +/// ListEventEmailAddressesOptionalParams is a struct for passing parameters to the method [`EventsAPI::list_event_email_addresses`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct ListEventEmailAddressesOptionalParams { + /// When set to `true`, returns only active (non-revoked) email addresses. + pub active: Option, + /// Comma-separated list of related resources to include in the response. + /// Supported values are `created_by` and `revoked_by`. + pub include: Option, +} + +impl ListEventEmailAddressesOptionalParams { + /// When set to `true`, returns only active (non-revoked) email addresses. + pub fn active(mut self, value: bool) -> Self { + self.active = Some(value); + self + } + /// Comma-separated list of related resources to include in the response. + /// Supported values are `created_by` and `revoked_by`. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } +} + /// ListEventsOptionalParams is a struct for passing parameters to the method [`EventsAPI::list_events`] #[non_exhaustive] #[derive(Clone, Default, Debug)] @@ -86,6 +112,42 @@ pub enum CreateEventError { UnknownValue(serde_json::Value), } +/// CreateEventEmailAddressError is a struct for typed errors of method [`EventsAPI::create_event_email_address`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateEventEmailAddressError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// CreateOnCallEventEmailAddressError is a struct for typed errors of method [`EventsAPI::create_on_call_event_email_address`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateOnCallEventEmailAddressError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// DeleteEventEmailAddressError is a struct for typed errors of method [`EventsAPI::delete_event_email_address`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteEventEmailAddressError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// DeleteOnCallEventEmailAddressError is a struct for typed errors of method [`EventsAPI::delete_on_call_event_email_address`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteOnCallEventEmailAddressError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// GetEventError is a struct for typed errors of method [`EventsAPI::get_event`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -94,6 +156,24 @@ pub enum GetEventError { UnknownValue(serde_json::Value), } +/// GetEventEmailAddressError is a struct for typed errors of method [`EventsAPI::get_event_email_address`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetEventEmailAddressError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// ListEventEmailAddressesError is a struct for typed errors of method [`EventsAPI::list_event_email_addresses`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListEventEmailAddressesError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// ListEventsError is a struct for typed errors of method [`EventsAPI::list_events`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -102,6 +182,15 @@ pub enum ListEventsError { UnknownValue(serde_json::Value), } +/// ListOnCallEventEmailAddressesError is a struct for typed errors of method [`EventsAPI::list_on_call_event_email_addresses`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListOnCallEventEmailAddressesError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// SearchEventsError is a struct for typed errors of method [`EventsAPI::search_events`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -110,6 +199,15 @@ pub enum SearchEventsError { UnknownValue(serde_json::Value), } +/// UpdateEventEmailAddressError is a struct for typed errors of method [`EventsAPI::update_event_email_address`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateEventEmailAddressError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// The Event Management API allows you to programmatically post events to the Events Explorer and fetch events from the Events Explorer. See the [Event Management page]() for more information. /// /// **Update to Datadog monitor events `aggregation_key` starting March 1, 2025:** The Datadog monitor events `aggregation_key` is unique to each Monitor ID. Starting March 1st, this key will also include Monitor Group, making it unique per *Monitor ID and Monitor Group*. If you're using monitor events `aggregation_key` in dashboard queries or the Event API, you must migrate to use `@monitor.id`. Reach out to [support]() if you have any question. @@ -344,12 +442,15 @@ impl EventsAPI { } } - /// Get the details of an event by `event_id`. - pub async fn get_event( + /// Create a new API email address to use in an event email integration rule. + pub async fn create_event_email_address( &self, - event_id: String, - ) -> Result> { - match self.get_event_with_http_info(event_id).await { + body: crate::datadogV2::model::EventEmailAddressCreateRequest, + ) -> Result< + crate::datadogV2::model::EventEmailAddressSingleResponse, + datadog::Error, + > { + match self.create_event_email_address_with_http_info(body).await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -363,29 +464,37 @@ impl EventsAPI { } } - /// Get the details of an event by `event_id`. - pub async fn get_event_with_http_info( + /// Create a new API email address to use in an event email integration rule. + pub async fn create_event_email_address_with_http_info( &self, - event_id: String, + body: crate::datadogV2::model::EventEmailAddressCreateRequest, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.get_event"; + let operation_id = "v2.create_event_email_address"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.create_event_email_address' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/events/{event_id}", - local_configuration.get_operation_host(operation_id), - event_id = datadog::urlencode(event_id) + "{}/api/v2/events/mail", + local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = - local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); // build headers let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); headers.insert("Accept", HeaderValue::from_static("application/json")); // build user agent @@ -416,6 +525,51 @@ impl EventsAPI { ); }; + // 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()); @@ -426,7 +580,9 @@ impl EventsAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::(&local_content) { + match serde_json::from_str::( + &local_content, + ) { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -437,7 +593,8 @@ impl EventsAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_entity: Option = + serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, content: local_content, @@ -447,15 +604,18 @@ impl EventsAPI { } } - /// List endpoint returns events that match an events search query. - /// [Results are paginated similarly to logs](). - /// - /// Use this endpoint to see your latest events. - pub async fn list_events( + /// Create a new on-call event email address associated with a team handle. + pub async fn create_on_call_event_email_address( &self, - params: ListEventsOptionalParams, - ) -> Result> { - match self.list_events_with_http_info(params).await { + body: crate::datadogV2::model::OnCallEventEmailAddressCreateRequest, + ) -> Result< + crate::datadogV2::model::EventEmailAddressSingleResponse, + datadog::Error, + > { + match self + .create_on_call_event_email_address_with_http_info(body) + .await + { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -469,99 +629,37 @@ impl EventsAPI { } } - pub fn list_events_with_pagination( - &self, - mut params: ListEventsOptionalParams, - ) -> impl Stream< - Item = Result>, - > + '_ { - try_stream! { - let mut page_size: i32 = 10; - if params.page_limit.is_none() { - params.page_limit = Some(page_size); - } else { - page_size = params.page_limit.unwrap().clone(); - } - loop { - let resp = self.list_events(params.clone()).await?; - let Some(data) = resp.data else { break }; - - let r = data; - let count = r.len(); - for team in r { - yield team; - } - - if count < page_size as usize { - break; - } - let Some(meta) = resp.meta else { break }; - let Some(page) = meta.page else { break }; - let Some(after) = page.after else { break }; - - params.page_cursor = Some(after); - } - } - } - - /// List endpoint returns events that match an events search query. - /// [Results are paginated similarly to logs](). - /// - /// Use this endpoint to see your latest events. - pub async fn list_events_with_http_info( + /// Create a new on-call event email address associated with a team handle. + pub async fn create_on_call_event_email_address_with_http_info( &self, - params: ListEventsOptionalParams, + body: crate::datadogV2::model::OnCallEventEmailAddressCreateRequest, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.list_events"; - - // unbox and build optional parameters - let filter_query = params.filter_query; - let filter_from = params.filter_from; - let filter_to = params.filter_to; - let sort = params.sort; - let page_cursor = params.page_cursor; - let page_limit = params.page_limit; + let operation_id = "v2.create_on_call_event_email_address"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.create_on_call_event_email_address' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/events", + "{}/api/v2/events/mail/on-call", local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = - local_client.request(reqwest::Method::GET, local_uri_str.as_str()); - - if let Some(ref local_query_param) = filter_query { - local_req_builder = - local_req_builder.query(&[("filter[query]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_from { - local_req_builder = - local_req_builder.query(&[("filter[from]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_to { - local_req_builder = - local_req_builder.query(&[("filter[to]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = sort { - local_req_builder = - local_req_builder.query(&[("sort", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = page_cursor { - local_req_builder = - local_req_builder.query(&[("page[cursor]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = page_limit { - local_req_builder = - local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]); - }; + 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 @@ -592,30 +690,927 @@ impl EventsAPI { ); }; - 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(); + // 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)) + } + } + + /// Revoke an existing API email address in your organization. + pub async fn delete_event_email_address( + &self, + email_uuid: uuid::Uuid, + ) -> Result<(), datadog::Error> { + match self + .delete_event_email_address_with_http_info(email_uuid) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Revoke an existing API email address in your organization. + pub async fn delete_event_email_address_with_http_info( + &self, + email_uuid: uuid::Uuid, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.delete_event_email_address"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.delete_event_email_address' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/events/mail/{email_uuid}", + local_configuration.get_operation_host(operation_id), + email_uuid = datadog::urlencode(email_uuid.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Revoke an existing on-call event email address in your organization. + pub async fn delete_on_call_event_email_address( + &self, + id: uuid::Uuid, + ) -> Result<(), datadog::Error> { + match self + .delete_on_call_event_email_address_with_http_info(id) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Revoke an existing on-call event email address in your organization. + pub async fn delete_on_call_event_email_address_with_http_info( + &self, + id: uuid::Uuid, + ) -> Result, datadog::Error> + { + let local_configuration = &self.config; + let operation_id = "v2.delete_on_call_event_email_address"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.delete_on_call_event_email_address' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/events/mail/on-call/{id}", + local_configuration.get_operation_host(operation_id), + id = datadog::urlencode(id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Get the details of an event by `event_id`. + pub async fn get_event( + &self, + event_id: String, + ) -> Result> { + match self.get_event_with_http_info(event_id).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get the details of an event by `event_id`. + pub async fn get_event_with_http_info( + &self, + event_id: String, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_event"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/events/{event_id}", + local_configuration.get_operation_host(operation_id), + event_id = datadog::urlencode(event_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 single API email address for your organization. + pub async fn get_event_email_address( + &self, + email_uuid: uuid::Uuid, + ) -> Result< + crate::datadogV2::model::EventEmailAddressSingleResponse, + datadog::Error, + > { + match self + .get_event_email_address_with_http_info(email_uuid) + .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 a single API email address for your organization. + pub async fn get_event_email_address_with_http_info( + &self, + email_uuid: uuid::Uuid, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_event_email_address"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.get_event_email_address' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/events/mail/{email_uuid}", + local_configuration.get_operation_host(operation_id), + email_uuid = datadog::urlencode(email_uuid.to_string()) + ); + 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)) + } + } + + /// List all API email addresses for your organization. + pub async fn list_event_email_addresses( + &self, + params: ListEventEmailAddressesOptionalParams, + ) -> Result< + crate::datadogV2::model::EventEmailAddressesResponse, + datadog::Error, + > { + match self.list_event_email_addresses_with_http_info(params).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// List all API email addresses for your organization. + pub async fn list_event_email_addresses_with_http_info( + &self, + params: ListEventEmailAddressesOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_event_email_addresses"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.list_event_email_addresses' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let active = params.active; + let include = params.include; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/events/mail", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = active { + local_req_builder = + local_req_builder.query(&[("active", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = include { + local_req_builder = + local_req_builder.query(&[("include", &local_query_param.to_string())]); + }; + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// List endpoint returns events that match an events search query. + /// [Results are paginated similarly to logs](). + /// + /// Use this endpoint to see your latest events. + pub async fn list_events( + &self, + params: ListEventsOptionalParams, + ) -> Result> { + match self.list_events_with_http_info(params).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + pub fn list_events_with_pagination( + &self, + mut params: ListEventsOptionalParams, + ) -> impl Stream< + Item = Result>, + > + '_ { + try_stream! { + let mut page_size: i32 = 10; + if params.page_limit.is_none() { + params.page_limit = Some(page_size); + } else { + page_size = params.page_limit.unwrap().clone(); + } + loop { + let resp = self.list_events(params.clone()).await?; + let Some(data) = resp.data else { break }; + + let r = data; + let count = r.len(); + for team in r { + yield team; + } + + if count < page_size as usize { + break; + } + let Some(meta) = resp.meta else { break }; + let Some(page) = meta.page else { break }; + let Some(after) = page.after else { break }; + + params.page_cursor = Some(after); + } + } + } + + /// List endpoint returns events that match an events search query. + /// [Results are paginated similarly to logs](). + /// + /// Use this endpoint to see your latest events. + pub async fn list_events_with_http_info( + &self, + params: ListEventsOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_events"; + + // unbox and build optional parameters + let filter_query = params.filter_query; + let filter_from = params.filter_from; + let filter_to = params.filter_to; + let sort = params.sort; + let page_cursor = params.page_cursor; + let page_limit = params.page_limit; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/events", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = filter_query { + local_req_builder = + local_req_builder.query(&[("filter[query]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_from { + local_req_builder = + local_req_builder.query(&[("filter[from]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_to { + local_req_builder = + local_req_builder.query(&[("filter[to]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = sort { + local_req_builder = + local_req_builder.query(&[("sort", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = page_cursor { + local_req_builder = + local_req_builder.query(&[("page[cursor]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = page_limit { + local_req_builder = + local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]); + }; + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// List all on-call event email addresses for a given team handle. + pub async fn list_on_call_event_email_addresses( + &self, + filter_team_handle: String, + ) -> Result< + crate::datadogV2::model::EventEmailAddressesResponse, + datadog::Error, + > { + match self + .list_on_call_event_email_addresses_with_http_info(filter_team_handle) + .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), + } + } + + /// List all on-call event email addresses for a given team handle. + pub async fn list_on_call_event_email_addresses_with_http_info( + &self, + filter_team_handle: String, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_on_call_event_email_addresses"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.list_on_call_event_email_addresses' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/events/mail/on-call", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + local_req_builder = + local_req_builder.query(&[("filter[team_handle]", &filter_team_handle.to_string())]); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, content: local_content, @@ -825,4 +1820,172 @@ impl EventsAPI { Err(datadog::Error::ResponseError(local_error)) } } + + /// Update an existing API email address in your organization. + pub async fn update_event_email_address( + &self, + email_uuid: uuid::Uuid, + body: crate::datadogV2::model::EventEmailAddressUpdateRequest, + ) -> Result< + crate::datadogV2::model::EventEmailAddressSingleResponse, + datadog::Error, + > { + match self + .update_event_email_address_with_http_info(email_uuid, body) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Update an existing API email address in your organization. + pub async fn update_event_email_address_with_http_info( + &self, + email_uuid: uuid::Uuid, + body: crate::datadogV2::model::EventEmailAddressUpdateRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.update_event_email_address"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.update_event_email_address' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/events/mail/{email_uuid}", + local_configuration.get_operation_host(operation_id), + email_uuid = datadog::urlencode(email_uuid.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } } diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index ea0e124a9..880e90189 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -2884,6 +2884,50 @@ pub mod model_event_create_response_attributes_attributes_evt; pub use self::model_event_create_response_attributes_attributes_evt::EventCreateResponseAttributesAttributesEvt; pub mod model_event_create_response_payload_links; pub use self::model_event_create_response_payload_links::EventCreateResponsePayloadLinks; +pub mod model_event_email_addresses_response; +pub use self::model_event_email_addresses_response::EventEmailAddressesResponse; +pub mod model_event_email_address_data; +pub use self::model_event_email_address_data::EventEmailAddressData; +pub mod model_event_email_address_response_attributes; +pub use self::model_event_email_address_response_attributes::EventEmailAddressResponseAttributes; +pub mod model_event_email_address_alert_type; +pub use self::model_event_email_address_alert_type::EventEmailAddressAlertType; +pub mod model_event_email_address_format; +pub use self::model_event_email_address_format::EventEmailAddressFormat; +pub mod model_event_email_address_relationships; +pub use self::model_event_email_address_relationships::EventEmailAddressRelationships; +pub mod model_event_email_address_created_by_relationship; +pub use self::model_event_email_address_created_by_relationship::EventEmailAddressCreatedByRelationship; +pub mod model_event_email_address_user_data; +pub use self::model_event_email_address_user_data::EventEmailAddressUserData; +pub mod model_event_email_address_revoked_by_relationship; +pub use self::model_event_email_address_revoked_by_relationship::EventEmailAddressRevokedByRelationship; +pub mod model_event_email_address_resource_type; +pub use self::model_event_email_address_resource_type::EventEmailAddressResourceType; +pub mod model_event_email_address_included_user; +pub use self::model_event_email_address_included_user::EventEmailAddressIncludedUser; +pub mod model_event_email_address_included_user_attributes; +pub use self::model_event_email_address_included_user_attributes::EventEmailAddressIncludedUserAttributes; +pub mod model_event_email_address_create_request; +pub use self::model_event_email_address_create_request::EventEmailAddressCreateRequest; +pub mod model_event_email_address_create_data; +pub use self::model_event_email_address_create_data::EventEmailAddressCreateData; +pub mod model_event_email_address_create_attributes; +pub use self::model_event_email_address_create_attributes::EventEmailAddressCreateAttributes; +pub mod model_event_email_address_single_response; +pub use self::model_event_email_address_single_response::EventEmailAddressSingleResponse; +pub mod model_on_call_event_email_address_create_request; +pub use self::model_on_call_event_email_address_create_request::OnCallEventEmailAddressCreateRequest; +pub mod model_on_call_event_email_address_create_data; +pub use self::model_on_call_event_email_address_create_data::OnCallEventEmailAddressCreateData; +pub mod model_on_call_event_email_address_create_attributes; +pub use self::model_on_call_event_email_address_create_attributes::OnCallEventEmailAddressCreateAttributes; +pub mod model_event_email_address_update_request; +pub use self::model_event_email_address_update_request::EventEmailAddressUpdateRequest; +pub mod model_event_email_address_update_data; +pub use self::model_event_email_address_update_data::EventEmailAddressUpdateData; +pub mod model_event_email_address_update_attributes; +pub use self::model_event_email_address_update_attributes::EventEmailAddressUpdateAttributes; pub mod model_events_list_request; pub use self::model_events_list_request::EventsListRequest; pub mod model_events_query_filter; diff --git a/src/datadogV2/model/model_event_email_address_alert_type.rs b/src/datadogV2/model/model_event_email_address_alert_type.rs new file mode 100644 index 000000000..520bd3bd0 --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_alert_type.rs @@ -0,0 +1,57 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum EventEmailAddressAlertType { + INFO, + WARN, + ERROR, + SUCCESS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for EventEmailAddressAlertType { + fn to_string(&self) -> String { + match self { + Self::INFO => String::from("info"), + Self::WARN => String::from("warn"), + Self::ERROR => String::from("error"), + Self::SUCCESS => String::from("success"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for EventEmailAddressAlertType { + 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 EventEmailAddressAlertType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "info" => Self::INFO, + "warn" => Self::WARN, + "error" => Self::ERROR, + "success" => Self::SUCCESS, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_event_email_address_create_attributes.rs b/src/datadogV2/model/model_event_email_address_create_attributes.rs new file mode 100644 index 000000000..df8e69a96 --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_create_attributes.rs @@ -0,0 +1,184 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes for creating an event email address. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressCreateAttributes { + /// The alert type of events generated from the email address. + #[serde(rename = "alert_type")] + pub alert_type: Option, + /// A description of the event email address. + #[serde(rename = "description")] + pub description: Option, + /// The format of events ingested through the email address. + #[serde(rename = "format")] + pub format: crate::datadogV2::model::EventEmailAddressFormat, + /// A list of handles to notify when an email is received. + #[serde(rename = "notify_handles")] + pub notify_handles: Option>, + /// A list of tags to apply to events generated from the email address. + #[serde(rename = "tags")] + pub tags: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressCreateAttributes { + pub fn new( + format: crate::datadogV2::model::EventEmailAddressFormat, + ) -> EventEmailAddressCreateAttributes { + EventEmailAddressCreateAttributes { + alert_type: None, + description: None, + format, + notify_handles: None, + tags: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn alert_type( + mut self, + value: crate::datadogV2::model::EventEmailAddressAlertType, + ) -> Self { + self.alert_type = Some(value); + self + } + + pub fn description(mut self, value: String) -> Self { + self.description = Some(value); + self + } + + pub fn notify_handles(mut self, value: Vec) -> Self { + self.notify_handles = Some(value); + self + } + + pub fn tags(mut self, value: Vec) -> Self { + self.tags = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for EventEmailAddressCreateAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressCreateAttributesVisitor; + impl<'a> Visitor<'a> for EventEmailAddressCreateAttributesVisitor { + type Value = EventEmailAddressCreateAttributes; + + 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 alert_type: Option = + None; + let mut description: Option = None; + let mut format: Option = None; + let mut notify_handles: 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() { + "alert_type" => { + if v.is_null() { + continue; + } + alert_type = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _alert_type) = alert_type { + match _alert_type { + crate::datadogV2::model::EventEmailAddressAlertType::UnparsedObject(_alert_type) => { + _unparsed = true; + }, + _ => {} + } + } + } + "description" => { + if v.is_null() { + continue; + } + description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "format" => { + format = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _format) = format { + match _format { + crate::datadogV2::model::EventEmailAddressFormat::UnparsedObject(_format) => { + _unparsed = true; + }, + _ => {} + } + } + } + "notify_handles" => { + if v.is_null() { + continue; + } + notify_handles = + 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 format = format.ok_or_else(|| M::Error::missing_field("format"))?; + + let content = EventEmailAddressCreateAttributes { + alert_type, + description, + format, + notify_handles, + tags, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressCreateAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_event_email_address_create_data.rs b/src/datadogV2/model/model_event_email_address_create_data.rs new file mode 100644 index 000000000..2f119d32f --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_create_data.rs @@ -0,0 +1,116 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Data for creating an event email address. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressCreateData { + /// Attributes for creating an event email address. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::EventEmailAddressCreateAttributes, + /// The type of the resource. Must be `event_emails`. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::EventEmailAddressResourceType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressCreateData { + pub fn new( + attributes: crate::datadogV2::model::EventEmailAddressCreateAttributes, + type_: crate::datadogV2::model::EventEmailAddressResourceType, + ) -> EventEmailAddressCreateData { + EventEmailAddressCreateData { + 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 EventEmailAddressCreateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressCreateDataVisitor; + impl<'a> Visitor<'a> for EventEmailAddressCreateDataVisitor { + type Value = EventEmailAddressCreateData; + + 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::EventEmailAddressCreateAttributes, + > = 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::EventEmailAddressResourceType::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 = EventEmailAddressCreateData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressCreateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_event_email_address_create_request.rs b/src/datadogV2/model/model_event_email_address_create_request.rs new file mode 100644 index 000000000..644fa23b1 --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_create_request.rs @@ -0,0 +1,94 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request body for creating an event email address. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressCreateRequest { + /// Data for creating an event email address. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::EventEmailAddressCreateData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressCreateRequest { + pub fn new( + data: crate::datadogV2::model::EventEmailAddressCreateData, + ) -> EventEmailAddressCreateRequest { + EventEmailAddressCreateRequest { + 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 EventEmailAddressCreateRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressCreateRequestVisitor; + impl<'a> Visitor<'a> for EventEmailAddressCreateRequestVisitor { + type Value = EventEmailAddressCreateRequest; + + 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 = EventEmailAddressCreateRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressCreateRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_event_email_address_created_by_relationship.rs b/src/datadogV2/model/model_event_email_address_created_by_relationship.rs new file mode 100644 index 000000000..a1f5ddb56 --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_created_by_relationship.rs @@ -0,0 +1,94 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Relationship to the user who created the email address. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressCreatedByRelationship { + /// A user data reference in a relationship. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::EventEmailAddressUserData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressCreatedByRelationship { + pub fn new( + data: crate::datadogV2::model::EventEmailAddressUserData, + ) -> EventEmailAddressCreatedByRelationship { + EventEmailAddressCreatedByRelationship { + 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 EventEmailAddressCreatedByRelationship { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressCreatedByRelationshipVisitor; + impl<'a> Visitor<'a> for EventEmailAddressCreatedByRelationshipVisitor { + type Value = EventEmailAddressCreatedByRelationship; + + 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 = EventEmailAddressCreatedByRelationship { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressCreatedByRelationshipVisitor) + } +} diff --git a/src/datadogV2/model/model_event_email_address_data.rs b/src/datadogV2/model/model_event_email_address_data.rs new file mode 100644 index 000000000..05a94ceda --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_data.rs @@ -0,0 +1,142 @@ +// 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 single event email address resource. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressData { + /// Attributes of an event email address resource. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::EventEmailAddressResponseAttributes, + /// The UUID of the event email address. + #[serde(rename = "id")] + pub id: String, + /// Relationships associated with an event email address resource. + #[serde(rename = "relationships")] + pub relationships: crate::datadogV2::model::EventEmailAddressRelationships, + /// The type of the resource. Must be `event_emails`. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::EventEmailAddressResourceType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressData { + pub fn new( + attributes: crate::datadogV2::model::EventEmailAddressResponseAttributes, + id: String, + relationships: crate::datadogV2::model::EventEmailAddressRelationships, + type_: crate::datadogV2::model::EventEmailAddressResourceType, + ) -> EventEmailAddressData { + EventEmailAddressData { + attributes, + id, + relationships, + 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 EventEmailAddressData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressDataVisitor; + impl<'a> Visitor<'a> for EventEmailAddressDataVisitor { + type Value = EventEmailAddressData; + + 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::EventEmailAddressResponseAttributes, + > = None; + let mut id: Option = None; + let mut relationships: Option< + crate::datadogV2::model::EventEmailAddressRelationships, + > = 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)?); + } + "relationships" => { + relationships = + 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::EventEmailAddressResourceType::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 relationships = + relationships.ok_or_else(|| M::Error::missing_field("relationships"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = EventEmailAddressData { + attributes, + id, + relationships, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressDataVisitor) + } +} diff --git a/src/datadogV2/model/model_event_email_address_format.rs b/src/datadogV2/model/model_event_email_address_format.rs new file mode 100644 index 000000000..c82ed23a1 --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_format.rs @@ -0,0 +1,51 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum EventEmailAddressFormat { + JSON, + PLAIN_TEXT, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for EventEmailAddressFormat { + fn to_string(&self) -> String { + match self { + Self::JSON => String::from("json"), + Self::PLAIN_TEXT => String::from("plain-text"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for EventEmailAddressFormat { + 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 EventEmailAddressFormat { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "json" => Self::JSON, + "plain-text" => Self::PLAIN_TEXT, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_event_email_address_included_user.rs b/src/datadogV2/model/model_event_email_address_included_user.rs new file mode 100644 index 000000000..92a8380e2 --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_included_user.rs @@ -0,0 +1,118 @@ +// 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 included user resource in an event email address response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressIncludedUser { + /// Attributes of an included user resource. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::EventEmailAddressIncludedUserAttributes, + /// The UUID of the user. + #[serde(rename = "id")] + pub id: String, + /// The type of the resource. + #[serde(rename = "type")] + pub type_: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressIncludedUser { + pub fn new( + attributes: crate::datadogV2::model::EventEmailAddressIncludedUserAttributes, + id: String, + type_: String, + ) -> EventEmailAddressIncludedUser { + EventEmailAddressIncludedUser { + 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 EventEmailAddressIncludedUser { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressIncludedUserVisitor; + impl<'a> Visitor<'a> for EventEmailAddressIncludedUserVisitor { + type Value = EventEmailAddressIncludedUser; + + 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::EventEmailAddressIncludedUserAttributes, + > = 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 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 = EventEmailAddressIncludedUser { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressIncludedUserVisitor) + } +} diff --git a/src/datadogV2/model/model_event_email_address_included_user_attributes.rs b/src/datadogV2/model/model_event_email_address_included_user_attributes.rs new file mode 100644 index 000000000..66712a961 --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_included_user_attributes.rs @@ -0,0 +1,92 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes of an included user resource. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressIncludedUserAttributes { + /// The name of the user. + #[serde(rename = "name")] + pub name: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressIncludedUserAttributes { + pub fn new(name: String) -> EventEmailAddressIncludedUserAttributes { + EventEmailAddressIncludedUserAttributes { + name, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for EventEmailAddressIncludedUserAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressIncludedUserAttributesVisitor; + impl<'a> Visitor<'a> for EventEmailAddressIncludedUserAttributesVisitor { + type Value = EventEmailAddressIncludedUserAttributes; + + 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 additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + + let content = EventEmailAddressIncludedUserAttributes { + name, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressIncludedUserAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_event_email_address_relationships.rs b/src/datadogV2/model/model_event_email_address_relationships.rs new file mode 100644 index 000000000..838e4b335 --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_relationships.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}; + +/// Relationships associated with an event email address resource. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressRelationships { + /// Relationship to the user who created the email address. + #[serde(rename = "created_by")] + pub created_by: crate::datadogV2::model::EventEmailAddressCreatedByRelationship, + /// Relationship to the user who revoked the email address. + #[serde( + rename = "revoked_by", + default, + with = "::serde_with::rust::double_option" + )] + pub revoked_by: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressRelationships { + pub fn new( + created_by: crate::datadogV2::model::EventEmailAddressCreatedByRelationship, + ) -> EventEmailAddressRelationships { + EventEmailAddressRelationships { + created_by, + revoked_by: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn revoked_by( + mut self, + value: Option, + ) -> Self { + self.revoked_by = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for EventEmailAddressRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressRelationshipsVisitor; + impl<'a> Visitor<'a> for EventEmailAddressRelationshipsVisitor { + type Value = EventEmailAddressRelationships; + + 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 created_by: Option< + crate::datadogV2::model::EventEmailAddressCreatedByRelationship, + > = None; + let mut revoked_by: Option< + 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() { + "created_by" => { + created_by = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "revoked_by" => { + revoked_by = 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 created_by = created_by.ok_or_else(|| M::Error::missing_field("created_by"))?; + + let content = EventEmailAddressRelationships { + created_by, + revoked_by, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_event_email_address_resource_type.rs b/src/datadogV2/model/model_event_email_address_resource_type.rs new file mode 100644 index 000000000..d50cd7c85 --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_resource_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 EventEmailAddressResourceType { + EVENT_EMAILS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for EventEmailAddressResourceType { + fn to_string(&self) -> String { + match self { + Self::EVENT_EMAILS => String::from("event_emails"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for EventEmailAddressResourceType { + 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 EventEmailAddressResourceType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "event_emails" => Self::EVENT_EMAILS, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_event_email_address_response_attributes.rs b/src/datadogV2/model/model_event_email_address_response_attributes.rs new file mode 100644 index 000000000..a98a02ada --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_response_attributes.rs @@ -0,0 +1,244 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes of an event email address resource. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressResponseAttributes { + /// The alert type of events generated from the email address. + #[serde(rename = "alert_type")] + pub alert_type: Option, + /// The timestamp of when the event email address was created. + #[serde(rename = "created_at")] + pub created_at: chrono::DateTime, + /// A description of the event email address. + #[serde( + rename = "description", + default, + with = "::serde_with::rust::double_option" + )] + pub description: Option>, + /// The generated email address for ingesting events. + #[serde(rename = "email")] + pub email: String, + /// The format of events ingested through the email address. + #[serde(rename = "format")] + pub format: crate::datadogV2::model::EventEmailAddressFormat, + /// The timestamp of when the event email address was last used. + #[serde( + rename = "last_used_at", + default, + with = "::serde_with::rust::double_option" + )] + pub last_used_at: Option>>, + /// A list of handles to notify when an email is received. + #[serde(rename = "notify_handles")] + pub notify_handles: Option>, + /// The timestamp of when the event email address was revoked. + #[serde( + rename = "revoked_at", + default, + with = "::serde_with::rust::double_option" + )] + pub revoked_at: Option>>, + /// A list of tags to apply to events generated from the email address. + #[serde(rename = "tags")] + pub tags: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressResponseAttributes { + pub fn new( + created_at: chrono::DateTime, + email: String, + format: crate::datadogV2::model::EventEmailAddressFormat, + ) -> EventEmailAddressResponseAttributes { + EventEmailAddressResponseAttributes { + alert_type: None, + created_at, + description: None, + email, + format, + last_used_at: None, + notify_handles: None, + revoked_at: None, + tags: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn alert_type( + mut self, + value: crate::datadogV2::model::EventEmailAddressAlertType, + ) -> Self { + self.alert_type = Some(value); + self + } + + pub fn description(mut self, value: Option) -> Self { + self.description = Some(value); + self + } + + pub fn last_used_at(mut self, value: Option>) -> Self { + self.last_used_at = Some(value); + self + } + + pub fn notify_handles(mut self, value: Vec) -> Self { + self.notify_handles = Some(value); + self + } + + pub fn revoked_at(mut self, value: Option>) -> Self { + self.revoked_at = Some(value); + self + } + + pub fn tags(mut self, value: Vec) -> Self { + self.tags = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for EventEmailAddressResponseAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressResponseAttributesVisitor; + impl<'a> Visitor<'a> for EventEmailAddressResponseAttributesVisitor { + type Value = EventEmailAddressResponseAttributes; + + 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 alert_type: Option = + None; + let mut created_at: Option> = None; + let mut description: Option> = None; + let mut email: Option = None; + let mut format: Option = None; + let mut last_used_at: Option>> = None; + let mut notify_handles: Option> = None; + let mut revoked_at: 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() { + "alert_type" => { + if v.is_null() { + continue; + } + alert_type = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _alert_type) = alert_type { + match _alert_type { + crate::datadogV2::model::EventEmailAddressAlertType::UnparsedObject(_alert_type) => { + _unparsed = true; + }, + _ => {} + } + } + } + "created_at" => { + created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "description" => { + description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "email" => { + email = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "format" => { + format = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _format) = format { + match _format { + crate::datadogV2::model::EventEmailAddressFormat::UnparsedObject(_format) => { + _unparsed = true; + }, + _ => {} + } + } + } + "last_used_at" => { + last_used_at = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "notify_handles" => { + if v.is_null() { + continue; + } + notify_handles = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "revoked_at" => { + revoked_at = 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 created_at = created_at.ok_or_else(|| M::Error::missing_field("created_at"))?; + let email = email.ok_or_else(|| M::Error::missing_field("email"))?; + let format = format.ok_or_else(|| M::Error::missing_field("format"))?; + + let content = EventEmailAddressResponseAttributes { + alert_type, + created_at, + description, + email, + format, + last_used_at, + notify_handles, + revoked_at, + tags, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressResponseAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_event_email_address_revoked_by_relationship.rs b/src/datadogV2/model/model_event_email_address_revoked_by_relationship.rs new file mode 100644 index 000000000..9b471d55d --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_revoked_by_relationship.rs @@ -0,0 +1,105 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Relationship to the user who revoked the email address. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressRevokedByRelationship { + /// A user data reference in a relationship. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressRevokedByRelationship { + pub fn new() -> EventEmailAddressRevokedByRelationship { + EventEmailAddressRevokedByRelationship { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::EventEmailAddressUserData) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for EventEmailAddressRevokedByRelationship { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for EventEmailAddressRevokedByRelationship { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressRevokedByRelationshipVisitor; + impl<'a> Visitor<'a> for EventEmailAddressRevokedByRelationshipVisitor { + type Value = EventEmailAddressRevokedByRelationship; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = EventEmailAddressRevokedByRelationship { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressRevokedByRelationshipVisitor) + } +} diff --git a/src/datadogV2/model/model_event_email_address_single_response.rs b/src/datadogV2/model/model_event_email_address_single_response.rs new file mode 100644 index 000000000..ade601f35 --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_single_response.rs @@ -0,0 +1,116 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response containing a single event email address. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressSingleResponse { + /// A single event email address resource. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::EventEmailAddressData, + /// Related resources included in the response. + #[serde(rename = "included")] + pub included: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressSingleResponse { + pub fn new( + data: crate::datadogV2::model::EventEmailAddressData, + ) -> EventEmailAddressSingleResponse { + EventEmailAddressSingleResponse { + data, + included: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn included( + mut self, + value: Vec, + ) -> Self { + self.included = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for EventEmailAddressSingleResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressSingleResponseVisitor; + impl<'a> Visitor<'a> for EventEmailAddressSingleResponseVisitor { + type Value = EventEmailAddressSingleResponse; + + 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 included: Option< + Vec, + > = 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)?); + } + "included" => { + if v.is_null() { + continue; + } + included = 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 = EventEmailAddressSingleResponse { + data, + included, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressSingleResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_event_email_address_update_attributes.rs b/src/datadogV2/model/model_event_email_address_update_attributes.rs new file mode 100644 index 000000000..2478e6845 --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_update_attributes.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}; + +/// Attributes for updating an event email address. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressUpdateAttributes { + /// The alert type of events generated from the email address. + #[serde(rename = "alert_type")] + pub alert_type: crate::datadogV2::model::EventEmailAddressAlertType, + /// A description of the event email address. + #[serialize_always] + #[serde(rename = "description")] + pub description: Option, + /// A list of handles to notify when an email is received. + #[serde(rename = "notify_handles")] + pub notify_handles: Vec, + /// A list of tags to apply to events generated from the email address. + #[serde(rename = "tags")] + pub tags: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressUpdateAttributes { + pub fn new( + alert_type: crate::datadogV2::model::EventEmailAddressAlertType, + description: Option, + notify_handles: Vec, + tags: Vec, + ) -> EventEmailAddressUpdateAttributes { + EventEmailAddressUpdateAttributes { + alert_type, + description, + notify_handles, + tags, + 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 EventEmailAddressUpdateAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressUpdateAttributesVisitor; + impl<'a> Visitor<'a> for EventEmailAddressUpdateAttributesVisitor { + type Value = EventEmailAddressUpdateAttributes; + + 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 alert_type: Option = + None; + let mut description: Option> = None; + let mut notify_handles: 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() { + "alert_type" => { + alert_type = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _alert_type) = alert_type { + match _alert_type { + crate::datadogV2::model::EventEmailAddressAlertType::UnparsedObject(_alert_type) => { + _unparsed = true; + }, + _ => {} + } + } + } + "description" => { + description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "notify_handles" => { + notify_handles = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "tags" => { + 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 alert_type = alert_type.ok_or_else(|| M::Error::missing_field("alert_type"))?; + let description = + description.ok_or_else(|| M::Error::missing_field("description"))?; + let notify_handles = + notify_handles.ok_or_else(|| M::Error::missing_field("notify_handles"))?; + let tags = tags.ok_or_else(|| M::Error::missing_field("tags"))?; + + let content = EventEmailAddressUpdateAttributes { + alert_type, + description, + notify_handles, + tags, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressUpdateAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_event_email_address_update_data.rs b/src/datadogV2/model/model_event_email_address_update_data.rs new file mode 100644 index 000000000..c3936bc90 --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_update_data.rs @@ -0,0 +1,116 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Data for updating an event email address. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressUpdateData { + /// Attributes for updating an event email address. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::EventEmailAddressUpdateAttributes, + /// The type of the resource. Must be `event_emails`. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::EventEmailAddressResourceType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressUpdateData { + pub fn new( + attributes: crate::datadogV2::model::EventEmailAddressUpdateAttributes, + type_: crate::datadogV2::model::EventEmailAddressResourceType, + ) -> EventEmailAddressUpdateData { + EventEmailAddressUpdateData { + 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 EventEmailAddressUpdateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressUpdateDataVisitor; + impl<'a> Visitor<'a> for EventEmailAddressUpdateDataVisitor { + type Value = EventEmailAddressUpdateData; + + 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::EventEmailAddressUpdateAttributes, + > = 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::EventEmailAddressResourceType::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 = EventEmailAddressUpdateData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressUpdateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_event_email_address_update_request.rs b/src/datadogV2/model/model_event_email_address_update_request.rs new file mode 100644 index 000000000..cec3a05d9 --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_update_request.rs @@ -0,0 +1,94 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request body for updating an event email address. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressUpdateRequest { + /// Data for updating an event email address. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::EventEmailAddressUpdateData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressUpdateRequest { + pub fn new( + data: crate::datadogV2::model::EventEmailAddressUpdateData, + ) -> EventEmailAddressUpdateRequest { + EventEmailAddressUpdateRequest { + 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 EventEmailAddressUpdateRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressUpdateRequestVisitor; + impl<'a> Visitor<'a> for EventEmailAddressUpdateRequestVisitor { + type Value = EventEmailAddressUpdateRequest; + + 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 = EventEmailAddressUpdateRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressUpdateRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_event_email_address_user_data.rs b/src/datadogV2/model/model_event_email_address_user_data.rs new file mode 100644 index 000000000..7bc0df1fa --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_user_data.rs @@ -0,0 +1,102 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// A user data reference in a relationship. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressUserData { + /// The UUID of the user. + #[serde(rename = "id")] + pub id: String, + /// The type of the resource. + #[serde(rename = "type")] + pub type_: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressUserData { + pub fn new(id: String, type_: String) -> EventEmailAddressUserData { + EventEmailAddressUserData { + 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 EventEmailAddressUserData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressUserDataVisitor; + impl<'a> Visitor<'a> for EventEmailAddressUserDataVisitor { + type Value = EventEmailAddressUserData; + + 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 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() { + "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 Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = EventEmailAddressUserData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressUserDataVisitor) + } +} diff --git a/src/datadogV2/model/model_event_email_addresses_response.rs b/src/datadogV2/model/model_event_email_addresses_response.rs new file mode 100644 index 000000000..5f3ba8279 --- /dev/null +++ b/src/datadogV2/model/model_event_email_addresses_response.rs @@ -0,0 +1,116 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response containing a list of event email addresses. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressesResponse { + /// A list of event email address resources. + #[serde(rename = "data")] + pub data: Vec, + /// Related resources included in the response. + #[serde(rename = "included")] + pub included: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressesResponse { + pub fn new( + data: Vec, + ) -> EventEmailAddressesResponse { + EventEmailAddressesResponse { + data, + included: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn included( + mut self, + value: Vec, + ) -> Self { + self.included = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for EventEmailAddressesResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressesResponseVisitor; + impl<'a> Visitor<'a> for EventEmailAddressesResponseVisitor { + type Value = EventEmailAddressesResponse; + + 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 included: Option< + Vec, + > = 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)?); + } + "included" => { + if v.is_null() { + continue; + } + included = 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 = EventEmailAddressesResponse { + data, + included, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressesResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_on_call_event_email_address_create_attributes.rs b/src/datadogV2/model/model_on_call_event_email_address_create_attributes.rs new file mode 100644 index 000000000..257434647 --- /dev/null +++ b/src/datadogV2/model/model_on_call_event_email_address_create_attributes.rs @@ -0,0 +1,180 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes for creating an on-call event email address. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OnCallEventEmailAddressCreateAttributes { + /// The alert type of events generated from the email address. + #[serde(rename = "alert_type")] + pub alert_type: Option, + /// A description of the on-call event email address. + #[serde(rename = "description")] + pub description: Option, + /// The format of events ingested through the email address. + #[serde(rename = "format")] + pub format: crate::datadogV2::model::EventEmailAddressFormat, + /// A list of tags to apply to events generated from the email address. + #[serde(rename = "tags")] + pub tags: Option>, + /// The team handle associated with the on-call email address. + /// Must contain only alphanumeric characters, hyphens, and underscores. + #[serde(rename = "team_handle")] + pub team_handle: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OnCallEventEmailAddressCreateAttributes { + pub fn new( + format: crate::datadogV2::model::EventEmailAddressFormat, + team_handle: String, + ) -> OnCallEventEmailAddressCreateAttributes { + OnCallEventEmailAddressCreateAttributes { + alert_type: None, + description: None, + format, + tags: None, + team_handle, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn alert_type( + mut self, + value: crate::datadogV2::model::EventEmailAddressAlertType, + ) -> Self { + self.alert_type = Some(value); + self + } + + pub fn description(mut self, value: String) -> Self { + self.description = Some(value); + self + } + + pub fn tags(mut self, value: Vec) -> Self { + self.tags = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for OnCallEventEmailAddressCreateAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OnCallEventEmailAddressCreateAttributesVisitor; + impl<'a> Visitor<'a> for OnCallEventEmailAddressCreateAttributesVisitor { + type Value = OnCallEventEmailAddressCreateAttributes; + + 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 alert_type: Option = + None; + let mut description: Option = None; + let mut format: Option = None; + let mut tags: Option> = None; + let mut team_handle: 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() { + "alert_type" => { + if v.is_null() { + continue; + } + alert_type = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _alert_type) = alert_type { + match _alert_type { + crate::datadogV2::model::EventEmailAddressAlertType::UnparsedObject(_alert_type) => { + _unparsed = true; + }, + _ => {} + } + } + } + "description" => { + if v.is_null() { + continue; + } + description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "format" => { + format = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _format) = format { + match _format { + crate::datadogV2::model::EventEmailAddressFormat::UnparsedObject(_format) => { + _unparsed = true; + }, + _ => {} + } + } + } + "tags" => { + if v.is_null() { + continue; + } + tags = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "team_handle" => { + team_handle = + 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 format = format.ok_or_else(|| M::Error::missing_field("format"))?; + let team_handle = + team_handle.ok_or_else(|| M::Error::missing_field("team_handle"))?; + + let content = OnCallEventEmailAddressCreateAttributes { + alert_type, + description, + format, + tags, + team_handle, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OnCallEventEmailAddressCreateAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_on_call_event_email_address_create_data.rs b/src/datadogV2/model/model_on_call_event_email_address_create_data.rs new file mode 100644 index 000000000..03a66d5f6 --- /dev/null +++ b/src/datadogV2/model/model_on_call_event_email_address_create_data.rs @@ -0,0 +1,116 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Data for creating an on-call event email address. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OnCallEventEmailAddressCreateData { + /// Attributes for creating an on-call event email address. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::OnCallEventEmailAddressCreateAttributes, + /// The type of the resource. Must be `event_emails`. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::EventEmailAddressResourceType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OnCallEventEmailAddressCreateData { + pub fn new( + attributes: crate::datadogV2::model::OnCallEventEmailAddressCreateAttributes, + type_: crate::datadogV2::model::EventEmailAddressResourceType, + ) -> OnCallEventEmailAddressCreateData { + OnCallEventEmailAddressCreateData { + 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 OnCallEventEmailAddressCreateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OnCallEventEmailAddressCreateDataVisitor; + impl<'a> Visitor<'a> for OnCallEventEmailAddressCreateDataVisitor { + type Value = OnCallEventEmailAddressCreateData; + + 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::OnCallEventEmailAddressCreateAttributes, + > = 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::EventEmailAddressResourceType::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 = OnCallEventEmailAddressCreateData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OnCallEventEmailAddressCreateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_on_call_event_email_address_create_request.rs b/src/datadogV2/model/model_on_call_event_email_address_create_request.rs new file mode 100644 index 000000000..ab24b651c --- /dev/null +++ b/src/datadogV2/model/model_on_call_event_email_address_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}; + +/// Request body for creating an on-call event email address. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OnCallEventEmailAddressCreateRequest { + /// Data for creating an on-call event email address. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::OnCallEventEmailAddressCreateData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OnCallEventEmailAddressCreateRequest { + pub fn new( + data: crate::datadogV2::model::OnCallEventEmailAddressCreateData, + ) -> OnCallEventEmailAddressCreateRequest { + OnCallEventEmailAddressCreateRequest { + 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 OnCallEventEmailAddressCreateRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OnCallEventEmailAddressCreateRequestVisitor; + impl<'a> Visitor<'a> for OnCallEventEmailAddressCreateRequestVisitor { + type Value = OnCallEventEmailAddressCreateRequest; + + 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 = OnCallEventEmailAddressCreateRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OnCallEventEmailAddressCreateRequestVisitor) + } +} diff --git a/tests/scenarios/features/v2/events.feature b/tests/scenarios/features/v2/events.feature index 5beda13d5..9ff0d0a1e 100644 --- a/tests/scenarios/features/v2/events.feature +++ b/tests/scenarios/features/v2/events.feature @@ -17,6 +17,46 @@ Feature: Events And a valid "appKeyAuth" key in the system And an instance of "Events" API + @generated @skip @team:DataDog/event-management + Scenario: Create an event email address returns "Bad Request" response + Given operation "CreateEventEmailAddress" enabled + And new "CreateEventEmailAddress" request + And body with value {"data": {"attributes": {"alert_type": "info", "description": "Email address for production alerts.", "format": "json", "notify_handles": ["@slack-my-channel"], "tags": ["env:production", "team:my-team"]}, "type": "event_emails"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/event-management + Scenario: Create an event email address returns "Created" response + Given operation "CreateEventEmailAddress" enabled + And new "CreateEventEmailAddress" request + And body with value {"data": {"attributes": {"alert_type": "info", "description": "Email address for production alerts.", "format": "json", "notify_handles": ["@slack-my-channel"], "tags": ["env:production", "team:my-team"]}, "type": "event_emails"}} + When the request is sent + Then the response status is 201 Created + + @generated @skip @team:DataDog/event-management + Scenario: Create an event email address returns "Method Not Allowed" response + Given operation "CreateEventEmailAddress" enabled + And new "CreateEventEmailAddress" request + And body with value {"data": {"attributes": {"alert_type": "info", "description": "Email address for production alerts.", "format": "json", "notify_handles": ["@slack-my-channel"], "tags": ["env:production", "team:my-team"]}, "type": "event_emails"}} + When the request is sent + Then the response status is 405 Method Not Allowed + + @generated @skip @team:DataDog/event-management + Scenario: Create an on-call event email address returns "Bad Request" response + Given operation "CreateOnCallEventEmailAddress" enabled + And new "CreateOnCallEventEmailAddress" request + And body with value {"data": {"attributes": {"alert_type": "info", "description": "On-call email address for my team.", "format": "json", "tags": ["env:production", "team:my-team"], "team_handle": "my-team"}, "type": "event_emails"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/event-management + Scenario: Create an on-call event email address returns "Created" response + Given operation "CreateOnCallEventEmailAddress" enabled + And new "CreateOnCallEventEmailAddress" request + And body with value {"data": {"attributes": {"alert_type": "info", "description": "On-call email address for my team.", "format": "json", "tags": ["env:production", "team:my-team"], "team_handle": "my-team"}, "type": "event_emails"}} + When the request is sent + Then the response status is 201 Created + @generated @skip @team:DataDog/event-management Scenario: Get a list of events returns "Bad Request" response Given new "ListEvents" request @@ -50,6 +90,30 @@ Feature: Events Then the response status is 200 OK And the response "data" has length 0 + @generated @skip @team:DataDog/event-management + Scenario: Get an event email address returns "Bad Request" response + Given operation "GetEventEmailAddress" enabled + And new "GetEventEmailAddress" request + And request contains "email_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/event-management + Scenario: Get an event email address returns "Not Found" response + Given operation "GetEventEmailAddress" enabled + And new "GetEventEmailAddress" request + And request contains "email_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/event-management + Scenario: Get an event email address returns "OK" response + Given operation "GetEventEmailAddress" enabled + And new "GetEventEmailAddress" request + And request contains "email_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/event-management Scenario: Get an event returns "Bad Request" response Given new "GetEvent" request @@ -71,6 +135,29 @@ Feature: Events When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/event-management + Scenario: List event email addresses returns "OK" response + Given operation "ListEventEmailAddresses" enabled + And new "ListEventEmailAddresses" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/event-management + Scenario: List on-call event email addresses returns "Bad Request" response + Given operation "ListOnCallEventEmailAddresses" enabled + And new "ListOnCallEventEmailAddresses" request + And request contains "filter[team_handle]" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/event-management + Scenario: List on-call event email addresses returns "OK" response + Given operation "ListOnCallEventEmailAddresses" enabled + And new "ListOnCallEventEmailAddresses" request + And request contains "filter[team_handle]" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @team:DataDog/event-management Scenario: Post an event returns "Bad request" response Given new "CreateEvent" request @@ -87,6 +174,54 @@ Feature: Events And the response "data.type" is equal to "event" And the response "data.attributes.attributes.evt" has field "uid" + @generated @skip @team:DataDog/event-management + Scenario: Revoke an event email address returns "Bad Request" response + Given operation "DeleteEventEmailAddress" enabled + And new "DeleteEventEmailAddress" request + And request contains "email_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/event-management + Scenario: Revoke an event email address returns "No Content" response + Given operation "DeleteEventEmailAddress" enabled + And new "DeleteEventEmailAddress" request + And request contains "email_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/event-management + Scenario: Revoke an event email address returns "Not Found" response + Given operation "DeleteEventEmailAddress" enabled + And new "DeleteEventEmailAddress" request + And request contains "email_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/event-management + Scenario: Revoke an on-call event email address returns "Bad Request" response + Given operation "DeleteOnCallEventEmailAddress" enabled + And new "DeleteOnCallEventEmailAddress" request + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/event-management + Scenario: Revoke an on-call event email address returns "No Content" response + Given operation "DeleteOnCallEventEmailAddress" enabled + And new "DeleteOnCallEventEmailAddress" request + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/event-management + Scenario: Revoke an on-call event email address returns "Not Found" response + Given operation "DeleteOnCallEventEmailAddress" enabled + And new "DeleteOnCallEventEmailAddress" request + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @team:DataDog/event-management Scenario: Search events returns "Bad Request" response Given new "SearchEvents" request @@ -109,3 +244,30 @@ Feature: Events When the request with pagination is sent Then the response status is 200 OK And the response has 3 items + + @generated @skip @team:DataDog/event-management + Scenario: Update an event email address returns "Bad Request" response + Given operation "UpdateEventEmailAddress" enabled + And new "UpdateEventEmailAddress" request + And request contains "email_uuid" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"alert_type": "info", "description": "Updated description for the email address.", "notify_handles": ["@slack-my-channel"], "tags": ["env:production", "team:my-team"]}, "type": "event_emails"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/event-management + Scenario: Update an event email address returns "Not Found" response + Given operation "UpdateEventEmailAddress" enabled + And new "UpdateEventEmailAddress" request + And request contains "email_uuid" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"alert_type": "info", "description": "Updated description for the email address.", "notify_handles": ["@slack-my-channel"], "tags": ["env:production", "team:my-team"]}, "type": "event_emails"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/event-management + Scenario: Update an event email address returns "OK" response + Given operation "UpdateEventEmailAddress" enabled + And new "UpdateEventEmailAddress" request + And request contains "email_uuid" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"alert_type": "info", "description": "Updated description for the email address.", "notify_handles": ["@slack-my-channel"], "tags": ["env:production", "team:my-team"]}, "type": "event_emails"}} + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 09186eef6..4c52d6ba4 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1737,6 +1737,68 @@ "type": "safe" } }, + "ListEventEmailAddresses": { + "tag": "Events", + "undo": { + "type": "safe" + } + }, + "CreateEventEmailAddress": { + "tag": "Events", + "undo": { + "operationId": "DeleteEventEmailAddress", + "parameters": [ + { + "name": "email_uuid", + "source": "" + } + ], + "type": "unsafe" + } + }, + "ListOnCallEventEmailAddresses": { + "tag": "Events", + "undo": { + "type": "safe" + } + }, + "CreateOnCallEventEmailAddress": { + "tag": "Events", + "undo": { + "operationId": "DeleteOnCallEventEmailAddress", + "parameters": [ + { + "name": "id", + "source": "" + } + ], + "type": "unsafe" + } + }, + "DeleteOnCallEventEmailAddress": { + "tag": "Events", + "undo": { + "type": "idempotent" + } + }, + "DeleteEventEmailAddress": { + "tag": "Events", + "undo": { + "type": "idempotent" + } + }, + "GetEventEmailAddress": { + "tag": "Events", + "undo": { + "type": "safe" + } + }, + "UpdateEventEmailAddress": { + "tag": "Events", + "undo": { + "type": "idempotent" + } + }, "SearchEvents": { "tag": "Events", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index dbafb6667..e6fa5c7bf 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -3339,6 +3339,38 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { world .function_mappings .insert("v2.CreateEvent".into(), test_v2_create_event); + world.function_mappings.insert( + "v2.ListEventEmailAddresses".into(), + test_v2_list_event_email_addresses, + ); + world.function_mappings.insert( + "v2.CreateEventEmailAddress".into(), + test_v2_create_event_email_address, + ); + world.function_mappings.insert( + "v2.ListOnCallEventEmailAddresses".into(), + test_v2_list_on_call_event_email_addresses, + ); + world.function_mappings.insert( + "v2.CreateOnCallEventEmailAddress".into(), + test_v2_create_on_call_event_email_address, + ); + world.function_mappings.insert( + "v2.DeleteOnCallEventEmailAddress".into(), + test_v2_delete_on_call_event_email_address, + ); + world.function_mappings.insert( + "v2.DeleteEventEmailAddress".into(), + test_v2_delete_event_email_address, + ); + world.function_mappings.insert( + "v2.GetEventEmailAddress".into(), + test_v2_get_event_email_address, + ); + world.function_mappings.insert( + "v2.UpdateEventEmailAddress".into(), + test_v2_update_event_email_address, + ); world .function_mappings .insert("v2.SearchEvents".into(), test_v2_search_events); @@ -24492,6 +24524,241 @@ fn test_v2_create_event(world: &mut DatadogWorld, _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_events + .as_ref() + .expect("api instance not found"); + let active = _parameters + .get("active") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let include = _parameters + .get("include") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_events::ListEventEmailAddressesOptionalParams::default(); + params.active = active; + params.include = include; + let response = match block_on(api.list_event_email_addresses_with_http_info(params)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_create_event_email_address( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_events + .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_event_email_address_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_on_call_event_email_addresses( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_events + .as_ref() + .expect("api instance not found"); + let filter_team_handle = + serde_json::from_value(_parameters.get("filter[team_handle]").unwrap().clone()).unwrap(); + let response = + match block_on(api.list_on_call_event_email_addresses_with_http_info(filter_team_handle)) { + 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_on_call_event_email_address( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_events + .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_on_call_event_email_address_with_http_info(body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_delete_on_call_event_email_address( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_events + .as_ref() + .expect("api instance not found"); + let id = serde_json::from_value(_parameters.get("id").unwrap().clone()).unwrap(); + let response = match block_on(api.delete_on_call_event_email_address_with_http_info(id)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_delete_event_email_address( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_events + .as_ref() + .expect("api instance not found"); + let email_uuid = + serde_json::from_value(_parameters.get("email_uuid").unwrap().clone()).unwrap(); + let response = match block_on(api.delete_event_email_address_with_http_info(email_uuid)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_get_event_email_address(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_events + .as_ref() + .expect("api instance not found"); + let email_uuid = + serde_json::from_value(_parameters.get("email_uuid").unwrap().clone()).unwrap(); + let response = match block_on(api.get_event_email_address_with_http_info(email_uuid)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_update_event_email_address( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_events + .as_ref() + .expect("api instance not found"); + let email_uuid = + serde_json::from_value(_parameters.get("email_uuid").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.update_event_email_address_with_http_info(email_uuid, body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + fn test_v2_search_events(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances