Skip to content

Commit 9c77a21

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add missing incident attachments documentation (DataDog#3606)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 9f28542 commit 9c77a21

14 files changed

Lines changed: 1224 additions & 0 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41880,6 +41880,83 @@ components:
4188041880
type: string
4188141881
x-enum-varnames:
4188241882
- PERMISSIONS
41883+
PostmortemAttachmentRequest:
41884+
properties:
41885+
data:
41886+
$ref: '#/components/schemas/PostmortemAttachmentRequestData'
41887+
required:
41888+
- data
41889+
type: object
41890+
PostmortemAttachmentRequestAttributes:
41891+
description: Postmortem attachment attributes
41892+
properties:
41893+
cells:
41894+
description: The cells of the postmortem
41895+
items:
41896+
$ref: '#/components/schemas/PostmortemCell'
41897+
type: array
41898+
content:
41899+
description: The content of the postmortem
41900+
example: '# Incident Report - IR-123
41901+
41902+
[...]'
41903+
type: string
41904+
postmortem_template_id:
41905+
description: The ID of the postmortem template
41906+
example: 93645509-874e-45c4-adfa-623bfeaead89-123
41907+
type: string
41908+
title:
41909+
description: The title of the postmortem
41910+
example: Postmortem-IR-123
41911+
type: string
41912+
type: object
41913+
PostmortemAttachmentRequestData:
41914+
description: Postmortem attachment data
41915+
properties:
41916+
attributes:
41917+
$ref: '#/components/schemas/PostmortemAttachmentRequestAttributes'
41918+
type:
41919+
$ref: '#/components/schemas/IncidentAttachmentType'
41920+
required:
41921+
- type
41922+
- attributes
41923+
type: object
41924+
PostmortemCell:
41925+
description: A cell in the postmortem
41926+
properties:
41927+
attributes:
41928+
$ref: '#/components/schemas/PostmortemCellAttributes'
41929+
id:
41930+
description: The unique identifier of the cell
41931+
example: cell-1
41932+
type: string
41933+
type:
41934+
$ref: '#/components/schemas/PostmortemCellType'
41935+
type: object
41936+
PostmortemCellAttributes:
41937+
description: Attributes of a postmortem cell
41938+
properties:
41939+
definition:
41940+
$ref: '#/components/schemas/PostmortemCellDefinition'
41941+
type: object
41942+
PostmortemCellDefinition:
41943+
description: Definition of a postmortem cell
41944+
properties:
41945+
content:
41946+
description: The content of the cell in markdown format
41947+
example: '## Incident Summary
41948+
41949+
This incident was caused by...'
41950+
type: string
41951+
type: object
41952+
PostmortemCellType:
41953+
description: The postmortem cell resource type.
41954+
enum:
41955+
- markdown
41956+
example: markdown
41957+
type: string
41958+
x-enum-varnames:
41959+
- MARKDOWN
4188341960
Powerpack:
4188441961
description: Powerpacks are templated groups of dashboard widgets you can save
4188541962
from an existing dashboard and turn into reusable packs in the widget tray.
@@ -71685,6 +71762,46 @@ paths:
7168571762
- incident_write
7168671763
x-unstable: '**Note**: This endpoint is in Preview.
7168771764

71765+
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
71766+
/api/v2/incidents/{incident_id}/attachments/postmortems:
71767+
post:
71768+
description: Create a postmortem attachment for an incident.
71769+
operationId: CreateIncidentPostmortemAttachment
71770+
parameters:
71771+
- description: The ID of the incident
71772+
in: path
71773+
name: incident_id
71774+
required: true
71775+
schema:
71776+
example: 00000000-0000-0000-0000-000000000000
71777+
type: string
71778+
requestBody:
71779+
content:
71780+
application/json:
71781+
schema:
71782+
$ref: '#/components/schemas/PostmortemAttachmentRequest'
71783+
required: true
71784+
responses:
71785+
'201':
71786+
content:
71787+
application/json:
71788+
schema:
71789+
$ref: '#/components/schemas/Attachment'
71790+
description: Created
71791+
'400':
71792+
content:
71793+
application/json:
71794+
schema:
71795+
$ref: '#/components/schemas/JSONAPIErrorResponse'
71796+
description: Bad Request
71797+
'429':
71798+
$ref: '#/components/responses/TooManyRequestsResponse'
71799+
summary: Create postmortem attachment
71800+
tags:
71801+
- Incidents
71802+
x-unstable: '**Note**: This endpoint is in public beta and it''s subject to
71803+
change.
71804+
7168871805
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
7168971806
/api/v2/incidents/{incident_id}/attachments/{attachment_id}:
7169071807
delete:

api/datadog/configuration.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ func NewConfiguration() *Configuration {
717717
"v2.CreateIncidentIntegration": false,
718718
"v2.CreateIncidentNotificationRule": false,
719719
"v2.CreateIncidentNotificationTemplate": false,
720+
"v2.CreateIncidentPostmortemAttachment": false,
720721
"v2.CreateIncidentTodo": false,
721722
"v2.CreateIncidentType": false,
722723
"v2.DeleteIncident": false,

api/datadogV2/api_incidents.go

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,105 @@ func (a *IncidentsApi) CreateIncidentNotificationTemplate(ctx _context.Context,
602602
return localVarReturnValue, localVarHTTPResponse, nil
603603
}
604604

605+
// CreateIncidentPostmortemAttachment Create postmortem attachment.
606+
// Create a postmortem attachment for an incident.
607+
func (a *IncidentsApi) CreateIncidentPostmortemAttachment(ctx _context.Context, incidentId string, body PostmortemAttachmentRequest) (Attachment, *_nethttp.Response, error) {
608+
var (
609+
localVarHTTPMethod = _nethttp.MethodPost
610+
localVarPostBody interface{}
611+
localVarReturnValue Attachment
612+
)
613+
614+
operationId := "v2.CreateIncidentPostmortemAttachment"
615+
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
616+
if !isOperationEnabled {
617+
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
618+
}
619+
if isOperationEnabled && a.Client.Cfg.Debug {
620+
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
621+
}
622+
623+
localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentsApi.CreateIncidentPostmortemAttachment")
624+
if err != nil {
625+
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
626+
}
627+
628+
localVarPath := localBasePath + "/api/v2/incidents/{incident_id}/attachments/postmortems"
629+
localVarPath = datadog.ReplacePathParameter(localVarPath, "{incident_id}", _neturl.PathEscape(datadog.ParameterToString(incidentId, "")))
630+
631+
localVarHeaderParams := make(map[string]string)
632+
localVarQueryParams := _neturl.Values{}
633+
localVarFormParams := _neturl.Values{}
634+
localVarHeaderParams["Content-Type"] = "application/json"
635+
localVarHeaderParams["Accept"] = "application/json"
636+
637+
// body params
638+
localVarPostBody = &body
639+
if a.Client.Cfg.DelegatedTokenConfig != nil {
640+
err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig)
641+
if err != nil {
642+
return localVarReturnValue, nil, err
643+
}
644+
} else {
645+
datadog.SetAuthKeys(
646+
ctx,
647+
&localVarHeaderParams,
648+
[2]string{"apiKeyAuth", "DD-API-KEY"},
649+
[2]string{"appKeyAuth", "DD-APPLICATION-KEY"},
650+
)
651+
}
652+
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
653+
if err != nil {
654+
return localVarReturnValue, nil, err
655+
}
656+
657+
localVarHTTPResponse, err := a.Client.CallAPI(req)
658+
if err != nil || localVarHTTPResponse == nil {
659+
return localVarReturnValue, localVarHTTPResponse, err
660+
}
661+
662+
localVarBody, err := datadog.ReadBody(localVarHTTPResponse)
663+
if err != nil {
664+
return localVarReturnValue, localVarHTTPResponse, err
665+
}
666+
667+
if localVarHTTPResponse.StatusCode >= 300 {
668+
newErr := datadog.GenericOpenAPIError{
669+
ErrorBody: localVarBody,
670+
ErrorMessage: localVarHTTPResponse.Status,
671+
}
672+
if localVarHTTPResponse.StatusCode == 400 {
673+
var v JSONAPIErrorResponse
674+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
675+
if err != nil {
676+
return localVarReturnValue, localVarHTTPResponse, newErr
677+
}
678+
newErr.ErrorModel = v
679+
return localVarReturnValue, localVarHTTPResponse, newErr
680+
}
681+
if localVarHTTPResponse.StatusCode == 429 {
682+
var v APIErrorResponse
683+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
684+
if err != nil {
685+
return localVarReturnValue, localVarHTTPResponse, newErr
686+
}
687+
newErr.ErrorModel = v
688+
}
689+
return localVarReturnValue, localVarHTTPResponse, newErr
690+
}
691+
692+
err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
693+
if err != nil {
694+
newErr := datadog.GenericOpenAPIError{
695+
ErrorBody: localVarBody,
696+
ErrorMessage: err.Error(),
697+
}
698+
return localVarReturnValue, localVarHTTPResponse, newErr
699+
}
700+
701+
return localVarReturnValue, localVarHTTPResponse, nil
702+
}
703+
605704
// CreateIncidentTodo Create an incident todo.
606705
// Create an incident todo.
607706
func (a *IncidentsApi) CreateIncidentTodo(ctx _context.Context, incidentId string, body IncidentTodoCreateRequest) (IncidentTodoResponse, *_nethttp.Response, error) {

api/datadogV2/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@
296296
// - [IncidentsApi.CreateIncidentIntegration]
297297
// - [IncidentsApi.CreateIncidentNotificationRule]
298298
// - [IncidentsApi.CreateIncidentNotificationTemplate]
299+
// - [IncidentsApi.CreateIncidentPostmortemAttachment]
299300
// - [IncidentsApi.CreateIncidentTodo]
300301
// - [IncidentsApi.CreateIncidentType]
301302
// - [IncidentsApi.DeleteIncident]
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
5+
package datadogV2
6+
7+
import (
8+
"fmt"
9+
10+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
11+
)
12+
13+
// PostmortemAttachmentRequest
14+
type PostmortemAttachmentRequest struct {
15+
// Postmortem attachment data
16+
Data PostmortemAttachmentRequestData `json:"data"`
17+
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
18+
UnparsedObject map[string]interface{} `json:"-"`
19+
AdditionalProperties map[string]interface{} `json:"-"`
20+
}
21+
22+
// NewPostmortemAttachmentRequest instantiates a new PostmortemAttachmentRequest object.
23+
// This constructor will assign default values to properties that have it defined,
24+
// and makes sure properties required by API are set, but the set of arguments
25+
// will change when the set of required properties is changed.
26+
func NewPostmortemAttachmentRequest(data PostmortemAttachmentRequestData) *PostmortemAttachmentRequest {
27+
this := PostmortemAttachmentRequest{}
28+
this.Data = data
29+
return &this
30+
}
31+
32+
// NewPostmortemAttachmentRequestWithDefaults instantiates a new PostmortemAttachmentRequest object.
33+
// This constructor will only assign default values to properties that have it defined,
34+
// but it doesn't guarantee that properties required by API are set.
35+
func NewPostmortemAttachmentRequestWithDefaults() *PostmortemAttachmentRequest {
36+
this := PostmortemAttachmentRequest{}
37+
return &this
38+
}
39+
40+
// GetData returns the Data field value.
41+
func (o *PostmortemAttachmentRequest) GetData() PostmortemAttachmentRequestData {
42+
if o == nil {
43+
var ret PostmortemAttachmentRequestData
44+
return ret
45+
}
46+
return o.Data
47+
}
48+
49+
// GetDataOk returns a tuple with the Data field value
50+
// and a boolean to check if the value has been set.
51+
func (o *PostmortemAttachmentRequest) GetDataOk() (*PostmortemAttachmentRequestData, bool) {
52+
if o == nil {
53+
return nil, false
54+
}
55+
return &o.Data, true
56+
}
57+
58+
// SetData sets field value.
59+
func (o *PostmortemAttachmentRequest) SetData(v PostmortemAttachmentRequestData) {
60+
o.Data = v
61+
}
62+
63+
// MarshalJSON serializes the struct using spec logic.
64+
func (o PostmortemAttachmentRequest) MarshalJSON() ([]byte, error) {
65+
toSerialize := map[string]interface{}{}
66+
if o.UnparsedObject != nil {
67+
return datadog.Marshal(o.UnparsedObject)
68+
}
69+
toSerialize["data"] = o.Data
70+
71+
for key, value := range o.AdditionalProperties {
72+
toSerialize[key] = value
73+
}
74+
return datadog.Marshal(toSerialize)
75+
}
76+
77+
// UnmarshalJSON deserializes the given payload.
78+
func (o *PostmortemAttachmentRequest) UnmarshalJSON(bytes []byte) (err error) {
79+
all := struct {
80+
Data *PostmortemAttachmentRequestData `json:"data"`
81+
}{}
82+
if err = datadog.Unmarshal(bytes, &all); err != nil {
83+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
84+
}
85+
if all.Data == nil {
86+
return fmt.Errorf("required field data missing")
87+
}
88+
additionalProperties := make(map[string]interface{})
89+
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
90+
datadog.DeleteKeys(additionalProperties, &[]string{"data"})
91+
} else {
92+
return err
93+
}
94+
95+
hasInvalidField := false
96+
if all.Data.UnparsedObject != nil && o.UnparsedObject == nil {
97+
hasInvalidField = true
98+
}
99+
o.Data = *all.Data
100+
101+
if len(additionalProperties) > 0 {
102+
o.AdditionalProperties = additionalProperties
103+
}
104+
105+
if hasInvalidField {
106+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
107+
}
108+
109+
return nil
110+
}

0 commit comments

Comments
 (0)