diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 95f5775c6b9..0f936d8d3a9 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -45141,6 +45141,92 @@ components: type: string x-enum-varnames: - MARKDOWN + PostmortemTemplateAttributesRequest: + properties: + name: + description: The name of the template + example: Standard Postmortem Template + type: string + required: + - name + type: object + PostmortemTemplateAttributesResponse: + properties: + createdAt: + description: When the template was created + example: '2026-01-13T17:15:53.208340Z' + format: date-time + type: string + modifiedAt: + description: When the template was last modified + example: '2026-01-13T17:15:53.208340Z' + format: date-time + type: string + name: + description: The name of the template + example: Standard Postmortem Template + type: string + required: + - name + - createdAt + - modifiedAt + type: object + PostmortemTemplateDataRequest: + properties: + attributes: + $ref: '#/components/schemas/PostmortemTemplateAttributesRequest' + type: + $ref: '#/components/schemas/PostmortemTemplateType' + required: + - type + - attributes + type: object + PostmortemTemplateDataResponse: + properties: + attributes: + $ref: '#/components/schemas/PostmortemTemplateAttributesResponse' + id: + description: The ID of the template + example: template-456 + type: string + type: + $ref: '#/components/schemas/PostmortemTemplateType' + required: + - id + - type + - attributes + type: object + PostmortemTemplateRequest: + properties: + data: + $ref: '#/components/schemas/PostmortemTemplateDataRequest' + required: + - data + type: object + PostmortemTemplateResponse: + properties: + data: + $ref: '#/components/schemas/PostmortemTemplateDataResponse' + required: + - data + type: object + PostmortemTemplateType: + description: Postmortem template resource type + enum: + - postmortem_template + example: postmortem_template + type: string + x-enum-varnames: + - POSTMORTEM_TEMPLATE + PostmortemTemplatesResponse: + properties: + data: + items: + $ref: '#/components/schemas/PostmortemTemplateDataResponse' + type: array + required: + - data + type: object Powerpack: description: Powerpacks are templated groups of dashboard widgets you can save from an existing dashboard and turn into reusable packs in the widget tray. @@ -78136,6 +78222,184 @@ paths: - incident_notification_settings_write x-unstable: '**Note**: This endpoint is in Preview. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/incidents/config/postmortem-templates: + get: + description: Retrieve a list of all postmortem templates for incidents. + operationId: ListIncidentPostmortemTemplates + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/PostmortemTemplatesResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: List postmortem templates + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + post: + description: Create a new postmortem template for incidents. + operationId: CreateIncidentPostmortemTemplate + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PostmortemTemplateRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/PostmortemTemplateResponse' + description: Created + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Create postmortem template + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/incidents/config/postmortem-templates/{template_id}: + delete: + description: Delete a postmortem template. + operationId: DeleteIncidentPostmortemTemplate + parameters: + - description: The ID of the postmortem template + in: path + name: template_id + required: true + schema: + example: template-456 + type: string + responses: + '204': + description: No Content + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Delete postmortem template + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + get: + description: Retrieve details of a specific postmortem template. + operationId: GetIncidentPostmortemTemplate + parameters: + - description: The ID of the postmortem template + in: path + name: template_id + required: true + schema: + example: template-456 + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/PostmortemTemplateResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get postmortem template + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + patch: + description: Update an existing postmortem template. + operationId: UpdateIncidentPostmortemTemplate + parameters: + - description: The ID of the postmortem template + in: path + name: template_id + required: true + schema: + example: template-456 + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PostmortemTemplateRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/PostmortemTemplateResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Update postmortem template + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/incidents/config/types: get: diff --git a/api/datadog/configuration.go b/api/datadog/configuration.go index a4e3206ae89..6e36cfe4464 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -720,6 +720,7 @@ func NewConfiguration() *Configuration { "v2.CreateIncidentNotificationRule": false, "v2.CreateIncidentNotificationTemplate": false, "v2.CreateIncidentPostmortemAttachment": false, + "v2.CreateIncidentPostmortemTemplate": false, "v2.CreateIncidentTodo": false, "v2.CreateIncidentType": false, "v2.DeleteGlobalIncidentHandle": false, @@ -728,6 +729,7 @@ func NewConfiguration() *Configuration { "v2.DeleteIncidentIntegration": false, "v2.DeleteIncidentNotificationRule": false, "v2.DeleteIncidentNotificationTemplate": false, + "v2.DeleteIncidentPostmortemTemplate": false, "v2.DeleteIncidentTodo": false, "v2.DeleteIncidentType": false, "v2.GetGlobalIncidentSettings": false, @@ -735,6 +737,7 @@ func NewConfiguration() *Configuration { "v2.GetIncidentIntegration": false, "v2.GetIncidentNotificationRule": false, "v2.GetIncidentNotificationTemplate": false, + "v2.GetIncidentPostmortemTemplate": false, "v2.GetIncidentTodo": false, "v2.GetIncidentType": false, "v2.ListGlobalIncidentHandles": false, @@ -742,6 +745,7 @@ func NewConfiguration() *Configuration { "v2.ListIncidentIntegrations": false, "v2.ListIncidentNotificationRules": false, "v2.ListIncidentNotificationTemplates": false, + "v2.ListIncidentPostmortemTemplates": false, "v2.ListIncidents": false, "v2.ListIncidentTodos": false, "v2.ListIncidentTypes": false, @@ -753,6 +757,7 @@ func NewConfiguration() *Configuration { "v2.UpdateIncidentIntegration": false, "v2.UpdateIncidentNotificationRule": false, "v2.UpdateIncidentNotificationTemplate": false, + "v2.UpdateIncidentPostmortemTemplate": false, "v2.UpdateIncidentTodo": false, "v2.UpdateIncidentType": false, "v2.CreateJiraIssueTemplate": false, diff --git a/api/datadogV2/api_incidents.go b/api/datadogV2/api_incidents.go index 0fe569c306b..1e7dc230c8f 100644 --- a/api/datadogV2/api_incidents.go +++ b/api/datadogV2/api_incidents.go @@ -831,6 +831,104 @@ func (a *IncidentsApi) CreateIncidentPostmortemAttachment(ctx _context.Context, return localVarReturnValue, localVarHTTPResponse, nil } +// CreateIncidentPostmortemTemplate Create postmortem template. +// Create a new postmortem template for incidents. +func (a *IncidentsApi) CreateIncidentPostmortemTemplate(ctx _context.Context, body PostmortemTemplateRequest) (PostmortemTemplateResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue PostmortemTemplateResponse + ) + + operationId := "v2.CreateIncidentPostmortemTemplate" + 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.CreateIncidentPostmortemTemplate") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/incidents/config/postmortem-templates" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + 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 == 403 { + var v JSONAPIErrorResponse + 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 + } + if 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 +} + // CreateIncidentTodo Create an incident todo. // Create an incident todo. func (a *IncidentsApi) CreateIncidentTodo(ctx _context.Context, incidentId string, body IncidentTodoCreateRequest) (IncidentTodoResponse, *_nethttp.Response, error) { @@ -1607,6 +1705,92 @@ func (a *IncidentsApi) DeleteIncidentNotificationTemplate(ctx _context.Context, return localVarHTTPResponse, nil } +// DeleteIncidentPostmortemTemplate Delete postmortem template. +// Delete a postmortem template. +func (a *IncidentsApi) DeleteIncidentPostmortemTemplate(ctx _context.Context, templateId string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + operationId := "v2.DeleteIncidentPostmortemTemplate" + 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.DeleteIncidentPostmortemTemplate") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/incidents/config/postmortem-templates/{template_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{template_id}", _neturl.PathEscape(datadog.ParameterToString(templateId, ""))) + + 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 == 404 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarHTTPResponse, newErr + } + if 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 +} + // DeleteIncidentTodo Delete an incident todo. // Delete an incident todo. func (a *IncidentsApi) DeleteIncidentTodo(ctx _context.Context, incidentId string, todoId string) (*_nethttp.Response, error) { @@ -2290,6 +2474,102 @@ func (a *IncidentsApi) GetIncidentNotificationTemplate(ctx _context.Context, id 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) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue PostmortemTemplateResponse + ) + + operationId := "v2.GetIncidentPostmortemTemplate" + 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.GetIncidentPostmortemTemplate") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/incidents/config/postmortem-templates/{template_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{template_id}", _neturl.PathEscape(datadog.ParameterToString(templateId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + 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 == 404 { + var v JSONAPIErrorResponse + 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 + } + if 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 +} + // GetIncidentTodo Get incident todo details. // Get incident todo details. func (a *IncidentsApi) GetIncidentTodo(ctx _context.Context, incidentId string, todoId string) (IncidentTodoResponse, *_nethttp.Response, error) { @@ -3144,6 +3424,101 @@ func (a *IncidentsApi) ListIncidentNotificationTemplates(ctx _context.Context, o return localVarReturnValue, localVarHTTPResponse, nil } +// ListIncidentPostmortemTemplates List postmortem templates. +// Retrieve a list of all postmortem templates for incidents. +func (a *IncidentsApi) ListIncidentPostmortemTemplates(ctx _context.Context) (PostmortemTemplatesResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue PostmortemTemplatesResponse + ) + + operationId := "v2.ListIncidentPostmortemTemplates" + 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.ListIncidentPostmortemTemplates") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/incidents/config/postmortem-templates" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + 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 { + var v JSONAPIErrorResponse + 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 + } + if 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 +} + // ListIncidentTodos Get a list of an incident's todos. // Get all todos for an incident. func (a *IncidentsApi) ListIncidentTodos(ctx _context.Context, incidentId string) (IncidentTodoListResponse, *_nethttp.Response, error) { @@ -4520,6 +4895,105 @@ func (a *IncidentsApi) UpdateIncidentNotificationTemplate(ctx _context.Context, 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) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue PostmortemTemplateResponse + ) + + operationId := "v2.UpdateIncidentPostmortemTemplate" + 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.UpdateIncidentPostmortemTemplate") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/incidents/config/postmortem-templates/{template_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{template_id}", _neturl.PathEscape(datadog.ParameterToString(templateId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + 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 == 404 { + var v JSONAPIErrorResponse + 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 + } + if 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 +} + // UpdateIncidentTodo Update an incident todo. // Update an incident todo. func (a *IncidentsApi) UpdateIncidentTodo(ctx _context.Context, incidentId string, todoId string, body IncidentTodoPatchRequest) (IncidentTodoResponse, *_nethttp.Response, error) { diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index b167b02c2db..20575dc737a 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -309,6 +309,7 @@ // - [IncidentsApi.CreateIncidentNotificationRule] // - [IncidentsApi.CreateIncidentNotificationTemplate] // - [IncidentsApi.CreateIncidentPostmortemAttachment] +// - [IncidentsApi.CreateIncidentPostmortemTemplate] // - [IncidentsApi.CreateIncidentTodo] // - [IncidentsApi.CreateIncidentType] // - [IncidentsApi.DeleteGlobalIncidentHandle] @@ -318,6 +319,7 @@ // - [IncidentsApi.DeleteIncidentIntegration] // - [IncidentsApi.DeleteIncidentNotificationRule] // - [IncidentsApi.DeleteIncidentNotificationTemplate] +// - [IncidentsApi.DeleteIncidentPostmortemTemplate] // - [IncidentsApi.DeleteIncidentTodo] // - [IncidentsApi.DeleteIncidentType] // - [IncidentsApi.GetGlobalIncidentSettings] @@ -325,6 +327,7 @@ // - [IncidentsApi.GetIncidentIntegration] // - [IncidentsApi.GetIncidentNotificationRule] // - [IncidentsApi.GetIncidentNotificationTemplate] +// - [IncidentsApi.GetIncidentPostmortemTemplate] // - [IncidentsApi.GetIncidentTodo] // - [IncidentsApi.GetIncidentType] // - [IncidentsApi.ListGlobalIncidentHandles] @@ -333,6 +336,7 @@ // - [IncidentsApi.ListIncidentIntegrations] // - [IncidentsApi.ListIncidentNotificationRules] // - [IncidentsApi.ListIncidentNotificationTemplates] +// - [IncidentsApi.ListIncidentPostmortemTemplates] // - [IncidentsApi.ListIncidentTodos] // - [IncidentsApi.ListIncidentTypes] // - [IncidentsApi.ListIncidents] @@ -344,6 +348,7 @@ // - [IncidentsApi.UpdateIncidentIntegration] // - [IncidentsApi.UpdateIncidentNotificationRule] // - [IncidentsApi.UpdateIncidentNotificationTemplate] +// - [IncidentsApi.UpdateIncidentPostmortemTemplate] // - [IncidentsApi.UpdateIncidentTodo] // - [IncidentsApi.UpdateIncidentType] // - [JiraIntegrationApi.CreateJiraIssueTemplate] diff --git a/api/datadogV2/model_postmortem_template_attributes_request.go b/api/datadogV2/model_postmortem_template_attributes_request.go new file mode 100644 index 00000000000..9d41ef3abdb --- /dev/null +++ b/api/datadogV2/model_postmortem_template_attributes_request.go @@ -0,0 +1,101 @@ +// 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" +) + +// PostmortemTemplateAttributesRequest +type PostmortemTemplateAttributesRequest struct { + // The name of the template + Name string `json:"name"` + // 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:"-"` +} + +// NewPostmortemTemplateAttributesRequest instantiates a new PostmortemTemplateAttributesRequest 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 NewPostmortemTemplateAttributesRequest(name string) *PostmortemTemplateAttributesRequest { + this := PostmortemTemplateAttributesRequest{} + this.Name = name + return &this +} + +// NewPostmortemTemplateAttributesRequestWithDefaults instantiates a new PostmortemTemplateAttributesRequest 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 NewPostmortemTemplateAttributesRequestWithDefaults() *PostmortemTemplateAttributesRequest { + this := PostmortemTemplateAttributesRequest{} + return &this +} + +// GetName returns the Name field value. +func (o *PostmortemTemplateAttributesRequest) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *PostmortemTemplateAttributesRequest) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *PostmortemTemplateAttributesRequest) SetName(v string) { + o.Name = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PostmortemTemplateAttributesRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["name"] = o.Name + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PostmortemTemplateAttributesRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Name *string `json:"name"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"name"}) + } else { + return err + } + o.Name = *all.Name + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_postmortem_template_attributes_response.go b/api/datadogV2/model_postmortem_template_attributes_response.go new file mode 100644 index 00000000000..e0c0609d926 --- /dev/null +++ b/api/datadogV2/model_postmortem_template_attributes_response.go @@ -0,0 +1,174 @@ +// 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" +) + +// PostmortemTemplateAttributesResponse +type PostmortemTemplateAttributesResponse struct { + // When the template was created + CreatedAt time.Time `json:"createdAt"` + // When the template was last modified + ModifiedAt time.Time `json:"modifiedAt"` + // The name of the template + Name string `json:"name"` + // 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:"-"` +} + +// NewPostmortemTemplateAttributesResponse instantiates a new PostmortemTemplateAttributesResponse 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 NewPostmortemTemplateAttributesResponse(createdAt time.Time, modifiedAt time.Time, name string) *PostmortemTemplateAttributesResponse { + this := PostmortemTemplateAttributesResponse{} + this.CreatedAt = createdAt + this.ModifiedAt = modifiedAt + this.Name = name + return &this +} + +// NewPostmortemTemplateAttributesResponseWithDefaults instantiates a new PostmortemTemplateAttributesResponse 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 NewPostmortemTemplateAttributesResponseWithDefaults() *PostmortemTemplateAttributesResponse { + this := PostmortemTemplateAttributesResponse{} + return &this +} + +// GetCreatedAt returns the CreatedAt field value. +func (o *PostmortemTemplateAttributesResponse) GetCreatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *PostmortemTemplateAttributesResponse) GetCreatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.CreatedAt, true +} + +// SetCreatedAt sets field value. +func (o *PostmortemTemplateAttributesResponse) SetCreatedAt(v time.Time) { + o.CreatedAt = v +} + +// GetModifiedAt returns the ModifiedAt field value. +func (o *PostmortemTemplateAttributesResponse) GetModifiedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.ModifiedAt +} + +// GetModifiedAtOk returns a tuple with the ModifiedAt field value +// and a boolean to check if the value has been set. +func (o *PostmortemTemplateAttributesResponse) GetModifiedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.ModifiedAt, true +} + +// SetModifiedAt sets field value. +func (o *PostmortemTemplateAttributesResponse) SetModifiedAt(v time.Time) { + o.ModifiedAt = v +} + +// GetName returns the Name field value. +func (o *PostmortemTemplateAttributesResponse) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *PostmortemTemplateAttributesResponse) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *PostmortemTemplateAttributesResponse) SetName(v string) { + o.Name = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PostmortemTemplateAttributesResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.CreatedAt.Nanosecond() == 0 { + toSerialize["createdAt"] = o.CreatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["createdAt"] = o.CreatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + if o.ModifiedAt.Nanosecond() == 0 { + toSerialize["modifiedAt"] = o.ModifiedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["modifiedAt"] = o.ModifiedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["name"] = o.Name + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PostmortemTemplateAttributesResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CreatedAt *time.Time `json:"createdAt"` + ModifiedAt *time.Time `json:"modifiedAt"` + Name *string `json:"name"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.CreatedAt == nil { + return fmt.Errorf("required field createdAt missing") + } + if all.ModifiedAt == nil { + return fmt.Errorf("required field modifiedAt missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"createdAt", "modifiedAt", "name"}) + } else { + return err + } + o.CreatedAt = *all.CreatedAt + o.ModifiedAt = *all.ModifiedAt + o.Name = *all.Name + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_postmortem_template_data_request.go b/api/datadogV2/model_postmortem_template_data_request.go new file mode 100644 index 00000000000..18bc55cfd33 --- /dev/null +++ b/api/datadogV2/model_postmortem_template_data_request.go @@ -0,0 +1,146 @@ +// 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" +) + +// PostmortemTemplateDataRequest +type PostmortemTemplateDataRequest struct { + // + Attributes PostmortemTemplateAttributesRequest `json:"attributes"` + // Postmortem template resource type + Type PostmortemTemplateType `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:"-"` +} + +// NewPostmortemTemplateDataRequest instantiates a new PostmortemTemplateDataRequest 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 NewPostmortemTemplateDataRequest(attributes PostmortemTemplateAttributesRequest, typeVar PostmortemTemplateType) *PostmortemTemplateDataRequest { + this := PostmortemTemplateDataRequest{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewPostmortemTemplateDataRequestWithDefaults instantiates a new PostmortemTemplateDataRequest 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 NewPostmortemTemplateDataRequestWithDefaults() *PostmortemTemplateDataRequest { + this := PostmortemTemplateDataRequest{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *PostmortemTemplateDataRequest) GetAttributes() PostmortemTemplateAttributesRequest { + if o == nil { + var ret PostmortemTemplateAttributesRequest + 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 *PostmortemTemplateDataRequest) GetAttributesOk() (*PostmortemTemplateAttributesRequest, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *PostmortemTemplateDataRequest) SetAttributes(v PostmortemTemplateAttributesRequest) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *PostmortemTemplateDataRequest) GetType() PostmortemTemplateType { + if o == nil { + var ret PostmortemTemplateType + 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 *PostmortemTemplateDataRequest) GetTypeOk() (*PostmortemTemplateType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *PostmortemTemplateDataRequest) SetType(v PostmortemTemplateType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PostmortemTemplateDataRequest) 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 *PostmortemTemplateDataRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *PostmortemTemplateAttributesRequest `json:"attributes"` + Type *PostmortemTemplateType `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.Unmarshal(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_postmortem_template_data_response.go b/api/datadogV2/model_postmortem_template_data_response.go new file mode 100644 index 00000000000..c6827f774a8 --- /dev/null +++ b/api/datadogV2/model_postmortem_template_data_response.go @@ -0,0 +1,178 @@ +// 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" +) + +// PostmortemTemplateDataResponse +type PostmortemTemplateDataResponse struct { + // + Attributes PostmortemTemplateAttributesResponse `json:"attributes"` + // The ID of the template + Id string `json:"id"` + // Postmortem template resource type + Type PostmortemTemplateType `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:"-"` +} + +// NewPostmortemTemplateDataResponse instantiates a new PostmortemTemplateDataResponse 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 NewPostmortemTemplateDataResponse(attributes PostmortemTemplateAttributesResponse, id string, typeVar PostmortemTemplateType) *PostmortemTemplateDataResponse { + this := PostmortemTemplateDataResponse{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewPostmortemTemplateDataResponseWithDefaults instantiates a new PostmortemTemplateDataResponse 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 NewPostmortemTemplateDataResponseWithDefaults() *PostmortemTemplateDataResponse { + this := PostmortemTemplateDataResponse{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *PostmortemTemplateDataResponse) GetAttributes() PostmortemTemplateAttributesResponse { + if o == nil { + var ret PostmortemTemplateAttributesResponse + 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 *PostmortemTemplateDataResponse) GetAttributesOk() (*PostmortemTemplateAttributesResponse, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *PostmortemTemplateDataResponse) SetAttributes(v PostmortemTemplateAttributesResponse) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *PostmortemTemplateDataResponse) 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 *PostmortemTemplateDataResponse) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *PostmortemTemplateDataResponse) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *PostmortemTemplateDataResponse) GetType() PostmortemTemplateType { + if o == nil { + var ret PostmortemTemplateType + 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 *PostmortemTemplateDataResponse) GetTypeOk() (*PostmortemTemplateType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *PostmortemTemplateDataResponse) SetType(v PostmortemTemplateType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PostmortemTemplateDataResponse) 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 *PostmortemTemplateDataResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *PostmortemTemplateAttributesResponse `json:"attributes"` + Id *string `json:"id"` + Type *PostmortemTemplateType `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.Unmarshal(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_postmortem_template_request.go b/api/datadogV2/model_postmortem_template_request.go new file mode 100644 index 00000000000..d149cd0c528 --- /dev/null +++ b/api/datadogV2/model_postmortem_template_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" +) + +// PostmortemTemplateRequest +type PostmortemTemplateRequest struct { + // + Data PostmortemTemplateDataRequest `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:"-"` +} + +// NewPostmortemTemplateRequest instantiates a new PostmortemTemplateRequest 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 NewPostmortemTemplateRequest(data PostmortemTemplateDataRequest) *PostmortemTemplateRequest { + this := PostmortemTemplateRequest{} + this.Data = data + return &this +} + +// NewPostmortemTemplateRequestWithDefaults instantiates a new PostmortemTemplateRequest 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 NewPostmortemTemplateRequestWithDefaults() *PostmortemTemplateRequest { + this := PostmortemTemplateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *PostmortemTemplateRequest) GetData() PostmortemTemplateDataRequest { + if o == nil { + var ret PostmortemTemplateDataRequest + 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 *PostmortemTemplateRequest) GetDataOk() (*PostmortemTemplateDataRequest, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *PostmortemTemplateRequest) SetData(v PostmortemTemplateDataRequest) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PostmortemTemplateRequest) 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 *PostmortemTemplateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *PostmortemTemplateDataRequest `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.Unmarshal(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_postmortem_template_response.go b/api/datadogV2/model_postmortem_template_response.go new file mode 100644 index 00000000000..e1e1e304982 --- /dev/null +++ b/api/datadogV2/model_postmortem_template_response.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" +) + +// PostmortemTemplateResponse +type PostmortemTemplateResponse struct { + // + Data PostmortemTemplateDataResponse `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:"-"` +} + +// NewPostmortemTemplateResponse instantiates a new PostmortemTemplateResponse 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 NewPostmortemTemplateResponse(data PostmortemTemplateDataResponse) *PostmortemTemplateResponse { + this := PostmortemTemplateResponse{} + this.Data = data + return &this +} + +// NewPostmortemTemplateResponseWithDefaults instantiates a new PostmortemTemplateResponse 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 NewPostmortemTemplateResponseWithDefaults() *PostmortemTemplateResponse { + this := PostmortemTemplateResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *PostmortemTemplateResponse) GetData() PostmortemTemplateDataResponse { + if o == nil { + var ret PostmortemTemplateDataResponse + 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 *PostmortemTemplateResponse) GetDataOk() (*PostmortemTemplateDataResponse, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *PostmortemTemplateResponse) SetData(v PostmortemTemplateDataResponse) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PostmortemTemplateResponse) 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 *PostmortemTemplateResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *PostmortemTemplateDataResponse `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.Unmarshal(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_postmortem_template_type.go b/api/datadogV2/model_postmortem_template_type.go new file mode 100644 index 00000000000..6c35d28c2bb --- /dev/null +++ b/api/datadogV2/model_postmortem_template_type.go @@ -0,0 +1,64 @@ +// 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" +) + +// PostmortemTemplateType Postmortem template resource type +type PostmortemTemplateType string + +// List of PostmortemTemplateType. +const ( + POSTMORTEMTEMPLATETYPE_POSTMORTEM_TEMPLATE PostmortemTemplateType = "postmortem_template" +) + +var allowedPostmortemTemplateTypeEnumValues = []PostmortemTemplateType{ + POSTMORTEMTEMPLATETYPE_POSTMORTEM_TEMPLATE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *PostmortemTemplateType) GetAllowedValues() []PostmortemTemplateType { + return allowedPostmortemTemplateTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *PostmortemTemplateType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = PostmortemTemplateType(value) + return nil +} + +// NewPostmortemTemplateTypeFromValue returns a pointer to a valid PostmortemTemplateType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewPostmortemTemplateTypeFromValue(v string) (*PostmortemTemplateType, error) { + ev := PostmortemTemplateType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for PostmortemTemplateType: valid values are %v", v, allowedPostmortemTemplateTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v PostmortemTemplateType) IsValid() bool { + for _, existing := range allowedPostmortemTemplateTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to PostmortemTemplateType value. +func (v PostmortemTemplateType) Ptr() *PostmortemTemplateType { + return &v +} diff --git a/api/datadogV2/model_postmortem_templates_response.go b/api/datadogV2/model_postmortem_templates_response.go new file mode 100644 index 00000000000..70c77b4356d --- /dev/null +++ b/api/datadogV2/model_postmortem_templates_response.go @@ -0,0 +1,101 @@ +// 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" +) + +// PostmortemTemplatesResponse +type PostmortemTemplatesResponse struct { + // + Data []PostmortemTemplateDataResponse `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:"-"` +} + +// NewPostmortemTemplatesResponse instantiates a new PostmortemTemplatesResponse 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 NewPostmortemTemplatesResponse(data []PostmortemTemplateDataResponse) *PostmortemTemplatesResponse { + this := PostmortemTemplatesResponse{} + this.Data = data + return &this +} + +// NewPostmortemTemplatesResponseWithDefaults instantiates a new PostmortemTemplatesResponse 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 NewPostmortemTemplatesResponseWithDefaults() *PostmortemTemplatesResponse { + this := PostmortemTemplatesResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *PostmortemTemplatesResponse) GetData() []PostmortemTemplateDataResponse { + if o == nil { + var ret []PostmortemTemplateDataResponse + 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 *PostmortemTemplatesResponse) GetDataOk() (*[]PostmortemTemplateDataResponse, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *PostmortemTemplatesResponse) SetData(v []PostmortemTemplateDataResponse) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PostmortemTemplatesResponse) 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 *PostmortemTemplatesResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]PostmortemTemplateDataResponse `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.Unmarshal(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 +} diff --git a/examples/v2/incidents/CreateIncidentPostmortemTemplate.go b/examples/v2/incidents/CreateIncidentPostmortemTemplate.go new file mode 100644 index 00000000000..d5b389cbcbe --- /dev/null +++ b/examples/v2/incidents/CreateIncidentPostmortemTemplate.go @@ -0,0 +1,38 @@ +// Create postmortem template 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() { + body := datadogV2.PostmortemTemplateRequest{ + Data: datadogV2.PostmortemTemplateDataRequest{ + Attributes: datadogV2.PostmortemTemplateAttributesRequest{ + Name: "Standard Postmortem Template", + }, + Type: datadogV2.POSTMORTEMTEMPLATETYPE_POSTMORTEM_TEMPLATE, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.CreateIncidentPostmortemTemplate", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewIncidentsApi(apiClient) + resp, r, err := api.CreateIncidentPostmortemTemplate(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.CreateIncidentPostmortemTemplate`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.CreateIncidentPostmortemTemplate`:\n%s\n", responseContent) +} diff --git a/examples/v2/incidents/DeleteIncidentPostmortemTemplate.go b/examples/v2/incidents/DeleteIncidentPostmortemTemplate.go new file mode 100644 index 00000000000..22464a2cebf --- /dev/null +++ b/examples/v2/incidents/DeleteIncidentPostmortemTemplate.go @@ -0,0 +1,26 @@ +// Delete postmortem template returns "No Content" 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() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.DeleteIncidentPostmortemTemplate", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewIncidentsApi(apiClient) + r, err := api.DeleteIncidentPostmortemTemplate(ctx, "template-456") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.DeleteIncidentPostmortemTemplate`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/incidents/GetIncidentPostmortemTemplate.go b/examples/v2/incidents/GetIncidentPostmortemTemplate.go new file mode 100644 index 00000000000..c35c0658645 --- /dev/null +++ b/examples/v2/incidents/GetIncidentPostmortemTemplate.go @@ -0,0 +1,30 @@ +// Get postmortem template 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() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.GetIncidentPostmortemTemplate", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewIncidentsApi(apiClient) + resp, r, err := api.GetIncidentPostmortemTemplate(ctx, "template-456") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.GetIncidentPostmortemTemplate`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.GetIncidentPostmortemTemplate`:\n%s\n", responseContent) +} diff --git a/examples/v2/incidents/ListIncidentPostmortemTemplates.go b/examples/v2/incidents/ListIncidentPostmortemTemplates.go new file mode 100644 index 00000000000..35bc95a71e9 --- /dev/null +++ b/examples/v2/incidents/ListIncidentPostmortemTemplates.go @@ -0,0 +1,30 @@ +// List postmortem templates 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() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ListIncidentPostmortemTemplates", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewIncidentsApi(apiClient) + resp, r, err := api.ListIncidentPostmortemTemplates(ctx) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.ListIncidentPostmortemTemplates`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.ListIncidentPostmortemTemplates`:\n%s\n", responseContent) +} diff --git a/examples/v2/incidents/UpdateIncidentPostmortemTemplate.go b/examples/v2/incidents/UpdateIncidentPostmortemTemplate.go new file mode 100644 index 00000000000..bfd84cf9b35 --- /dev/null +++ b/examples/v2/incidents/UpdateIncidentPostmortemTemplate.go @@ -0,0 +1,38 @@ +// Update postmortem template 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() { + body := datadogV2.PostmortemTemplateRequest{ + Data: datadogV2.PostmortemTemplateDataRequest{ + Attributes: datadogV2.PostmortemTemplateAttributesRequest{ + Name: "Standard Postmortem Template", + }, + Type: datadogV2.POSTMORTEMTEMPLATETYPE_POSTMORTEM_TEMPLATE, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.UpdateIncidentPostmortemTemplate", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewIncidentsApi(apiClient) + resp, r, err := api.UpdateIncidentPostmortemTemplate(ctx, "template-456", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.UpdateIncidentPostmortemTemplate`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.UpdateIncidentPostmortemTemplate`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/features/v2/incidents.feature b/tests/scenarios/features/v2/incidents.feature index db706355841..a683c2cac14 100644 --- a/tests/scenarios/features/v2/incidents.feature +++ b/tests/scenarios/features/v2/incidents.feature @@ -290,6 +290,22 @@ Feature: Incidents When the request is sent Then the response status is 201 Created + @generated @skip @team:DataDog/incident-app + Scenario: Create postmortem template returns "Bad Request" response + Given operation "CreateIncidentPostmortemTemplate" enabled + And new "CreateIncidentPostmortemTemplate" request + And body with value {"data": {"attributes": {"name": "Standard Postmortem Template"}, "type": "postmortem_template"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Create postmortem template returns "Created" response + Given operation "CreateIncidentPostmortemTemplate" enabled + And new "CreateIncidentPostmortemTemplate" request + And body with value {"data": {"attributes": {"name": "Standard Postmortem Template"}, "type": "postmortem_template"}} + When the request is sent + Then the response status is 201 Created + @generated @skip @team:Datadog/incident-app Scenario: Delete a notification template returns "Bad Request" response Given operation "DeleteIncidentNotificationTemplate" enabled @@ -537,6 +553,30 @@ Feature: Incidents When the request is sent Then the response status is 204 No Content + @generated @skip @team:DataDog/incident-app + Scenario: Delete postmortem template returns "Bad Request" response + Given operation "DeleteIncidentPostmortemTemplate" enabled + And new "DeleteIncidentPostmortemTemplate" request + And request contains "template_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 template returns "No Content" response + Given operation "DeleteIncidentPostmortemTemplate" enabled + And new "DeleteIncidentPostmortemTemplate" request + And request contains "template_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/incident-app + Scenario: Delete postmortem template returns "Not Found" response + Given operation "DeleteIncidentPostmortemTemplate" enabled + And new "DeleteIncidentPostmortemTemplate" request + And request contains "template_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @generated @skip @team:DataDog/incident-app Scenario: Get a list of an incident's integration metadata returns "Bad Request" response Given operation "ListIncidentIntegrations" enabled @@ -811,6 +851,30 @@ Feature: Incidents When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/incident-app + Scenario: Get postmortem template returns "Bad Request" response + Given operation "GetIncidentPostmortemTemplate" enabled + And new "GetIncidentPostmortemTemplate" request + And request contains "template_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 template returns "Not Found" response + Given operation "GetIncidentPostmortemTemplate" enabled + And new "GetIncidentPostmortemTemplate" request + And request contains "template_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/incident-app + Scenario: Get postmortem template returns "OK" response + Given operation "GetIncidentPostmortemTemplate" enabled + And new "GetIncidentPostmortemTemplate" request + And request contains "template_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/incident-app Scenario: Get the details of an incident returns "Bad Request" response Given operation "GetIncident" enabled @@ -940,6 +1004,20 @@ Feature: Incidents Then the response status is 200 OK And the response "data" has length 0 + @generated @skip @team:DataDog/incident-app + Scenario: List postmortem templates returns "Bad Request" response + Given operation "ListIncidentPostmortemTemplates" enabled + And new "ListIncidentPostmortemTemplates" request + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: List postmortem templates returns "OK" response + Given operation "ListIncidentPostmortemTemplates" enabled + And new "ListIncidentPostmortemTemplates" request + When the request is sent + Then the response status is 200 OK + @team:DataDog/incident-app Scenario: Remove commander from an incident returns "OK" response Given operation "UpdateIncident" enabled @@ -1270,3 +1348,30 @@ Feature: Incidents And the response "data.id" has the same value as "notification_template.data.id" 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 template returns "Bad Request" response + Given operation "UpdateIncidentPostmortemTemplate" enabled + And new "UpdateIncidentPostmortemTemplate" request + And request contains "template_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"name": "Standard Postmortem Template"}, "type": "postmortem_template"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Update postmortem template returns "Not Found" response + Given operation "UpdateIncidentPostmortemTemplate" enabled + And new "UpdateIncidentPostmortemTemplate" request + And request contains "template_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"name": "Standard Postmortem Template"}, "type": "postmortem_template"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/incident-app + Scenario: Update postmortem template returns "OK" response + Given operation "UpdateIncidentPostmortemTemplate" enabled + And new "UpdateIncidentPostmortemTemplate" request + And request contains "template_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"name": "Standard Postmortem Template"}, "type": "postmortem_template"}} + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 7e549784ee6..c77dfee3356 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1761,6 +1761,43 @@ "type": "idempotent" } }, + "ListIncidentPostmortemTemplates": { + "tag": "Incidents", + "undo": { + "type": "safe" + } + }, + "CreateIncidentPostmortemTemplate": { + "tag": "Incidents", + "undo": { + "operationId": "DeleteIncidentPostmortemTemplate", + "parameters": [ + { + "name": "template_id", + "source": "" + } + ], + "type": "unsafe" + } + }, + "DeleteIncidentPostmortemTemplate": { + "tag": "Incidents", + "undo": { + "type": "idempotent" + } + }, + "GetIncidentPostmortemTemplate": { + "tag": "Incidents", + "undo": { + "type": "safe" + } + }, + "UpdateIncidentPostmortemTemplate": { + "tag": "Incidents", + "undo": { + "type": "idempotent" + } + }, "ListIncidentTypes": { "tag": "Incidents", "undo": {