From a317127d30a97e5c74958056bfc33c31df9a0519 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 10 Jul 2026 17:36:49 +0000 Subject: [PATCH] Regenerate client from commit 91098ba of spec repo --- .generator/schemas/v2/openapi.yaml | 451 ++++++++++++++++++ api/datadog/configuration.go | 4 + api/datadogV2/api_incidents.go | 431 +++++++++++++++++ api/datadogV2/doc.go | 4 + .../model_incident_postmortem_attributes.go | 312 ++++++++++++ ...l_incident_postmortem_create_attributes.go | 133 ++++++ .../model_incident_postmortem_create_data.go | 148 ++++++ ...odel_incident_postmortem_create_request.go | 110 +++++ .../model_incident_postmortem_data.go | 215 +++++++++ .../model_incident_postmortem_included.go | 105 ++++ ...model_incident_postmortem_relationships.go | 241 ++++++++++ .../model_incident_postmortem_response.go | 145 ++++++ ...l_incident_postmortem_update_attributes.go | 112 +++++ .../model_incident_postmortem_update_data.go | 180 +++++++ ...odel_incident_postmortem_update_request.go | 110 +++++ ...relationship_to_incident_responder_data.go | 193 ++++++++ api/datadogV2/model_postmortem_status.go | 68 +++ ...odel_relationship_to_incident_responder.go | 153 ++++++ .../v2/incidents/CreateIncidentPostmortem.go | 42 ++ .../v2/incidents/DeleteIncidentPostmortem.go | 29 ++ .../v2/incidents/GetIncidentPostmortem.go | 33 ++ .../v2/incidents/UpdateIncidentPostmortem.go | 43 ++ ...n_incident_returns_CREATED_response.freeze | 1 + ..._an_incident_returns_CREATED_response.yaml | 78 +++ ...for_an_incident_returns_OK_response.freeze | 1 + ...m_for_an_incident_returns_OK_response.yaml | 95 ++++ ...for_an_incident_returns_OK_response.freeze | 1 + ...m_for_an_incident_returns_OK_response.yaml | 96 ++++ ...for_an_incident_returns_OK_response.freeze | 1 + ...m_for_an_incident_returns_OK_response.yaml | 99 ++++ tests/scenarios/features/v2/given.json | 16 + tests/scenarios/features/v2/incidents.feature | 122 +++++ tests/scenarios/features/v2/undo.json | 31 ++ 33 files changed, 3803 insertions(+) create mode 100644 api/datadogV2/model_incident_postmortem_attributes.go create mode 100644 api/datadogV2/model_incident_postmortem_create_attributes.go create mode 100644 api/datadogV2/model_incident_postmortem_create_data.go create mode 100644 api/datadogV2/model_incident_postmortem_create_request.go create mode 100644 api/datadogV2/model_incident_postmortem_data.go create mode 100644 api/datadogV2/model_incident_postmortem_included.go create mode 100644 api/datadogV2/model_incident_postmortem_relationships.go create mode 100644 api/datadogV2/model_incident_postmortem_response.go create mode 100644 api/datadogV2/model_incident_postmortem_update_attributes.go create mode 100644 api/datadogV2/model_incident_postmortem_update_data.go create mode 100644 api/datadogV2/model_incident_postmortem_update_request.go create mode 100644 api/datadogV2/model_nullable_relationship_to_incident_responder_data.go create mode 100644 api/datadogV2/model_postmortem_status.go create mode 100644 api/datadogV2/model_relationship_to_incident_responder.go create mode 100644 examples/v2/incidents/CreateIncidentPostmortem.go create mode 100644 examples/v2/incidents/DeleteIncidentPostmortem.go create mode 100644 examples/v2/incidents/GetIncidentPostmortem.go create mode 100644 examples/v2/incidents/UpdateIncidentPostmortem.go create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Create_postmortem_for_an_incident_returns_CREATED_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Create_postmortem_for_an_incident_returns_CREATED_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Delete_postmortem_for_an_incident_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Delete_postmortem_for_an_incident_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_postmortem_for_an_incident_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_postmortem_for_an_incident_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Update_postmortem_for_an_incident_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Update_postmortem_for_an_incident_returns_OK_response.yaml diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 5638f0c0dfa..9a2db4ea428 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/api/datadog/configuration.go b/api/datadog/configuration.go index 9d96ad0c12a..1a69ca381bc 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -978,6 +978,7 @@ func NewConfiguration() *Configuration { "v2.CreateIncidentIntegration": false, "v2.CreateIncidentNotificationRule": false, "v2.CreateIncidentNotificationTemplate": false, + "v2.CreateIncidentPostmortem": false, "v2.CreateIncidentPostmortemAttachment": false, "v2.CreateIncidentPostmortemTemplate": false, "v2.CreateIncidentTodo": false, @@ -989,6 +990,7 @@ func NewConfiguration() *Configuration { "v2.DeleteIncidentIntegration": false, "v2.DeleteIncidentNotificationRule": false, "v2.DeleteIncidentNotificationTemplate": false, + "v2.DeleteIncidentPostmortem": false, "v2.DeleteIncidentPostmortemTemplate": false, "v2.DeleteIncidentTodo": false, "v2.DeleteIncidentType": false, @@ -998,6 +1000,7 @@ func NewConfiguration() *Configuration { "v2.GetIncidentIntegration": false, "v2.GetIncidentNotificationRule": false, "v2.GetIncidentNotificationTemplate": false, + "v2.GetIncidentPostmortem": false, "v2.GetIncidentPostmortemTemplate": false, "v2.GetIncidentTodo": false, "v2.GetIncidentType": false, @@ -1021,6 +1024,7 @@ func NewConfiguration() *Configuration { "v2.UpdateIncidentIntegration": false, "v2.UpdateIncidentNotificationRule": false, "v2.UpdateIncidentNotificationTemplate": false, + "v2.UpdateIncidentPostmortem": false, "v2.UpdateIncidentPostmortemTemplate": false, "v2.UpdateIncidentTodo": false, "v2.UpdateIncidentType": false, diff --git a/api/datadogV2/api_incidents.go b/api/datadogV2/api_incidents.go index aacbc6be95a..c32f1cbb9d7 100644 --- a/api/datadogV2/api_incidents.go +++ b/api/datadogV2/api_incidents.go @@ -728,6 +728,127 @@ func (a *IncidentsApi) CreateIncidentNotificationTemplate(ctx _context.Context, return localVarReturnValue, localVarHTTPResponse, nil } +// CreateIncidentPostmortemOptionalParameters holds optional parameters for CreateIncidentPostmortem. +type CreateIncidentPostmortemOptionalParameters struct { + Include *string +} + +// NewCreateIncidentPostmortemOptionalParameters creates an empty struct for parameters. +func NewCreateIncidentPostmortemOptionalParameters() *CreateIncidentPostmortemOptionalParameters { + this := CreateIncidentPostmortemOptionalParameters{} + return &this +} + +// WithInclude sets the corresponding parameter name and returns the struct. +func (r *CreateIncidentPostmortemOptionalParameters) WithInclude(include string) *CreateIncidentPostmortemOptionalParameters { + r.Include = &include + return r +} + +// CreateIncidentPostmortem Create postmortem for an incident. +// 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. +func (a *IncidentsApi) CreateIncidentPostmortem(ctx _context.Context, incidentId string, body IncidentPostmortemCreateRequest, o ...CreateIncidentPostmortemOptionalParameters) (IncidentPostmortemResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue IncidentPostmortemResponse + optionalParams CreateIncidentPostmortemOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type CreateIncidentPostmortemOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + operationId := "v2.CreateIncidentPostmortem" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentsApi.CreateIncidentPostmortem") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/incidents/{incident_id}/postmortem" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{incident_id}", _neturl.PathEscape(datadog.ParameterToString(incidentId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.Include != nil { + localVarQueryParams.Add("include", datadog.ParameterToString(*optionalParams.Include, "")) + } + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 409 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // CreateIncidentPostmortemAttachment Create postmortem attachment. // Create a postmortem attachment for an incident. // @@ -1831,6 +1952,83 @@ func (a *IncidentsApi) DeleteIncidentNotificationTemplate(ctx _context.Context, return localVarHTTPResponse, nil } +// DeleteIncidentPostmortem Delete postmortem for an incident. +// Delete the postmortem attached to an incident. +func (a *IncidentsApi) DeleteIncidentPostmortem(ctx _context.Context, incidentId string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + operationId := "v2.DeleteIncidentPostmortem" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentsApi.DeleteIncidentPostmortem") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/incidents/{incident_id}/postmortem" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{incident_id}", _neturl.PathEscape(datadog.ParameterToString(incidentId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "*/*" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + // DeleteIncidentPostmortemTemplate Delete postmortem template. // Delete a postmortem template. func (a *IncidentsApi) DeleteIncidentPostmortemTemplate(ctx _context.Context, templateId string) (*_nethttp.Response, error) { @@ -2686,6 +2884,121 @@ func (a *IncidentsApi) GetIncidentNotificationTemplate(ctx _context.Context, id return localVarReturnValue, localVarHTTPResponse, nil } +// GetIncidentPostmortemOptionalParameters holds optional parameters for GetIncidentPostmortem. +type GetIncidentPostmortemOptionalParameters struct { + Include *string +} + +// NewGetIncidentPostmortemOptionalParameters creates an empty struct for parameters. +func NewGetIncidentPostmortemOptionalParameters() *GetIncidentPostmortemOptionalParameters { + this := GetIncidentPostmortemOptionalParameters{} + return &this +} + +// WithInclude sets the corresponding parameter name and returns the struct. +func (r *GetIncidentPostmortemOptionalParameters) WithInclude(include string) *GetIncidentPostmortemOptionalParameters { + r.Include = &include + return r +} + +// GetIncidentPostmortem Get postmortem for an incident. +// Get the postmortem attached to an incident. +func (a *IncidentsApi) GetIncidentPostmortem(ctx _context.Context, incidentId string, o ...GetIncidentPostmortemOptionalParameters) (IncidentPostmortemResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue IncidentPostmortemResponse + optionalParams GetIncidentPostmortemOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type GetIncidentPostmortemOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + operationId := "v2.GetIncidentPostmortem" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentsApi.GetIncidentPostmortem") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/incidents/{incident_id}/postmortem" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{incident_id}", _neturl.PathEscape(datadog.ParameterToString(incidentId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.Include != nil { + localVarQueryParams.Add("include", datadog.ParameterToString(*optionalParams.Include, "")) + } + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // GetIncidentPostmortemTemplate Get postmortem template. // Retrieve details of a specific postmortem template. func (a *IncidentsApi) GetIncidentPostmortemTemplate(ctx _context.Context, templateId string) (PostmortemTemplateResponse, *_nethttp.Response, error) { @@ -5513,6 +5826,124 @@ func (a *IncidentsApi) UpdateIncidentNotificationTemplate(ctx _context.Context, return localVarReturnValue, localVarHTTPResponse, nil } +// UpdateIncidentPostmortemOptionalParameters holds optional parameters for UpdateIncidentPostmortem. +type UpdateIncidentPostmortemOptionalParameters struct { + Include *string +} + +// NewUpdateIncidentPostmortemOptionalParameters creates an empty struct for parameters. +func NewUpdateIncidentPostmortemOptionalParameters() *UpdateIncidentPostmortemOptionalParameters { + this := UpdateIncidentPostmortemOptionalParameters{} + return &this +} + +// WithInclude sets the corresponding parameter name and returns the struct. +func (r *UpdateIncidentPostmortemOptionalParameters) WithInclude(include string) *UpdateIncidentPostmortemOptionalParameters { + r.Include = &include + return r +} + +// UpdateIncidentPostmortem Update postmortem for an incident. +// Update the postmortem attached to an incident, for example to change its status. +func (a *IncidentsApi) UpdateIncidentPostmortem(ctx _context.Context, incidentId string, body IncidentPostmortemUpdateRequest, o ...UpdateIncidentPostmortemOptionalParameters) (IncidentPostmortemResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue IncidentPostmortemResponse + optionalParams UpdateIncidentPostmortemOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type UpdateIncidentPostmortemOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + operationId := "v2.UpdateIncidentPostmortem" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentsApi.UpdateIncidentPostmortem") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/incidents/{incident_id}/postmortem" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{incident_id}", _neturl.PathEscape(datadog.ParameterToString(incidentId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.Include != nil { + localVarQueryParams.Add("include", datadog.ParameterToString(*optionalParams.Include, "")) + } + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // UpdateIncidentPostmortemTemplate Update postmortem template. // Update an existing postmortem template. func (a *IncidentsApi) UpdateIncidentPostmortemTemplate(ctx _context.Context, templateId string, body PostmortemTemplateRequest) (PostmortemTemplateResponse, *_nethttp.Response, error) { diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 140606af346..7395dee9253 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -504,6 +504,7 @@ // - [IncidentsApi.CreateIncidentIntegration] // - [IncidentsApi.CreateIncidentNotificationRule] // - [IncidentsApi.CreateIncidentNotificationTemplate] +// - [IncidentsApi.CreateIncidentPostmortem] // - [IncidentsApi.CreateIncidentPostmortemAttachment] // - [IncidentsApi.CreateIncidentPostmortemTemplate] // - [IncidentsApi.CreateIncidentTodo] @@ -516,6 +517,7 @@ // - [IncidentsApi.DeleteIncidentIntegration] // - [IncidentsApi.DeleteIncidentNotificationRule] // - [IncidentsApi.DeleteIncidentNotificationTemplate] +// - [IncidentsApi.DeleteIncidentPostmortem] // - [IncidentsApi.DeleteIncidentPostmortemTemplate] // - [IncidentsApi.DeleteIncidentTodo] // - [IncidentsApi.DeleteIncidentType] @@ -525,6 +527,7 @@ // - [IncidentsApi.GetIncidentIntegration] // - [IncidentsApi.GetIncidentNotificationRule] // - [IncidentsApi.GetIncidentNotificationTemplate] +// - [IncidentsApi.GetIncidentPostmortem] // - [IncidentsApi.GetIncidentPostmortemTemplate] // - [IncidentsApi.GetIncidentTodo] // - [IncidentsApi.GetIncidentType] @@ -549,6 +552,7 @@ // - [IncidentsApi.UpdateIncidentIntegration] // - [IncidentsApi.UpdateIncidentNotificationRule] // - [IncidentsApi.UpdateIncidentNotificationTemplate] +// - [IncidentsApi.UpdateIncidentPostmortem] // - [IncidentsApi.UpdateIncidentPostmortemTemplate] // - [IncidentsApi.UpdateIncidentTodo] // - [IncidentsApi.UpdateIncidentType] diff --git a/api/datadogV2/model_incident_postmortem_attributes.go b/api/datadogV2/model_incident_postmortem_attributes.go new file mode 100644 index 00000000000..479f7f4cf02 --- /dev/null +++ b/api/datadogV2/model_incident_postmortem_attributes.go @@ -0,0 +1,312 @@ +// 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. + +package datadogV2 + +import ( + "fmt" + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// IncidentPostmortemAttributes The postmortem's attributes. +type IncidentPostmortemAttributes struct { + // Timestamp when the postmortem was created. + Created time.Time `json:"created"` + // The identifier of the postmortem document within its host platform. + DocumentId string `json:"document_id"` + // The type of document backing the postmortem (for example, `datadog_notebooks`, `confluence`, or `google_docs`). Can be empty if the document type is unknown. + DocumentType string `json:"document_type"` + // The URL of the postmortem document. + DocumentUrl string `json:"document_url"` + // Timestamp when the postmortem was last modified. + Modified time.Time `json:"modified"` + // The status of the postmortem. + Status PostmortemStatus `json:"status"` + // The title of the postmortem. + Title string `json:"title"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewIncidentPostmortemAttributes instantiates a new IncidentPostmortemAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewIncidentPostmortemAttributes(created time.Time, documentId string, documentType string, documentUrl string, modified time.Time, status PostmortemStatus, title string) *IncidentPostmortemAttributes { + this := IncidentPostmortemAttributes{} + this.Created = created + this.DocumentId = documentId + this.DocumentType = documentType + this.DocumentUrl = documentUrl + this.Modified = modified + this.Status = status + this.Title = title + return &this +} + +// NewIncidentPostmortemAttributesWithDefaults instantiates a new IncidentPostmortemAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewIncidentPostmortemAttributesWithDefaults() *IncidentPostmortemAttributes { + this := IncidentPostmortemAttributes{} + return &this +} + +// GetCreated returns the Created field value. +func (o *IncidentPostmortemAttributes) GetCreated() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.Created +} + +// GetCreatedOk returns a tuple with the Created field value +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemAttributes) GetCreatedOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.Created, true +} + +// SetCreated sets field value. +func (o *IncidentPostmortemAttributes) SetCreated(v time.Time) { + o.Created = v +} + +// GetDocumentId returns the DocumentId field value. +func (o *IncidentPostmortemAttributes) GetDocumentId() string { + if o == nil { + var ret string + return ret + } + return o.DocumentId +} + +// GetDocumentIdOk returns a tuple with the DocumentId field value +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemAttributes) GetDocumentIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.DocumentId, true +} + +// SetDocumentId sets field value. +func (o *IncidentPostmortemAttributes) SetDocumentId(v string) { + o.DocumentId = v +} + +// GetDocumentType returns the DocumentType field value. +func (o *IncidentPostmortemAttributes) GetDocumentType() string { + if o == nil { + var ret string + return ret + } + return o.DocumentType +} + +// GetDocumentTypeOk returns a tuple with the DocumentType field value +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemAttributes) GetDocumentTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.DocumentType, true +} + +// SetDocumentType sets field value. +func (o *IncidentPostmortemAttributes) SetDocumentType(v string) { + o.DocumentType = v +} + +// GetDocumentUrl returns the DocumentUrl field value. +func (o *IncidentPostmortemAttributes) GetDocumentUrl() string { + if o == nil { + var ret string + return ret + } + return o.DocumentUrl +} + +// GetDocumentUrlOk returns a tuple with the DocumentUrl field value +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemAttributes) GetDocumentUrlOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.DocumentUrl, true +} + +// SetDocumentUrl sets field value. +func (o *IncidentPostmortemAttributes) SetDocumentUrl(v string) { + o.DocumentUrl = v +} + +// GetModified returns the Modified field value. +func (o *IncidentPostmortemAttributes) GetModified() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.Modified +} + +// GetModifiedOk returns a tuple with the Modified field value +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemAttributes) GetModifiedOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.Modified, true +} + +// SetModified sets field value. +func (o *IncidentPostmortemAttributes) SetModified(v time.Time) { + o.Modified = v +} + +// GetStatus returns the Status field value. +func (o *IncidentPostmortemAttributes) GetStatus() PostmortemStatus { + if o == nil { + var ret PostmortemStatus + return ret + } + return o.Status +} + +// GetStatusOk returns a tuple with the Status field value +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemAttributes) GetStatusOk() (*PostmortemStatus, bool) { + if o == nil { + return nil, false + } + return &o.Status, true +} + +// SetStatus sets field value. +func (o *IncidentPostmortemAttributes) SetStatus(v PostmortemStatus) { + o.Status = v +} + +// GetTitle returns the Title field value. +func (o *IncidentPostmortemAttributes) GetTitle() string { + if o == nil { + var ret string + return ret + } + return o.Title +} + +// GetTitleOk returns a tuple with the Title field value +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemAttributes) GetTitleOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Title, true +} + +// SetTitle sets field value. +func (o *IncidentPostmortemAttributes) SetTitle(v string) { + o.Title = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentPostmortemAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Created.Nanosecond() == 0 { + toSerialize["created"] = o.Created.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["created"] = o.Created.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["document_id"] = o.DocumentId + toSerialize["document_type"] = o.DocumentType + toSerialize["document_url"] = o.DocumentUrl + if o.Modified.Nanosecond() == 0 { + toSerialize["modified"] = o.Modified.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["modified"] = o.Modified.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["status"] = o.Status + toSerialize["title"] = o.Title + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentPostmortemAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Created *time.Time `json:"created"` + DocumentId *string `json:"document_id"` + DocumentType *string `json:"document_type"` + DocumentUrl *string `json:"document_url"` + Modified *time.Time `json:"modified"` + Status *PostmortemStatus `json:"status"` + Title *string `json:"title"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Created == nil { + return fmt.Errorf("required field created missing") + } + if all.DocumentId == nil { + return fmt.Errorf("required field document_id missing") + } + if all.DocumentType == nil { + return fmt.Errorf("required field document_type missing") + } + if all.DocumentUrl == nil { + return fmt.Errorf("required field document_url missing") + } + if all.Modified == nil { + return fmt.Errorf("required field modified missing") + } + if all.Status == nil { + return fmt.Errorf("required field status missing") + } + if all.Title == nil { + return fmt.Errorf("required field title missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"created", "document_id", "document_type", "document_url", "modified", "status", "title"}) + } else { + return err + } + + hasInvalidField := false + o.Created = *all.Created + o.DocumentId = *all.DocumentId + o.DocumentType = *all.DocumentType + o.DocumentUrl = *all.DocumentUrl + o.Modified = *all.Modified + if !all.Status.IsValid() { + hasInvalidField = true + } else { + o.Status = *all.Status + } + o.Title = *all.Title + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_incident_postmortem_create_attributes.go b/api/datadogV2/model_incident_postmortem_create_attributes.go new file mode 100644 index 00000000000..27bb2f25aef --- /dev/null +++ b/api/datadogV2/model_incident_postmortem_create_attributes.go @@ -0,0 +1,133 @@ +// 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. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// IncidentPostmortemCreateAttributes The postmortem's attributes for a creation request. +type IncidentPostmortemCreateAttributes struct { + // The URL of the postmortem document (for example, a Datadog notebook, Confluence page, or Google Doc). + DocumentUrl string `json:"document_url"` + // The title of the postmortem. + Title string `json:"title"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewIncidentPostmortemCreateAttributes instantiates a new IncidentPostmortemCreateAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewIncidentPostmortemCreateAttributes(documentUrl string, title string) *IncidentPostmortemCreateAttributes { + this := IncidentPostmortemCreateAttributes{} + this.DocumentUrl = documentUrl + this.Title = title + return &this +} + +// NewIncidentPostmortemCreateAttributesWithDefaults instantiates a new IncidentPostmortemCreateAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewIncidentPostmortemCreateAttributesWithDefaults() *IncidentPostmortemCreateAttributes { + this := IncidentPostmortemCreateAttributes{} + return &this +} + +// GetDocumentUrl returns the DocumentUrl field value. +func (o *IncidentPostmortemCreateAttributes) GetDocumentUrl() string { + if o == nil { + var ret string + return ret + } + return o.DocumentUrl +} + +// GetDocumentUrlOk returns a tuple with the DocumentUrl field value +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemCreateAttributes) GetDocumentUrlOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.DocumentUrl, true +} + +// SetDocumentUrl sets field value. +func (o *IncidentPostmortemCreateAttributes) SetDocumentUrl(v string) { + o.DocumentUrl = v +} + +// GetTitle returns the Title field value. +func (o *IncidentPostmortemCreateAttributes) GetTitle() string { + if o == nil { + var ret string + return ret + } + return o.Title +} + +// GetTitleOk returns a tuple with the Title field value +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemCreateAttributes) GetTitleOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Title, true +} + +// SetTitle sets field value. +func (o *IncidentPostmortemCreateAttributes) SetTitle(v string) { + o.Title = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentPostmortemCreateAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["document_url"] = o.DocumentUrl + toSerialize["title"] = o.Title + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentPostmortemCreateAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + DocumentUrl *string `json:"document_url"` + Title *string `json:"title"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.DocumentUrl == nil { + return fmt.Errorf("required field document_url missing") + } + if all.Title == nil { + return fmt.Errorf("required field title missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"document_url", "title"}) + } else { + return err + } + o.DocumentUrl = *all.DocumentUrl + o.Title = *all.Title + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_incident_postmortem_create_data.go b/api/datadogV2/model_incident_postmortem_create_data.go new file mode 100644 index 00000000000..637217a4074 --- /dev/null +++ b/api/datadogV2/model_incident_postmortem_create_data.go @@ -0,0 +1,148 @@ +// 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. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// IncidentPostmortemCreateData The postmortem resource for a creation request. +type IncidentPostmortemCreateData struct { + // The postmortem's attributes for a creation request. + Attributes IncidentPostmortemCreateAttributes `json:"attributes"` + // Incident postmortem resource type. + Type IncidentPostmortemType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewIncidentPostmortemCreateData instantiates a new IncidentPostmortemCreateData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewIncidentPostmortemCreateData(attributes IncidentPostmortemCreateAttributes, typeVar IncidentPostmortemType) *IncidentPostmortemCreateData { + this := IncidentPostmortemCreateData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewIncidentPostmortemCreateDataWithDefaults instantiates a new IncidentPostmortemCreateData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewIncidentPostmortemCreateDataWithDefaults() *IncidentPostmortemCreateData { + this := IncidentPostmortemCreateData{} + var typeVar IncidentPostmortemType = INCIDENTPOSTMORTEMTYPE_INCIDENT_POSTMORTEMS + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *IncidentPostmortemCreateData) GetAttributes() IncidentPostmortemCreateAttributes { + if o == nil { + var ret IncidentPostmortemCreateAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemCreateData) GetAttributesOk() (*IncidentPostmortemCreateAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *IncidentPostmortemCreateData) SetAttributes(v IncidentPostmortemCreateAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *IncidentPostmortemCreateData) GetType() IncidentPostmortemType { + if o == nil { + var ret IncidentPostmortemType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemCreateData) GetTypeOk() (*IncidentPostmortemType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *IncidentPostmortemCreateData) SetType(v IncidentPostmortemType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentPostmortemCreateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentPostmortemCreateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *IncidentPostmortemCreateAttributes `json:"attributes"` + Type *IncidentPostmortemType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_incident_postmortem_create_request.go b/api/datadogV2/model_incident_postmortem_create_request.go new file mode 100644 index 00000000000..fdcfbb75dd1 --- /dev/null +++ b/api/datadogV2/model_incident_postmortem_create_request.go @@ -0,0 +1,110 @@ +// 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. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// IncidentPostmortemCreateRequest Request to create a postmortem for an incident. +type IncidentPostmortemCreateRequest struct { + // The postmortem resource for a creation request. + Data IncidentPostmortemCreateData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewIncidentPostmortemCreateRequest instantiates a new IncidentPostmortemCreateRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewIncidentPostmortemCreateRequest(data IncidentPostmortemCreateData) *IncidentPostmortemCreateRequest { + this := IncidentPostmortemCreateRequest{} + this.Data = data + return &this +} + +// NewIncidentPostmortemCreateRequestWithDefaults instantiates a new IncidentPostmortemCreateRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewIncidentPostmortemCreateRequestWithDefaults() *IncidentPostmortemCreateRequest { + this := IncidentPostmortemCreateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *IncidentPostmortemCreateRequest) GetData() IncidentPostmortemCreateData { + if o == nil { + var ret IncidentPostmortemCreateData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemCreateRequest) GetDataOk() (*IncidentPostmortemCreateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *IncidentPostmortemCreateRequest) SetData(v IncidentPostmortemCreateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentPostmortemCreateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentPostmortemCreateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *IncidentPostmortemCreateData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_incident_postmortem_data.go b/api/datadogV2/model_incident_postmortem_data.go new file mode 100644 index 00000000000..7b717b854e4 --- /dev/null +++ b/api/datadogV2/model_incident_postmortem_data.go @@ -0,0 +1,215 @@ +// 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. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// IncidentPostmortemData The postmortem resource. +type IncidentPostmortemData struct { + // The postmortem's attributes. + Attributes IncidentPostmortemAttributes `json:"attributes"` + // The UUID of the postmortem. + Id string `json:"id"` + // The postmortem's relationships. + Relationships IncidentPostmortemRelationships `json:"relationships"` + // Incident postmortem resource type. + Type IncidentPostmortemType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewIncidentPostmortemData instantiates a new IncidentPostmortemData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewIncidentPostmortemData(attributes IncidentPostmortemAttributes, id string, relationships IncidentPostmortemRelationships, typeVar IncidentPostmortemType) *IncidentPostmortemData { + this := IncidentPostmortemData{} + this.Attributes = attributes + this.Id = id + this.Relationships = relationships + this.Type = typeVar + return &this +} + +// NewIncidentPostmortemDataWithDefaults instantiates a new IncidentPostmortemData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewIncidentPostmortemDataWithDefaults() *IncidentPostmortemData { + this := IncidentPostmortemData{} + var typeVar IncidentPostmortemType = INCIDENTPOSTMORTEMTYPE_INCIDENT_POSTMORTEMS + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *IncidentPostmortemData) GetAttributes() IncidentPostmortemAttributes { + if o == nil { + var ret IncidentPostmortemAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemData) GetAttributesOk() (*IncidentPostmortemAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *IncidentPostmortemData) SetAttributes(v IncidentPostmortemAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *IncidentPostmortemData) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *IncidentPostmortemData) SetId(v string) { + o.Id = v +} + +// GetRelationships returns the Relationships field value. +func (o *IncidentPostmortemData) GetRelationships() IncidentPostmortemRelationships { + if o == nil { + var ret IncidentPostmortemRelationships + return ret + } + return o.Relationships +} + +// GetRelationshipsOk returns a tuple with the Relationships field value +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemData) GetRelationshipsOk() (*IncidentPostmortemRelationships, bool) { + if o == nil { + return nil, false + } + return &o.Relationships, true +} + +// SetRelationships sets field value. +func (o *IncidentPostmortemData) SetRelationships(v IncidentPostmortemRelationships) { + o.Relationships = v +} + +// GetType returns the Type field value. +func (o *IncidentPostmortemData) GetType() IncidentPostmortemType { + if o == nil { + var ret IncidentPostmortemType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemData) GetTypeOk() (*IncidentPostmortemType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *IncidentPostmortemData) SetType(v IncidentPostmortemType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentPostmortemData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + toSerialize["relationships"] = o.Relationships + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentPostmortemData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *IncidentPostmortemAttributes `json:"attributes"` + Id *string `json:"id"` + Relationships *IncidentPostmortemRelationships `json:"relationships"` + Type *IncidentPostmortemType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Relationships == nil { + return fmt.Errorf("required field relationships missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "relationships", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if all.Relationships.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Relationships = *all.Relationships + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_incident_postmortem_included.go b/api/datadogV2/model_incident_postmortem_included.go new file mode 100644 index 00000000000..5887b24edfb --- /dev/null +++ b/api/datadogV2/model_incident_postmortem_included.go @@ -0,0 +1,105 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// IncidentPostmortemIncluded - An object related to a postmortem that is included in the response. +type IncidentPostmortemIncluded struct { + IncidentUserData *IncidentUserData + IncidentResponseData *IncidentResponseData + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// IncidentUserDataAsIncidentPostmortemIncluded is a convenience function that returns IncidentUserData wrapped in IncidentPostmortemIncluded. +func IncidentUserDataAsIncidentPostmortemIncluded(v *IncidentUserData) IncidentPostmortemIncluded { + return IncidentPostmortemIncluded{IncidentUserData: v} +} + +// IncidentResponseDataAsIncidentPostmortemIncluded is a convenience function that returns IncidentResponseData wrapped in IncidentPostmortemIncluded. +func IncidentResponseDataAsIncidentPostmortemIncluded(v *IncidentResponseData) IncidentPostmortemIncluded { + return IncidentPostmortemIncluded{IncidentResponseData: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *IncidentPostmortemIncluded) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into IncidentUserData + err = datadog.Unmarshal(data, &obj.IncidentUserData) + if err == nil { + if obj.IncidentUserData != nil && obj.IncidentUserData.UnparsedObject == nil { + jsonIncidentUserData, _ := datadog.Marshal(obj.IncidentUserData) + if string(jsonIncidentUserData) == "{}" && string(data) != "{}" { // empty struct + obj.IncidentUserData = nil + } else { + match++ + } + } else { + obj.IncidentUserData = nil + } + } else { + obj.IncidentUserData = nil + } + + // try to unmarshal data into IncidentResponseData + err = datadog.Unmarshal(data, &obj.IncidentResponseData) + if err == nil { + if obj.IncidentResponseData != nil && obj.IncidentResponseData.UnparsedObject == nil { + jsonIncidentResponseData, _ := datadog.Marshal(obj.IncidentResponseData) + if string(jsonIncidentResponseData) == "{}" { // empty struct + obj.IncidentResponseData = nil + } else { + match++ + } + } else { + obj.IncidentResponseData = nil + } + } else { + obj.IncidentResponseData = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.IncidentUserData = nil + obj.IncidentResponseData = nil + return datadog.Unmarshal(data, &obj.UnparsedObject) + } + return nil // exactly one match +} + +// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. +func (obj IncidentPostmortemIncluded) MarshalJSON() ([]byte, error) { + if obj.IncidentUserData != nil { + return datadog.Marshal(&obj.IncidentUserData) + } + + if obj.IncidentResponseData != nil { + return datadog.Marshal(&obj.IncidentResponseData) + } + + if obj.UnparsedObject != nil { + return datadog.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *IncidentPostmortemIncluded) GetActualInstance() interface{} { + if obj.IncidentUserData != nil { + return obj.IncidentUserData + } + + if obj.IncidentResponseData != nil { + return obj.IncidentResponseData + } + + // all schemas are nil + return nil +} diff --git a/api/datadogV2/model_incident_postmortem_relationships.go b/api/datadogV2/model_incident_postmortem_relationships.go new file mode 100644 index 00000000000..1f74c430d4a --- /dev/null +++ b/api/datadogV2/model_incident_postmortem_relationships.go @@ -0,0 +1,241 @@ +// 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. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// IncidentPostmortemRelationships The postmortem's relationships. +type IncidentPostmortemRelationships struct { + // Relationship to incident. + Incident *RelationshipToIncident `json:"incident,omitempty"` + // Relationship to user. + LastModifiedByUser *RelationshipToUser `json:"last_modified_by_user,omitempty"` + // A relationship reference for a single incident responder. + PostmortemOwnerResponder NullableRelationshipToIncidentResponder `json:"postmortem_owner_responder,omitempty"` + // Relationship to user. + PostmortemOwnerUser NullableNullableRelationshipToUser `json:"postmortem_owner_user,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewIncidentPostmortemRelationships instantiates a new IncidentPostmortemRelationships object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewIncidentPostmortemRelationships() *IncidentPostmortemRelationships { + this := IncidentPostmortemRelationships{} + return &this +} + +// NewIncidentPostmortemRelationshipsWithDefaults instantiates a new IncidentPostmortemRelationships object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewIncidentPostmortemRelationshipsWithDefaults() *IncidentPostmortemRelationships { + this := IncidentPostmortemRelationships{} + return &this +} + +// GetIncident returns the Incident field value if set, zero value otherwise. +func (o *IncidentPostmortemRelationships) GetIncident() RelationshipToIncident { + if o == nil || o.Incident == nil { + var ret RelationshipToIncident + return ret + } + return *o.Incident +} + +// GetIncidentOk returns a tuple with the Incident field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemRelationships) GetIncidentOk() (*RelationshipToIncident, bool) { + if o == nil || o.Incident == nil { + return nil, false + } + return o.Incident, true +} + +// HasIncident returns a boolean if a field has been set. +func (o *IncidentPostmortemRelationships) HasIncident() bool { + return o != nil && o.Incident != nil +} + +// SetIncident gets a reference to the given RelationshipToIncident and assigns it to the Incident field. +func (o *IncidentPostmortemRelationships) SetIncident(v RelationshipToIncident) { + o.Incident = &v +} + +// GetLastModifiedByUser returns the LastModifiedByUser field value if set, zero value otherwise. +func (o *IncidentPostmortemRelationships) GetLastModifiedByUser() RelationshipToUser { + if o == nil || o.LastModifiedByUser == nil { + var ret RelationshipToUser + return ret + } + return *o.LastModifiedByUser +} + +// GetLastModifiedByUserOk returns a tuple with the LastModifiedByUser field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemRelationships) GetLastModifiedByUserOk() (*RelationshipToUser, bool) { + if o == nil || o.LastModifiedByUser == nil { + return nil, false + } + return o.LastModifiedByUser, true +} + +// HasLastModifiedByUser returns a boolean if a field has been set. +func (o *IncidentPostmortemRelationships) HasLastModifiedByUser() bool { + return o != nil && o.LastModifiedByUser != nil +} + +// SetLastModifiedByUser gets a reference to the given RelationshipToUser and assigns it to the LastModifiedByUser field. +func (o *IncidentPostmortemRelationships) SetLastModifiedByUser(v RelationshipToUser) { + o.LastModifiedByUser = &v +} + +// GetPostmortemOwnerResponder returns the PostmortemOwnerResponder field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *IncidentPostmortemRelationships) GetPostmortemOwnerResponder() RelationshipToIncidentResponder { + if o == nil || o.PostmortemOwnerResponder.Get() == nil { + var ret RelationshipToIncidentResponder + return ret + } + return *o.PostmortemOwnerResponder.Get() +} + +// GetPostmortemOwnerResponderOk returns a tuple with the PostmortemOwnerResponder field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *IncidentPostmortemRelationships) GetPostmortemOwnerResponderOk() (*RelationshipToIncidentResponder, bool) { + if o == nil { + return nil, false + } + return o.PostmortemOwnerResponder.Get(), o.PostmortemOwnerResponder.IsSet() +} + +// HasPostmortemOwnerResponder returns a boolean if a field has been set. +func (o *IncidentPostmortemRelationships) HasPostmortemOwnerResponder() bool { + return o != nil && o.PostmortemOwnerResponder.IsSet() +} + +// SetPostmortemOwnerResponder gets a reference to the given NullableRelationshipToIncidentResponder and assigns it to the PostmortemOwnerResponder field. +func (o *IncidentPostmortemRelationships) SetPostmortemOwnerResponder(v RelationshipToIncidentResponder) { + o.PostmortemOwnerResponder.Set(&v) +} + +// SetPostmortemOwnerResponderNil sets the value for PostmortemOwnerResponder to be an explicit nil. +func (o *IncidentPostmortemRelationships) SetPostmortemOwnerResponderNil() { + o.PostmortemOwnerResponder.Set(nil) +} + +// UnsetPostmortemOwnerResponder ensures that no value is present for PostmortemOwnerResponder, not even an explicit nil. +func (o *IncidentPostmortemRelationships) UnsetPostmortemOwnerResponder() { + o.PostmortemOwnerResponder.Unset() +} + +// GetPostmortemOwnerUser returns the PostmortemOwnerUser field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *IncidentPostmortemRelationships) GetPostmortemOwnerUser() NullableRelationshipToUser { + if o == nil || o.PostmortemOwnerUser.Get() == nil { + var ret NullableRelationshipToUser + return ret + } + return *o.PostmortemOwnerUser.Get() +} + +// GetPostmortemOwnerUserOk returns a tuple with the PostmortemOwnerUser field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *IncidentPostmortemRelationships) GetPostmortemOwnerUserOk() (*NullableRelationshipToUser, bool) { + if o == nil { + return nil, false + } + return o.PostmortemOwnerUser.Get(), o.PostmortemOwnerUser.IsSet() +} + +// HasPostmortemOwnerUser returns a boolean if a field has been set. +func (o *IncidentPostmortemRelationships) HasPostmortemOwnerUser() bool { + return o != nil && o.PostmortemOwnerUser.IsSet() +} + +// SetPostmortemOwnerUser gets a reference to the given NullableNullableRelationshipToUser and assigns it to the PostmortemOwnerUser field. +func (o *IncidentPostmortemRelationships) SetPostmortemOwnerUser(v NullableRelationshipToUser) { + o.PostmortemOwnerUser.Set(&v) +} + +// SetPostmortemOwnerUserNil sets the value for PostmortemOwnerUser to be an explicit nil. +func (o *IncidentPostmortemRelationships) SetPostmortemOwnerUserNil() { + o.PostmortemOwnerUser.Set(nil) +} + +// UnsetPostmortemOwnerUser ensures that no value is present for PostmortemOwnerUser, not even an explicit nil. +func (o *IncidentPostmortemRelationships) UnsetPostmortemOwnerUser() { + o.PostmortemOwnerUser.Unset() +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentPostmortemRelationships) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Incident != nil { + toSerialize["incident"] = o.Incident + } + if o.LastModifiedByUser != nil { + toSerialize["last_modified_by_user"] = o.LastModifiedByUser + } + if o.PostmortemOwnerResponder.IsSet() { + toSerialize["postmortem_owner_responder"] = o.PostmortemOwnerResponder.Get() + } + if o.PostmortemOwnerUser.IsSet() { + toSerialize["postmortem_owner_user"] = o.PostmortemOwnerUser.Get() + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentPostmortemRelationships) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Incident *RelationshipToIncident `json:"incident,omitempty"` + LastModifiedByUser *RelationshipToUser `json:"last_modified_by_user,omitempty"` + PostmortemOwnerResponder NullableRelationshipToIncidentResponder `json:"postmortem_owner_responder,omitempty"` + PostmortemOwnerUser NullableNullableRelationshipToUser `json:"postmortem_owner_user,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"incident", "last_modified_by_user", "postmortem_owner_responder", "postmortem_owner_user"}) + } else { + return err + } + + hasInvalidField := false + if all.Incident != nil && all.Incident.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Incident = all.Incident + if all.LastModifiedByUser != nil && all.LastModifiedByUser.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.LastModifiedByUser = all.LastModifiedByUser + o.PostmortemOwnerResponder = all.PostmortemOwnerResponder + o.PostmortemOwnerUser = all.PostmortemOwnerUser + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_incident_postmortem_response.go b/api/datadogV2/model_incident_postmortem_response.go new file mode 100644 index 00000000000..cde79ab1e3f --- /dev/null +++ b/api/datadogV2/model_incident_postmortem_response.go @@ -0,0 +1,145 @@ +// 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. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// IncidentPostmortemResponse Response with a single incident postmortem. +type IncidentPostmortemResponse struct { + // The postmortem resource. + Data IncidentPostmortemData `json:"data"` + // Related objects included in the response. + Included []IncidentPostmortemIncluded `json:"included,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewIncidentPostmortemResponse instantiates a new IncidentPostmortemResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewIncidentPostmortemResponse(data IncidentPostmortemData) *IncidentPostmortemResponse { + this := IncidentPostmortemResponse{} + this.Data = data + return &this +} + +// NewIncidentPostmortemResponseWithDefaults instantiates a new IncidentPostmortemResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewIncidentPostmortemResponseWithDefaults() *IncidentPostmortemResponse { + this := IncidentPostmortemResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *IncidentPostmortemResponse) GetData() IncidentPostmortemData { + if o == nil { + var ret IncidentPostmortemData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemResponse) GetDataOk() (*IncidentPostmortemData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *IncidentPostmortemResponse) SetData(v IncidentPostmortemData) { + o.Data = v +} + +// GetIncluded returns the Included field value if set, zero value otherwise. +func (o *IncidentPostmortemResponse) GetIncluded() []IncidentPostmortemIncluded { + if o == nil || o.Included == nil { + var ret []IncidentPostmortemIncluded + return ret + } + return o.Included +} + +// GetIncludedOk returns a tuple with the Included field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemResponse) GetIncludedOk() (*[]IncidentPostmortemIncluded, bool) { + if o == nil || o.Included == nil { + return nil, false + } + return &o.Included, true +} + +// HasIncluded returns a boolean if a field has been set. +func (o *IncidentPostmortemResponse) HasIncluded() bool { + return o != nil && o.Included != nil +} + +// SetIncluded gets a reference to the given []IncidentPostmortemIncluded and assigns it to the Included field. +func (o *IncidentPostmortemResponse) SetIncluded(v []IncidentPostmortemIncluded) { + o.Included = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentPostmortemResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + if o.Included != nil { + toSerialize["included"] = o.Included + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentPostmortemResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *IncidentPostmortemData `json:"data"` + Included []IncidentPostmortemIncluded `json:"included,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data", "included"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + o.Included = all.Included + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_incident_postmortem_update_attributes.go b/api/datadogV2/model_incident_postmortem_update_attributes.go new file mode 100644 index 00000000000..d37181741e8 --- /dev/null +++ b/api/datadogV2/model_incident_postmortem_update_attributes.go @@ -0,0 +1,112 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// IncidentPostmortemUpdateAttributes The postmortem's attributes for an update request. +type IncidentPostmortemUpdateAttributes struct { + // The status of the postmortem. + Status *PostmortemStatus `json:"status,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewIncidentPostmortemUpdateAttributes instantiates a new IncidentPostmortemUpdateAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewIncidentPostmortemUpdateAttributes() *IncidentPostmortemUpdateAttributes { + this := IncidentPostmortemUpdateAttributes{} + return &this +} + +// NewIncidentPostmortemUpdateAttributesWithDefaults instantiates a new IncidentPostmortemUpdateAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewIncidentPostmortemUpdateAttributesWithDefaults() *IncidentPostmortemUpdateAttributes { + this := IncidentPostmortemUpdateAttributes{} + return &this +} + +// GetStatus returns the Status field value if set, zero value otherwise. +func (o *IncidentPostmortemUpdateAttributes) GetStatus() PostmortemStatus { + if o == nil || o.Status == nil { + var ret PostmortemStatus + return ret + } + return *o.Status +} + +// GetStatusOk returns a tuple with the Status field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemUpdateAttributes) GetStatusOk() (*PostmortemStatus, bool) { + if o == nil || o.Status == nil { + return nil, false + } + return o.Status, true +} + +// HasStatus returns a boolean if a field has been set. +func (o *IncidentPostmortemUpdateAttributes) HasStatus() bool { + return o != nil && o.Status != nil +} + +// SetStatus gets a reference to the given PostmortemStatus and assigns it to the Status field. +func (o *IncidentPostmortemUpdateAttributes) SetStatus(v PostmortemStatus) { + o.Status = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentPostmortemUpdateAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Status != nil { + toSerialize["status"] = o.Status + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentPostmortemUpdateAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Status *PostmortemStatus `json:"status,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"status"}) + } else { + return err + } + + hasInvalidField := false + if all.Status != nil && !all.Status.IsValid() { + hasInvalidField = true + } else { + o.Status = all.Status + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_incident_postmortem_update_data.go b/api/datadogV2/model_incident_postmortem_update_data.go new file mode 100644 index 00000000000..17d3850c99a --- /dev/null +++ b/api/datadogV2/model_incident_postmortem_update_data.go @@ -0,0 +1,180 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// IncidentPostmortemUpdateData The postmortem resource for an update request. +type IncidentPostmortemUpdateData struct { + // The postmortem's attributes for an update request. + Attributes IncidentPostmortemUpdateAttributes `json:"attributes"` + // The UUID of the postmortem. + Id string `json:"id"` + // Incident postmortem resource type. + Type IncidentPostmortemType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewIncidentPostmortemUpdateData instantiates a new IncidentPostmortemUpdateData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewIncidentPostmortemUpdateData(attributes IncidentPostmortemUpdateAttributes, id string, typeVar IncidentPostmortemType) *IncidentPostmortemUpdateData { + this := IncidentPostmortemUpdateData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewIncidentPostmortemUpdateDataWithDefaults instantiates a new IncidentPostmortemUpdateData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewIncidentPostmortemUpdateDataWithDefaults() *IncidentPostmortemUpdateData { + this := IncidentPostmortemUpdateData{} + var typeVar IncidentPostmortemType = INCIDENTPOSTMORTEMTYPE_INCIDENT_POSTMORTEMS + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *IncidentPostmortemUpdateData) GetAttributes() IncidentPostmortemUpdateAttributes { + if o == nil { + var ret IncidentPostmortemUpdateAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemUpdateData) GetAttributesOk() (*IncidentPostmortemUpdateAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *IncidentPostmortemUpdateData) SetAttributes(v IncidentPostmortemUpdateAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *IncidentPostmortemUpdateData) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemUpdateData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *IncidentPostmortemUpdateData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *IncidentPostmortemUpdateData) GetType() IncidentPostmortemType { + if o == nil { + var ret IncidentPostmortemType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemUpdateData) GetTypeOk() (*IncidentPostmortemType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *IncidentPostmortemUpdateData) SetType(v IncidentPostmortemType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentPostmortemUpdateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentPostmortemUpdateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *IncidentPostmortemUpdateAttributes `json:"attributes"` + Id *string `json:"id"` + Type *IncidentPostmortemType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_incident_postmortem_update_request.go b/api/datadogV2/model_incident_postmortem_update_request.go new file mode 100644 index 00000000000..7b127689eea --- /dev/null +++ b/api/datadogV2/model_incident_postmortem_update_request.go @@ -0,0 +1,110 @@ +// 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. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// IncidentPostmortemUpdateRequest Request to update the postmortem attached to an incident. +type IncidentPostmortemUpdateRequest struct { + // The postmortem resource for an update request. + Data IncidentPostmortemUpdateData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewIncidentPostmortemUpdateRequest instantiates a new IncidentPostmortemUpdateRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewIncidentPostmortemUpdateRequest(data IncidentPostmortemUpdateData) *IncidentPostmortemUpdateRequest { + this := IncidentPostmortemUpdateRequest{} + this.Data = data + return &this +} + +// NewIncidentPostmortemUpdateRequestWithDefaults instantiates a new IncidentPostmortemUpdateRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewIncidentPostmortemUpdateRequestWithDefaults() *IncidentPostmortemUpdateRequest { + this := IncidentPostmortemUpdateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *IncidentPostmortemUpdateRequest) GetData() IncidentPostmortemUpdateData { + if o == nil { + var ret IncidentPostmortemUpdateData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *IncidentPostmortemUpdateRequest) GetDataOk() (*IncidentPostmortemUpdateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *IncidentPostmortemUpdateRequest) SetData(v IncidentPostmortemUpdateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentPostmortemUpdateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentPostmortemUpdateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *IncidentPostmortemUpdateData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_nullable_relationship_to_incident_responder_data.go b/api/datadogV2/model_nullable_relationship_to_incident_responder_data.go new file mode 100644 index 00000000000..420456542df --- /dev/null +++ b/api/datadogV2/model_nullable_relationship_to_incident_responder_data.go @@ -0,0 +1,193 @@ +// 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. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// NullableRelationshipToIncidentResponderData Relationship to impact object. +type NullableRelationshipToIncidentResponderData struct { + // A unique identifier that represents the responder. + Id string `json:"id"` + // The incident responders type. + Type IncidentRespondersType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewNullableRelationshipToIncidentResponderData instantiates a new NullableRelationshipToIncidentResponderData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewNullableRelationshipToIncidentResponderData(id string, typeVar IncidentRespondersType) *NullableRelationshipToIncidentResponderData { + this := NullableRelationshipToIncidentResponderData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewNullableRelationshipToIncidentResponderDataWithDefaults instantiates a new NullableRelationshipToIncidentResponderData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewNullableRelationshipToIncidentResponderDataWithDefaults() *NullableRelationshipToIncidentResponderData { + this := NullableRelationshipToIncidentResponderData{} + return &this +} + +// GetId returns the Id field value. +func (o *NullableRelationshipToIncidentResponderData) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *NullableRelationshipToIncidentResponderData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *NullableRelationshipToIncidentResponderData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *NullableRelationshipToIncidentResponderData) GetType() IncidentRespondersType { + if o == nil { + var ret IncidentRespondersType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *NullableRelationshipToIncidentResponderData) GetTypeOk() (*IncidentRespondersType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *NullableRelationshipToIncidentResponderData) SetType(v IncidentRespondersType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o NullableRelationshipToIncidentResponderData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *NullableRelationshipToIncidentResponderData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Type *IncidentRespondersType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} + +// NullableNullableRelationshipToIncidentResponderData handles when a null is used for NullableRelationshipToIncidentResponderData. +type NullableNullableRelationshipToIncidentResponderData struct { + value *NullableRelationshipToIncidentResponderData + isSet bool +} + +// Get returns the associated value. +func (v NullableNullableRelationshipToIncidentResponderData) Get() *NullableRelationshipToIncidentResponderData { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableNullableRelationshipToIncidentResponderData) Set(val *NullableRelationshipToIncidentResponderData) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableNullableRelationshipToIncidentResponderData) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag/ +func (v *NullableNullableRelationshipToIncidentResponderData) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableNullableRelationshipToIncidentResponderData initializes the struct as if Set has been called. +func NewNullableNullableRelationshipToIncidentResponderData(val *NullableRelationshipToIncidentResponderData) *NullableNullableRelationshipToIncidentResponderData { + return &NullableNullableRelationshipToIncidentResponderData{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableNullableRelationshipToIncidentResponderData) MarshalJSON() ([]byte, error) { + return datadog.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableNullableRelationshipToIncidentResponderData) UnmarshalJSON(src []byte) error { + v.isSet = true + + // this object is nullable so check if the payload is null or empty string + if string(src) == "" || string(src) == "{}" { + return nil + } + + return datadog.Unmarshal(src, &v.value) +} diff --git a/api/datadogV2/model_postmortem_status.go b/api/datadogV2/model_postmortem_status.go new file mode 100644 index 00000000000..6aaec3aa6ba --- /dev/null +++ b/api/datadogV2/model_postmortem_status.go @@ -0,0 +1,68 @@ +// 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. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PostmortemStatus The status of the postmortem. +type PostmortemStatus string + +// List of PostmortemStatus. +const ( + POSTMORTEMSTATUS_DRAFT PostmortemStatus = "draft" + POSTMORTEMSTATUS_IN_REVIEW PostmortemStatus = "in_review" + POSTMORTEMSTATUS_COMPLETED PostmortemStatus = "completed" +) + +var allowedPostmortemStatusEnumValues = []PostmortemStatus{ + POSTMORTEMSTATUS_DRAFT, + POSTMORTEMSTATUS_IN_REVIEW, + POSTMORTEMSTATUS_COMPLETED, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *PostmortemStatus) GetAllowedValues() []PostmortemStatus { + return allowedPostmortemStatusEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *PostmortemStatus) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = PostmortemStatus(value) + return nil +} + +// NewPostmortemStatusFromValue returns a pointer to a valid PostmortemStatus +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewPostmortemStatusFromValue(v string) (*PostmortemStatus, error) { + ev := PostmortemStatus(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for PostmortemStatus: valid values are %v", v, allowedPostmortemStatusEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v PostmortemStatus) IsValid() bool { + for _, existing := range allowedPostmortemStatusEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to PostmortemStatus value. +func (v PostmortemStatus) Ptr() *PostmortemStatus { + return &v +} diff --git a/api/datadogV2/model_relationship_to_incident_responder.go b/api/datadogV2/model_relationship_to_incident_responder.go new file mode 100644 index 00000000000..0db38847040 --- /dev/null +++ b/api/datadogV2/model_relationship_to_incident_responder.go @@ -0,0 +1,153 @@ +// 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. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RelationshipToIncidentResponder A relationship reference for a single incident responder. +type RelationshipToIncidentResponder struct { + // Relationship to impact object. + Data NullableNullableRelationshipToIncidentResponderData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewRelationshipToIncidentResponder instantiates a new RelationshipToIncidentResponder object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewRelationshipToIncidentResponder(data NullableNullableRelationshipToIncidentResponderData) *RelationshipToIncidentResponder { + this := RelationshipToIncidentResponder{} + this.Data = data + return &this +} + +// NewRelationshipToIncidentResponderWithDefaults instantiates a new RelationshipToIncidentResponder object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewRelationshipToIncidentResponderWithDefaults() *RelationshipToIncidentResponder { + this := RelationshipToIncidentResponder{} + return &this +} + +// GetData returns the Data field value. +// If the value is explicit nil, the zero value for NullableRelationshipToIncidentResponderData will be returned. +func (o *RelationshipToIncidentResponder) GetData() NullableRelationshipToIncidentResponderData { + if o == nil || o.Data.Get() == nil { + var ret NullableRelationshipToIncidentResponderData + return ret + } + return *o.Data.Get() +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *RelationshipToIncidentResponder) GetDataOk() (*NullableRelationshipToIncidentResponderData, bool) { + if o == nil { + return nil, false + } + return o.Data.Get(), o.Data.IsSet() +} + +// SetData sets field value. +func (o *RelationshipToIncidentResponder) SetData(v NullableRelationshipToIncidentResponderData) { + o.Data.Set(&v) +} + +// MarshalJSON serializes the struct using spec logic. +func (o RelationshipToIncidentResponder) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data.Get() + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RelationshipToIncidentResponder) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data NullableNullableRelationshipToIncidentResponderData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if !all.Data.IsSet() { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} + +// NullableRelationshipToIncidentResponder handles when a null is used for RelationshipToIncidentResponder. +type NullableRelationshipToIncidentResponder struct { + value *RelationshipToIncidentResponder + isSet bool +} + +// Get returns the associated value. +func (v NullableRelationshipToIncidentResponder) Get() *RelationshipToIncidentResponder { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableRelationshipToIncidentResponder) Set(val *RelationshipToIncidentResponder) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableRelationshipToIncidentResponder) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag/ +func (v *NullableRelationshipToIncidentResponder) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableRelationshipToIncidentResponder initializes the struct as if Set has been called. +func NewNullableRelationshipToIncidentResponder(val *RelationshipToIncidentResponder) *NullableRelationshipToIncidentResponder { + return &NullableRelationshipToIncidentResponder{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableRelationshipToIncidentResponder) MarshalJSON() ([]byte, error) { + return datadog.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableRelationshipToIncidentResponder) UnmarshalJSON(src []byte) error { + v.isSet = true + + // this object is nullable so check if the payload is null or empty string + if string(src) == "" || string(src) == "{}" { + return nil + } + + return datadog.Unmarshal(src, &v.value) +} diff --git a/examples/v2/incidents/CreateIncidentPostmortem.go b/examples/v2/incidents/CreateIncidentPostmortem.go new file mode 100644 index 00000000000..d3185f6cb90 --- /dev/null +++ b/examples/v2/incidents/CreateIncidentPostmortem.go @@ -0,0 +1,42 @@ +// Create postmortem for an incident returns "CREATED" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "incident" in the system + IncidentDataID := os.Getenv("INCIDENT_DATA_ID") + + body := datadogV2.IncidentPostmortemCreateRequest{ + Data: datadogV2.IncidentPostmortemCreateData{ + Attributes: datadogV2.IncidentPostmortemCreateAttributes{ + DocumentUrl: "https://app.datadoghq.com/notebook/123", + Title: "Postmortem for IR-123", + }, + Type: datadogV2.INCIDENTPOSTMORTEMTYPE_INCIDENT_POSTMORTEMS, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.CreateIncidentPostmortem", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewIncidentsApi(apiClient) + resp, r, err := api.CreateIncidentPostmortem(ctx, IncidentDataID, body, *datadogV2.NewCreateIncidentPostmortemOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.CreateIncidentPostmortem`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.CreateIncidentPostmortem`:\n%s\n", responseContent) +} diff --git a/examples/v2/incidents/DeleteIncidentPostmortem.go b/examples/v2/incidents/DeleteIncidentPostmortem.go new file mode 100644 index 00000000000..eb10aae8e9e --- /dev/null +++ b/examples/v2/incidents/DeleteIncidentPostmortem.go @@ -0,0 +1,29 @@ +// Delete postmortem for an incident returns "OK" response + +package main + +import ( + "context" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "postmortem" in the system + PostmortemDataRelationshipsIncidentDataID := os.Getenv("POSTMORTEM_DATA_RELATIONSHIPS_INCIDENT_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.DeleteIncidentPostmortem", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewIncidentsApi(apiClient) + r, err := api.DeleteIncidentPostmortem(ctx, PostmortemDataRelationshipsIncidentDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.DeleteIncidentPostmortem`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/incidents/GetIncidentPostmortem.go b/examples/v2/incidents/GetIncidentPostmortem.go new file mode 100644 index 00000000000..1a904aa9757 --- /dev/null +++ b/examples/v2/incidents/GetIncidentPostmortem.go @@ -0,0 +1,33 @@ +// Get postmortem for an incident returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "postmortem" in the system + PostmortemDataRelationshipsIncidentDataID := os.Getenv("POSTMORTEM_DATA_RELATIONSHIPS_INCIDENT_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.GetIncidentPostmortem", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewIncidentsApi(apiClient) + resp, r, err := api.GetIncidentPostmortem(ctx, PostmortemDataRelationshipsIncidentDataID, *datadogV2.NewGetIncidentPostmortemOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.GetIncidentPostmortem`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.GetIncidentPostmortem`:\n%s\n", responseContent) +} diff --git a/examples/v2/incidents/UpdateIncidentPostmortem.go b/examples/v2/incidents/UpdateIncidentPostmortem.go new file mode 100644 index 00000000000..97b58d33688 --- /dev/null +++ b/examples/v2/incidents/UpdateIncidentPostmortem.go @@ -0,0 +1,43 @@ +// Update postmortem for an incident returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "postmortem" in the system + PostmortemDataID := os.Getenv("POSTMORTEM_DATA_ID") + PostmortemDataRelationshipsIncidentDataID := os.Getenv("POSTMORTEM_DATA_RELATIONSHIPS_INCIDENT_DATA_ID") + + body := datadogV2.IncidentPostmortemUpdateRequest{ + Data: datadogV2.IncidentPostmortemUpdateData{ + Attributes: datadogV2.IncidentPostmortemUpdateAttributes{ + Status: datadogV2.POSTMORTEMSTATUS_IN_REVIEW.Ptr(), + }, + Id: PostmortemDataID, + Type: datadogV2.INCIDENTPOSTMORTEMTYPE_INCIDENT_POSTMORTEMS, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.UpdateIncidentPostmortem", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewIncidentsApi(apiClient) + resp, r, err := api.UpdateIncidentPostmortem(ctx, PostmortemDataRelationshipsIncidentDataID, body, *datadogV2.NewUpdateIncidentPostmortemOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.UpdateIncidentPostmortem`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.UpdateIncidentPostmortem`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Create_postmortem_for_an_incident_returns_CREATED_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Create_postmortem_for_an_incident_returns_CREATED_response.freeze new file mode 100644 index 00000000000..20dff1d9fb7 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Create_postmortem_for_an_incident_returns_CREATED_response.freeze @@ -0,0 +1 @@ +2026-07-09T20:46:31.190Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Create_postmortem_for_an_incident_returns_CREATED_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Create_postmortem_for_an_incident_returns_CREATED_response.yaml new file mode 100644 index 00000000000..0a13b49fde9 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Create_postmortem_for_an_incident_returns_CREATED_response.yaml @@ -0,0 +1,78 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"customer_impacted":false,"title":"Test-Create_postmortem_for_an_incident_returns_CREATED_response-1783629991"},"type":"incidents"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/incidents + response: + body: '{"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":[]}}}} + + ' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"document_url":"https://app.datadoghq.com/notebook/123","title":"Postmortem for IR-123"},"type":"incident_postmortems"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: POST + url: https://api.datadoghq.com/api/v2/incidents/254910ed-d27e-5cb4-9f29-b0d5562e78d1/postmortem + response: + body: '{"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}}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/incidents/254910ed-d27e-5cb4-9f29-b0d5562e78d1/postmortem + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 3 + method: DELETE + url: https://api.datadoghq.com/api/v2/incidents/254910ed-d27e-5cb4-9f29-b0d5562e78d1 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Delete_postmortem_for_an_incident_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Delete_postmortem_for_an_incident_returns_OK_response.freeze new file mode 100644 index 00000000000..7f1eefa3ee9 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Delete_postmortem_for_an_incident_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-07-09T20:46:34.566Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Delete_postmortem_for_an_incident_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Delete_postmortem_for_an_incident_returns_OK_response.yaml new file mode 100644 index 00000000000..65f5dc3ab56 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Delete_postmortem_for_an_incident_returns_OK_response.yaml @@ -0,0 +1,95 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"customer_impacted":false,"title":"Test-Delete_postmortem_for_an_incident_returns_OK_response-1783629994"},"type":"incidents"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/incidents + response: + body: '{"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":[]}}}} + + ' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: POST + url: https://api.datadoghq.com/api/v2/incidents/b481c61d-b0b2-5786-b2c2-381d5334d201/postmortem + response: + body: '{"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}}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/incidents/b481c61d-b0b2-5786-b2c2-381d5334d201/postmortem + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 3 + method: DELETE + url: https://api.datadoghq.com/api/v2/incidents/b481c61d-b0b2-5786-b2c2-381d5334d201/postmortem + response: + body: '{"errors":[{"title":"Generic Error","detail":"postmortem not found"}]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 404 Not Found +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 4 + method: DELETE + url: https://api.datadoghq.com/api/v2/incidents/b481c61d-b0b2-5786-b2c2-381d5334d201 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_postmortem_for_an_incident_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_postmortem_for_an_incident_returns_OK_response.freeze new file mode 100644 index 00000000000..b0c18a72902 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_postmortem_for_an_incident_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-07-09T20:46:36.398Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_postmortem_for_an_incident_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_postmortem_for_an_incident_returns_OK_response.yaml new file mode 100644 index 00000000000..c486801b8f4 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Get_postmortem_for_an_incident_returns_OK_response.yaml @@ -0,0 +1,96 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"customer_impacted":false,"title":"Test-Get_postmortem_for_an_incident_returns_OK_response-1783629996"},"type":"incidents"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/incidents + response: + body: '{"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":[]}}}} + + ' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: POST + url: https://api.datadoghq.com/api/v2/incidents/4832db36-b2ec-5f98-917a-3b2fff43a58c/postmortem + response: + body: '{"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}}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 2 + method: GET + url: https://api.datadoghq.com/api/v2/incidents/4832db36-b2ec-5f98-917a-3b2fff43a58c/postmortem + response: + body: '{"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}}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 3 + method: DELETE + url: https://api.datadoghq.com/api/v2/incidents/4832db36-b2ec-5f98-917a-3b2fff43a58c/postmortem + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 4 + method: DELETE + url: https://api.datadoghq.com/api/v2/incidents/4832db36-b2ec-5f98-917a-3b2fff43a58c + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Update_postmortem_for_an_incident_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Update_postmortem_for_an_incident_returns_OK_response.freeze new file mode 100644 index 00000000000..de335b344d9 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Update_postmortem_for_an_incident_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-07-09T20:46:38.293Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Update_postmortem_for_an_incident_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Update_postmortem_for_an_incident_returns_OK_response.yaml new file mode 100644 index 00000000000..c10c09c8c45 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Incidents/Scenario_Update_postmortem_for_an_incident_returns_OK_response.yaml @@ -0,0 +1,99 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"customer_impacted":false,"title":"Test-Update_postmortem_for_an_incident_returns_OK_response-1783629998"},"type":"incidents"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/incidents + response: + body: '{"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":[]}}}} + + ' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: | + {"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"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: POST + url: https://api.datadoghq.com/api/v2/incidents/c22705d8-525c-52bd-89bc-c7b33823c592/postmortem + response: + body: '{"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}}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"status":"in_review"},"id":"d37b1ea1-eeae-4fc9-93d0-41e64d9df187","type":"incident_postmortems"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 2 + method: PATCH + url: https://api.datadoghq.com/api/v2/incidents/c22705d8-525c-52bd-89bc-c7b33823c592/postmortem + response: + body: '{"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}}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 3 + method: DELETE + url: https://api.datadoghq.com/api/v2/incidents/c22705d8-525c-52bd-89bc-c7b33823c592/postmortem + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 4 + method: DELETE + url: https://api.datadoghq.com/api/v2/incidents/c22705d8-525c-52bd-89bc-c7b33823c592 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 0f9de6d48a2..d4b1c012995 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 646ec88d879..f06b7f6c839 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 1eaba52ee9b..d9d1f7b28d3 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": {