From c143bba9b05e6b43aa3fa3ca848393d7892aec69 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 10 Jul 2026 17:37:09 +0000 Subject: [PATCH] Regenerate client from commit 91098ba of spec repo --- .generator/schemas/v2/openapi.yaml | 451 ++++++++++ .../v2_incidents_CreateIncidentPostmortem.rs | 36 + .../v2_incidents_DeleteIncidentPostmortem.rs | 21 + .../v2_incidents_GetIncidentPostmortem.rs | 25 + .../v2_incidents_UpdateIncidentPostmortem.rs | 37 + src/datadog/configuration.rs | 4 + src/datadogV2/api/api_incidents.rs | 777 ++++++++++++++++-- src/datadogV2/model/mod.rs | 28 + .../model_incident_postmortem_attributes.rs | 176 ++++ ...l_incident_postmortem_create_attributes.rs | 104 +++ .../model_incident_postmortem_create_data.rs | 115 +++ ...odel_incident_postmortem_create_request.rs | 94 +++ .../model/model_incident_postmortem_data.rs | 140 ++++ .../model_incident_postmortem_included.rs | 41 + ...model_incident_postmortem_relationships.rs | 176 ++++ .../model_incident_postmortem_response.rs | 115 +++ ...l_incident_postmortem_update_attributes.rs | 115 +++ .../model_incident_postmortem_update_data.rs | 126 +++ ...odel_incident_postmortem_update_request.rs | 94 +++ ...relationship_to_incident_responder_data.rs | 113 +++ .../model/model_postmortem_status.rs | 54 ++ ...odel_relationship_to_incident_responder.rs | 97 +++ ...n-incident-returns-CREATED-response.frozen | 1 + ...-an-incident-returns-CREATED-response.json | 121 +++ ...for-an-incident-returns-OK-response.frozen | 1 + ...m-for-an-incident-returns-OK-response.json | 149 ++++ ...for-an-incident-returns-OK-response.frozen | 1 + ...m-for-an-incident-returns-OK-response.json | 149 ++++ ...for-an-incident-returns-OK-response.frozen | 1 + ...m-for-an-incident-returns-OK-response.json | 155 ++++ tests/scenarios/features/v2/given.json | 16 + tests/scenarios/features/v2/incidents.feature | 122 +++ tests/scenarios/features/v2/undo.json | 31 + tests/scenarios/function_mappings.rs | 148 ++++ 34 files changed, 3782 insertions(+), 52 deletions(-) create mode 100644 examples/v2_incidents_CreateIncidentPostmortem.rs create mode 100644 examples/v2_incidents_DeleteIncidentPostmortem.rs create mode 100644 examples/v2_incidents_GetIncidentPostmortem.rs create mode 100644 examples/v2_incidents_UpdateIncidentPostmortem.rs create mode 100644 src/datadogV2/model/model_incident_postmortem_attributes.rs create mode 100644 src/datadogV2/model/model_incident_postmortem_create_attributes.rs create mode 100644 src/datadogV2/model/model_incident_postmortem_create_data.rs create mode 100644 src/datadogV2/model/model_incident_postmortem_create_request.rs create mode 100644 src/datadogV2/model/model_incident_postmortem_data.rs create mode 100644 src/datadogV2/model/model_incident_postmortem_included.rs create mode 100644 src/datadogV2/model/model_incident_postmortem_relationships.rs create mode 100644 src/datadogV2/model/model_incident_postmortem_response.rs create mode 100644 src/datadogV2/model/model_incident_postmortem_update_attributes.rs create mode 100644 src/datadogV2/model/model_incident_postmortem_update_data.rs create mode 100644 src/datadogV2/model/model_incident_postmortem_update_request.rs create mode 100644 src/datadogV2/model/model_nullable_relationship_to_incident_responder_data.rs create mode 100644 src/datadogV2/model/model_postmortem_status.rs create mode 100644 src/datadogV2/model/model_relationship_to_incident_responder.rs create mode 100644 tests/scenarios/cassettes/v2/incidents/Create-postmortem-for-an-incident-returns-CREATED-response.frozen create mode 100644 tests/scenarios/cassettes/v2/incidents/Create-postmortem-for-an-incident-returns-CREATED-response.json create mode 100644 tests/scenarios/cassettes/v2/incidents/Delete-postmortem-for-an-incident-returns-OK-response.frozen create mode 100644 tests/scenarios/cassettes/v2/incidents/Delete-postmortem-for-an-incident-returns-OK-response.json create mode 100644 tests/scenarios/cassettes/v2/incidents/Get-postmortem-for-an-incident-returns-OK-response.frozen create mode 100644 tests/scenarios/cassettes/v2/incidents/Get-postmortem-for-an-incident-returns-OK-response.json create mode 100644 tests/scenarios/cassettes/v2/incidents/Update-postmortem-for-an-incident-returns-OK-response.frozen create mode 100644 tests/scenarios/cassettes/v2/incidents/Update-postmortem-for-an-incident-returns-OK-response.json diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 5638f0c0df..9a2db4ea42 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1413,6 +1413,15 @@ components: required: false schema: $ref: "#/components/schemas/OrgGroupPolicySortOption" + PostmortemIncludeQueryParameter: + description: "Resources to include in the response. Supported values: `last_modified_by_user`, `postmortem_owner_user`, `postmortem_owner_responder`, `incident`." + explode: false + in: query + name: include + required: false + schema: + example: "postmortem_owner_user" + type: string ProductName: description: Name of the product to be deleted, either `logs` or `rum`. in: path @@ -45930,6 +45939,130 @@ components: - id - type type: object + IncidentPostmortemAttributes: + description: The postmortem's attributes. + properties: + created: + description: Timestamp when the postmortem was created. + example: "2024-01-01T00:00:00+00:00" + format: date-time + type: string + document_id: + description: The identifier of the postmortem document within its host platform. + example: "123" + type: string + document_type: + description: >- + The type of document backing the postmortem (for example, `datadog_notebooks`, `confluence`, or `google_docs`). Can be empty if the document type is unknown. + example: datadog_notebooks + type: string + document_url: + description: The URL of the postmortem document. + example: "https://app.datadoghq.com/notebook/123" + type: string + modified: + description: Timestamp when the postmortem was last modified. + example: "2024-01-01T00:00:00+00:00" + format: date-time + type: string + status: + $ref: "#/components/schemas/PostmortemStatus" + title: + description: The title of the postmortem. + example: "Postmortem for IR-123" + type: string + required: + - title + - document_url + - document_id + - document_type + - status + - created + - modified + type: object + IncidentPostmortemCreateAttributes: + description: The postmortem's attributes for a creation request. + properties: + document_url: + description: The URL of the postmortem document (for example, a Datadog notebook, Confluence page, or Google Doc). + example: "https://app.datadoghq.com/notebook/123" + type: string + title: + description: The title of the postmortem. + example: "Postmortem for IR-123" + type: string + required: + - title + - document_url + type: object + IncidentPostmortemCreateData: + description: The postmortem resource for a creation request. + properties: + attributes: + $ref: "#/components/schemas/IncidentPostmortemCreateAttributes" + type: + $ref: "#/components/schemas/IncidentPostmortemType" + required: + - type + - attributes + type: object + IncidentPostmortemCreateRequest: + description: Request to create a postmortem for an incident. + properties: + data: + $ref: "#/components/schemas/IncidentPostmortemCreateData" + required: + - data + type: object + IncidentPostmortemData: + description: The postmortem resource. + properties: + attributes: + $ref: "#/components/schemas/IncidentPostmortemAttributes" + id: + description: The UUID of the postmortem. + example: "00000000-0000-abcd-1000-000000000000" + type: string + relationships: + $ref: "#/components/schemas/IncidentPostmortemRelationships" + type: + $ref: "#/components/schemas/IncidentPostmortemType" + required: + - id + - type + - attributes + - relationships + type: object + IncidentPostmortemIncluded: + description: An object related to a postmortem that is included in the response. + oneOf: + - $ref: "#/components/schemas/IncidentUserData" + - $ref: "#/components/schemas/IncidentResponseData" + IncidentPostmortemRelationships: + description: The postmortem's relationships. + properties: + incident: + $ref: "#/components/schemas/RelationshipToIncident" + last_modified_by_user: + $ref: "#/components/schemas/RelationshipToUser" + postmortem_owner_responder: + $ref: "#/components/schemas/RelationshipToIncidentResponder" + postmortem_owner_user: + $ref: "#/components/schemas/NullableRelationshipToUser" + type: object + IncidentPostmortemResponse: + description: Response with a single incident postmortem. + properties: + data: + $ref: "#/components/schemas/IncidentPostmortemData" + included: + description: Related objects included in the response. + items: + $ref: "#/components/schemas/IncidentPostmortemIncluded" + type: array + required: + - data + type: object IncidentPostmortemType: default: incident_postmortems description: Incident postmortem resource type. @@ -45939,6 +46072,36 @@ components: type: string x-enum-varnames: - INCIDENT_POSTMORTEMS + IncidentPostmortemUpdateAttributes: + description: The postmortem's attributes for an update request. + properties: + status: + $ref: "#/components/schemas/PostmortemStatus" + type: object + IncidentPostmortemUpdateData: + description: The postmortem resource for an update request. + properties: + attributes: + $ref: "#/components/schemas/IncidentPostmortemUpdateAttributes" + id: + description: The UUID of the postmortem. + example: "00000000-0000-abcd-1000-000000000000" + type: string + type: + $ref: "#/components/schemas/IncidentPostmortemType" + required: + - id + - type + - attributes + type: object + IncidentPostmortemUpdateRequest: + description: Request to update the postmortem attached to an incident. + properties: + data: + $ref: "#/components/schemas/IncidentPostmortemUpdateData" + required: + - data + type: object IncidentRelatedObject: description: Object related to an incident. enum: @@ -64127,6 +64290,20 @@ components: required: - type type: object + NullableRelationshipToIncidentResponderData: + description: Relationship to impact object. + nullable: true + properties: + id: + description: A unique identifier that represents the responder. + example: "00000000-0000-0000-2345-000000000000" + type: string + type: + $ref: "#/components/schemas/IncidentRespondersType" + required: + - id + - type + type: object NullableRelationshipToUser: description: Relationship to user. nullable: true @@ -75323,6 +75500,18 @@ components: type: string x-enum-varnames: - MARKDOWN + PostmortemStatus: + description: The status of the postmortem. + enum: + - draft + - in_review + - completed + example: draft + type: string + x-enum-varnames: + - DRAFT + - IN_REVIEW + - COMPLETED PostmortemTemplateAttributesRequest: description: Attributes for creating or updating a postmortem template. properties: @@ -78741,6 +78930,15 @@ components: required: - data type: object + RelationshipToIncidentResponder: + description: A relationship reference for a single incident responder. + nullable: true + properties: + data: + $ref: "#/components/schemas/NullableRelationshipToIncidentResponderData" + required: + - data + type: object RelationshipToIncidentResponderData: description: Relationship to impact object. properties: @@ -140824,6 +141022,259 @@ paths: operator: OR permissions: - incident_write + /api/v2/incidents/{incident_id}/postmortem: + delete: + description: Delete the postmortem attached to an incident. + operationId: DeleteIncidentPostmortem + parameters: + - $ref: "#/components/parameters/IncidentIDPathParameter" + responses: + "204": + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "401": + $ref: "#/components/responses/UnauthorizedResponse" + "403": + $ref: "#/components/responses/ForbiddenResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - incident_write + summary: Delete postmortem for an incident + tags: + - Incidents + x-permission: + operator: OR + permissions: + - incident_write + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + get: + description: Get the postmortem attached to an incident. + operationId: GetIncidentPostmortem + parameters: + - $ref: "#/components/parameters/IncidentIDPathParameter" + - $ref: "#/components/parameters/PostmortemIncludeQueryParameter" + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + created: "2024-01-01T00:00:00+00:00" + document_id: "123" + document_type: datadog_notebooks + document_url: "https://app.datadoghq.com/notebook/123" + modified: "2024-01-01T00:00:00+00:00" + status: draft + title: "Postmortem for IR-123" + id: 00000000-0000-abcd-1000-000000000000 + relationships: + incident: + data: + id: 00000000-0000-0000-1234-000000000000 + type: incidents + last_modified_by_user: + data: + id: 00000000-0000-0000-1234-000000000000 + type: users + type: incident_postmortems + schema: + $ref: "#/components/schemas/IncidentPostmortemResponse" + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "401": + $ref: "#/components/responses/UnauthorizedResponse" + "403": + $ref: "#/components/responses/ForbiddenResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - incident_read + summary: Get postmortem for an incident + tags: + - Incidents + x-permission: + operator: OR + permissions: + - incident_read + 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 the postmortem attached to an incident, for example to change its status. + operationId: UpdateIncidentPostmortem + parameters: + - $ref: "#/components/parameters/IncidentIDPathParameter" + - $ref: "#/components/parameters/PostmortemIncludeQueryParameter" + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + status: in_review + id: 00000000-0000-abcd-1000-000000000000 + type: incident_postmortems + schema: + $ref: "#/components/schemas/IncidentPostmortemUpdateRequest" + description: Postmortem update payload. + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + created: "2024-01-01T00:00:00+00:00" + document_id: "123" + document_type: datadog_notebooks + document_url: "https://app.datadoghq.com/notebook/123" + modified: "2024-01-01T00:00:00+00:00" + status: in_review + title: "Postmortem for IR-123" + id: 00000000-0000-abcd-1000-000000000000 + relationships: + incident: + data: + id: 00000000-0000-0000-1234-000000000000 + type: incidents + last_modified_by_user: + data: + id: 00000000-0000-0000-1234-000000000000 + type: users + type: incident_postmortems + schema: + $ref: "#/components/schemas/IncidentPostmortemResponse" + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "401": + $ref: "#/components/responses/UnauthorizedResponse" + "403": + $ref: "#/components/responses/ForbiddenResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - incident_write + summary: Update postmortem for an incident + tags: + - Incidents + x-permission: + operator: OR + permissions: + - incident_write + 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 postmortem for an incident by linking a title and document URL + (for example, a Datadog notebook, Confluence page, or Google Doc). + + Only one postmortem is allowed per incident. + operationId: CreateIncidentPostmortem + parameters: + - $ref: "#/components/parameters/IncidentIDPathParameter" + - $ref: "#/components/parameters/PostmortemIncludeQueryParameter" + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + document_url: "https://app.datadoghq.com/notebook/123" + title: "Postmortem for IR-123" + type: incident_postmortems + schema: + $ref: "#/components/schemas/IncidentPostmortemCreateRequest" + description: Postmortem creation payload. + required: true + responses: + "201": + content: + application/json: + examples: + default: + value: + data: + attributes: + created: "2024-01-01T00:00:00+00:00" + document_id: "123" + document_type: datadog_notebooks + document_url: "https://app.datadoghq.com/notebook/123" + modified: "2024-01-01T00:00:00+00:00" + status: draft + title: "Postmortem for IR-123" + id: 00000000-0000-abcd-1000-000000000000 + relationships: + incident: + data: + id: 00000000-0000-0000-1234-000000000000 + type: incidents + last_modified_by_user: + data: + id: 00000000-0000-0000-1234-000000000000 + type: users + type: incident_postmortems + schema: + $ref: "#/components/schemas/IncidentPostmortemResponse" + description: CREATED + "400": + $ref: "#/components/responses/BadRequestResponse" + "401": + $ref: "#/components/responses/UnauthorizedResponse" + "403": + $ref: "#/components/responses/ForbiddenResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "409": + $ref: "#/components/responses/ConflictResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - incident_write + summary: Create postmortem for an incident + tags: + - Incidents + x-permission: + operator: OR + permissions: + - incident_write + 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}/relationships/integrations: get: description: Get all integration metadata for an incident. diff --git a/examples/v2_incidents_CreateIncidentPostmortem.rs b/examples/v2_incidents_CreateIncidentPostmortem.rs new file mode 100644 index 0000000000..a13c3da835 --- /dev/null +++ b/examples/v2_incidents_CreateIncidentPostmortem.rs @@ -0,0 +1,36 @@ +// Create postmortem for an incident returns "CREATED" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_incidents::CreateIncidentPostmortemOptionalParams; +use datadog_api_client::datadogV2::api_incidents::IncidentsAPI; +use datadog_api_client::datadogV2::model::IncidentPostmortemCreateAttributes; +use datadog_api_client::datadogV2::model::IncidentPostmortemCreateData; +use datadog_api_client::datadogV2::model::IncidentPostmortemCreateRequest; +use datadog_api_client::datadogV2::model::IncidentPostmortemType; + +#[tokio::main] +async fn main() { + // there is a valid "incident" in the system + let incident_data_id = std::env::var("INCIDENT_DATA_ID").unwrap(); + let body = IncidentPostmortemCreateRequest::new(IncidentPostmortemCreateData::new( + IncidentPostmortemCreateAttributes::new( + "https://app.datadoghq.com/notebook/123".to_string(), + "Postmortem for IR-123".to_string(), + ), + IncidentPostmortemType::INCIDENT_POSTMORTEMS, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.CreateIncidentPostmortem", true); + let api = IncidentsAPI::with_config(configuration); + let resp = api + .create_incident_postmortem( + incident_data_id.clone(), + body, + CreateIncidentPostmortemOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_incidents_DeleteIncidentPostmortem.rs b/examples/v2_incidents_DeleteIncidentPostmortem.rs new file mode 100644 index 0000000000..b0bb181171 --- /dev/null +++ b/examples/v2_incidents_DeleteIncidentPostmortem.rs @@ -0,0 +1,21 @@ +// Delete postmortem for an incident returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_incidents::IncidentsAPI; + +#[tokio::main] +async fn main() { + // there is a valid "postmortem" in the system + let postmortem_data_relationships_incident_data_id = + std::env::var("POSTMORTEM_DATA_RELATIONSHIPS_INCIDENT_DATA_ID").unwrap(); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.DeleteIncidentPostmortem", true); + let api = IncidentsAPI::with_config(configuration); + let resp = api + .delete_incident_postmortem(postmortem_data_relationships_incident_data_id.clone()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_incidents_GetIncidentPostmortem.rs b/examples/v2_incidents_GetIncidentPostmortem.rs new file mode 100644 index 0000000000..96691d9dad --- /dev/null +++ b/examples/v2_incidents_GetIncidentPostmortem.rs @@ -0,0 +1,25 @@ +// Get postmortem for an incident returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_incidents::GetIncidentPostmortemOptionalParams; +use datadog_api_client::datadogV2::api_incidents::IncidentsAPI; + +#[tokio::main] +async fn main() { + // there is a valid "postmortem" in the system + let postmortem_data_relationships_incident_data_id = + std::env::var("POSTMORTEM_DATA_RELATIONSHIPS_INCIDENT_DATA_ID").unwrap(); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.GetIncidentPostmortem", true); + let api = IncidentsAPI::with_config(configuration); + let resp = api + .get_incident_postmortem( + postmortem_data_relationships_incident_data_id.clone(), + GetIncidentPostmortemOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_incidents_UpdateIncidentPostmortem.rs b/examples/v2_incidents_UpdateIncidentPostmortem.rs new file mode 100644 index 0000000000..b0aa4fe804 --- /dev/null +++ b/examples/v2_incidents_UpdateIncidentPostmortem.rs @@ -0,0 +1,37 @@ +// Update postmortem 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::UpdateIncidentPostmortemOptionalParams; +use datadog_api_client::datadogV2::model::IncidentPostmortemType; +use datadog_api_client::datadogV2::model::IncidentPostmortemUpdateAttributes; +use datadog_api_client::datadogV2::model::IncidentPostmortemUpdateData; +use datadog_api_client::datadogV2::model::IncidentPostmortemUpdateRequest; +use datadog_api_client::datadogV2::model::PostmortemStatus; + +#[tokio::main] +async fn main() { + // there is a valid "postmortem" in the system + let postmortem_data_id = std::env::var("POSTMORTEM_DATA_ID").unwrap(); + let postmortem_data_relationships_incident_data_id = + std::env::var("POSTMORTEM_DATA_RELATIONSHIPS_INCIDENT_DATA_ID").unwrap(); + let body = IncidentPostmortemUpdateRequest::new(IncidentPostmortemUpdateData::new( + IncidentPostmortemUpdateAttributes::new().status(PostmortemStatus::IN_REVIEW), + postmortem_data_id.clone(), + IncidentPostmortemType::INCIDENT_POSTMORTEMS, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.UpdateIncidentPostmortem", true); + let api = IncidentsAPI::with_config(configuration); + let resp = api + .update_incident_postmortem( + postmortem_data_relationships_incident_data_id.clone(), + body, + UpdateIncidentPostmortemOptionalParams::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 2a671e1309..9efe54af01 100644 --- a/src/datadog/configuration.rs +++ b/src/datadog/configuration.rs @@ -590,6 +590,7 @@ impl Default for Configuration { ("v2.create_incident_integration".to_owned(), false), ("v2.create_incident_notification_rule".to_owned(), false), ("v2.create_incident_notification_template".to_owned(), false), + ("v2.create_incident_postmortem".to_owned(), false), ("v2.create_incident_postmortem_attachment".to_owned(), false), ("v2.create_incident_postmortem_template".to_owned(), false), ("v2.create_incident_todo".to_owned(), false), @@ -601,6 +602,7 @@ impl Default for Configuration { ("v2.delete_incident_integration".to_owned(), false), ("v2.delete_incident_notification_rule".to_owned(), false), ("v2.delete_incident_notification_template".to_owned(), false), + ("v2.delete_incident_postmortem".to_owned(), false), ("v2.delete_incident_postmortem_template".to_owned(), false), ("v2.delete_incident_todo".to_owned(), false), ("v2.delete_incident_type".to_owned(), false), @@ -610,6 +612,7 @@ impl Default for Configuration { ("v2.get_incident_integration".to_owned(), false), ("v2.get_incident_notification_rule".to_owned(), false), ("v2.get_incident_notification_template".to_owned(), false), + ("v2.get_incident_postmortem".to_owned(), false), ("v2.get_incident_postmortem_template".to_owned(), false), ("v2.get_incident_todo".to_owned(), false), ("v2.get_incident_type".to_owned(), false), @@ -633,6 +636,7 @@ impl Default for Configuration { ("v2.update_incident_integration".to_owned(), false), ("v2.update_incident_notification_rule".to_owned(), false), ("v2.update_incident_notification_template".to_owned(), false), + ("v2.update_incident_postmortem".to_owned(), false), ("v2.update_incident_postmortem_template".to_owned(), false), ("v2.update_incident_todo".to_owned(), false), ("v2.update_incident_type".to_owned(), false), diff --git a/src/datadogV2/api/api_incidents.rs b/src/datadogV2/api/api_incidents.rs index 4481da0699..9be224ba6b 100644 --- a/src/datadogV2/api/api_incidents.rs +++ b/src/datadogV2/api/api_incidents.rs @@ -64,6 +64,22 @@ impl CreateIncidentImpactOptionalParams { } } +/// CreateIncidentPostmortemOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::create_incident_postmortem`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct CreateIncidentPostmortemOptionalParams { + /// Resources to include in the response. Supported values: `last_modified_by_user`, `postmortem_owner_user`, `postmortem_owner_responder`, `incident`. + pub include: Option, +} + +impl CreateIncidentPostmortemOptionalParams { + /// Resources to include in the response. Supported values: `last_modified_by_user`, `postmortem_owner_user`, `postmortem_owner_responder`, `incident`. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } +} + /// CreateIncidentUserDefinedFieldOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::create_incident_user_defined_field`] #[non_exhaustive] #[derive(Clone, Default, Debug)] @@ -160,6 +176,22 @@ impl GetIncidentNotificationTemplateOptionalParams { } } +/// GetIncidentPostmortemOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::get_incident_postmortem`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct GetIncidentPostmortemOptionalParams { + /// Resources to include in the response. Supported values: `last_modified_by_user`, `postmortem_owner_user`, `postmortem_owner_responder`, `incident`. + pub include: Option, +} + +impl GetIncidentPostmortemOptionalParams { + /// Resources to include in the response. Supported values: `last_modified_by_user`, `postmortem_owner_user`, `postmortem_owner_responder`, `incident`. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } +} + /// GetIncidentUserDefinedFieldOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::get_incident_user_defined_field`] #[non_exhaustive] #[derive(Clone, Default, Debug)] @@ -499,6 +531,22 @@ impl UpdateIncidentNotificationTemplateOptionalParams { } } +/// UpdateIncidentPostmortemOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::update_incident_postmortem`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct UpdateIncidentPostmortemOptionalParams { + /// Resources to include in the response. Supported values: `last_modified_by_user`, `postmortem_owner_user`, `postmortem_owner_responder`, `incident`. + pub include: Option, +} + +impl UpdateIncidentPostmortemOptionalParams { + /// Resources to include in the response. Supported values: `last_modified_by_user`, `postmortem_owner_user`, `postmortem_owner_responder`, `incident`. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } +} + /// UpdateIncidentUserDefinedFieldOptionalParams is a struct for passing parameters to the method [`IncidentsAPI::update_incident_user_defined_field`] #[non_exhaustive] #[derive(Clone, Default, Debug)] @@ -572,6 +620,14 @@ pub enum CreateIncidentNotificationTemplateError { UnknownValue(serde_json::Value), } +/// CreateIncidentPostmortemError is a struct for typed errors of method [`IncidentsAPI::create_incident_postmortem`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateIncidentPostmortemError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// CreateIncidentPostmortemAttachmentError is a struct for typed errors of method [`IncidentsAPI::create_incident_postmortem_attachment`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -672,6 +728,14 @@ pub enum DeleteIncidentNotificationTemplateError { UnknownValue(serde_json::Value), } +/// DeleteIncidentPostmortemError is a struct for typed errors of method [`IncidentsAPI::delete_incident_postmortem`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteIncidentPostmortemError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// DeleteIncidentPostmortemTemplateError is a struct for typed errors of method [`IncidentsAPI::delete_incident_postmortem_template`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -747,6 +811,14 @@ pub enum GetIncidentNotificationTemplateError { UnknownValue(serde_json::Value), } +/// GetIncidentPostmortemError is a struct for typed errors of method [`IncidentsAPI::get_incident_postmortem`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetIncidentPostmortemError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// GetIncidentPostmortemTemplateError is a struct for typed errors of method [`IncidentsAPI::get_incident_postmortem_template`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -946,6 +1018,14 @@ pub enum UpdateIncidentNotificationTemplateError { UnknownValue(serde_json::Value), } +/// UpdateIncidentPostmortemError is a struct for typed errors of method [`IncidentsAPI::update_incident_postmortem`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateIncidentPostmortemError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// UpdateIncidentPostmortemTemplateError is a struct for typed errors of method [`IncidentsAPI::update_incident_postmortem_template`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -2245,6 +2325,191 @@ impl IncidentsAPI { } } + /// Create a postmortem for an incident by linking a title and document URL + /// (for example, a Datadog notebook, Confluence page, or Google Doc). + /// + /// Only one postmortem is allowed per incident. + pub async fn create_incident_postmortem( + &self, + incident_id: String, + body: crate::datadogV2::model::IncidentPostmortemCreateRequest, + params: CreateIncidentPostmortemOptionalParams, + ) -> Result< + crate::datadogV2::model::IncidentPostmortemResponse, + datadog::Error, + > { + match self + .create_incident_postmortem_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 postmortem for an incident by linking a title and document URL + /// (for example, a Datadog notebook, Confluence page, or Google Doc). + /// + /// Only one postmortem is allowed per incident. + pub async fn create_incident_postmortem_with_http_info( + &self, + incident_id: String, + body: crate::datadogV2::model::IncidentPostmortemCreateRequest, + params: CreateIncidentPostmortemOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_incident_postmortem"; + 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_postmortem' 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}/postmortem", + local_configuration.get_operation_host(operation_id), + incident_id = datadog::urlencode(incident_id) + ); + 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)), + } + } + #[cfg(feature = "zstd")] + "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 a postmortem attachment for an incident. /// /// The endpoint accepts markdown for notebooks created in Confluence or Google Docs. @@ -3803,6 +4068,105 @@ impl IncidentsAPI { } } + /// Delete the postmortem attached to an incident. + pub async fn delete_incident_postmortem( + &self, + incident_id: String, + ) -> Result<(), datadog::Error> { + match self + .delete_incident_postmortem_with_http_info(incident_id) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Delete the postmortem attached to an incident. + pub async fn delete_incident_postmortem_with_http_info( + &self, + incident_id: String, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.delete_incident_postmortem"; + 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_postmortem' 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}/postmortem", + local_configuration.get_operation_host(operation_id), + incident_id = datadog::urlencode(incident_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 a postmortem template. pub async fn delete_incident_postmortem_template( &self, @@ -4458,7 +4822,131 @@ impl IncidentsAPI { datadog::Error, > { match self - .get_incident_integration_with_http_info(incident_id, integration_metadata_id) + .get_incident_integration_with_http_info(incident_id, integration_metadata_id) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get incident integration metadata details. + pub async fn get_incident_integration_with_http_info( + &self, + incident_id: String, + integration_metadata_id: String, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_incident_integration"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.get_incident_integration' 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/integrations/{integration_metadata_id}", + local_configuration.get_operation_host(operation_id), incident_id= + datadog::urlencode(incident_id) + , integration_metadata_id= + datadog::urlencode(integration_metadata_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Retrieves a specific notification rule by its ID. + pub async fn get_incident_notification_rule( + &self, + id: uuid::Uuid, + params: GetIncidentNotificationRuleOptionalParams, + ) -> Result< + crate::datadogV2::model::IncidentNotificationRule, + datadog::Error, + > { + match self + .get_incident_notification_rule_with_http_info(id, params) .await { Ok(response_content) => { @@ -4474,38 +4962,44 @@ impl IncidentsAPI { } } - /// Get incident integration metadata details. - pub async fn get_incident_integration_with_http_info( + /// Retrieves a specific notification rule by its ID. + pub async fn get_incident_notification_rule_with_http_info( &self, - incident_id: String, - integration_metadata_id: String, + id: uuid::Uuid, + params: GetIncidentNotificationRuleOptionalParams, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.get_incident_integration"; + let operation_id = "v2.get_incident_notification_rule"; if local_configuration.is_unstable_operation_enabled(operation_id) { warn!("Using unstable operation {operation_id}"); } else { let local_error = datadog::UnstableOperationDisabledError { - msg: "Operation 'v2.get_incident_integration' is not enabled".to_string(), + msg: "Operation 'v2.get_incident_notification_rule' 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}/relationships/integrations/{integration_metadata_id}", - local_configuration.get_operation_host(operation_id), incident_id= - datadog::urlencode(incident_id) - , integration_metadata_id= - datadog::urlencode(integration_metadata_id) - ); + "{}/api/v2/incidents/config/notification-rules/{id}", + local_configuration.get_operation_host(operation_id), + id = datadog::urlencode(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())]); + }; + // build headers let mut headers = HeaderMap::new(); headers.insert("Accept", HeaderValue::from_static("application/json")); @@ -4548,7 +5042,7 @@ impl IncidentsAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( + match serde_json::from_str::( &local_content, ) { Ok(e) => { @@ -4561,7 +5055,7 @@ impl IncidentsAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -4572,17 +5066,17 @@ impl IncidentsAPI { } } - /// Retrieves a specific notification rule by its ID. - pub async fn get_incident_notification_rule( + /// Retrieves a specific notification template by its ID. + pub async fn get_incident_notification_template( &self, id: uuid::Uuid, - params: GetIncidentNotificationRuleOptionalParams, + params: GetIncidentNotificationTemplateOptionalParams, ) -> Result< - crate::datadogV2::model::IncidentNotificationRule, - datadog::Error, + crate::datadogV2::model::IncidentNotificationTemplate, + datadog::Error, > { match self - .get_incident_notification_rule_with_http_info(id, params) + .get_incident_notification_template_with_http_info(id, params) .await { Ok(response_content) => { @@ -4598,22 +5092,22 @@ impl IncidentsAPI { } } - /// Retrieves a specific notification rule by its ID. - pub async fn get_incident_notification_rule_with_http_info( + /// Retrieves a specific notification template by its ID. + pub async fn get_incident_notification_template_with_http_info( &self, id: uuid::Uuid, - params: GetIncidentNotificationRuleOptionalParams, + params: GetIncidentNotificationTemplateOptionalParams, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.get_incident_notification_rule"; + let operation_id = "v2.get_incident_notification_template"; if local_configuration.is_unstable_operation_enabled(operation_id) { warn!("Using unstable operation {operation_id}"); } else { let local_error = datadog::UnstableOperationDisabledError { - msg: "Operation 'v2.get_incident_notification_rule' is not enabled".to_string(), + msg: "Operation 'v2.get_incident_notification_template' is not enabled".to_string(), }; return Err(datadog::Error::UnstableOperationDisabledError(local_error)); } @@ -4624,7 +5118,7 @@ impl IncidentsAPI { let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/incidents/config/notification-rules/{id}", + "{}/api/v2/incidents/config/notification-templates/{id}", local_configuration.get_operation_host(operation_id), id = datadog::urlencode(id.to_string()) ); @@ -4678,7 +5172,7 @@ impl IncidentsAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( + match serde_json::from_str::( &local_content, ) { Ok(e) => { @@ -4691,7 +5185,7 @@ impl IncidentsAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -4702,17 +5196,17 @@ impl IncidentsAPI { } } - /// Retrieves a specific notification template by its ID. - pub async fn get_incident_notification_template( + /// Get the postmortem attached to an incident. + pub async fn get_incident_postmortem( &self, - id: uuid::Uuid, - params: GetIncidentNotificationTemplateOptionalParams, + incident_id: String, + params: GetIncidentPostmortemOptionalParams, ) -> Result< - crate::datadogV2::model::IncidentNotificationTemplate, - datadog::Error, + crate::datadogV2::model::IncidentPostmortemResponse, + datadog::Error, > { match self - .get_incident_notification_template_with_http_info(id, params) + .get_incident_postmortem_with_http_info(incident_id, params) .await { Ok(response_content) => { @@ -4728,22 +5222,22 @@ impl IncidentsAPI { } } - /// Retrieves a specific notification template by its ID. - pub async fn get_incident_notification_template_with_http_info( + /// Get the postmortem attached to an incident. + pub async fn get_incident_postmortem_with_http_info( &self, - id: uuid::Uuid, - params: GetIncidentNotificationTemplateOptionalParams, + incident_id: String, + params: GetIncidentPostmortemOptionalParams, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.get_incident_notification_template"; + let operation_id = "v2.get_incident_postmortem"; if local_configuration.is_unstable_operation_enabled(operation_id) { warn!("Using unstable operation {operation_id}"); } else { let local_error = datadog::UnstableOperationDisabledError { - msg: "Operation 'v2.get_incident_notification_template' is not enabled".to_string(), + msg: "Operation 'v2.get_incident_postmortem' is not enabled".to_string(), }; return Err(datadog::Error::UnstableOperationDisabledError(local_error)); } @@ -4754,9 +5248,9 @@ impl IncidentsAPI { let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/incidents/config/notification-templates/{id}", + "{}/api/v2/incidents/{incident_id}/postmortem", local_configuration.get_operation_host(operation_id), - id = datadog::urlencode(id.to_string()) + incident_id = datadog::urlencode(incident_id) ); let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); @@ -4808,7 +5302,7 @@ impl IncidentsAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( + match serde_json::from_str::( &local_content, ) { Ok(e) => { @@ -4821,7 +5315,7 @@ impl IncidentsAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -8364,6 +8858,185 @@ impl IncidentsAPI { } } + /// Update the postmortem attached to an incident, for example to change its status. + pub async fn update_incident_postmortem( + &self, + incident_id: String, + body: crate::datadogV2::model::IncidentPostmortemUpdateRequest, + params: UpdateIncidentPostmortemOptionalParams, + ) -> Result< + crate::datadogV2::model::IncidentPostmortemResponse, + datadog::Error, + > { + match self + .update_incident_postmortem_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), + } + } + + /// Update the postmortem attached to an incident, for example to change its status. + pub async fn update_incident_postmortem_with_http_info( + &self, + incident_id: String, + body: crate::datadogV2::model::IncidentPostmortemUpdateRequest, + params: UpdateIncidentPostmortemOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.update_incident_postmortem"; + 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_postmortem' 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}/postmortem", + local_configuration.get_operation_host(operation_id), + incident_id = datadog::urlencode(incident_id) + ); + 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)), + } + } + #[cfg(feature = "zstd")] + "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 existing postmortem template. pub async fn update_incident_postmortem_template( &self, diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index b041c1f299..1b5fbb72d2 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -4760,6 +4760,34 @@ pub mod model_incident_impact_create_attributes; pub use self::model_incident_impact_create_attributes::IncidentImpactCreateAttributes; pub mod model_incident_impact_response; pub use self::model_incident_impact_response::IncidentImpactResponse; +pub mod model_incident_postmortem_response; +pub use self::model_incident_postmortem_response::IncidentPostmortemResponse; +pub mod model_incident_postmortem_data; +pub use self::model_incident_postmortem_data::IncidentPostmortemData; +pub mod model_incident_postmortem_attributes; +pub use self::model_incident_postmortem_attributes::IncidentPostmortemAttributes; +pub mod model_postmortem_status; +pub use self::model_postmortem_status::PostmortemStatus; +pub mod model_incident_postmortem_relationships; +pub use self::model_incident_postmortem_relationships::IncidentPostmortemRelationships; +pub mod model_relationship_to_incident_responder; +pub use self::model_relationship_to_incident_responder::RelationshipToIncidentResponder; +pub mod model_nullable_relationship_to_incident_responder_data; +pub use self::model_nullable_relationship_to_incident_responder_data::NullableRelationshipToIncidentResponderData; +pub mod model_incident_postmortem_included; +pub use self::model_incident_postmortem_included::IncidentPostmortemIncluded; +pub mod model_incident_postmortem_update_request; +pub use self::model_incident_postmortem_update_request::IncidentPostmortemUpdateRequest; +pub mod model_incident_postmortem_update_data; +pub use self::model_incident_postmortem_update_data::IncidentPostmortemUpdateData; +pub mod model_incident_postmortem_update_attributes; +pub use self::model_incident_postmortem_update_attributes::IncidentPostmortemUpdateAttributes; +pub mod model_incident_postmortem_create_request; +pub use self::model_incident_postmortem_create_request::IncidentPostmortemCreateRequest; +pub mod model_incident_postmortem_create_data; +pub use self::model_incident_postmortem_create_data::IncidentPostmortemCreateData; +pub mod model_incident_postmortem_create_attributes; +pub use self::model_incident_postmortem_create_attributes::IncidentPostmortemCreateAttributes; pub mod model_incident_integration_metadata_list_response; pub use self::model_incident_integration_metadata_list_response::IncidentIntegrationMetadataListResponse; pub mod model_incident_integration_metadata_response_data; diff --git a/src/datadogV2/model/model_incident_postmortem_attributes.rs b/src/datadogV2/model/model_incident_postmortem_attributes.rs new file mode 100644 index 0000000000..2be640a67f --- /dev/null +++ b/src/datadogV2/model/model_incident_postmortem_attributes.rs @@ -0,0 +1,176 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The postmortem's attributes. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentPostmortemAttributes { + /// Timestamp when the postmortem was created. + #[serde(rename = "created")] + pub created: chrono::DateTime, + /// The identifier of the postmortem document within its host platform. + #[serde(rename = "document_id")] + pub document_id: String, + /// The type of document backing the postmortem (for example, `datadog_notebooks`, `confluence`, or `google_docs`). Can be empty if the document type is unknown. + #[serde(rename = "document_type")] + pub document_type: String, + /// The URL of the postmortem document. + #[serde(rename = "document_url")] + pub document_url: String, + /// Timestamp when the postmortem was last modified. + #[serde(rename = "modified")] + pub modified: chrono::DateTime, + /// The status of the postmortem. + #[serde(rename = "status")] + pub status: crate::datadogV2::model::PostmortemStatus, + /// The title of the postmortem. + #[serde(rename = "title")] + pub title: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentPostmortemAttributes { + pub fn new( + created: chrono::DateTime, + document_id: String, + document_type: String, + document_url: String, + modified: chrono::DateTime, + status: crate::datadogV2::model::PostmortemStatus, + title: String, + ) -> IncidentPostmortemAttributes { + IncidentPostmortemAttributes { + created, + document_id, + document_type, + document_url, + modified, + status, + title, + 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 IncidentPostmortemAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentPostmortemAttributesVisitor; + impl<'a> Visitor<'a> for IncidentPostmortemAttributesVisitor { + type Value = IncidentPostmortemAttributes; + + 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: Option> = None; + let mut document_id: Option = None; + let mut document_type: Option = None; + let mut document_url: Option = None; + let mut modified: Option> = None; + let mut status: Option = None; + let mut title: 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" => { + created = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "document_id" => { + document_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "document_type" => { + document_type = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "document_url" => { + document_url = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "modified" => { + modified = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "status" => { + status = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _status) = status { + match _status { + crate::datadogV2::model::PostmortemStatus::UnparsedObject( + _status, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "title" => { + title = 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 = created.ok_or_else(|| M::Error::missing_field("created"))?; + let document_id = + document_id.ok_or_else(|| M::Error::missing_field("document_id"))?; + let document_type = + document_type.ok_or_else(|| M::Error::missing_field("document_type"))?; + let document_url = + document_url.ok_or_else(|| M::Error::missing_field("document_url"))?; + let modified = modified.ok_or_else(|| M::Error::missing_field("modified"))?; + let status = status.ok_or_else(|| M::Error::missing_field("status"))?; + let title = title.ok_or_else(|| M::Error::missing_field("title"))?; + + let content = IncidentPostmortemAttributes { + created, + document_id, + document_type, + document_url, + modified, + status, + title, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentPostmortemAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_postmortem_create_attributes.rs b/src/datadogV2/model/model_incident_postmortem_create_attributes.rs new file mode 100644 index 0000000000..2dfba879e8 --- /dev/null +++ b/src/datadogV2/model/model_incident_postmortem_create_attributes.rs @@ -0,0 +1,104 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The postmortem's attributes for a creation request. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentPostmortemCreateAttributes { + /// The URL of the postmortem document (for example, a Datadog notebook, Confluence page, or Google Doc). + #[serde(rename = "document_url")] + pub document_url: String, + /// The title of the postmortem. + #[serde(rename = "title")] + pub title: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentPostmortemCreateAttributes { + pub fn new(document_url: String, title: String) -> IncidentPostmortemCreateAttributes { + IncidentPostmortemCreateAttributes { + document_url, + title, + 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 IncidentPostmortemCreateAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentPostmortemCreateAttributesVisitor; + impl<'a> Visitor<'a> for IncidentPostmortemCreateAttributesVisitor { + type Value = IncidentPostmortemCreateAttributes; + + 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 document_url: Option = None; + let mut title: 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() { + "document_url" => { + document_url = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "title" => { + title = 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 document_url = + document_url.ok_or_else(|| M::Error::missing_field("document_url"))?; + let title = title.ok_or_else(|| M::Error::missing_field("title"))?; + + let content = IncidentPostmortemCreateAttributes { + document_url, + title, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentPostmortemCreateAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_postmortem_create_data.rs b/src/datadogV2/model/model_incident_postmortem_create_data.rs new file mode 100644 index 0000000000..dbf3a51a5a --- /dev/null +++ b/src/datadogV2/model/model_incident_postmortem_create_data.rs @@ -0,0 +1,115 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The postmortem resource for a creation request. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentPostmortemCreateData { + /// The postmortem's attributes for a creation request. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::IncidentPostmortemCreateAttributes, + /// Incident postmortem resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::IncidentPostmortemType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentPostmortemCreateData { + pub fn new( + attributes: crate::datadogV2::model::IncidentPostmortemCreateAttributes, + type_: crate::datadogV2::model::IncidentPostmortemType, + ) -> IncidentPostmortemCreateData { + IncidentPostmortemCreateData { + 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 IncidentPostmortemCreateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentPostmortemCreateDataVisitor; + impl<'a> Visitor<'a> for IncidentPostmortemCreateDataVisitor { + type Value = IncidentPostmortemCreateData; + + 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::IncidentPostmortemCreateAttributes, + > = 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::IncidentPostmortemType::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 = IncidentPostmortemCreateData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentPostmortemCreateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_postmortem_create_request.rs b/src/datadogV2/model/model_incident_postmortem_create_request.rs new file mode 100644 index 0000000000..aff8187b0d --- /dev/null +++ b/src/datadogV2/model/model_incident_postmortem_create_request.rs @@ -0,0 +1,94 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request to create a postmortem for an incident. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentPostmortemCreateRequest { + /// The postmortem resource for a creation request. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::IncidentPostmortemCreateData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentPostmortemCreateRequest { + pub fn new( + data: crate::datadogV2::model::IncidentPostmortemCreateData, + ) -> IncidentPostmortemCreateRequest { + IncidentPostmortemCreateRequest { + 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 IncidentPostmortemCreateRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentPostmortemCreateRequestVisitor; + impl<'a> Visitor<'a> for IncidentPostmortemCreateRequestVisitor { + type Value = IncidentPostmortemCreateRequest; + + 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 = IncidentPostmortemCreateRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentPostmortemCreateRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_postmortem_data.rs b/src/datadogV2/model/model_incident_postmortem_data.rs new file mode 100644 index 0000000000..85903affb0 --- /dev/null +++ b/src/datadogV2/model/model_incident_postmortem_data.rs @@ -0,0 +1,140 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The postmortem resource. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentPostmortemData { + /// The postmortem's attributes. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::IncidentPostmortemAttributes, + /// The UUID of the postmortem. + #[serde(rename = "id")] + pub id: String, + /// The postmortem's relationships. + #[serde(rename = "relationships")] + pub relationships: crate::datadogV2::model::IncidentPostmortemRelationships, + /// Incident postmortem resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::IncidentPostmortemType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentPostmortemData { + pub fn new( + attributes: crate::datadogV2::model::IncidentPostmortemAttributes, + id: String, + relationships: crate::datadogV2::model::IncidentPostmortemRelationships, + type_: crate::datadogV2::model::IncidentPostmortemType, + ) -> IncidentPostmortemData { + IncidentPostmortemData { + 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 IncidentPostmortemData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentPostmortemDataVisitor; + impl<'a> Visitor<'a> for IncidentPostmortemDataVisitor { + type Value = IncidentPostmortemData; + + 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 relationships: Option< + crate::datadogV2::model::IncidentPostmortemRelationships, + > = 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::IncidentPostmortemType::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 = IncidentPostmortemData { + attributes, + id, + relationships, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentPostmortemDataVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_postmortem_included.rs b/src/datadogV2/model/model_incident_postmortem_included.rs new file mode 100644 index 0000000000..858fe4f14e --- /dev/null +++ b/src/datadogV2/model/model_incident_postmortem_included.rs @@ -0,0 +1,41 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::{Deserialize, Deserializer, Serialize}; + +/// An object related to a postmortem that is included in the response. +#[non_exhaustive] +#[derive(Clone, Debug, PartialEq, Serialize)] +#[serde(untagged)] +pub enum IncidentPostmortemIncluded { + IncidentUserData(Box), + IncidentResponseData(Box), + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl<'de> Deserialize<'de> for IncidentPostmortemIncluded { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let value: serde_json::Value = Deserialize::deserialize(deserializer)?; + if let Ok(_v) = + serde_json::from_value::>(value.clone()) + { + if !_v._unparsed { + return Ok(IncidentPostmortemIncluded::IncidentUserData(_v)); + } + } + if let Ok(_v) = serde_json::from_value::>( + value.clone(), + ) { + if !_v._unparsed { + return Ok(IncidentPostmortemIncluded::IncidentResponseData(_v)); + } + } + + return Ok(IncidentPostmortemIncluded::UnparsedObject( + crate::datadog::UnparsedObject { value }, + )); + } +} diff --git a/src/datadogV2/model/model_incident_postmortem_relationships.rs b/src/datadogV2/model/model_incident_postmortem_relationships.rs new file mode 100644 index 0000000000..324544d47b --- /dev/null +++ b/src/datadogV2/model/model_incident_postmortem_relationships.rs @@ -0,0 +1,176 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The postmortem's relationships. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentPostmortemRelationships { + /// Relationship to incident. + #[serde(rename = "incident")] + pub incident: Option, + /// Relationship to user. + #[serde(rename = "last_modified_by_user")] + pub last_modified_by_user: Option, + /// A relationship reference for a single incident responder. + #[serde( + rename = "postmortem_owner_responder", + default, + with = "::serde_with::rust::double_option" + )] + pub postmortem_owner_responder: + Option>, + /// Relationship to user. + #[serde( + rename = "postmortem_owner_user", + default, + with = "::serde_with::rust::double_option" + )] + pub postmortem_owner_user: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentPostmortemRelationships { + pub fn new() -> IncidentPostmortemRelationships { + IncidentPostmortemRelationships { + incident: None, + last_modified_by_user: None, + postmortem_owner_responder: None, + postmortem_owner_user: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn incident(mut self, value: crate::datadogV2::model::RelationshipToIncident) -> Self { + self.incident = Some(value); + self + } + + pub fn last_modified_by_user( + mut self, + value: crate::datadogV2::model::RelationshipToUser, + ) -> Self { + self.last_modified_by_user = Some(value); + self + } + + pub fn postmortem_owner_responder( + mut self, + value: Option, + ) -> Self { + self.postmortem_owner_responder = Some(value); + self + } + + pub fn postmortem_owner_user( + mut self, + value: Option, + ) -> Self { + self.postmortem_owner_user = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for IncidentPostmortemRelationships { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for IncidentPostmortemRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentPostmortemRelationshipsVisitor; + impl<'a> Visitor<'a> for IncidentPostmortemRelationshipsVisitor { + type Value = IncidentPostmortemRelationships; + + 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 incident: Option = None; + let mut last_modified_by_user: Option = + None; + let mut postmortem_owner_responder: Option< + Option, + > = None; + let mut postmortem_owner_user: Option< + Option, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "incident" => { + if v.is_null() { + continue; + } + incident = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "last_modified_by_user" => { + if v.is_null() { + continue; + } + last_modified_by_user = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "postmortem_owner_responder" => { + postmortem_owner_responder = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "postmortem_owner_user" => { + postmortem_owner_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 content = IncidentPostmortemRelationships { + incident, + last_modified_by_user, + postmortem_owner_responder, + postmortem_owner_user, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentPostmortemRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_postmortem_response.rs b/src/datadogV2/model/model_incident_postmortem_response.rs new file mode 100644 index 0000000000..20e87d03b1 --- /dev/null +++ b/src/datadogV2/model/model_incident_postmortem_response.rs @@ -0,0 +1,115 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response with a single incident postmortem. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentPostmortemResponse { + /// The postmortem resource. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::IncidentPostmortemData, + /// Related objects included in the response. + #[serde(rename = "included")] + pub included: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentPostmortemResponse { + pub fn new( + data: crate::datadogV2::model::IncidentPostmortemData, + ) -> IncidentPostmortemResponse { + IncidentPostmortemResponse { + 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 IncidentPostmortemResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentPostmortemResponseVisitor; + impl<'a> Visitor<'a> for IncidentPostmortemResponseVisitor { + type Value = IncidentPostmortemResponse; + + 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 = IncidentPostmortemResponse { + data, + included, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentPostmortemResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_postmortem_update_attributes.rs b/src/datadogV2/model/model_incident_postmortem_update_attributes.rs new file mode 100644 index 0000000000..1c5478c340 --- /dev/null +++ b/src/datadogV2/model/model_incident_postmortem_update_attributes.rs @@ -0,0 +1,115 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The postmortem's attributes for an update request. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentPostmortemUpdateAttributes { + /// The status of the postmortem. + #[serde(rename = "status")] + pub status: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentPostmortemUpdateAttributes { + pub fn new() -> IncidentPostmortemUpdateAttributes { + IncidentPostmortemUpdateAttributes { + status: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn status(mut self, value: crate::datadogV2::model::PostmortemStatus) -> Self { + self.status = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for IncidentPostmortemUpdateAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for IncidentPostmortemUpdateAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentPostmortemUpdateAttributesVisitor; + impl<'a> Visitor<'a> for IncidentPostmortemUpdateAttributesVisitor { + type Value = IncidentPostmortemUpdateAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut status: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "status" => { + if v.is_null() { + continue; + } + status = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _status) = status { + match _status { + crate::datadogV2::model::PostmortemStatus::UnparsedObject( + _status, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = IncidentPostmortemUpdateAttributes { + status, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentPostmortemUpdateAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_postmortem_update_data.rs b/src/datadogV2/model/model_incident_postmortem_update_data.rs new file mode 100644 index 0000000000..046e8b91ff --- /dev/null +++ b/src/datadogV2/model/model_incident_postmortem_update_data.rs @@ -0,0 +1,126 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The postmortem resource for an update request. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentPostmortemUpdateData { + /// The postmortem's attributes for an update request. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::IncidentPostmortemUpdateAttributes, + /// The UUID of the postmortem. + #[serde(rename = "id")] + pub id: String, + /// Incident postmortem resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::IncidentPostmortemType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentPostmortemUpdateData { + pub fn new( + attributes: crate::datadogV2::model::IncidentPostmortemUpdateAttributes, + id: String, + type_: crate::datadogV2::model::IncidentPostmortemType, + ) -> IncidentPostmortemUpdateData { + IncidentPostmortemUpdateData { + 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 IncidentPostmortemUpdateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentPostmortemUpdateDataVisitor; + impl<'a> Visitor<'a> for IncidentPostmortemUpdateDataVisitor { + type Value = IncidentPostmortemUpdateData; + + 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::IncidentPostmortemUpdateAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::IncidentPostmortemType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = IncidentPostmortemUpdateData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentPostmortemUpdateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_incident_postmortem_update_request.rs b/src/datadogV2/model/model_incident_postmortem_update_request.rs new file mode 100644 index 0000000000..31b430cd15 --- /dev/null +++ b/src/datadogV2/model/model_incident_postmortem_update_request.rs @@ -0,0 +1,94 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request to update the postmortem attached to an incident. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IncidentPostmortemUpdateRequest { + /// The postmortem resource for an update request. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::IncidentPostmortemUpdateData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IncidentPostmortemUpdateRequest { + pub fn new( + data: crate::datadogV2::model::IncidentPostmortemUpdateData, + ) -> IncidentPostmortemUpdateRequest { + IncidentPostmortemUpdateRequest { + 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 IncidentPostmortemUpdateRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IncidentPostmortemUpdateRequestVisitor; + impl<'a> Visitor<'a> for IncidentPostmortemUpdateRequestVisitor { + type Value = IncidentPostmortemUpdateRequest; + + 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 = IncidentPostmortemUpdateRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IncidentPostmortemUpdateRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_nullable_relationship_to_incident_responder_data.rs b/src/datadogV2/model/model_nullable_relationship_to_incident_responder_data.rs new file mode 100644 index 0000000000..88ee6a4e27 --- /dev/null +++ b/src/datadogV2/model/model_nullable_relationship_to_incident_responder_data.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}; + +/// Relationship to impact object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct NullableRelationshipToIncidentResponderData { + /// A unique identifier that represents the responder. + #[serde(rename = "id")] + pub id: String, + /// The incident responders type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::IncidentRespondersType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl NullableRelationshipToIncidentResponderData { + pub fn new( + id: String, + type_: crate::datadogV2::model::IncidentRespondersType, + ) -> NullableRelationshipToIncidentResponderData { + NullableRelationshipToIncidentResponderData { + 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 NullableRelationshipToIncidentResponderData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct NullableRelationshipToIncidentResponderDataVisitor; + impl<'a> Visitor<'a> for NullableRelationshipToIncidentResponderDataVisitor { + type Value = NullableRelationshipToIncidentResponderData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::IncidentRespondersType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = NullableRelationshipToIncidentResponderData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(NullableRelationshipToIncidentResponderDataVisitor) + } +} diff --git a/src/datadogV2/model/model_postmortem_status.rs b/src/datadogV2/model/model_postmortem_status.rs new file mode 100644 index 0000000000..169ece39bd --- /dev/null +++ b/src/datadogV2/model/model_postmortem_status.rs @@ -0,0 +1,54 @@ +// 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 PostmortemStatus { + DRAFT, + IN_REVIEW, + COMPLETED, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for PostmortemStatus { + fn to_string(&self) -> String { + match self { + Self::DRAFT => String::from("draft"), + Self::IN_REVIEW => String::from("in_review"), + Self::COMPLETED => String::from("completed"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for PostmortemStatus { + 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 PostmortemStatus { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "draft" => Self::DRAFT, + "in_review" => Self::IN_REVIEW, + "completed" => Self::COMPLETED, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_relationship_to_incident_responder.rs b/src/datadogV2/model/model_relationship_to_incident_responder.rs new file mode 100644 index 0000000000..d1aa1b0bb4 --- /dev/null +++ b/src/datadogV2/model/model_relationship_to_incident_responder.rs @@ -0,0 +1,97 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// A relationship reference for a single incident responder. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RelationshipToIncidentResponder { + /// Relationship to impact object. + #[serialize_always] + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RelationshipToIncidentResponder { + pub fn new( + data: Option, + ) -> RelationshipToIncidentResponder { + RelationshipToIncidentResponder { + 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 RelationshipToIncidentResponder { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RelationshipToIncidentResponderVisitor; + impl<'a> Visitor<'a> for RelationshipToIncidentResponderVisitor { + type Value = RelationshipToIncidentResponder; + + 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< + 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 = RelationshipToIncidentResponder { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RelationshipToIncidentResponderVisitor) + } +} diff --git a/tests/scenarios/cassettes/v2/incidents/Create-postmortem-for-an-incident-returns-CREATED-response.frozen b/tests/scenarios/cassettes/v2/incidents/Create-postmortem-for-an-incident-returns-CREATED-response.frozen new file mode 100644 index 0000000000..20dff1d9fb --- /dev/null +++ b/tests/scenarios/cassettes/v2/incidents/Create-postmortem-for-an-incident-returns-CREATED-response.frozen @@ -0,0 +1 @@ +2026-07-09T20:46:31.190Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/incidents/Create-postmortem-for-an-incident-returns-CREATED-response.json b/tests/scenarios/cassettes/v2/incidents/Create-postmortem-for-an-incident-returns-CREATED-response.json new file mode 100644 index 0000000000..0b58dc51a7 --- /dev/null +++ b/tests/scenarios/cassettes/v2/incidents/Create-postmortem-for-an-incident-returns-CREATED-response.json @@ -0,0 +1,121 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"customer_impacted\":false,\"title\":\"Test-Create_postmortem_for_an_incident_returns_CREATED_response-1783629991\"},\"type\":\"incidents\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/incidents" + }, + "response": { + "body": { + "string": "{\"data\":{\"type\":\"incidents\",\"id\":\"254910ed-d27e-5cb4-9f29-b0d5562e78d1\",\"attributes\":{\"public_id\":364275,\"incident_type_uuid\":\"41d2e10b-4108-4736-92d7-791d00ea0702\",\"title\":\"Test-Create_postmortem_for_an_incident_returns_CREATED_response-1783629991\",\"resolved\":null,\"customer_impact_scope\":null,\"customer_impact_start\":null,\"customer_impact_end\":null,\"customer_impacted\":false,\"notification_handles\":null,\"last_modified_by\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"attributes\":{\"uuid\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"name\":\"CI Account\",\"icon\":\"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro\"}}},\"last_modified_by_uuid\":null,\"created\":\"2026-07-09T20:46:33.090861+00:00\",\"modified\":\"2026-07-09T20:46:33.090861+00:00\",\"commander\":null,\"detected\":\"2026-07-09T20:46:33.080842+00:00\",\"created_by\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"attributes\":{\"uuid\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"name\":\"CI Account\",\"icon\":\"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro\"}}},\"created_by_uuid\":null,\"creation_idempotency_key\":null,\"customer_impact_duration\":0,\"time_to_detect\":0,\"time_to_repair\":0,\"time_to_internal_response\":0,\"time_to_resolve\":0,\"is_test\":false,\"declared\":\"2026-07-09T20:46:33.090861+00:00\",\"declared_by\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"attributes\":{\"uuid\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"name\":\"CI Account\",\"icon\":\"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro\"}}},\"declared_by_uuid\":null,\"fields\":{\"teams\":{\"type\":\"autocomplete\",\"value\":null},\"severity\":{\"type\":\"dropdown\",\"value\":\"UNKNOWN\"},\"state\":{\"type\":\"dropdown\",\"value\":\"active\"},\"detection_method\":{\"type\":\"dropdown\",\"value\":\"unknown\"},\"root_cause\":{\"type\":\"textbox\",\"value\":null},\"summary\":{\"type\":\"textbox\",\"value\":null},\"services\":{\"type\":\"autocomplete\",\"value\":null},\"slug\":{\"type\":\"textbox\",\"value\":\"IR-364275\"}},\"field_analytics\":null,\"severity\":\"UNKNOWN\",\"state\":\"active\",\"non_datadog_creator\":null,\"visibility\":\"organization\",\"case_id\":null},\"relationships\":{\"created_by_user\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}},\"last_modified_by_user\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}},\"commander_user\":{\"data\":null},\"declared_by_user\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}},\"user_defined_fields\":{\"data\":[{\"type\":\"user_defined_field\",\"id\":\"3cbe9e60-d794-532c-acc0-73641f782813\"},{\"type\":\"user_defined_field\",\"id\":\"33457d2a-570c-5567-b4af-979a2a8f1164\"},{\"type\":\"user_defined_field\",\"id\":\"d003693c-bee9-5420-8d46-859269c20914\"},{\"type\":\"user_defined_field\",\"id\":\"1ddff6f6-cb1f-51a0-9d81-dc18ef52cc9d\"},{\"type\":\"user_defined_field\",\"id\":\"6bc9d32b-c2cd-591e-9b7a-74c886a5ddcf\"},{\"type\":\"user_defined_field\",\"id\":\"95c53547-2ba3-5d8a-9c3b-cf245bc0c629\"},{\"type\":\"user_defined_field\",\"id\":\"39044b03-cee4-555f-b1e0-3eb3aa759a86\"},{\"type\":\"user_defined_field\",\"id\":\"2b9f1063-b915-4c7a-8bbd-fc3940245529\"}]},\"integrations\":{\"data\":[]},\"attachments\":{\"data\":[]},\"responders\":{\"data\":[]},\"impacts\":{\"data\":[]}}}}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Thu, 09 Jul 2026 20:46:31 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"document_url\":\"https://app.datadoghq.com/notebook/123\",\"title\":\"Postmortem for IR-123\"},\"type\":\"incident_postmortems\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/incidents/254910ed-d27e-5cb4-9f29-b0d5562e78d1/postmortem" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"83e96252-8ed9-4032-aa08-7c99a3229eeb\",\"type\":\"incident_postmortems\",\"attributes\":{\"created\":\"2026-07-09T20:46:33.603296Z\",\"document_id\":\"\",\"document_type\":\"\",\"document_url\":\"https://app.datadoghq.com/notebook/123\",\"modified\":\"2026-07-09T20:46:33.603296Z\",\"status\":\"draft\",\"title\":\"Postmortem for IR-123\"},\"relationships\":{\"incident\":{\"data\":{\"id\":\"254910ed-d27e-5cb4-9f29-b0d5562e78d1\",\"type\":\"incidents\"}},\"last_modified_by_user\":{\"data\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"type\":\"users\"}},\"postmortem_owner_responder\":{\"data\":null},\"postmortem_owner_user\":{\"data\":null}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Thu, 09 Jul 2026 20:46:31 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/incidents/254910ed-d27e-5cb4-9f29-b0d5562e78d1/postmortem" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Thu, 09 Jul 2026 20:46:31 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/incidents/254910ed-d27e-5cb4-9f29-b0d5562e78d1" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Thu, 09 Jul 2026 20:46:31 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/incidents/Delete-postmortem-for-an-incident-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/incidents/Delete-postmortem-for-an-incident-returns-OK-response.frozen new file mode 100644 index 0000000000..7f1eefa3ee --- /dev/null +++ b/tests/scenarios/cassettes/v2/incidents/Delete-postmortem-for-an-incident-returns-OK-response.frozen @@ -0,0 +1 @@ +2026-07-09T20:46:34.566Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/incidents/Delete-postmortem-for-an-incident-returns-OK-response.json b/tests/scenarios/cassettes/v2/incidents/Delete-postmortem-for-an-incident-returns-OK-response.json new file mode 100644 index 0000000000..49cdaaf92f --- /dev/null +++ b/tests/scenarios/cassettes/v2/incidents/Delete-postmortem-for-an-incident-returns-OK-response.json @@ -0,0 +1,149 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"customer_impacted\":false,\"title\":\"Test-Delete_postmortem_for_an_incident_returns_OK_response-1783629994\"},\"type\":\"incidents\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/incidents" + }, + "response": { + "body": { + "string": "{\"data\":{\"type\":\"incidents\",\"id\":\"b481c61d-b0b2-5786-b2c2-381d5334d201\",\"attributes\":{\"public_id\":364276,\"incident_type_uuid\":\"41d2e10b-4108-4736-92d7-791d00ea0702\",\"title\":\"Test-Delete_postmortem_for_an_incident_returns_OK_response-1783629994\",\"resolved\":null,\"customer_impact_scope\":null,\"customer_impact_start\":null,\"customer_impact_end\":null,\"customer_impacted\":false,\"notification_handles\":null,\"last_modified_by\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"attributes\":{\"uuid\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"name\":\"CI Account\",\"icon\":\"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro\"}}},\"last_modified_by_uuid\":null,\"created\":\"2026-07-09T20:46:34.742676+00:00\",\"modified\":\"2026-07-09T20:46:34.742676+00:00\",\"commander\":null,\"detected\":\"2026-07-09T20:46:34.734288+00:00\",\"created_by\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"attributes\":{\"uuid\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"name\":\"CI Account\",\"icon\":\"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro\"}}},\"created_by_uuid\":null,\"creation_idempotency_key\":null,\"customer_impact_duration\":0,\"time_to_detect\":0,\"time_to_repair\":0,\"time_to_internal_response\":0,\"time_to_resolve\":0,\"is_test\":false,\"declared\":\"2026-07-09T20:46:34.742676+00:00\",\"declared_by\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"attributes\":{\"uuid\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"name\":\"CI Account\",\"icon\":\"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro\"}}},\"declared_by_uuid\":null,\"fields\":{\"teams\":{\"type\":\"autocomplete\",\"value\":null},\"severity\":{\"type\":\"dropdown\",\"value\":\"UNKNOWN\"},\"state\":{\"type\":\"dropdown\",\"value\":\"active\"},\"detection_method\":{\"type\":\"dropdown\",\"value\":\"unknown\"},\"root_cause\":{\"type\":\"textbox\",\"value\":null},\"summary\":{\"type\":\"textbox\",\"value\":null},\"services\":{\"type\":\"autocomplete\",\"value\":null},\"slug\":{\"type\":\"textbox\",\"value\":\"IR-364276\"}},\"field_analytics\":null,\"severity\":\"UNKNOWN\",\"state\":\"active\",\"non_datadog_creator\":null,\"visibility\":\"organization\",\"case_id\":null},\"relationships\":{\"created_by_user\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}},\"last_modified_by_user\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}},\"commander_user\":{\"data\":null},\"declared_by_user\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}},\"user_defined_fields\":{\"data\":[{\"type\":\"user_defined_field\",\"id\":\"3cbe9e60-d794-532c-acc0-73641f782813\"},{\"type\":\"user_defined_field\",\"id\":\"33457d2a-570c-5567-b4af-979a2a8f1164\"},{\"type\":\"user_defined_field\",\"id\":\"d003693c-bee9-5420-8d46-859269c20914\"},{\"type\":\"user_defined_field\",\"id\":\"1ddff6f6-cb1f-51a0-9d81-dc18ef52cc9d\"},{\"type\":\"user_defined_field\",\"id\":\"6bc9d32b-c2cd-591e-9b7a-74c886a5ddcf\"},{\"type\":\"user_defined_field\",\"id\":\"95c53547-2ba3-5d8a-9c3b-cf245bc0c629\"},{\"type\":\"user_defined_field\",\"id\":\"39044b03-cee4-555f-b1e0-3eb3aa759a86\"},{\"type\":\"user_defined_field\",\"id\":\"2b9f1063-b915-4c7a-8bbd-fc3940245529\"}]},\"integrations\":{\"data\":[]},\"attachments\":{\"data\":[]},\"responders\":{\"data\":[]},\"impacts\":{\"data\":[]}}}}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Thu, 09 Jul 2026 20:46:34 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"document_url\":\"https://docs.example.com/postmortem-test-delete_postmortem_for_an_incident_returns_ok_response-1783629994\",\"title\":\"Postmortem for Test-Delete_postmortem_for_an_incident_returns_OK_response-1783629994\"},\"type\":\"incident_postmortems\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/incidents/b481c61d-b0b2-5786-b2c2-381d5334d201/postmortem" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"1f42ee03-8e4c-49ad-8626-875dc3c88862\",\"type\":\"incident_postmortems\",\"attributes\":{\"created\":\"2026-07-09T20:46:35.181043Z\",\"document_id\":\"\",\"document_type\":\"\",\"document_url\":\"https://docs.example.com/postmortem-test-delete_postmortem_for_an_incident_returns_ok_response-1783629994\",\"modified\":\"2026-07-09T20:46:35.181043Z\",\"status\":\"draft\",\"title\":\"Postmortem for Test-Delete_postmortem_for_an_incident_returns_OK_response-1783629994\"},\"relationships\":{\"incident\":{\"data\":{\"id\":\"b481c61d-b0b2-5786-b2c2-381d5334d201\",\"type\":\"incidents\"}},\"last_modified_by_user\":{\"data\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"type\":\"users\"}},\"postmortem_owner_responder\":{\"data\":null},\"postmortem_owner_user\":{\"data\":null}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Thu, 09 Jul 2026 20:46:34 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/incidents/b481c61d-b0b2-5786-b2c2-381d5334d201/postmortem" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Thu, 09 Jul 2026 20:46:34 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/incidents/b481c61d-b0b2-5786-b2c2-381d5334d201/postmortem" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"postmortem not found\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Thu, 09 Jul 2026 20:46:34 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/incidents/b481c61d-b0b2-5786-b2c2-381d5334d201" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Thu, 09 Jul 2026 20:46:34 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/incidents/Get-postmortem-for-an-incident-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/incidents/Get-postmortem-for-an-incident-returns-OK-response.frozen new file mode 100644 index 0000000000..b0c18a7290 --- /dev/null +++ b/tests/scenarios/cassettes/v2/incidents/Get-postmortem-for-an-incident-returns-OK-response.frozen @@ -0,0 +1 @@ +2026-07-09T20:46:36.398Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/incidents/Get-postmortem-for-an-incident-returns-OK-response.json b/tests/scenarios/cassettes/v2/incidents/Get-postmortem-for-an-incident-returns-OK-response.json new file mode 100644 index 0000000000..a2e3bf77f1 --- /dev/null +++ b/tests/scenarios/cassettes/v2/incidents/Get-postmortem-for-an-incident-returns-OK-response.json @@ -0,0 +1,149 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"customer_impacted\":false,\"title\":\"Test-Get_postmortem_for_an_incident_returns_OK_response-1783629996\"},\"type\":\"incidents\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/incidents" + }, + "response": { + "body": { + "string": "{\"data\":{\"type\":\"incidents\",\"id\":\"4832db36-b2ec-5f98-917a-3b2fff43a58c\",\"attributes\":{\"public_id\":364277,\"incident_type_uuid\":\"41d2e10b-4108-4736-92d7-791d00ea0702\",\"title\":\"Test-Get_postmortem_for_an_incident_returns_OK_response-1783629996\",\"resolved\":null,\"customer_impact_scope\":null,\"customer_impact_start\":null,\"customer_impact_end\":null,\"customer_impacted\":false,\"notification_handles\":null,\"last_modified_by\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"attributes\":{\"uuid\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"name\":\"CI Account\",\"icon\":\"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro\"}}},\"last_modified_by_uuid\":null,\"created\":\"2026-07-09T20:46:36.588869+00:00\",\"modified\":\"2026-07-09T20:46:36.588869+00:00\",\"commander\":null,\"detected\":\"2026-07-09T20:46:36.580740+00:00\",\"created_by\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"attributes\":{\"uuid\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"name\":\"CI Account\",\"icon\":\"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro\"}}},\"created_by_uuid\":null,\"creation_idempotency_key\":null,\"customer_impact_duration\":0,\"time_to_detect\":0,\"time_to_repair\":0,\"time_to_internal_response\":0,\"time_to_resolve\":0,\"is_test\":false,\"declared\":\"2026-07-09T20:46:36.588869+00:00\",\"declared_by\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"attributes\":{\"uuid\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"name\":\"CI Account\",\"icon\":\"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro\"}}},\"declared_by_uuid\":null,\"fields\":{\"teams\":{\"type\":\"autocomplete\",\"value\":null},\"severity\":{\"type\":\"dropdown\",\"value\":\"UNKNOWN\"},\"state\":{\"type\":\"dropdown\",\"value\":\"active\"},\"detection_method\":{\"type\":\"dropdown\",\"value\":\"unknown\"},\"root_cause\":{\"type\":\"textbox\",\"value\":null},\"summary\":{\"type\":\"textbox\",\"value\":null},\"services\":{\"type\":\"autocomplete\",\"value\":null},\"slug\":{\"type\":\"textbox\",\"value\":\"IR-364277\"}},\"field_analytics\":null,\"severity\":\"UNKNOWN\",\"state\":\"active\",\"non_datadog_creator\":null,\"visibility\":\"organization\",\"case_id\":null},\"relationships\":{\"created_by_user\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}},\"last_modified_by_user\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}},\"commander_user\":{\"data\":null},\"declared_by_user\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}},\"user_defined_fields\":{\"data\":[{\"type\":\"user_defined_field\",\"id\":\"3cbe9e60-d794-532c-acc0-73641f782813\"},{\"type\":\"user_defined_field\",\"id\":\"33457d2a-570c-5567-b4af-979a2a8f1164\"},{\"type\":\"user_defined_field\",\"id\":\"d003693c-bee9-5420-8d46-859269c20914\"},{\"type\":\"user_defined_field\",\"id\":\"1ddff6f6-cb1f-51a0-9d81-dc18ef52cc9d\"},{\"type\":\"user_defined_field\",\"id\":\"6bc9d32b-c2cd-591e-9b7a-74c886a5ddcf\"},{\"type\":\"user_defined_field\",\"id\":\"95c53547-2ba3-5d8a-9c3b-cf245bc0c629\"},{\"type\":\"user_defined_field\",\"id\":\"39044b03-cee4-555f-b1e0-3eb3aa759a86\"},{\"type\":\"user_defined_field\",\"id\":\"2b9f1063-b915-4c7a-8bbd-fc3940245529\"}]},\"integrations\":{\"data\":[]},\"attachments\":{\"data\":[]},\"responders\":{\"data\":[]},\"impacts\":{\"data\":[]}}}}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Thu, 09 Jul 2026 20:46:36 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"document_url\":\"https://docs.example.com/postmortem-test-get_postmortem_for_an_incident_returns_ok_response-1783629996\",\"title\":\"Postmortem for Test-Get_postmortem_for_an_incident_returns_OK_response-1783629996\"},\"type\":\"incident_postmortems\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/incidents/4832db36-b2ec-5f98-917a-3b2fff43a58c/postmortem" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"9a2e832e-e9b8-48f2-9251-f189ae5bae54\",\"type\":\"incident_postmortems\",\"attributes\":{\"created\":\"2026-07-09T20:46:37.029493Z\",\"document_id\":\"\",\"document_type\":\"\",\"document_url\":\"https://docs.example.com/postmortem-test-get_postmortem_for_an_incident_returns_ok_response-1783629996\",\"modified\":\"2026-07-09T20:46:37.029493Z\",\"status\":\"draft\",\"title\":\"Postmortem for Test-Get_postmortem_for_an_incident_returns_OK_response-1783629996\"},\"relationships\":{\"incident\":{\"data\":{\"id\":\"4832db36-b2ec-5f98-917a-3b2fff43a58c\",\"type\":\"incidents\"}},\"last_modified_by_user\":{\"data\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"type\":\"users\"}},\"postmortem_owner_responder\":{\"data\":null},\"postmortem_owner_user\":{\"data\":null}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Thu, 09 Jul 2026 20:46:36 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/incidents/4832db36-b2ec-5f98-917a-3b2fff43a58c/postmortem" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"9a2e832e-e9b8-48f2-9251-f189ae5bae54\",\"type\":\"incident_postmortems\",\"attributes\":{\"created\":\"2026-07-09T20:46:37.029493Z\",\"document_id\":\"\",\"document_type\":\"\",\"document_url\":\"https://docs.example.com/postmortem-test-get_postmortem_for_an_incident_returns_ok_response-1783629996\",\"modified\":\"2026-07-09T20:46:37.029493Z\",\"status\":\"draft\",\"title\":\"Postmortem for Test-Get_postmortem_for_an_incident_returns_OK_response-1783629996\"},\"relationships\":{\"incident\":{\"data\":{\"id\":\"4832db36-b2ec-5f98-917a-3b2fff43a58c\",\"type\":\"incidents\"}},\"last_modified_by_user\":{\"data\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"type\":\"users\"}},\"postmortem_owner_responder\":{\"data\":null},\"postmortem_owner_user\":{\"data\":null}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Thu, 09 Jul 2026 20:46:36 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/incidents/4832db36-b2ec-5f98-917a-3b2fff43a58c/postmortem" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Thu, 09 Jul 2026 20:46:36 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/incidents/4832db36-b2ec-5f98-917a-3b2fff43a58c" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Thu, 09 Jul 2026 20:46:36 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/incidents/Update-postmortem-for-an-incident-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/incidents/Update-postmortem-for-an-incident-returns-OK-response.frozen new file mode 100644 index 0000000000..de335b344d --- /dev/null +++ b/tests/scenarios/cassettes/v2/incidents/Update-postmortem-for-an-incident-returns-OK-response.frozen @@ -0,0 +1 @@ +2026-07-09T20:46:38.293Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/incidents/Update-postmortem-for-an-incident-returns-OK-response.json b/tests/scenarios/cassettes/v2/incidents/Update-postmortem-for-an-incident-returns-OK-response.json new file mode 100644 index 0000000000..95758080ce --- /dev/null +++ b/tests/scenarios/cassettes/v2/incidents/Update-postmortem-for-an-incident-returns-OK-response.json @@ -0,0 +1,155 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"customer_impacted\":false,\"title\":\"Test-Update_postmortem_for_an_incident_returns_OK_response-1783629998\"},\"type\":\"incidents\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/incidents" + }, + "response": { + "body": { + "string": "{\"data\":{\"type\":\"incidents\",\"id\":\"c22705d8-525c-52bd-89bc-c7b33823c592\",\"attributes\":{\"public_id\":364278,\"incident_type_uuid\":\"41d2e10b-4108-4736-92d7-791d00ea0702\",\"title\":\"Test-Update_postmortem_for_an_incident_returns_OK_response-1783629998\",\"resolved\":null,\"customer_impact_scope\":null,\"customer_impact_start\":null,\"customer_impact_end\":null,\"customer_impacted\":false,\"notification_handles\":null,\"last_modified_by\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"attributes\":{\"uuid\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"name\":\"CI Account\",\"icon\":\"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro\"}}},\"last_modified_by_uuid\":null,\"created\":\"2026-07-09T20:46:38.508134+00:00\",\"modified\":\"2026-07-09T20:46:38.508134+00:00\",\"commander\":null,\"detected\":\"2026-07-09T20:46:38.500429+00:00\",\"created_by\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"attributes\":{\"uuid\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"name\":\"CI Account\",\"icon\":\"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro\"}}},\"created_by_uuid\":null,\"creation_idempotency_key\":null,\"customer_impact_duration\":0,\"time_to_detect\":0,\"time_to_repair\":0,\"time_to_internal_response\":0,\"time_to_resolve\":0,\"is_test\":false,\"declared\":\"2026-07-09T20:46:38.508134+00:00\",\"declared_by\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"attributes\":{\"uuid\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"name\":\"CI Account\",\"icon\":\"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro\"}}},\"declared_by_uuid\":null,\"fields\":{\"teams\":{\"type\":\"autocomplete\",\"value\":null},\"severity\":{\"type\":\"dropdown\",\"value\":\"UNKNOWN\"},\"state\":{\"type\":\"dropdown\",\"value\":\"active\"},\"detection_method\":{\"type\":\"dropdown\",\"value\":\"unknown\"},\"root_cause\":{\"type\":\"textbox\",\"value\":null},\"summary\":{\"type\":\"textbox\",\"value\":null},\"services\":{\"type\":\"autocomplete\",\"value\":null},\"slug\":{\"type\":\"textbox\",\"value\":\"IR-364278\"}},\"field_analytics\":null,\"severity\":\"UNKNOWN\",\"state\":\"active\",\"non_datadog_creator\":null,\"visibility\":\"organization\",\"case_id\":null},\"relationships\":{\"created_by_user\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}},\"last_modified_by_user\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}},\"commander_user\":{\"data\":null},\"declared_by_user\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}},\"user_defined_fields\":{\"data\":[{\"type\":\"user_defined_field\",\"id\":\"3cbe9e60-d794-532c-acc0-73641f782813\"},{\"type\":\"user_defined_field\",\"id\":\"33457d2a-570c-5567-b4af-979a2a8f1164\"},{\"type\":\"user_defined_field\",\"id\":\"d003693c-bee9-5420-8d46-859269c20914\"},{\"type\":\"user_defined_field\",\"id\":\"1ddff6f6-cb1f-51a0-9d81-dc18ef52cc9d\"},{\"type\":\"user_defined_field\",\"id\":\"6bc9d32b-c2cd-591e-9b7a-74c886a5ddcf\"},{\"type\":\"user_defined_field\",\"id\":\"95c53547-2ba3-5d8a-9c3b-cf245bc0c629\"},{\"type\":\"user_defined_field\",\"id\":\"39044b03-cee4-555f-b1e0-3eb3aa759a86\"},{\"type\":\"user_defined_field\",\"id\":\"2b9f1063-b915-4c7a-8bbd-fc3940245529\"}]},\"integrations\":{\"data\":[]},\"attachments\":{\"data\":[]},\"responders\":{\"data\":[]},\"impacts\":{\"data\":[]}}}}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Thu, 09 Jul 2026 20:46:38 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"document_url\":\"https://docs.example.com/postmortem-test-update_postmortem_for_an_incident_returns_ok_response-1783629998\",\"title\":\"Postmortem for Test-Update_postmortem_for_an_incident_returns_OK_response-1783629998\"},\"type\":\"incident_postmortems\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/incidents/c22705d8-525c-52bd-89bc-c7b33823c592/postmortem" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"d37b1ea1-eeae-4fc9-93d0-41e64d9df187\",\"type\":\"incident_postmortems\",\"attributes\":{\"created\":\"2026-07-09T20:46:38.961153Z\",\"document_id\":\"\",\"document_type\":\"\",\"document_url\":\"https://docs.example.com/postmortem-test-update_postmortem_for_an_incident_returns_ok_response-1783629998\",\"modified\":\"2026-07-09T20:46:38.961153Z\",\"status\":\"draft\",\"title\":\"Postmortem for Test-Update_postmortem_for_an_incident_returns_OK_response-1783629998\"},\"relationships\":{\"incident\":{\"data\":{\"id\":\"c22705d8-525c-52bd-89bc-c7b33823c592\",\"type\":\"incidents\"}},\"last_modified_by_user\":{\"data\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"type\":\"users\"}},\"postmortem_owner_responder\":{\"data\":null},\"postmortem_owner_user\":{\"data\":null}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Thu, 09 Jul 2026 20:46:38 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"status\":\"in_review\"},\"id\":\"d37b1ea1-eeae-4fc9-93d0-41e64d9df187\",\"type\":\"incident_postmortems\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "patch", + "uri": "https://api.datadoghq.com/api/v2/incidents/c22705d8-525c-52bd-89bc-c7b33823c592/postmortem" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"d37b1ea1-eeae-4fc9-93d0-41e64d9df187\",\"type\":\"incident_postmortems\",\"attributes\":{\"created\":\"2026-07-09T20:46:38.961153Z\",\"document_id\":\"\",\"document_type\":\"\",\"document_url\":\"https://docs.example.com/postmortem-test-update_postmortem_for_an_incident_returns_ok_response-1783629998\",\"modified\":\"2026-07-09T20:46:43.136363Z\",\"status\":\"in_review\",\"title\":\"Postmortem for Test-Update_postmortem_for_an_incident_returns_OK_response-1783629998\"},\"relationships\":{\"incident\":{\"data\":{\"id\":\"c22705d8-525c-52bd-89bc-c7b33823c592\",\"type\":\"incidents\"}},\"last_modified_by_user\":{\"data\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"type\":\"users\"}},\"postmortem_owner_responder\":{\"data\":null},\"postmortem_owner_user\":{\"data\":null}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Thu, 09 Jul 2026 20:46:38 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/incidents/c22705d8-525c-52bd-89bc-c7b33823c592/postmortem" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Thu, 09 Jul 2026 20:46:38 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/incidents/c22705d8-525c-52bd-89bc-c7b33823c592" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Thu, 09 Jul 2026 20:46:38 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 0f9de6d48a..d4b1c01299 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -602,6 +602,22 @@ "key": "incident_impact", "tag": "Incidents" }, + { + "parameters": [ + { + "name": "incident_id", + "source": "incident.data.id" + }, + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"incident_postmortems\",\n \"attributes\": {\n \"title\": \"Postmortem for {{ unique }}\",\n \"document_url\": \"https://docs.example.com/postmortem-{{ unique_lower }}\"\n }\n }\n}" + } + ], + "step": "there is a valid \"postmortem\" in the system", + "key": "postmortem", + "tag": "Incidents", + "operationId": "CreateIncidentPostmortem" + }, { "parameters": [ { diff --git a/tests/scenarios/features/v2/incidents.feature b/tests/scenarios/features/v2/incidents.feature index 646ec88d87..f06b7f6c83 100644 --- a/tests/scenarios/features/v2/incidents.feature +++ b/tests/scenarios/features/v2/incidents.feature @@ -314,6 +314,45 @@ Feature: Incidents When the request is sent Then the response status is 201 Created + @generated @skip @team:DataDog/incident-app + Scenario: Create postmortem for an incident returns "Bad Request" response + Given operation "CreateIncidentPostmortem" enabled + And new "CreateIncidentPostmortem" request + And request contains "incident_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"document_url": "https://app.datadoghq.com/notebook/123", "title": "Postmortem for IR-123"}, "type": "incident_postmortems"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/incident-app + Scenario: Create postmortem for an incident returns "CREATED" response + Given operation "CreateIncidentPostmortem" enabled + And there is a valid "incident" in the system + And new "CreateIncidentPostmortem" request + And request contains "incident_id" parameter from "incident.data.id" + And body with value {"data": {"attributes": {"document_url": "https://app.datadoghq.com/notebook/123", "title": "Postmortem for IR-123"}, "type": "incident_postmortems"}} + When the request is sent + Then the response status is 201 CREATED + And the response "data.type" is equal to "incident_postmortems" + And the response "data.relationships.incident.data.id" has the same value as "incident.data.id" + + @generated @skip @team:DataDog/incident-app + Scenario: Create postmortem for an incident returns "Conflict" response + Given operation "CreateIncidentPostmortem" enabled + And new "CreateIncidentPostmortem" request + And request contains "incident_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"document_url": "https://app.datadoghq.com/notebook/123", "title": "Postmortem for IR-123"}, "type": "incident_postmortems"}} + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:DataDog/incident-app + Scenario: Create postmortem for an incident returns "Not Found" response + Given operation "CreateIncidentPostmortem" enabled + And new "CreateIncidentPostmortem" request + And request contains "incident_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"document_url": "https://app.datadoghq.com/notebook/123", "title": "Postmortem for IR-123"}, "type": "incident_postmortems"}} + When the request is sent + Then the response status is 404 Not Found + @generated @skip @team:DataDog/incident-app Scenario: Create postmortem template returns "Bad Request" response Given operation "CreateIncidentPostmortemTemplate" enabled @@ -601,6 +640,32 @@ Feature: Incidents When the request is sent Then the response status is 204 No Content + @generated @skip @team:DataDog/incident-app + Scenario: Delete postmortem for an incident returns "Bad Request" response + Given operation "DeleteIncidentPostmortem" enabled + And new "DeleteIncidentPostmortem" request + And request contains "incident_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Delete postmortem for an incident returns "Not Found" response + Given operation "DeleteIncidentPostmortem" enabled + And new "DeleteIncidentPostmortem" request + And request contains "incident_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/incident-app + Scenario: Delete postmortem for an incident returns "OK" response + Given operation "DeleteIncidentPostmortem" enabled + And there is a valid "incident" in the system + And there is a valid "postmortem" in the system + And new "DeleteIncidentPostmortem" request + And request contains "incident_id" parameter from "postmortem.data.relationships.incident.data.id" + When the request is sent + Then the response status is 204 OK + @generated @skip @team:DataDog/incident-app Scenario: Delete postmortem template returns "Bad Request" response Given operation "DeleteIncidentPostmortemTemplate" enabled @@ -929,6 +994,33 @@ Feature: Incidents When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/incident-app + Scenario: Get postmortem for an incident returns "Bad Request" response + Given operation "GetIncidentPostmortem" enabled + And new "GetIncidentPostmortem" request + And request contains "incident_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Get postmortem for an incident returns "Not Found" response + Given operation "GetIncidentPostmortem" enabled + And new "GetIncidentPostmortem" request + And request contains "incident_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/incident-app + Scenario: Get postmortem for an incident returns "OK" response + Given operation "GetIncidentPostmortem" enabled + And there is a valid "incident" in the system + And there is a valid "postmortem" in the system + And new "GetIncidentPostmortem" request + And request contains "incident_id" parameter from "postmortem.data.relationships.incident.data.id" + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.title" has the same value as "postmortem.data.attributes.title" + @generated @skip @team:DataDog/incident-app Scenario: Get postmortem template returns "Bad Request" response Given operation "GetIncidentPostmortemTemplate" enabled @@ -1480,6 +1572,36 @@ Feature: Incidents And the response "data.attributes.name" has the same value as "unique" And the response "data.attributes.category" is equal to "update" + @generated @skip @team:DataDog/incident-app + Scenario: Update postmortem for an incident returns "Bad Request" response + Given operation "UpdateIncidentPostmortem" enabled + And new "UpdateIncidentPostmortem" request + And request contains "incident_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"status": "draft"}, "id": "00000000-0000-abcd-1000-000000000000", "type": "incident_postmortems"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Update postmortem for an incident returns "Not Found" response + Given operation "UpdateIncidentPostmortem" enabled + And new "UpdateIncidentPostmortem" request + And request contains "incident_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"status": "draft"}, "id": "00000000-0000-abcd-1000-000000000000", "type": "incident_postmortems"}} + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/incident-app + Scenario: Update postmortem for an incident returns "OK" response + Given operation "UpdateIncidentPostmortem" enabled + And there is a valid "incident" in the system + And there is a valid "postmortem" in the system + And new "UpdateIncidentPostmortem" request + And request contains "incident_id" parameter from "postmortem.data.relationships.incident.data.id" + And body with value {"data": {"attributes": {"status": "in_review"}, "id": "{{ postmortem.data.id }}", "type": "incident_postmortems"}} + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.status" is equal to "in_review" + @generated @skip @team:DataDog/incident-app Scenario: Update postmortem template returns "Bad Request" response Given operation "UpdateIncidentPostmortemTemplate" enabled diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 1eaba52ee9..d9d1f7b28d 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -3218,6 +3218,37 @@ "type": "idempotent" } }, + "DeleteIncidentPostmortem": { + "tag": "Incidents", + "undo": { + "type": "idempotent" + } + }, + "GetIncidentPostmortem": { + "tag": "Incidents", + "undo": { + "type": "safe" + } + }, + "UpdateIncidentPostmortem": { + "tag": "Incidents", + "undo": { + "type": "idempotent" + } + }, + "CreateIncidentPostmortem": { + "tag": "Incidents", + "undo": { + "operationId": "DeleteIncidentPostmortem", + "parameters": [ + { + "name": "incident_id", + "source": "data.relationships.incident.data.id" + } + ], + "type": "unsafe" + } + }, "ListIncidentIntegrations": { "tag": "Incidents", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 17934d0b8b..34b4deffc0 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -5130,6 +5130,22 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.DeleteIncidentImpact".into(), test_v2_delete_incident_impact, ); + world.function_mappings.insert( + "v2.DeleteIncidentPostmortem".into(), + test_v2_delete_incident_postmortem, + ); + world.function_mappings.insert( + "v2.GetIncidentPostmortem".into(), + test_v2_get_incident_postmortem, + ); + world.function_mappings.insert( + "v2.UpdateIncidentPostmortem".into(), + test_v2_update_incident_postmortem, + ); + world.function_mappings.insert( + "v2.CreateIncidentPostmortem".into(), + test_v2_create_incident_postmortem, + ); world.function_mappings.insert( "v2.ListIncidentIntegrations".into(), test_v2_list_incident_integrations, @@ -39460,6 +39476,138 @@ fn test_v2_delete_incident_impact(world: &mut DatadogWorld, _parameters: &HashMa world.response.code = response.status.as_u16(); } +fn test_v2_delete_incident_postmortem( + 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 response = match block_on(api.delete_incident_postmortem_with_http_info(incident_id)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_get_incident_postmortem(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 mut params = datadogV2::api_incidents::GetIncidentPostmortemOptionalParams::default(); + params.include = include; + let response = match block_on(api.get_incident_postmortem_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_update_incident_postmortem( + 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::UpdateIncidentPostmortemOptionalParams::default(); + params.include = include; + let response = + match block_on(api.update_incident_postmortem_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_create_incident_postmortem( + 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::CreateIncidentPostmortemOptionalParams::default(); + params.include = include; + let response = + match block_on(api.create_incident_postmortem_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_list_incident_integrations( world: &mut DatadogWorld, _parameters: &HashMap,