diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index e301432ac..1fbbc4330 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -494,6 +494,15 @@ components: items: $ref: '#/components/schemas/GetIssueIncludeQueryParameterItem' type: array + IncidentID: + description: The UUID of the incident. + in: path + name: incident_id + required: true + schema: + example: 9cecfde8-e35d-4387-8985-9b30dcb9cb1c + format: uuid + type: string IncidentIDPathParameter: description: The UUID of the incident. in: path @@ -660,6 +669,14 @@ components: schema: example: ExampleTeamName type: string + IncidentTimestampOverrideInclude: + description: Specifies which types of related objects are included in the response. + in: query + name: include + required: false + schema: + example: created_by_user,last_modified_by_user + type: string IncidentTodoIDPathParameter: description: The UUID of the incident todo. in: path @@ -689,6 +706,15 @@ components: required: false schema: $ref: '#/components/schemas/IncludeType' + IncludeDeleted: + description: Specifies whether to include deleted timestamp overrides in the + response. + in: query + name: include-deleted + required: false + schema: + example: false + type: boolean InstanceId: description: The ID of the workflow instance. in: path @@ -1152,6 +1178,15 @@ components: required: true schema: type: string + TimestampOverrideID: + description: The UUID of the timestamp override. + in: path + name: timestamp_override_id + required: true + schema: + example: 6f48a86f-9a39-4bcf-a76b-9a1b20188995 + format: uuid + type: string ToTimestamp: description: The ending timestamp for the SLO status query in epoch seconds. in: query @@ -30334,6 +30369,168 @@ components: nullable: false type: string type: object + IncidentTimestampOverrideAttributes: + description: Attributes of an incident timestamp override. + properties: + created_at: + description: Timestamp of when the override was created. + example: '2026-01-13T17:15:55.379155748Z' + format: date-time + type: string + deleted_at: + description: Timestamp of when the override was deleted (soft delete). + example: null + format: date-time + nullable: true + type: string + incident_id: + description: The UUID of the incident. + example: 9cecfde8-e35d-4387-8985-9b30dcb9cb1c + format: uuid + type: string + modified_at: + description: Timestamp of when the override was last modified. + example: '2026-01-13T17:15:55.379155834Z' + format: date-time + type: string + timestamp_type: + $ref: '#/components/schemas/TimestampType' + timestamp_value: + description: The timestamp value for the override. + example: '2024-12-29T10:00:00Z' + format: date-time + type: string + required: + - incident_id + - timestamp_type + - timestamp_value + - created_at + - modified_at + - deleted_at + type: object + IncidentTimestampOverrideCreateAttributes: + description: Attributes for creating an incident timestamp override. + properties: + timestamp_type: + $ref: '#/components/schemas/TimestampType' + timestamp_value: + description: The timestamp value for the override. + example: '2024-12-29T10:00:00Z' + format: date-time + type: string + required: + - timestamp_type + - timestamp_value + type: object + IncidentTimestampOverrideCreateData: + description: Data for creating an incident timestamp override. + properties: + attributes: + $ref: '#/components/schemas/IncidentTimestampOverrideCreateAttributes' + type: + $ref: '#/components/schemas/IncidentsTimestampOverridesType' + required: + - type + - attributes + type: object + IncidentTimestampOverrideCreateRequest: + description: Request to create an incident timestamp override. + properties: + data: + $ref: '#/components/schemas/IncidentTimestampOverrideCreateData' + required: + - data + type: object + IncidentTimestampOverrideData: + description: Data for a single incident timestamp override. + properties: + attributes: + $ref: '#/components/schemas/IncidentTimestampOverrideAttributes' + id: + description: The UUID of the timestamp override. + example: 35301c93-75c0-4ec4-a889-28e1dfc092a9 + format: uuid + type: string + relationships: + $ref: '#/components/schemas/IncidentTimestampOverrideRelationships' + type: + $ref: '#/components/schemas/IncidentsTimestampOverridesType' + required: + - id + - type + - attributes + - relationships + type: object + IncidentTimestampOverridePatchAttributes: + description: Attributes for patching an incident timestamp override. + properties: + timestamp_value: + description: The timestamp value for the override. + example: '2024-12-29T11:00:00Z' + format: date-time + type: string + required: + - timestamp_value + type: object + IncidentTimestampOverridePatchData: + description: Data for patching an incident timestamp override. + properties: + attributes: + $ref: '#/components/schemas/IncidentTimestampOverridePatchAttributes' + type: + $ref: '#/components/schemas/IncidentsTimestampOverridesType' + required: + - type + - attributes + type: object + IncidentTimestampOverridePatchRequest: + description: Request to patch an incident timestamp override. + properties: + data: + $ref: '#/components/schemas/IncidentTimestampOverridePatchData' + required: + - data + type: object + IncidentTimestampOverrideRelationships: + description: Relationships for incident timestamp override. + properties: + created_by_user: + $ref: '#/components/schemas/TimestampOverrideUserRelationship' + last_modified_by_user: + $ref: '#/components/schemas/TimestampOverrideUserRelationship' + required: + - created_by_user + - last_modified_by_user + type: object + IncidentTimestampOverrideResponse: + description: Response containing a single incident timestamp override. + properties: + data: + $ref: '#/components/schemas/IncidentTimestampOverrideData' + included: + description: Included related resources. + items: + $ref: '#/components/schemas/UserIncluded' + type: array + required: + - data + type: object + IncidentTimestampOverridesResponse: + description: Response containing a list of incident timestamp overrides. + properties: + data: + description: Array of incident timestamp overrides. + items: + $ref: '#/components/schemas/IncidentTimestampOverrideData' + type: array + included: + description: Included related resources. + items: + $ref: '#/components/schemas/UserIncluded' + type: array + required: + - data + type: object IncidentTodoAnonymousAssignee: description: Anonymous assignee entity. properties: @@ -30994,6 +31191,15 @@ components: required: - data type: object + IncidentsTimestampOverridesType: + default: incidents_timestamp_overrides + description: The JSON:API type for timestamp overrides. + enum: + - incidents_timestamp_overrides + example: incidents_timestamp_overrides + type: string + x-enum-varnames: + - INCIDENTS_TIMESTAMP_OVERRIDES IncludeType: description: Supported include types. enum: @@ -64053,6 +64259,44 @@ components: items: $ref: '#/components/schemas/TimeseriesResponseValues' type: array + TimestampOverrideUserRelationship: + description: Relationship to a user. + properties: + data: + $ref: '#/components/schemas/TimestampOverrideUserRelationshipData' + required: + - data + type: object + TimestampOverrideUserRelationshipData: + description: User relationship data. + properties: + id: + description: The UUID of the user. + example: 8ec982dd-cd99-41c6-992a-c47fc9168cad + format: uuid + type: string + type: + description: The type of the related resource. + example: users + type: string + required: + - id + - type + type: object + TimestampType: + description: The type of timestamp being overridden. + enum: + - created + - detected + - resolved + - declared + example: created + type: string + x-enum-varnames: + - CREATED + - DETECTED + - RESOLVED + - DECLARED TokenName: description: Name for tokens. example: MyTokenName @@ -65792,6 +66036,56 @@ components: required: - data type: object + UserIncluded: + description: Included user data. + properties: + attributes: + $ref: '#/components/schemas/UserIncludedAttributes' + id: + description: The UUID of the user. + example: 8ec982dd-cd99-41c6-992a-c47fc9168cad + format: uuid + type: string + type: + description: The type of the included resource. + example: users + type: string + required: + - id + - type + - attributes + type: object + UserIncludedAttributes: + description: Attributes of an included user. + properties: + email: + description: The email address of the user. + example: fake1@email.com + type: string + handle: + description: The handle of the user. + example: fakeUserHandle1 + type: string + icon: + description: The icon URL for the user. + example: http://a.com/some-icon-1.jpg + type: string + name: + description: The name of the user. + example: fakeUserName1 + type: string + uuid: + description: The UUID of the user. + example: 8ec982dd-cd99-41c6-992a-c47fc9168cad + format: uuid + type: string + required: + - email + - handle + - icon + - name + - uuid + type: object UserInvitationData: description: Object to create a user invitation. properties: @@ -79659,6 +79953,184 @@ paths: - incident_write x-unstable: '**Note**: This endpoint is in public beta. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/incidents/{incident_id}/timestamp-overrides: + get: + description: Get all timestamp overrides for a specific incident. + operationId: ListIncidentTimestampOverrides + parameters: + - $ref: '#/components/parameters/IncidentID' + - $ref: '#/components/parameters/IncidentTimestampOverrideInclude' + - $ref: '#/components/parameters/IncludeDeleted' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentTimestampOverridesResponse' + description: OK + '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: [] + - AuthZ: + - incident_read + summary: List timestamp overrides for an incident + tags: + - Incidents + 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 timestamp override for a specific incident. + operationId: CreateIncidentTimestampOverride + parameters: + - $ref: '#/components/parameters/IncidentID' + - $ref: '#/components/parameters/IncidentTimestampOverrideInclude' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentTimestampOverrideCreateRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentTimestampOverrideResponse' + 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 + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - incident_write + summary: Create a timestamp override for an incident + tags: + - Incidents + x-codegen-request-body-name: body + 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/incidents/{incident_id}/timestamp-overrides/{timestamp_override_id}: + delete: + description: Delete an existing timestamp override for a specific incident. + operationId: DeleteIncidentTimestampOverride + parameters: + - $ref: '#/components/parameters/IncidentID' + - $ref: '#/components/parameters/TimestampOverrideID' + responses: + '204': + description: No Content + '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: [] + - AuthZ: + - incident_write + summary: Delete a timestamp override for an incident + tags: + - Incidents + 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 timestamp override for a specific incident. + operationId: UpdateIncidentTimestampOverride + parameters: + - $ref: '#/components/parameters/IncidentID' + - $ref: '#/components/parameters/TimestampOverrideID' + - $ref: '#/components/parameters/IncidentTimestampOverrideInclude' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentTimestampOverridePatchRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentTimestampOverrideResponse' + 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: [] + - AuthZ: + - incident_write + summary: Update a timestamp override for an incident + tags: + - Incidents + x-codegen-request-body-name: body + 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/integration/aws/accounts: get: diff --git a/examples/v2_incidents_CreateIncidentTimestampOverride.rs b/examples/v2_incidents_CreateIncidentTimestampOverride.rs new file mode 100644 index 000000000..b46be64df --- /dev/null +++ b/examples/v2_incidents_CreateIncidentTimestampOverride.rs @@ -0,0 +1,40 @@ +// Create a timestamp override for an incident returns "Created" response +use chrono::{DateTime, Utc}; +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_incidents::CreateIncidentTimestampOverrideOptionalParams; +use datadog_api_client::datadogV2::api_incidents::IncidentsAPI; +use datadog_api_client::datadogV2::model::IncidentTimestampOverrideCreateAttributes; +use datadog_api_client::datadogV2::model::IncidentTimestampOverrideCreateData; +use datadog_api_client::datadogV2::model::IncidentTimestampOverrideCreateRequest; +use datadog_api_client::datadogV2::model::IncidentsTimestampOverridesType; +use datadog_api_client::datadogV2::model::TimestampType; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let body = + IncidentTimestampOverrideCreateRequest::new(IncidentTimestampOverrideCreateData::new( + IncidentTimestampOverrideCreateAttributes::new( + TimestampType::CREATED, + DateTime::parse_from_rfc3339("2024-12-29T10:00:00+00:00") + .expect("Failed to parse datetime") + .with_timezone(&Utc), + ), + IncidentsTimestampOverridesType::INCIDENTS_TIMESTAMP_OVERRIDES, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.CreateIncidentTimestampOverride", true); + let api = IncidentsAPI::with_config(configuration); + let resp = api + .create_incident_timestamp_override( + Uuid::parse_str("9cecfde8-e35d-4387-8985-9b30dcb9cb1c").expect("invalid UUID"), + body, + CreateIncidentTimestampOverrideOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_incidents_DeleteIncidentTimestampOverride.rs b/examples/v2_incidents_DeleteIncidentTimestampOverride.rs new file mode 100644 index 000000000..7f0f255be --- /dev/null +++ b/examples/v2_incidents_DeleteIncidentTimestampOverride.rs @@ -0,0 +1,22 @@ +// Delete a timestamp override for an incident returns "No Content" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_incidents::IncidentsAPI; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.DeleteIncidentTimestampOverride", true); + let api = IncidentsAPI::with_config(configuration); + let resp = api + .delete_incident_timestamp_override( + Uuid::parse_str("9cecfde8-e35d-4387-8985-9b30dcb9cb1c").expect("invalid UUID"), + Uuid::parse_str("6f48a86f-9a39-4bcf-a76b-9a1b20188995").expect("invalid UUID"), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_incidents_ListIncidentTimestampOverrides.rs b/examples/v2_incidents_ListIncidentTimestampOverrides.rs new file mode 100644 index 000000000..c64cedd92 --- /dev/null +++ b/examples/v2_incidents_ListIncidentTimestampOverrides.rs @@ -0,0 +1,23 @@ +// List timestamp overrides for an incident returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_incidents::IncidentsAPI; +use datadog_api_client::datadogV2::api_incidents::ListIncidentTimestampOverridesOptionalParams; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.ListIncidentTimestampOverrides", true); + let api = IncidentsAPI::with_config(configuration); + let resp = api + .list_incident_timestamp_overrides( + Uuid::parse_str("9cecfde8-e35d-4387-8985-9b30dcb9cb1c").expect("invalid UUID"), + ListIncidentTimestampOverridesOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_incidents_UpdateIncidentTimestampOverride.rs b/examples/v2_incidents_UpdateIncidentTimestampOverride.rs new file mode 100644 index 000000000..00268cbeb --- /dev/null +++ b/examples/v2_incidents_UpdateIncidentTimestampOverride.rs @@ -0,0 +1,38 @@ +// Update a timestamp override for an incident returns "OK" response +use chrono::{DateTime, Utc}; +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_incidents::IncidentsAPI; +use datadog_api_client::datadogV2::api_incidents::UpdateIncidentTimestampOverrideOptionalParams; +use datadog_api_client::datadogV2::model::IncidentTimestampOverridePatchAttributes; +use datadog_api_client::datadogV2::model::IncidentTimestampOverridePatchData; +use datadog_api_client::datadogV2::model::IncidentTimestampOverridePatchRequest; +use datadog_api_client::datadogV2::model::IncidentsTimestampOverridesType; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let body = IncidentTimestampOverridePatchRequest::new(IncidentTimestampOverridePatchData::new( + IncidentTimestampOverridePatchAttributes::new( + DateTime::parse_from_rfc3339("2024-12-29T11:00:00+00:00") + .expect("Failed to parse datetime") + .with_timezone(&Utc), + ), + IncidentsTimestampOverridesType::INCIDENTS_TIMESTAMP_OVERRIDES, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.UpdateIncidentTimestampOverride", true); + let api = IncidentsAPI::with_config(configuration); + let resp = api + .update_incident_timestamp_override( + Uuid::parse_str("9cecfde8-e35d-4387-8985-9b30dcb9cb1c").expect("invalid UUID"), + Uuid::parse_str("6f48a86f-9a39-4bcf-a76b-9a1b20188995").expect("invalid UUID"), + body, + UpdateIncidentTimestampOverrideOptionalParams::default(), + ) + .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 dcdcd2c0f..f040f646c 100644 --- a/src/datadog/configuration.rs +++ b/src/datadog/configuration.rs @@ -196,6 +196,7 @@ impl Default for Configuration { ("v2.create_incident_notification_template".to_owned(), false), ("v2.create_incident_postmortem_attachment".to_owned(), false), ("v2.create_incident_postmortem_template".to_owned(), false), + ("v2.create_incident_timestamp_override".to_owned(), false), ("v2.create_incident_todo".to_owned(), false), ("v2.create_incident_type".to_owned(), false), ("v2.delete_global_incident_handle".to_owned(), false), @@ -205,6 +206,7 @@ impl Default for Configuration { ("v2.delete_incident_notification_rule".to_owned(), false), ("v2.delete_incident_notification_template".to_owned(), false), ("v2.delete_incident_postmortem_template".to_owned(), false), + ("v2.delete_incident_timestamp_override".to_owned(), false), ("v2.delete_incident_todo".to_owned(), false), ("v2.delete_incident_type".to_owned(), false), ("v2.get_global_incident_settings".to_owned(), false), @@ -222,6 +224,7 @@ impl Default for Configuration { ("v2.list_incident_notification_templates".to_owned(), false), ("v2.list_incident_postmortem_templates".to_owned(), false), ("v2.list_incidents".to_owned(), false), + ("v2.list_incident_timestamp_overrides".to_owned(), false), ("v2.list_incident_todos".to_owned(), false), ("v2.list_incident_types".to_owned(), false), ("v2.search_incidents".to_owned(), false), @@ -233,6 +236,7 @@ impl Default for Configuration { ("v2.update_incident_notification_rule".to_owned(), false), ("v2.update_incident_notification_template".to_owned(), false), ("v2.update_incident_postmortem_template".to_owned(), false), + ("v2.update_incident_timestamp_override".to_owned(), false), ("v2.update_incident_todo".to_owned(), false), ("v2.update_incident_type".to_owned(), false), ("v2.create_jira_issue_template".to_owned(), false), diff --git a/src/datadogV2/api/api_incidents.rs b/src/datadogV2/api/api_incidents.rs index 893c4d7f0..0c45a791a 100644 --- a/src/datadogV2/api/api_incidents.rs +++ b/src/datadogV2/api/api_incidents.rs @@ -64,6 +64,22 @@ impl CreateIncidentImpactOptionalParams { } } +/// CreateIncidentTimestampOverrideOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::create_incident_timestamp_override`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct CreateIncidentTimestampOverrideOptionalParams { + /// Specifies which types of related objects are included in the response. + pub include: Option, +} + +impl CreateIncidentTimestampOverrideOptionalParams { + /// Specifies which types of related objects are included in the response. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } +} + /// DeleteIncidentNotificationRuleOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::delete_incident_notification_rule`] #[non_exhaustive] #[derive(Clone, Default, Debug)] @@ -241,6 +257,29 @@ impl ListIncidentNotificationTemplatesOptionalParams { } } +/// ListIncidentTimestampOverridesOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::list_incident_timestamp_overrides`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct ListIncidentTimestampOverridesOptionalParams { + /// Specifies which types of related objects are included in the response. + pub include: Option, + /// Specifies whether to include deleted timestamp overrides in the response. + pub include_deleted: Option, +} + +impl ListIncidentTimestampOverridesOptionalParams { + /// Specifies which types of related objects are included in the response. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } + /// Specifies whether to include deleted timestamp overrides in the response. + pub fn include_deleted(mut self, value: bool) -> Self { + self.include_deleted = Some(value); + self + } +} + /// ListIncidentTypesOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::list_incident_types`] #[non_exhaustive] #[derive(Clone, Default, Debug)] @@ -404,6 +443,22 @@ impl UpdateIncidentNotificationTemplateOptionalParams { } } +/// UpdateIncidentTimestampOverrideOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::update_incident_timestamp_override`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct UpdateIncidentTimestampOverrideOptionalParams { + /// Specifies which types of related objects are included in the response. + pub include: Option, +} + +impl UpdateIncidentTimestampOverrideOptionalParams { + /// Specifies which types of related objects are included in the response. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } +} + /// CreateGlobalIncidentHandleError is a struct for typed errors of method [`IncidentsAPI::create_global_incident_handle`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -479,6 +534,15 @@ pub enum CreateIncidentPostmortemTemplateError { UnknownValue(serde_json::Value), } +/// CreateIncidentTimestampOverrideError is a struct for typed errors of method [`IncidentsAPI::create_incident_timestamp_override`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateIncidentTimestampOverrideError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// CreateIncidentTodoError is a struct for typed errors of method [`IncidentsAPI::create_incident_todo`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -561,6 +625,15 @@ pub enum DeleteIncidentPostmortemTemplateError { UnknownValue(serde_json::Value), } +/// DeleteIncidentTimestampOverrideError is a struct for typed errors of method [`IncidentsAPI::delete_incident_timestamp_override`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteIncidentTimestampOverrideError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// DeleteIncidentTodoError is a struct for typed errors of method [`IncidentsAPI::delete_incident_todo`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -701,6 +774,15 @@ pub enum ListIncidentPostmortemTemplatesError { UnknownValue(serde_json::Value), } +/// ListIncidentTimestampOverridesError is a struct for typed errors of method [`IncidentsAPI::list_incident_timestamp_overrides`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListIncidentTimestampOverridesError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// ListIncidentTodosError is a struct for typed errors of method [`IncidentsAPI::list_incident_todos`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -800,6 +882,15 @@ pub enum UpdateIncidentPostmortemTemplateError { UnknownValue(serde_json::Value), } +/// UpdateIncidentTimestampOverrideError is a struct for typed errors of method [`IncidentsAPI::update_incident_timestamp_override`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateIncidentTimestampOverrideError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// UpdateIncidentTodoError is a struct for typed errors of method [`IncidentsAPI::update_incident_todo`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -2406,6 +2497,184 @@ impl IncidentsAPI { } } + /// Create a new timestamp override for a specific incident. + pub async fn create_incident_timestamp_override( + &self, + incident_id: uuid::Uuid, + body: crate::datadogV2::model::IncidentTimestampOverrideCreateRequest, + params: CreateIncidentTimestampOverrideOptionalParams, + ) -> Result< + crate::datadogV2::model::IncidentTimestampOverrideResponse, + datadog::Error, + > { + match self + .create_incident_timestamp_override_with_http_info(incident_id, body, 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), + } + } + + /// Create a new timestamp override for a specific incident. + pub async fn create_incident_timestamp_override_with_http_info( + &self, + incident_id: uuid::Uuid, + body: crate::datadogV2::model::IncidentTimestampOverrideCreateRequest, + params: CreateIncidentTimestampOverrideOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_incident_timestamp_override"; + 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_incident_timestamp_override' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let include = params.include; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/incidents/{incident_id}/timestamp-overrides", + local_configuration.get_operation_host(operation_id), + incident_id = datadog::urlencode(incident_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + 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("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)) + } + } + /// Create an incident todo. pub async fn create_incident_todo( &self, @@ -3544,14 +3813,14 @@ impl IncidentsAPI { } } - /// Delete an incident todo. - pub async fn delete_incident_todo( + /// Delete an existing timestamp override for a specific incident. + pub async fn delete_incident_timestamp_override( &self, - incident_id: String, - todo_id: String, - ) -> Result<(), datadog::Error> { + incident_id: uuid::Uuid, + timestamp_override_id: uuid::Uuid, + ) -> Result<(), datadog::Error> { match self - .delete_incident_todo_with_http_info(incident_id, todo_id) + .delete_incident_timestamp_override_with_http_info(incident_id, timestamp_override_id) .await { Ok(_) => Ok(()), @@ -3559,19 +3828,20 @@ impl IncidentsAPI { } } - /// Delete an incident todo. - pub async fn delete_incident_todo_with_http_info( + /// Delete an existing timestamp override for a specific incident. + pub async fn delete_incident_timestamp_override_with_http_info( &self, - incident_id: String, - todo_id: String, - ) -> Result, datadog::Error> { + incident_id: uuid::Uuid, + timestamp_override_id: uuid::Uuid, + ) -> Result, datadog::Error> + { let local_configuration = &self.config; - let operation_id = "v2.delete_incident_todo"; + let operation_id = "v2.delete_incident_timestamp_override"; 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_incident_todo' is not enabled".to_string(), + msg: "Operation 'v2.delete_incident_timestamp_override' is not enabled".to_string(), }; return Err(datadog::Error::UnstableOperationDisabledError(local_error)); } @@ -3579,10 +3849,10 @@ impl IncidentsAPI { let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/incidents/{incident_id}/relationships/todos/{todo_id}", + "{}/api/v2/incidents/{incident_id}/timestamp-overrides/{timestamp_override_id}", local_configuration.get_operation_host(operation_id), - incident_id = datadog::urlencode(incident_id), - todo_id = datadog::urlencode(todo_id) + incident_id = datadog::urlencode(incident_id.to_string()), + timestamp_override_id = datadog::urlencode(timestamp_override_id.to_string()) ); let mut local_req_builder = local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); @@ -3635,7 +3905,7 @@ impl IncidentsAPI { entity: None, }) } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -3646,13 +3916,14 @@ impl IncidentsAPI { } } - /// Delete an incident type. - pub async fn delete_incident_type( + /// Delete an incident todo. + pub async fn delete_incident_todo( &self, - incident_type_id: String, - ) -> Result<(), datadog::Error> { + incident_id: String, + todo_id: String, + ) -> Result<(), datadog::Error> { match self - .delete_incident_type_with_http_info(incident_type_id) + .delete_incident_todo_with_http_info(incident_id, todo_id) .await { Ok(_) => Ok(()), @@ -3660,8 +3931,109 @@ impl IncidentsAPI { } } - /// Delete an incident type. - pub async fn delete_incident_type_with_http_info( + /// Delete an incident todo. + pub async fn delete_incident_todo_with_http_info( + &self, + incident_id: String, + todo_id: String, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.delete_incident_todo"; + 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_incident_todo' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/incidents/{incident_id}/relationships/todos/{todo_id}", + local_configuration.get_operation_host(operation_id), + incident_id = datadog::urlencode(incident_id), + todo_id = datadog::urlencode(todo_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Delete an incident type. + pub async fn delete_incident_type( + &self, + incident_type_id: String, + ) -> Result<(), datadog::Error> { + match self + .delete_incident_type_with_http_info(incident_type_id) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Delete an incident type. + pub async fn delete_incident_type_with_http_info( &self, incident_type_id: String, ) -> Result, datadog::Error> { @@ -5618,6 +5990,141 @@ impl IncidentsAPI { } } + /// Get all timestamp overrides for a specific incident. + pub async fn list_incident_timestamp_overrides( + &self, + incident_id: uuid::Uuid, + params: ListIncidentTimestampOverridesOptionalParams, + ) -> Result< + crate::datadogV2::model::IncidentTimestampOverridesResponse, + datadog::Error, + > { + match self + .list_incident_timestamp_overrides_with_http_info(incident_id, 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), + } + } + + /// Get all timestamp overrides for a specific incident. + pub async fn list_incident_timestamp_overrides_with_http_info( + &self, + incident_id: uuid::Uuid, + params: ListIncidentTimestampOverridesOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_incident_timestamp_overrides"; + 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_incident_timestamp_overrides' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let include = params.include; + let include_deleted = params.include_deleted; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/incidents/{incident_id}/timestamp-overrides", + local_configuration.get_operation_host(operation_id), + incident_id = datadog::urlencode(incident_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = include { + local_req_builder = + local_req_builder.query(&[("include", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = include_deleted { + local_req_builder = + local_req_builder.query(&[("include-deleted", &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)) + } + } + /// Get all todos for an incident. pub async fn list_incident_todos( &self, @@ -7608,6 +8115,192 @@ impl IncidentsAPI { } } + /// Update an existing timestamp override for a specific incident. + pub async fn update_incident_timestamp_override( + &self, + incident_id: uuid::Uuid, + timestamp_override_id: uuid::Uuid, + body: crate::datadogV2::model::IncidentTimestampOverridePatchRequest, + params: UpdateIncidentTimestampOverrideOptionalParams, + ) -> Result< + crate::datadogV2::model::IncidentTimestampOverrideResponse, + datadog::Error, + > { + match self + .update_incident_timestamp_override_with_http_info( + incident_id, + timestamp_override_id, + body, + 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), + } + } + + /// Update an existing timestamp override for a specific incident. + pub async fn update_incident_timestamp_override_with_http_info( + &self, + incident_id: uuid::Uuid, + timestamp_override_id: uuid::Uuid, + body: crate::datadogV2::model::IncidentTimestampOverridePatchRequest, + params: UpdateIncidentTimestampOverrideOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.update_incident_timestamp_override"; + 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_incident_timestamp_override' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let include = params.include; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/incidents/{incident_id}/timestamp-overrides/{timestamp_override_id}", + local_configuration.get_operation_host(operation_id), + incident_id = datadog::urlencode(incident_id.to_string()), + timestamp_override_id = datadog::urlencode(timestamp_override_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); + + 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("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)) + } + } + /// Update an incident todo. pub async fn update_incident_todo( &self, diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 90e97e10a..94a9cdce3 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -3222,6 +3222,40 @@ pub mod model_incident_todo_patch_request; pub use self::model_incident_todo_patch_request::IncidentTodoPatchRequest; pub mod model_incident_todo_patch_data; pub use self::model_incident_todo_patch_data::IncidentTodoPatchData; +pub mod model_incident_timestamp_overrides_response; +pub use self::model_incident_timestamp_overrides_response::IncidentTimestampOverridesResponse; +pub mod model_incident_timestamp_override_data; +pub use self::model_incident_timestamp_override_data::IncidentTimestampOverrideData; +pub mod model_incident_timestamp_override_attributes; +pub use self::model_incident_timestamp_override_attributes::IncidentTimestampOverrideAttributes; +pub mod model_timestamp_type; +pub use self::model_timestamp_type::TimestampType; +pub mod model_incident_timestamp_override_relationships; +pub use self::model_incident_timestamp_override_relationships::IncidentTimestampOverrideRelationships; +pub mod model_timestamp_override_user_relationship; +pub use self::model_timestamp_override_user_relationship::TimestampOverrideUserRelationship; +pub mod model_timestamp_override_user_relationship_data; +pub use self::model_timestamp_override_user_relationship_data::TimestampOverrideUserRelationshipData; +pub mod model_incidents_timestamp_overrides_type; +pub use self::model_incidents_timestamp_overrides_type::IncidentsTimestampOverridesType; +pub mod model_user_included; +pub use self::model_user_included::UserIncluded; +pub mod model_user_included_attributes; +pub use self::model_user_included_attributes::UserIncludedAttributes; +pub mod model_incident_timestamp_override_create_request; +pub use self::model_incident_timestamp_override_create_request::IncidentTimestampOverrideCreateRequest; +pub mod model_incident_timestamp_override_create_data; +pub use self::model_incident_timestamp_override_create_data::IncidentTimestampOverrideCreateData; +pub mod model_incident_timestamp_override_create_attributes; +pub use self::model_incident_timestamp_override_create_attributes::IncidentTimestampOverrideCreateAttributes; +pub mod model_incident_timestamp_override_response; +pub use self::model_incident_timestamp_override_response::IncidentTimestampOverrideResponse; +pub mod model_incident_timestamp_override_patch_request; +pub use self::model_incident_timestamp_override_patch_request::IncidentTimestampOverridePatchRequest; +pub mod model_incident_timestamp_override_patch_data; +pub use self::model_incident_timestamp_override_patch_data::IncidentTimestampOverridePatchData; +pub mod model_incident_timestamp_override_patch_attributes; +pub use self::model_incident_timestamp_override_patch_attributes::IncidentTimestampOverridePatchAttributes; pub mod model_aws_accounts_response; pub use self::model_aws_accounts_response::AWSAccountsResponse; pub mod model_aws_account_response_data; diff --git a/src/datadogV2/model/model_incident_timestamp_override_attributes.rs b/src/datadogV2/model/model_incident_timestamp_override_attributes.rs new file mode 100644 index 000000000..6fe07f6f9 --- /dev/null +++ b/src/datadogV2/model/model_incident_timestamp_override_attributes.rs @@ -0,0 +1,168 @@ +// 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 incident timestamp override. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentTimestampOverrideAttributes { + /// Timestamp of when the override was created. + #[serde(rename = "created_at")] + pub created_at: chrono::DateTime, + /// Timestamp of when the override was deleted (soft delete). + #[serialize_always] + #[serde(rename = "deleted_at")] + pub deleted_at: Option>, + /// The UUID of the incident. + #[serde(rename = "incident_id")] + pub incident_id: uuid::Uuid, + /// Timestamp of when the override was last modified. + #[serde(rename = "modified_at")] + pub modified_at: chrono::DateTime, + /// The type of timestamp being overridden. + #[serde(rename = "timestamp_type")] + pub timestamp_type: crate::datadogV2::model::TimestampType, + /// The timestamp value for the override. + #[serde(rename = "timestamp_value")] + pub timestamp_value: chrono::DateTime, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentTimestampOverrideAttributes { + pub fn new( + created_at: chrono::DateTime, + deleted_at: Option>, + incident_id: uuid::Uuid, + modified_at: chrono::DateTime, + timestamp_type: crate::datadogV2::model::TimestampType, + timestamp_value: chrono::DateTime, + ) -> IncidentTimestampOverrideAttributes { + IncidentTimestampOverrideAttributes { + created_at, + deleted_at, + incident_id, + modified_at, + timestamp_type, + timestamp_value, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for IncidentTimestampOverrideAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentTimestampOverrideAttributesVisitor; + impl<'a> Visitor<'a> for IncidentTimestampOverrideAttributesVisitor { + type Value = IncidentTimestampOverrideAttributes; + + 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_at: Option> = None; + let mut deleted_at: Option>> = None; + let mut incident_id: Option = None; + let mut modified_at: Option> = None; + let mut timestamp_type: Option = None; + let mut timestamp_value: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "created_at" => { + created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "deleted_at" => { + deleted_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "incident_id" => { + incident_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "modified_at" => { + modified_at = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "timestamp_type" => { + timestamp_type = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _timestamp_type) = timestamp_type { + match _timestamp_type { + crate::datadogV2::model::TimestampType::UnparsedObject( + _timestamp_type, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "timestamp_value" => { + timestamp_value = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let created_at = created_at.ok_or_else(|| M::Error::missing_field("created_at"))?; + let deleted_at = deleted_at.ok_or_else(|| M::Error::missing_field("deleted_at"))?; + let incident_id = + incident_id.ok_or_else(|| M::Error::missing_field("incident_id"))?; + let modified_at = + modified_at.ok_or_else(|| M::Error::missing_field("modified_at"))?; + let timestamp_type = + timestamp_type.ok_or_else(|| M::Error::missing_field("timestamp_type"))?; + let timestamp_value = + timestamp_value.ok_or_else(|| M::Error::missing_field("timestamp_value"))?; + + let content = IncidentTimestampOverrideAttributes { + created_at, + deleted_at, + incident_id, + modified_at, + timestamp_type, + timestamp_value, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentTimestampOverrideAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_timestamp_override_create_attributes.rs b/src/datadogV2/model/model_incident_timestamp_override_create_attributes.rs new file mode 100644 index 000000000..61290074b --- /dev/null +++ b/src/datadogV2/model/model_incident_timestamp_override_create_attributes.rs @@ -0,0 +1,119 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes for creating an incident timestamp override. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentTimestampOverrideCreateAttributes { + /// The type of timestamp being overridden. + #[serde(rename = "timestamp_type")] + pub timestamp_type: crate::datadogV2::model::TimestampType, + /// The timestamp value for the override. + #[serde(rename = "timestamp_value")] + pub timestamp_value: chrono::DateTime, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentTimestampOverrideCreateAttributes { + pub fn new( + timestamp_type: crate::datadogV2::model::TimestampType, + timestamp_value: chrono::DateTime, + ) -> IncidentTimestampOverrideCreateAttributes { + IncidentTimestampOverrideCreateAttributes { + timestamp_type, + timestamp_value, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for IncidentTimestampOverrideCreateAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentTimestampOverrideCreateAttributesVisitor; + impl<'a> Visitor<'a> for IncidentTimestampOverrideCreateAttributesVisitor { + type Value = IncidentTimestampOverrideCreateAttributes; + + 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 timestamp_type: Option = None; + let mut timestamp_value: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "timestamp_type" => { + timestamp_type = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _timestamp_type) = timestamp_type { + match _timestamp_type { + crate::datadogV2::model::TimestampType::UnparsedObject( + _timestamp_type, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "timestamp_value" => { + timestamp_value = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let timestamp_type = + timestamp_type.ok_or_else(|| M::Error::missing_field("timestamp_type"))?; + let timestamp_value = + timestamp_value.ok_or_else(|| M::Error::missing_field("timestamp_value"))?; + + let content = IncidentTimestampOverrideCreateAttributes { + timestamp_type, + timestamp_value, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentTimestampOverrideCreateAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_timestamp_override_create_data.rs b/src/datadogV2/model/model_incident_timestamp_override_create_data.rs new file mode 100644 index 000000000..32876f20a --- /dev/null +++ b/src/datadogV2/model/model_incident_timestamp_override_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 incident timestamp override. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentTimestampOverrideCreateData { + /// Attributes for creating an incident timestamp override. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::IncidentTimestampOverrideCreateAttributes, + /// The JSON:API type for timestamp overrides. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::IncidentsTimestampOverridesType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentTimestampOverrideCreateData { + pub fn new( + attributes: crate::datadogV2::model::IncidentTimestampOverrideCreateAttributes, + type_: crate::datadogV2::model::IncidentsTimestampOverridesType, + ) -> IncidentTimestampOverrideCreateData { + IncidentTimestampOverrideCreateData { + 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 IncidentTimestampOverrideCreateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentTimestampOverrideCreateDataVisitor; + impl<'a> Visitor<'a> for IncidentTimestampOverrideCreateDataVisitor { + type Value = IncidentTimestampOverrideCreateData; + + 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::IncidentTimestampOverrideCreateAttributes, + > = 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::IncidentsTimestampOverridesType::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 = IncidentTimestampOverrideCreateData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentTimestampOverrideCreateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_timestamp_override_create_request.rs b/src/datadogV2/model/model_incident_timestamp_override_create_request.rs new file mode 100644 index 000000000..a361c5dd2 --- /dev/null +++ b/src/datadogV2/model/model_incident_timestamp_override_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 to create an incident timestamp override. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentTimestampOverrideCreateRequest { + /// Data for creating an incident timestamp override. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::IncidentTimestampOverrideCreateData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentTimestampOverrideCreateRequest { + pub fn new( + data: crate::datadogV2::model::IncidentTimestampOverrideCreateData, + ) -> IncidentTimestampOverrideCreateRequest { + IncidentTimestampOverrideCreateRequest { + 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 IncidentTimestampOverrideCreateRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentTimestampOverrideCreateRequestVisitor; + impl<'a> Visitor<'a> for IncidentTimestampOverrideCreateRequestVisitor { + type Value = IncidentTimestampOverrideCreateRequest; + + 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 = IncidentTimestampOverrideCreateRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentTimestampOverrideCreateRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_timestamp_override_data.rs b/src/datadogV2/model/model_incident_timestamp_override_data.rs new file mode 100644 index 000000000..6d2736178 --- /dev/null +++ b/src/datadogV2/model/model_incident_timestamp_override_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}; + +/// Data for a single incident timestamp override. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentTimestampOverrideData { + /// Attributes of an incident timestamp override. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::IncidentTimestampOverrideAttributes, + /// The UUID of the timestamp override. + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// Relationships for incident timestamp override. + #[serde(rename = "relationships")] + pub relationships: crate::datadogV2::model::IncidentTimestampOverrideRelationships, + /// The JSON:API type for timestamp overrides. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::IncidentsTimestampOverridesType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentTimestampOverrideData { + pub fn new( + attributes: crate::datadogV2::model::IncidentTimestampOverrideAttributes, + id: uuid::Uuid, + relationships: crate::datadogV2::model::IncidentTimestampOverrideRelationships, + type_: crate::datadogV2::model::IncidentsTimestampOverridesType, + ) -> IncidentTimestampOverrideData { + IncidentTimestampOverrideData { + 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 IncidentTimestampOverrideData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentTimestampOverrideDataVisitor; + impl<'a> Visitor<'a> for IncidentTimestampOverrideDataVisitor { + type Value = IncidentTimestampOverrideData; + + 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::IncidentTimestampOverrideAttributes, + > = None; + let mut id: Option = None; + let mut relationships: Option< + crate::datadogV2::model::IncidentTimestampOverrideRelationships, + > = 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::IncidentsTimestampOverridesType::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 = IncidentTimestampOverrideData { + attributes, + id, + relationships, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentTimestampOverrideDataVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_timestamp_override_patch_attributes.rs b/src/datadogV2/model/model_incident_timestamp_override_patch_attributes.rs new file mode 100644 index 000000000..7f4bf4b80 --- /dev/null +++ b/src/datadogV2/model/model_incident_timestamp_override_patch_attributes.rs @@ -0,0 +1,96 @@ +// 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 patching an incident timestamp override. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentTimestampOverridePatchAttributes { + /// The timestamp value for the override. + #[serde(rename = "timestamp_value")] + pub timestamp_value: chrono::DateTime, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentTimestampOverridePatchAttributes { + pub fn new( + timestamp_value: chrono::DateTime, + ) -> IncidentTimestampOverridePatchAttributes { + IncidentTimestampOverridePatchAttributes { + timestamp_value, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for IncidentTimestampOverridePatchAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentTimestampOverridePatchAttributesVisitor; + impl<'a> Visitor<'a> for IncidentTimestampOverridePatchAttributesVisitor { + type Value = IncidentTimestampOverridePatchAttributes; + + 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 timestamp_value: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "timestamp_value" => { + timestamp_value = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let timestamp_value = + timestamp_value.ok_or_else(|| M::Error::missing_field("timestamp_value"))?; + + let content = IncidentTimestampOverridePatchAttributes { + timestamp_value, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentTimestampOverridePatchAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_timestamp_override_patch_data.rs b/src/datadogV2/model/model_incident_timestamp_override_patch_data.rs new file mode 100644 index 000000000..a41d78381 --- /dev/null +++ b/src/datadogV2/model/model_incident_timestamp_override_patch_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 patching an incident timestamp override. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentTimestampOverridePatchData { + /// Attributes for patching an incident timestamp override. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::IncidentTimestampOverridePatchAttributes, + /// The JSON:API type for timestamp overrides. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::IncidentsTimestampOverridesType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentTimestampOverridePatchData { + pub fn new( + attributes: crate::datadogV2::model::IncidentTimestampOverridePatchAttributes, + type_: crate::datadogV2::model::IncidentsTimestampOverridesType, + ) -> IncidentTimestampOverridePatchData { + IncidentTimestampOverridePatchData { + 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 IncidentTimestampOverridePatchData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentTimestampOverridePatchDataVisitor; + impl<'a> Visitor<'a> for IncidentTimestampOverridePatchDataVisitor { + type Value = IncidentTimestampOverridePatchData; + + 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::IncidentTimestampOverridePatchAttributes, + > = 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::IncidentsTimestampOverridesType::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 = IncidentTimestampOverridePatchData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentTimestampOverridePatchDataVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_timestamp_override_patch_request.rs b/src/datadogV2/model/model_incident_timestamp_override_patch_request.rs new file mode 100644 index 000000000..34041a3f5 --- /dev/null +++ b/src/datadogV2/model/model_incident_timestamp_override_patch_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 to patch an incident timestamp override. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentTimestampOverridePatchRequest { + /// Data for patching an incident timestamp override. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::IncidentTimestampOverridePatchData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentTimestampOverridePatchRequest { + pub fn new( + data: crate::datadogV2::model::IncidentTimestampOverridePatchData, + ) -> IncidentTimestampOverridePatchRequest { + IncidentTimestampOverridePatchRequest { + 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 IncidentTimestampOverridePatchRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentTimestampOverridePatchRequestVisitor; + impl<'a> Visitor<'a> for IncidentTimestampOverridePatchRequestVisitor { + type Value = IncidentTimestampOverridePatchRequest; + + 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 = IncidentTimestampOverridePatchRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentTimestampOverridePatchRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_timestamp_override_relationships.rs b/src/datadogV2/model/model_incident_timestamp_override_relationships.rs new file mode 100644 index 000000000..19691fe37 --- /dev/null +++ b/src/datadogV2/model/model_incident_timestamp_override_relationships.rs @@ -0,0 +1,113 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Relationships for incident timestamp override. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentTimestampOverrideRelationships { + /// Relationship to a user. + #[serde(rename = "created_by_user")] + pub created_by_user: crate::datadogV2::model::TimestampOverrideUserRelationship, + /// Relationship to a user. + #[serde(rename = "last_modified_by_user")] + pub last_modified_by_user: crate::datadogV2::model::TimestampOverrideUserRelationship, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentTimestampOverrideRelationships { + pub fn new( + created_by_user: crate::datadogV2::model::TimestampOverrideUserRelationship, + last_modified_by_user: crate::datadogV2::model::TimestampOverrideUserRelationship, + ) -> IncidentTimestampOverrideRelationships { + IncidentTimestampOverrideRelationships { + created_by_user, + last_modified_by_user, + 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 IncidentTimestampOverrideRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentTimestampOverrideRelationshipsVisitor; + impl<'a> Visitor<'a> for IncidentTimestampOverrideRelationshipsVisitor { + type Value = IncidentTimestampOverrideRelationships; + + 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_user: Option< + crate::datadogV2::model::TimestampOverrideUserRelationship, + > = None; + let mut last_modified_by_user: Option< + crate::datadogV2::model::TimestampOverrideUserRelationship, + > = 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_user" => { + created_by_user = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "last_modified_by_user" => { + last_modified_by_user = + 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_user = + created_by_user.ok_or_else(|| M::Error::missing_field("created_by_user"))?; + let last_modified_by_user = last_modified_by_user + .ok_or_else(|| M::Error::missing_field("last_modified_by_user"))?; + + let content = IncidentTimestampOverrideRelationships { + created_by_user, + last_modified_by_user, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentTimestampOverrideRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_timestamp_override_response.rs b/src/datadogV2/model/model_incident_timestamp_override_response.rs new file mode 100644 index 000000000..a59c2a9fa --- /dev/null +++ b/src/datadogV2/model/model_incident_timestamp_override_response.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}; + +/// Response containing a single incident timestamp override. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentTimestampOverrideResponse { + /// Data for a single incident timestamp override. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::IncidentTimestampOverrideData, + /// Included related resources. + #[serde(rename = "included")] + pub included: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentTimestampOverrideResponse { + pub fn new( + data: crate::datadogV2::model::IncidentTimestampOverrideData, + ) -> IncidentTimestampOverrideResponse { + IncidentTimestampOverrideResponse { + 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 IncidentTimestampOverrideResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentTimestampOverrideResponseVisitor; + impl<'a> Visitor<'a> for IncidentTimestampOverrideResponseVisitor { + type Value = IncidentTimestampOverrideResponse; + + 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> = 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 = IncidentTimestampOverrideResponse { + data, + included, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentTimestampOverrideResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_timestamp_overrides_response.rs b/src/datadogV2/model/model_incident_timestamp_overrides_response.rs new file mode 100644 index 000000000..b857926be --- /dev/null +++ b/src/datadogV2/model/model_incident_timestamp_overrides_response.rs @@ -0,0 +1,112 @@ +// 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 incident timestamp overrides. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentTimestampOverridesResponse { + /// Array of incident timestamp overrides. + #[serde(rename = "data")] + pub data: Vec, + /// Included related resources. + #[serde(rename = "included")] + pub included: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentTimestampOverridesResponse { + pub fn new( + data: Vec, + ) -> IncidentTimestampOverridesResponse { + IncidentTimestampOverridesResponse { + 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 IncidentTimestampOverridesResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentTimestampOverridesResponseVisitor; + impl<'a> Visitor<'a> for IncidentTimestampOverridesResponseVisitor { + type Value = IncidentTimestampOverridesResponse; + + 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> = 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 = IncidentTimestampOverridesResponse { + data, + included, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentTimestampOverridesResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_incidents_timestamp_overrides_type.rs b/src/datadogV2/model/model_incidents_timestamp_overrides_type.rs new file mode 100644 index 000000000..f4eae6e2d --- /dev/null +++ b/src/datadogV2/model/model_incidents_timestamp_overrides_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 IncidentsTimestampOverridesType { + INCIDENTS_TIMESTAMP_OVERRIDES, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for IncidentsTimestampOverridesType { + fn to_string(&self) -> String { + match self { + Self::INCIDENTS_TIMESTAMP_OVERRIDES => String::from("incidents_timestamp_overrides"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for IncidentsTimestampOverridesType { + 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 IncidentsTimestampOverridesType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "incidents_timestamp_overrides" => Self::INCIDENTS_TIMESTAMP_OVERRIDES, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_timestamp_override_user_relationship.rs b/src/datadogV2/model/model_timestamp_override_user_relationship.rs new file mode 100644 index 000000000..0176cdf50 --- /dev/null +++ b/src/datadogV2/model/model_timestamp_override_user_relationship.rs @@ -0,0 +1,96 @@ +// 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 a user. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TimestampOverrideUserRelationship { + /// User relationship data. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::TimestampOverrideUserRelationshipData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TimestampOverrideUserRelationship { + pub fn new( + data: crate::datadogV2::model::TimestampOverrideUserRelationshipData, + ) -> TimestampOverrideUserRelationship { + TimestampOverrideUserRelationship { + 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 TimestampOverrideUserRelationship { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TimestampOverrideUserRelationshipVisitor; + impl<'a> Visitor<'a> for TimestampOverrideUserRelationshipVisitor { + type Value = TimestampOverrideUserRelationship; + + 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::TimestampOverrideUserRelationshipData, + > = 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 = TimestampOverrideUserRelationship { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TimestampOverrideUserRelationshipVisitor) + } +} diff --git a/src/datadogV2/model/model_timestamp_override_user_relationship_data.rs b/src/datadogV2/model/model_timestamp_override_user_relationship_data.rs new file mode 100644 index 000000000..db8e8ceb6 --- /dev/null +++ b/src/datadogV2/model/model_timestamp_override_user_relationship_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}; + +/// User relationship data. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TimestampOverrideUserRelationshipData { + /// The UUID of the user. + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// The type of the related resource. + #[serde(rename = "type")] + pub type_: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TimestampOverrideUserRelationshipData { + pub fn new(id: uuid::Uuid, type_: String) -> TimestampOverrideUserRelationshipData { + TimestampOverrideUserRelationshipData { + 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 TimestampOverrideUserRelationshipData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TimestampOverrideUserRelationshipDataVisitor; + impl<'a> Visitor<'a> for TimestampOverrideUserRelationshipDataVisitor { + type Value = TimestampOverrideUserRelationshipData; + + 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 = TimestampOverrideUserRelationshipData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TimestampOverrideUserRelationshipDataVisitor) + } +} diff --git a/src/datadogV2/model/model_timestamp_type.rs b/src/datadogV2/model/model_timestamp_type.rs new file mode 100644 index 000000000..a21042b4f --- /dev/null +++ b/src/datadogV2/model/model_timestamp_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 TimestampType { + CREATED, + DETECTED, + RESOLVED, + DECLARED, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for TimestampType { + fn to_string(&self) -> String { + match self { + Self::CREATED => String::from("created"), + Self::DETECTED => String::from("detected"), + Self::RESOLVED => String::from("resolved"), + Self::DECLARED => String::from("declared"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for TimestampType { + 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 TimestampType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "created" => Self::CREATED, + "detected" => Self::DETECTED, + "resolved" => Self::RESOLVED, + "declared" => Self::DECLARED, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_user_included.rs b/src/datadogV2/model/model_user_included.rs new file mode 100644 index 000000000..d8dd4f8c9 --- /dev/null +++ b/src/datadogV2/model/model_user_included.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}; + +/// Included user data. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct UserIncluded { + /// Attributes of an included user. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::UserIncludedAttributes, + /// The UUID of the user. + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// The type of the included resource. + #[serde(rename = "type")] + pub type_: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl UserIncluded { + pub fn new( + attributes: crate::datadogV2::model::UserIncludedAttributes, + id: uuid::Uuid, + type_: String, + ) -> UserIncluded { + UserIncluded { + 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 UserIncluded { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct UserIncludedVisitor; + impl<'a> Visitor<'a> for UserIncludedVisitor { + type Value = UserIncluded; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + 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 = UserIncluded { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(UserIncludedVisitor) + } +} diff --git a/src/datadogV2/model/model_user_included_attributes.rs b/src/datadogV2/model/model_user_included_attributes.rs new file mode 100644 index 000000000..328829447 --- /dev/null +++ b/src/datadogV2/model/model_user_included_attributes.rs @@ -0,0 +1,138 @@ +// 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. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct UserIncludedAttributes { + /// The email address of the user. + #[serde(rename = "email")] + pub email: String, + /// The handle of the user. + #[serde(rename = "handle")] + pub handle: String, + /// The icon URL for the user. + #[serde(rename = "icon")] + pub icon: String, + /// The name of the user. + #[serde(rename = "name")] + pub name: String, + /// The UUID of the user. + #[serde(rename = "uuid")] + pub uuid: uuid::Uuid, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl UserIncludedAttributes { + pub fn new( + email: String, + handle: String, + icon: String, + name: String, + uuid: uuid::Uuid, + ) -> UserIncludedAttributes { + UserIncludedAttributes { + email, + handle, + icon, + name, + uuid, + 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 UserIncludedAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct UserIncludedAttributesVisitor; + impl<'a> Visitor<'a> for UserIncludedAttributesVisitor { + type Value = UserIncludedAttributes; + + 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 email: Option = None; + let mut handle: Option = None; + let mut icon: Option = None; + let mut name: Option = None; + let mut uuid: 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() { + "email" => { + email = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "handle" => { + handle = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "icon" => { + icon = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "uuid" => { + uuid = 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 email = email.ok_or_else(|| M::Error::missing_field("email"))?; + let handle = handle.ok_or_else(|| M::Error::missing_field("handle"))?; + let icon = icon.ok_or_else(|| M::Error::missing_field("icon"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let uuid = uuid.ok_or_else(|| M::Error::missing_field("uuid"))?; + + let content = UserIncludedAttributes { + email, + handle, + icon, + name, + uuid, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(UserIncludedAttributesVisitor) + } +} diff --git a/tests/scenarios/features/v2/incidents.feature b/tests/scenarios/features/v2/incidents.feature index a683c2cac..e90620931 100644 --- a/tests/scenarios/features/v2/incidents.feature +++ b/tests/scenarios/features/v2/incidents.feature @@ -21,6 +21,33 @@ Feature: Incidents When the request is sent Then the response status is 200 OK + @generated @skip @team:Datadog/incident-app + Scenario: Create a timestamp override for an incident returns "Bad Request" response + Given operation "CreateIncidentTimestampOverride" enabled + And new "CreateIncidentTimestampOverride" request + And request contains "incident_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"timestamp_type": "created", "timestamp_value": "2024-12-29T10:00:00Z"}, "type": "incidents_timestamp_overrides"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/incident-app + Scenario: Create a timestamp override for an incident returns "Created" response + Given operation "CreateIncidentTimestampOverride" enabled + And new "CreateIncidentTimestampOverride" request + And request contains "incident_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"timestamp_type": "created", "timestamp_value": "2024-12-29T10:00:00Z"}, "type": "incidents_timestamp_overrides"}} + When the request is sent + Then the response status is 201 Created + + @generated @skip @team:Datadog/incident-app + Scenario: Create a timestamp override for an incident returns "Not Found" response + Given operation "CreateIncidentTimestampOverride" enabled + And new "CreateIncidentTimestampOverride" request + And request contains "incident_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"timestamp_type": "created", "timestamp_value": "2024-12-29T10:00:00Z"}, "type": "incidents_timestamp_overrides"}} + When the request is sent + Then the response status is 404 Not Found + @skip @team:DataDog/incident-app Scenario: Create an incident impact returns "Bad Request" response Given operation "CreateIncidentImpact" enabled @@ -330,6 +357,24 @@ Feature: Incidents When the request is sent Then the response status is 404 Not Found + @generated @skip @team:Datadog/incident-app + Scenario: Delete a timestamp override for an incident returns "No Content" response + Given operation "DeleteIncidentTimestampOverride" enabled + And new "DeleteIncidentTimestampOverride" request + And request contains "incident_id" parameter from "REPLACE.ME" + And request contains "timestamp_override_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:Datadog/incident-app + Scenario: Delete a timestamp override for an incident returns "Not Found" response + Given operation "DeleteIncidentTimestampOverride" enabled + And new "DeleteIncidentTimestampOverride" request + And request contains "incident_id" parameter from "REPLACE.ME" + And request contains "timestamp_override_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @generated @skip @team:DataDog/incident-app Scenario: Delete an existing incident returns "Bad Request" response Given operation "DeleteIncident" enabled @@ -1018,6 +1063,22 @@ Feature: Incidents When the request is sent Then the response status is 200 OK + @generated @skip @team:Datadog/incident-app + Scenario: List timestamp overrides for an incident returns "Not Found" response + Given operation "ListIncidentTimestampOverrides" enabled + And new "ListIncidentTimestampOverrides" request + And request contains "incident_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:Datadog/incident-app + Scenario: List timestamp overrides for an incident returns "OK" response + Given operation "ListIncidentTimestampOverrides" enabled + And new "ListIncidentTimestampOverrides" request + And request contains "incident_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @team:DataDog/incident-app Scenario: Remove commander from an incident returns "OK" response Given operation "UpdateIncident" enabled @@ -1066,6 +1127,36 @@ Feature: Incidents Then the response status is 200 OK And the response has 3 items + @generated @skip @team:Datadog/incident-app + Scenario: Update a timestamp override for an incident returns "Bad Request" response + Given operation "UpdateIncidentTimestampOverride" enabled + And new "UpdateIncidentTimestampOverride" request + And request contains "incident_id" parameter from "REPLACE.ME" + And request contains "timestamp_override_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"timestamp_value": "2024-12-29T11:00:00Z"}, "type": "incidents_timestamp_overrides"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/incident-app + Scenario: Update a timestamp override for an incident returns "Not Found" response + Given operation "UpdateIncidentTimestampOverride" enabled + And new "UpdateIncidentTimestampOverride" request + And request contains "incident_id" parameter from "REPLACE.ME" + And request contains "timestamp_override_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"timestamp_value": "2024-12-29T11:00:00Z"}, "type": "incidents_timestamp_overrides"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:Datadog/incident-app + Scenario: Update a timestamp override for an incident returns "OK" response + Given operation "UpdateIncidentTimestampOverride" enabled + And new "UpdateIncidentTimestampOverride" request + And request contains "incident_id" parameter from "REPLACE.ME" + And request contains "timestamp_override_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"timestamp_value": "2024-12-29T11:00:00Z"}, "type": "incidents_timestamp_overrides"}} + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/incident-app Scenario: Update an existing incident integration metadata returns "Bad Request" response Given operation "UpdateIncidentIntegration" enabled diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index c77dfee33..8c4911b6c 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -2013,6 +2013,30 @@ "type": "idempotent" } }, + "ListIncidentTimestampOverrides": { + "tag": "Incidents", + "undo": { + "type": "safe" + } + }, + "CreateIncidentTimestampOverride": { + "tag": "Incidents", + "undo": { + "type": "unsafe" + } + }, + "DeleteIncidentTimestampOverride": { + "tag": "Incidents", + "undo": { + "type": "idempotent" + } + }, + "UpdateIncidentTimestampOverride": { + "tag": "Incidents", + "undo": { + "type": "idempotent" + } + }, "ListAWSAccounts": { "tag": "AWS Integration", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 79c0a643f..23f0b7d6d 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -3425,6 +3425,22 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { world .function_mappings .insert("v2.UpdateIncidentTodo".into(), test_v2_update_incident_todo); + world.function_mappings.insert( + "v2.ListIncidentTimestampOverrides".into(), + test_v2_list_incident_timestamp_overrides, + ); + world.function_mappings.insert( + "v2.CreateIncidentTimestampOverride".into(), + test_v2_create_incident_timestamp_override, + ); + world.function_mappings.insert( + "v2.DeleteIncidentTimestampOverride".into(), + test_v2_delete_incident_timestamp_override, + ); + world.function_mappings.insert( + "v2.UpdateIncidentTimestampOverride".into(), + test_v2_update_incident_timestamp_override, + ); world .function_mappings .insert("v2.ListAWSAccounts".into(), test_v2_list_aws_accounts); @@ -25568,6 +25584,162 @@ fn test_v2_update_incident_todo(world: &mut DatadogWorld, _parameters: &HashMap< world.response.code = response.status.as_u16(); } +fn test_v2_list_incident_timestamp_overrides( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_incidents + .as_ref() + .expect("api instance not found"); + let incident_id = + serde_json::from_value(_parameters.get("incident_id").unwrap().clone()).unwrap(); + let include = _parameters + .get("include") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let include_deleted = _parameters + .get("include-deleted") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = + datadogV2::api_incidents::ListIncidentTimestampOverridesOptionalParams::default(); + params.include = include; + params.include_deleted = include_deleted; + let response = + match block_on(api.list_incident_timestamp_overrides_with_http_info(incident_id, 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_incident_timestamp_override( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_incidents + .as_ref() + .expect("api instance not found"); + let incident_id = + serde_json::from_value(_parameters.get("incident_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let include = _parameters + .get("include") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = + datadogV2::api_incidents::CreateIncidentTimestampOverrideOptionalParams::default(); + params.include = include; + let response = match block_on(api.create_incident_timestamp_override_with_http_info( + incident_id, + body, + 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_delete_incident_timestamp_override( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_incidents + .as_ref() + .expect("api instance not found"); + let incident_id = + serde_json::from_value(_parameters.get("incident_id").unwrap().clone()).unwrap(); + let timestamp_override_id = + serde_json::from_value(_parameters.get("timestamp_override_id").unwrap().clone()).unwrap(); + let response = match block_on( + api.delete_incident_timestamp_override_with_http_info(incident_id, timestamp_override_id), + ) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_update_incident_timestamp_override( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_incidents + .as_ref() + .expect("api instance not found"); + let incident_id = + serde_json::from_value(_parameters.get("incident_id").unwrap().clone()).unwrap(); + let timestamp_override_id = + serde_json::from_value(_parameters.get("timestamp_override_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let include = _parameters + .get("include") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = + datadogV2::api_incidents::UpdateIncidentTimestampOverrideOptionalParams::default(); + params.include = include; + let response = match block_on(api.update_incident_timestamp_override_with_http_info( + incident_id, + timestamp_override_id, + body, + 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_list_aws_accounts(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances