From 3ecc302c764084f6e2330aa4128c8dcfa3ef3018 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 24 Oct 2025 14:10:20 +0000 Subject: [PATCH] Regenerate client from commit 1ec8354 of spec repo --- .generator/schemas/v2/openapi.yaml | 270 ++++++++ examples/v2_events_CreateEventEmailAddress.rs | 29 + ...v2_events_CreateOnCallEventEmailAddress.rs | 28 + .../v2_events_GetOnCallEventEmailAddress.rs | 16 + examples/v2_events_ListEventEmailAddresses.rs | 16 + src/datadog/configuration.rs | 4 + src/datadogV2/api/api_events.rs | 580 ++++++++++++++++++ src/datadogV2/model/mod.rs | 28 + ...odel_create_event_email_address_request.rs | 107 ++++ ...create_event_email_address_request_data.rs | 124 ++++ ...t_email_address_request_data_attributes.rs | 147 +++++ ...ate_on_call_event_email_address_request.rs | 108 ++++ ...n_call_event_email_address_request_data.rs | 125 ++++ ...t_email_address_request_data_attributes.rs | 152 +++++ .../model_event_email_address_response.rs | 103 ++++ ...odel_event_email_address_response_array.rs | 93 +++ ...model_event_email_address_response_data.rs | 156 +++++ ..._email_address_response_data_attributes.rs | 200 ++++++ ...ail_address_response_data_relationships.rs | 115 ++++ ...ddress_response_data_relationships_user.rs | 94 +++ ...s_response_data_relationships_user_data.rs | 111 ++++ .../model/model_event_emails_type.rs | 48 ++ tests/scenarios/features/v2/events.feature | 30 + tests/scenarios/features/v2/undo.json | 28 + tests/scenarios/function_mappings.rs | 126 ++++ 25 files changed, 2838 insertions(+) create mode 100644 examples/v2_events_CreateEventEmailAddress.rs create mode 100644 examples/v2_events_CreateOnCallEventEmailAddress.rs create mode 100644 examples/v2_events_GetOnCallEventEmailAddress.rs create mode 100644 examples/v2_events_ListEventEmailAddresses.rs create mode 100644 src/datadogV2/model/model_create_event_email_address_request.rs create mode 100644 src/datadogV2/model/model_create_event_email_address_request_data.rs create mode 100644 src/datadogV2/model/model_create_event_email_address_request_data_attributes.rs create mode 100644 src/datadogV2/model/model_create_on_call_event_email_address_request.rs create mode 100644 src/datadogV2/model/model_create_on_call_event_email_address_request_data.rs create mode 100644 src/datadogV2/model/model_create_on_call_event_email_address_request_data_attributes.rs create mode 100644 src/datadogV2/model/model_event_email_address_response.rs create mode 100644 src/datadogV2/model/model_event_email_address_response_array.rs create mode 100644 src/datadogV2/model/model_event_email_address_response_data.rs create mode 100644 src/datadogV2/model/model_event_email_address_response_data_attributes.rs create mode 100644 src/datadogV2/model/model_event_email_address_response_data_relationships.rs create mode 100644 src/datadogV2/model/model_event_email_address_response_data_relationships_user.rs create mode 100644 src/datadogV2/model/model_event_email_address_response_data_relationships_user_data.rs create mode 100644 src/datadogV2/model/model_event_emails_type.rs diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 2c64bbd7a..5d5c5b180 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -12289,6 +12289,46 @@ components: meta: $ref: '#/components/schemas/DataDeletionResponseMeta' type: object + CreateEventEmailAddressRequest: + properties: + data: + $ref: '#/components/schemas/CreateEventEmailAddressRequestData' + type: object + CreateEventEmailAddressRequestData: + properties: + attributes: + $ref: '#/components/schemas/CreateEventEmailAddressRequestDataAttributes' + type: + $ref: '#/components/schemas/EventEmailsType' + required: + - type + type: object + CreateEventEmailAddressRequestDataAttributes: + properties: + alert_type: + type: string + description: + type: string + format: + example: '' + type: string + notify_handles: + example: + - '' + items: + type: string + type: array + tags: + example: + - '' + items: + type: string + type: array + required: + - format + - notify_handles + - tags + type: object CreateIncidentNotificationRuleRequest: description: Create request for a notification rule. properties: @@ -12341,6 +12381,41 @@ components: - name - targets type: object + CreateOnCallEventEmailAddressRequest: + properties: + data: + $ref: '#/components/schemas/CreateOnCallEventEmailAddressRequestData' + type: object + CreateOnCallEventEmailAddressRequestData: + properties: + attributes: + $ref: '#/components/schemas/CreateOnCallEventEmailAddressRequestDataAttributes' + type: + $ref: '#/components/schemas/EventEmailsType' + required: + - type + type: object + CreateOnCallEventEmailAddressRequestDataAttributes: + properties: + alert_type: + type: string + description: + type: string + format: + example: '' + type: string + tags: + example: + - '' + items: + type: string + type: array + team_handle: + type: string + required: + - format + - tags + type: object CreateOpenAPIResponse: description: Response for `CreateOpenAPI` operation. properties: @@ -18701,6 +18776,112 @@ components: the default subdomain. type: string type: object + EventEmailAddressResponse: + properties: + data: + $ref: '#/components/schemas/EventEmailAddressResponseData' + type: object + EventEmailAddressResponseArray: + properties: + data: + items: + $ref: '#/components/schemas/EventEmailAddressResponseData' + type: array + required: + - data + type: object + EventEmailAddressResponseData: + properties: + attributes: + $ref: '#/components/schemas/EventEmailAddressResponseDataAttributes' + id: + example: '' + type: string + relationships: + $ref: '#/components/schemas/EventEmailAddressResponseDataRelationships' + type: + $ref: '#/components/schemas/EventEmailsType' + required: + - type + - id + type: object + EventEmailAddressResponseDataAttributes: + properties: + alert_type: + type: string + created_at: + example: '' + format: date-time + type: string + description: + type: string + email: + example: '' + type: string + format: + example: '' + type: string + last_used_at: + format: date-time + type: string + notify_handles: + example: + - '' + items: + type: string + type: array + revoked_at: + format: date-time + type: string + tags: + example: + - '' + items: + type: string + type: array + required: + - created_at + - email + - format + - notify_handles + - tags + type: object + EventEmailAddressResponseDataRelationships: + properties: + created_by: + $ref: '#/components/schemas/EventEmailAddressResponseDataRelationshipsUser' + revoked_by: + $ref: '#/components/schemas/EventEmailAddressResponseDataRelationshipsUser' + required: + - created_by + type: object + EventEmailAddressResponseDataRelationshipsUser: + properties: + data: + $ref: '#/components/schemas/EventEmailAddressResponseDataRelationshipsUserData' + required: + - data + type: object + EventEmailAddressResponseDataRelationshipsUserData: + properties: + id: + example: '' + type: string + type: + $ref: '#/components/schemas/UsersType' + required: + - type + - id + type: object + EventEmailsType: + default: event_emails + description: Event emails resource type. + enum: + - event_emails + example: event_emails + type: string + x-enum-varnames: + - EVENT_EMAILS EventPayload: additionalProperties: false description: Event attributes. @@ -61743,6 +61924,92 @@ paths: tags: - Events x-codegen-request-body-name: body + /api/v2/events/mail: + get: + operationId: ListEventEmailAddresses + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/EventEmailAddressResponseArray' + description: OK + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: List event email addresses + tags: + - Events + x-unstable: '**Note**: This endpoint may be subject to changes.' + post: + operationId: CreateEventEmailAddress + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateEventEmailAddressRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/EventEmailAddressResponse' + description: Created + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Create event email address + tags: + - Events + x-unstable: '**Note**: This endpoint may be subject to changes.' + /api/v2/events/mail/on-call: + get: + operationId: GetOnCallEventEmailAddress + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/EventEmailAddressResponseArray' + description: OK + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Get on-call event email address + tags: + - Events + x-unstable: '**Note**: This endpoint may be subject to changes.' + post: + operationId: CreateOnCallEventEmailAddress + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateOnCallEventEmailAddressRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/EventEmailAddressResponse' + description: Created + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Create on-call event email address + tags: + - Events + x-unstable: '**Note**: This endpoint may be subject to changes.' /api/v2/events/search: post: description: 'List endpoint returns events that match an events search query. @@ -61771,6 +62038,9 @@ paths: $ref: '#/components/responses/NotAuthorizedResponse' '429': $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] summary: Search events tags: - Events diff --git a/examples/v2_events_CreateEventEmailAddress.rs b/examples/v2_events_CreateEventEmailAddress.rs new file mode 100644 index 000000000..d1e8277d5 --- /dev/null +++ b/examples/v2_events_CreateEventEmailAddress.rs @@ -0,0 +1,29 @@ +// Create 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::CreateEventEmailAddressRequest; +use datadog_api_client::datadogV2::model::CreateEventEmailAddressRequestData; +use datadog_api_client::datadogV2::model::CreateEventEmailAddressRequestDataAttributes; +use datadog_api_client::datadogV2::model::EventEmailsType; + +#[tokio::main] +async fn main() { + let body = CreateEventEmailAddressRequest::new().data( + CreateEventEmailAddressRequestData::new(EventEmailsType::EVENT_EMAILS).attributes( + CreateEventEmailAddressRequestDataAttributes::new( + "".to_string(), + vec!["".to_string()], + vec!["".to_string()], + ), + ), + ); + 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..3506d6515 --- /dev/null +++ b/examples/v2_events_CreateOnCallEventEmailAddress.rs @@ -0,0 +1,28 @@ +// Create 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::CreateOnCallEventEmailAddressRequest; +use datadog_api_client::datadogV2::model::CreateOnCallEventEmailAddressRequestData; +use datadog_api_client::datadogV2::model::CreateOnCallEventEmailAddressRequestDataAttributes; +use datadog_api_client::datadogV2::model::EventEmailsType; + +#[tokio::main] +async fn main() { + let body = CreateOnCallEventEmailAddressRequest::new().data( + CreateOnCallEventEmailAddressRequestData::new(EventEmailsType::EVENT_EMAILS).attributes( + CreateOnCallEventEmailAddressRequestDataAttributes::new( + "".to_string(), + vec!["".to_string()], + ), + ), + ); + 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_GetOnCallEventEmailAddress.rs b/examples/v2_events_GetOnCallEventEmailAddress.rs new file mode 100644 index 000000000..3a9b170b3 --- /dev/null +++ b/examples/v2_events_GetOnCallEventEmailAddress.rs @@ -0,0 +1,16 @@ +// Get on-call event email address 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.GetOnCallEventEmailAddress", true); + let api = EventsAPI::with_config(configuration); + let resp = api.get_on_call_event_email_address().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..bddb153c5 --- /dev/null +++ b/examples/v2_events_ListEventEmailAddresses.rs @@ -0,0 +1,16 @@ +// List 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.ListEventEmailAddresses", true); + let api = EventsAPI::with_config(configuration); + let resp = api.list_event_email_addresses().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 612ac9304..5062abcbb 100644 --- a/src/datadog/configuration.rs +++ b/src/datadog/configuration.rs @@ -164,6 +164,10 @@ impl Default for Configuration { ("v2.cancel_data_deletion_request".to_owned(), false), ("v2.create_data_deletion_request".to_owned(), false), ("v2.get_data_deletion_requests".to_owned(), false), + ("v2.create_event_email_address".to_owned(), false), + ("v2.create_on_call_event_email_address".to_owned(), false), + ("v2.get_on_call_event_email_address".to_owned(), false), + ("v2.list_event_email_addresses".to_owned(), false), ("v2.create_incident".to_owned(), false), ("v2.create_incident_impact".to_owned(), false), ("v2.create_incident_integration".to_owned(), false), diff --git a/src/datadogV2/api/api_events.rs b/src/datadogV2/api/api_events.rs index 9618cfacb..1fdfa0533 100644 --- a/src/datadogV2/api/api_events.rs +++ b/src/datadogV2/api/api_events.rs @@ -8,6 +8,7 @@ use flate2::{ Compression, }; use futures_core::stream::Stream; +use log::warn; use reqwest::header::{HeaderMap, HeaderValue}; use serde::{Deserialize, Serialize}; use std::io::Write; @@ -86,6 +87,22 @@ 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 { + 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 { + 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 +111,22 @@ pub enum GetEventError { UnknownValue(serde_json::Value), } +/// GetOnCallEventEmailAddressError is a struct for typed errors of method [`EventsAPI::get_on_call_event_email_address`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetOnCallEventEmailAddressError { + 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 { + 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)] @@ -344,6 +377,329 @@ impl EventsAPI { } } + pub async fn create_event_email_address( + &self, + body: crate::datadogV2::model::CreateEventEmailAddressRequest, + ) -> Result< + crate::datadogV2::model::EventEmailAddressResponse, + 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) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + pub async fn create_event_email_address_with_http_info( + &self, + body: crate::datadogV2::model::CreateEventEmailAddressRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + 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/mail", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + pub async fn create_on_call_event_email_address( + &self, + body: crate::datadogV2::model::CreateOnCallEventEmailAddressRequest, + ) -> Result< + crate::datadogV2::model::EventEmailAddressResponse, + 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) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + pub async fn create_on_call_event_email_address_with_http_info( + &self, + body: crate::datadogV2::model::CreateOnCallEventEmailAddressRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + 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/mail/on-call", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + /// Get the details of an event by `event_id`. pub async fn get_event( &self, @@ -447,6 +803,230 @@ impl EventsAPI { } } + pub async fn get_on_call_event_email_address( + &self, + ) -> Result< + crate::datadogV2::model::EventEmailAddressResponseArray, + datadog::Error, + > { + match self.get_on_call_event_email_address_with_http_info().await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + pub async fn get_on_call_event_email_address_with_http_info( + &self, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_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.get_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", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + pub async fn list_event_email_addresses( + &self, + ) -> Result< + crate::datadogV2::model::EventEmailAddressResponseArray, + datadog::Error, + > { + match self.list_event_email_addresses_with_http_info().await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + pub async fn list_event_email_addresses_with_http_info( + &self, + ) -> 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)); + } + + 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()); + + // 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](). /// diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 8a29dac6e..e8a422453 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -2390,6 +2390,34 @@ 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_address_response_array; +pub use self::model_event_email_address_response_array::EventEmailAddressResponseArray; +pub mod model_event_email_address_response_data; +pub use self::model_event_email_address_response_data::EventEmailAddressResponseData; +pub mod model_event_email_address_response_data_attributes; +pub use self::model_event_email_address_response_data_attributes::EventEmailAddressResponseDataAttributes; +pub mod model_event_email_address_response_data_relationships; +pub use self::model_event_email_address_response_data_relationships::EventEmailAddressResponseDataRelationships; +pub mod model_event_email_address_response_data_relationships_user; +pub use self::model_event_email_address_response_data_relationships_user::EventEmailAddressResponseDataRelationshipsUser; +pub mod model_event_email_address_response_data_relationships_user_data; +pub use self::model_event_email_address_response_data_relationships_user_data::EventEmailAddressResponseDataRelationshipsUserData; +pub mod model_event_emails_type; +pub use self::model_event_emails_type::EventEmailsType; +pub mod model_create_event_email_address_request; +pub use self::model_create_event_email_address_request::CreateEventEmailAddressRequest; +pub mod model_create_event_email_address_request_data; +pub use self::model_create_event_email_address_request_data::CreateEventEmailAddressRequestData; +pub mod model_create_event_email_address_request_data_attributes; +pub use self::model_create_event_email_address_request_data_attributes::CreateEventEmailAddressRequestDataAttributes; +pub mod model_event_email_address_response; +pub use self::model_event_email_address_response::EventEmailAddressResponse; +pub mod model_create_on_call_event_email_address_request; +pub use self::model_create_on_call_event_email_address_request::CreateOnCallEventEmailAddressRequest; +pub mod model_create_on_call_event_email_address_request_data; +pub use self::model_create_on_call_event_email_address_request_data::CreateOnCallEventEmailAddressRequestData; +pub mod model_create_on_call_event_email_address_request_data_attributes; +pub use self::model_create_on_call_event_email_address_request_data_attributes::CreateOnCallEventEmailAddressRequestDataAttributes; 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_create_event_email_address_request.rs b/src/datadogV2/model/model_create_event_email_address_request.rs new file mode 100644 index 000000000..aad132942 --- /dev/null +++ b/src/datadogV2/model/model_create_event_email_address_request.rs @@ -0,0 +1,107 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateEventEmailAddressRequest { + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateEventEmailAddressRequest { + pub fn new() -> CreateEventEmailAddressRequest { + CreateEventEmailAddressRequest { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: crate::datadogV2::model::CreateEventEmailAddressRequestData, + ) -> 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 CreateEventEmailAddressRequest { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CreateEventEmailAddressRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateEventEmailAddressRequestVisitor; + impl<'a> Visitor<'a> for CreateEventEmailAddressRequestVisitor { + type Value = CreateEventEmailAddressRequest; + + 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 = CreateEventEmailAddressRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateEventEmailAddressRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_create_event_email_address_request_data.rs b/src/datadogV2/model/model_create_event_email_address_request_data.rs new file mode 100644 index 000000000..5b43d7335 --- /dev/null +++ b/src/datadogV2/model/model_create_event_email_address_request_data.rs @@ -0,0 +1,124 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateEventEmailAddressRequestData { + #[serde(rename = "attributes")] + pub attributes: Option, + /// Event emails resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::EventEmailsType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateEventEmailAddressRequestData { + pub fn new( + type_: crate::datadogV2::model::EventEmailsType, + ) -> CreateEventEmailAddressRequestData { + CreateEventEmailAddressRequestData { + attributes: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::CreateEventEmailAddressRequestDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateEventEmailAddressRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateEventEmailAddressRequestDataVisitor; + impl<'a> Visitor<'a> for CreateEventEmailAddressRequestDataVisitor { + type Value = CreateEventEmailAddressRequestData; + + 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::CreateEventEmailAddressRequestDataAttributes, + > = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::EventEmailsType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = CreateEventEmailAddressRequestData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateEventEmailAddressRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_create_event_email_address_request_data_attributes.rs b/src/datadogV2/model/model_create_event_email_address_request_data_attributes.rs new file mode 100644 index 000000000..42de01f2c --- /dev/null +++ b/src/datadogV2/model/model_create_event_email_address_request_data_attributes.rs @@ -0,0 +1,147 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateEventEmailAddressRequestDataAttributes { + #[serde(rename = "alert_type")] + pub alert_type: Option, + #[serde(rename = "description")] + pub description: Option, + #[serde(rename = "format")] + pub format: String, + #[serde(rename = "notify_handles")] + pub notify_handles: Vec, + #[serde(rename = "tags")] + pub tags: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateEventEmailAddressRequestDataAttributes { + pub fn new( + format: String, + notify_handles: Vec, + tags: Vec, + ) -> CreateEventEmailAddressRequestDataAttributes { + CreateEventEmailAddressRequestDataAttributes { + alert_type: None, + description: None, + format, + notify_handles, + tags, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn alert_type(mut self, value: String) -> Self { + self.alert_type = Some(value); + self + } + + pub fn description(mut self, value: String) -> Self { + self.description = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateEventEmailAddressRequestDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateEventEmailAddressRequestDataAttributesVisitor; + impl<'a> Visitor<'a> for CreateEventEmailAddressRequestDataAttributesVisitor { + type Value = CreateEventEmailAddressRequestDataAttributes; + + 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)?); + } + "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)?); + } + "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 format = format.ok_or_else(|| M::Error::missing_field("format"))?; + 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 = CreateEventEmailAddressRequestDataAttributes { + alert_type, + description, + format, + notify_handles, + tags, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateEventEmailAddressRequestDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_create_on_call_event_email_address_request.rs b/src/datadogV2/model/model_create_on_call_event_email_address_request.rs new file mode 100644 index 000000000..56f6a6583 --- /dev/null +++ b/src/datadogV2/model/model_create_on_call_event_email_address_request.rs @@ -0,0 +1,108 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateOnCallEventEmailAddressRequest { + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateOnCallEventEmailAddressRequest { + pub fn new() -> CreateOnCallEventEmailAddressRequest { + CreateOnCallEventEmailAddressRequest { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: crate::datadogV2::model::CreateOnCallEventEmailAddressRequestData, + ) -> 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 CreateOnCallEventEmailAddressRequest { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CreateOnCallEventEmailAddressRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateOnCallEventEmailAddressRequestVisitor; + impl<'a> Visitor<'a> for CreateOnCallEventEmailAddressRequestVisitor { + type Value = CreateOnCallEventEmailAddressRequest; + + 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< + crate::datadogV2::model::CreateOnCallEventEmailAddressRequestData, + > = 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 = CreateOnCallEventEmailAddressRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateOnCallEventEmailAddressRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_create_on_call_event_email_address_request_data.rs b/src/datadogV2/model/model_create_on_call_event_email_address_request_data.rs new file mode 100644 index 000000000..797e5919b --- /dev/null +++ b/src/datadogV2/model/model_create_on_call_event_email_address_request_data.rs @@ -0,0 +1,125 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateOnCallEventEmailAddressRequestData { + #[serde(rename = "attributes")] + pub attributes: + Option, + /// Event emails resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::EventEmailsType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateOnCallEventEmailAddressRequestData { + pub fn new( + type_: crate::datadogV2::model::EventEmailsType, + ) -> CreateOnCallEventEmailAddressRequestData { + CreateOnCallEventEmailAddressRequestData { + attributes: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::CreateOnCallEventEmailAddressRequestDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateOnCallEventEmailAddressRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateOnCallEventEmailAddressRequestDataVisitor; + impl<'a> Visitor<'a> for CreateOnCallEventEmailAddressRequestDataVisitor { + type Value = CreateOnCallEventEmailAddressRequestData; + + 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::CreateOnCallEventEmailAddressRequestDataAttributes, + > = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::EventEmailsType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = CreateOnCallEventEmailAddressRequestData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateOnCallEventEmailAddressRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_create_on_call_event_email_address_request_data_attributes.rs b/src/datadogV2/model/model_create_on_call_event_email_address_request_data_attributes.rs new file mode 100644 index 000000000..85612eab5 --- /dev/null +++ b/src/datadogV2/model/model_create_on_call_event_email_address_request_data_attributes.rs @@ -0,0 +1,152 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateOnCallEventEmailAddressRequestDataAttributes { + #[serde(rename = "alert_type")] + pub alert_type: Option, + #[serde(rename = "description")] + pub description: Option, + #[serde(rename = "format")] + pub format: String, + #[serde(rename = "tags")] + pub tags: Vec, + #[serde(rename = "team_handle")] + pub team_handle: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateOnCallEventEmailAddressRequestDataAttributes { + pub fn new( + format: String, + tags: Vec, + ) -> CreateOnCallEventEmailAddressRequestDataAttributes { + CreateOnCallEventEmailAddressRequestDataAttributes { + alert_type: None, + description: None, + format, + tags, + team_handle: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn alert_type(mut self, value: String) -> Self { + self.alert_type = Some(value); + self + } + + pub fn description(mut self, value: String) -> Self { + self.description = Some(value); + self + } + + pub fn team_handle(mut self, value: String) -> Self { + self.team_handle = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateOnCallEventEmailAddressRequestDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateOnCallEventEmailAddressRequestDataAttributesVisitor; + impl<'a> Visitor<'a> for CreateOnCallEventEmailAddressRequestDataAttributesVisitor { + type Value = CreateOnCallEventEmailAddressRequestDataAttributes; + + 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)?); + } + "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)?); + } + "tags" => { + tags = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "team_handle" => { + if v.is_null() { + continue; + } + 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 tags = tags.ok_or_else(|| M::Error::missing_field("tags"))?; + + let content = CreateOnCallEventEmailAddressRequestDataAttributes { + alert_type, + description, + format, + tags, + team_handle, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateOnCallEventEmailAddressRequestDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_event_email_address_response.rs b/src/datadogV2/model/model_event_email_address_response.rs new file mode 100644 index 000000000..35c0a02d5 --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_response.rs @@ -0,0 +1,103 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressResponse { + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressResponse { + pub fn new() -> EventEmailAddressResponse { + EventEmailAddressResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::EventEmailAddressResponseData) -> 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 EventEmailAddressResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for EventEmailAddressResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressResponseVisitor; + impl<'a> Visitor<'a> for EventEmailAddressResponseVisitor { + type Value = EventEmailAddressResponse; + + 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 = EventEmailAddressResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_event_email_address_response_array.rs b/src/datadogV2/model/model_event_email_address_response_array.rs new file mode 100644 index 000000000..2ce26880c --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_response_array.rs @@ -0,0 +1,93 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressResponseArray { + #[serde(rename = "data")] + pub data: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressResponseArray { + pub fn new( + data: Vec, + ) -> EventEmailAddressResponseArray { + EventEmailAddressResponseArray { + 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 EventEmailAddressResponseArray { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressResponseArrayVisitor; + impl<'a> Visitor<'a> for EventEmailAddressResponseArrayVisitor { + type Value = EventEmailAddressResponseArray; + + 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 = EventEmailAddressResponseArray { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressResponseArrayVisitor) + } +} diff --git a/src/datadogV2/model/model_event_email_address_response_data.rs b/src/datadogV2/model/model_event_email_address_response_data.rs new file mode 100644 index 000000000..91a40e8bf --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_response_data.rs @@ -0,0 +1,156 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressResponseData { + #[serde(rename = "attributes")] + pub attributes: Option, + #[serde(rename = "id")] + pub id: String, + #[serde(rename = "relationships")] + pub relationships: Option, + /// Event emails resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::EventEmailsType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressResponseData { + pub fn new( + id: String, + type_: crate::datadogV2::model::EventEmailsType, + ) -> EventEmailAddressResponseData { + EventEmailAddressResponseData { + attributes: None, + id, + relationships: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::EventEmailAddressResponseDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn relationships( + mut self, + value: crate::datadogV2::model::EventEmailAddressResponseDataRelationships, + ) -> Self { + self.relationships = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for EventEmailAddressResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressResponseDataVisitor; + impl<'a> Visitor<'a> for EventEmailAddressResponseDataVisitor { + type Value = EventEmailAddressResponseData; + + 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::EventEmailAddressResponseDataAttributes, + > = None; + let mut id: Option = None; + let mut relationships: Option< + crate::datadogV2::model::EventEmailAddressResponseDataRelationships, + > = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "relationships" => { + if v.is_null() { + continue; + } + 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::EventEmailsType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + 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 = EventEmailAddressResponseData { + attributes, + id, + relationships, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_event_email_address_response_data_attributes.rs b/src/datadogV2/model/model_event_email_address_response_data_attributes.rs new file mode 100644 index 000000000..eb2568647 --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_response_data_attributes.rs @@ -0,0 +1,200 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressResponseDataAttributes { + #[serde(rename = "alert_type")] + pub alert_type: Option, + #[serde(rename = "created_at")] + pub created_at: chrono::DateTime, + #[serde(rename = "description")] + pub description: Option, + #[serde(rename = "email")] + pub email: String, + #[serde(rename = "format")] + pub format: String, + #[serde(rename = "last_used_at")] + pub last_used_at: Option>, + #[serde(rename = "notify_handles")] + pub notify_handles: Vec, + #[serde(rename = "revoked_at")] + pub revoked_at: Option>, + #[serde(rename = "tags")] + pub tags: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressResponseDataAttributes { + pub fn new( + created_at: chrono::DateTime, + email: String, + format: String, + notify_handles: Vec, + tags: Vec, + ) -> EventEmailAddressResponseDataAttributes { + EventEmailAddressResponseDataAttributes { + alert_type: None, + created_at, + description: None, + email, + format, + last_used_at: None, + notify_handles, + revoked_at: None, + tags, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn alert_type(mut self, value: String) -> Self { + self.alert_type = Some(value); + self + } + + pub fn description(mut self, value: String) -> Self { + self.description = Some(value); + self + } + + pub fn last_used_at(mut self, value: chrono::DateTime) -> Self { + self.last_used_at = Some(value); + self + } + + pub fn revoked_at(mut self, value: chrono::DateTime) -> Self { + self.revoked_at = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for EventEmailAddressResponseDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressResponseDataAttributesVisitor; + impl<'a> Visitor<'a> for EventEmailAddressResponseDataAttributesVisitor { + type Value = EventEmailAddressResponseDataAttributes; + + 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)?); + } + "created_at" => { + created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "description" => { + if v.is_null() { + continue; + } + 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)?); + } + "last_used_at" => { + if v.is_null() { + continue; + } + last_used_at = + 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)?); + } + "revoked_at" => { + if v.is_null() { + continue; + } + revoked_at = 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 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 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 = EventEmailAddressResponseDataAttributes { + alert_type, + created_at, + description, + email, + format, + last_used_at, + notify_handles, + revoked_at, + tags, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressResponseDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_event_email_address_response_data_relationships.rs b/src/datadogV2/model/model_event_email_address_response_data_relationships.rs new file mode 100644 index 000000000..605f948aa --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_response_data_relationships.rs @@ -0,0 +1,115 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressResponseDataRelationships { + #[serde(rename = "created_by")] + pub created_by: crate::datadogV2::model::EventEmailAddressResponseDataRelationshipsUser, + #[serde(rename = "revoked_by")] + pub revoked_by: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressResponseDataRelationships { + pub fn new( + created_by: crate::datadogV2::model::EventEmailAddressResponseDataRelationshipsUser, + ) -> EventEmailAddressResponseDataRelationships { + EventEmailAddressResponseDataRelationships { + created_by, + revoked_by: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn revoked_by( + mut self, + value: crate::datadogV2::model::EventEmailAddressResponseDataRelationshipsUser, + ) -> 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 EventEmailAddressResponseDataRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressResponseDataRelationshipsVisitor; + impl<'a> Visitor<'a> for EventEmailAddressResponseDataRelationshipsVisitor { + type Value = EventEmailAddressResponseDataRelationships; + + 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::EventEmailAddressResponseDataRelationshipsUser, + > = None; + let mut revoked_by: Option< + crate::datadogV2::model::EventEmailAddressResponseDataRelationshipsUser, + > = 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" => { + if v.is_null() { + continue; + } + 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 = EventEmailAddressResponseDataRelationships { + created_by, + revoked_by, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressResponseDataRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_event_email_address_response_data_relationships_user.rs b/src/datadogV2/model/model_event_email_address_response_data_relationships_user.rs new file mode 100644 index 000000000..8a51d76e8 --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_response_data_relationships_user.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}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressResponseDataRelationshipsUser { + #[serde(rename = "data")] + pub data: crate::datadogV2::model::EventEmailAddressResponseDataRelationshipsUserData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressResponseDataRelationshipsUser { + pub fn new( + data: crate::datadogV2::model::EventEmailAddressResponseDataRelationshipsUserData, + ) -> EventEmailAddressResponseDataRelationshipsUser { + EventEmailAddressResponseDataRelationshipsUser { + 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 EventEmailAddressResponseDataRelationshipsUser { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressResponseDataRelationshipsUserVisitor; + impl<'a> Visitor<'a> for EventEmailAddressResponseDataRelationshipsUserVisitor { + type Value = EventEmailAddressResponseDataRelationshipsUser; + + 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< + crate::datadogV2::model::EventEmailAddressResponseDataRelationshipsUserData, + > = 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 = EventEmailAddressResponseDataRelationshipsUser { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressResponseDataRelationshipsUserVisitor) + } +} diff --git a/src/datadogV2/model/model_event_email_address_response_data_relationships_user_data.rs b/src/datadogV2/model/model_event_email_address_response_data_relationships_user_data.rs new file mode 100644 index 000000000..25efa44ea --- /dev/null +++ b/src/datadogV2/model/model_event_email_address_response_data_relationships_user_data.rs @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventEmailAddressResponseDataRelationshipsUserData { + #[serde(rename = "id")] + pub id: String, + /// Users resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::UsersType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventEmailAddressResponseDataRelationshipsUserData { + pub fn new( + id: String, + type_: crate::datadogV2::model::UsersType, + ) -> EventEmailAddressResponseDataRelationshipsUserData { + EventEmailAddressResponseDataRelationshipsUserData { + 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 EventEmailAddressResponseDataRelationshipsUserData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventEmailAddressResponseDataRelationshipsUserDataVisitor; + impl<'a> Visitor<'a> for EventEmailAddressResponseDataRelationshipsUserDataVisitor { + type Value = EventEmailAddressResponseDataRelationshipsUserData; + + 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 Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::UsersType::UnparsedObject(_type_) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + 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 = EventEmailAddressResponseDataRelationshipsUserData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventEmailAddressResponseDataRelationshipsUserDataVisitor) + } +} diff --git a/src/datadogV2/model/model_event_emails_type.rs b/src/datadogV2/model/model_event_emails_type.rs new file mode 100644 index 000000000..751faa1ec --- /dev/null +++ b/src/datadogV2/model/model_event_emails_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 EventEmailsType { + EVENT_EMAILS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for EventEmailsType { + fn to_string(&self) -> String { + match self { + Self::EVENT_EMAILS => String::from("event_emails"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for EventEmailsType { + 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 EventEmailsType { + 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/tests/scenarios/features/v2/events.feature b/tests/scenarios/features/v2/events.feature index 61d824ce1..5d9436920 100644 --- a/tests/scenarios/features/v2/events.feature +++ b/tests/scenarios/features/v2/events.feature @@ -17,6 +17,22 @@ Feature: Events And a valid "appKeyAuth" key in the system And an instance of "Events" API + @generated @skip @team:DataDog/event-management + Scenario: Create event email address returns "Created" response + Given operation "CreateEventEmailAddress" enabled + And new "CreateEventEmailAddress" request + And body with value {"data": {"attributes": {"format": "", "notify_handles": [""], "tags": [""]}, "type": "event_emails"}} + When the request is sent + Then the response status is 201 Created + + @generated @skip @team:DataDog/event-management + Scenario: Create on-call event email address returns "Created" response + Given operation "CreateOnCallEventEmailAddress" enabled + And new "CreateOnCallEventEmailAddress" request + And body with value {"data": {"attributes": {"format": "", "tags": [""]}, "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 @@ -71,6 +87,20 @@ Feature: Events When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/event-management + Scenario: Get on-call event email address returns "OK" response + Given operation "GetOnCallEventEmailAddress" enabled + And new "GetOnCallEventEmailAddress" request + 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 + @team:DataDog/event-management Scenario: Post an event returns "Bad request" response Given new "CreateEvent" request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index bb35cea36..e94d595ef 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1380,6 +1380,34 @@ "type": "safe" } }, + "ListEventEmailAddresses": { + "tag": "Events", + "undo": { + "type": "safe" + } + }, + "CreateEventEmailAddress": { + "tag": "Events", + "undo": { + "operationId": "TODO", + "parameters": [], + "type": "unsafe" + } + }, + "GetOnCallEventEmailAddress": { + "tag": "Events", + "undo": { + "type": "safe" + } + }, + "CreateOnCallEventEmailAddress": { + "tag": "Events", + "undo": { + "operationId": "TODO", + "parameters": [], + "type": "unsafe" + } + }, "SearchEvents": { "tag": "Events", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 821ce5838..6d6c14588 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -2883,6 +2883,22 @@ 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.GetOnCallEventEmailAddress".into(), + test_v2_get_on_call_event_email_address, + ); + world.function_mappings.insert( + "v2.CreateOnCallEventEmailAddress".into(), + test_v2_create_on_call_event_email_address, + ); world .function_mappings .insert("v2.SearchEvents".into(), test_v2_search_events); @@ -21361,6 +21377,116 @@ 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 response = match block_on(api.list_event_email_addresses_with_http_info()) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_create_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_get_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 response = match block_on(api.get_on_call_event_email_address_with_http_info()) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_create_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_search_events(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances