Skip to content

Commit 58a42ad

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add missing incident attachments documentation (#3290)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 88fdae6 commit 58a42ad

16 files changed

Lines changed: 784 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:
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* Create postmortem attachment returns "Created" response
3+
*/
4+
5+
import { client, v2 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
configuration.unstableOperations["v2.createIncidentPostmortemAttachment"] =
9+
true;
10+
const apiInstance = new v2.IncidentsApi(configuration);
11+
12+
const params: v2.IncidentsApiCreateIncidentPostmortemAttachmentRequest = {
13+
body: {
14+
data: {
15+
attributes: {
16+
cells: [
17+
{
18+
attributes: {
19+
definition: {
20+
content: "## Incident Summary\nThis incident was caused by...",
21+
},
22+
},
23+
id: "cell-1",
24+
type: "markdown",
25+
},
26+
],
27+
content: "# Incident Report - IR-123\n[...]",
28+
postmortemTemplateId: "93645509-874e-45c4-adfa-623bfeaead89-123",
29+
title: "Postmortem-IR-123",
30+
},
31+
type: "incident_attachments",
32+
},
33+
},
34+
incidentId: "00000000-0000-0000-0000-000000000000",
35+
};
36+
37+
apiInstance
38+
.createIncidentPostmortemAttachment(params)
39+
.then((data: v2.Attachment) => {
40+
console.log(
41+
"API called successfully. Returned data: " + JSON.stringify(data)
42+
);
43+
})
44+
.catch((error: any) => console.error(error));

features/support/scenarios_model_mapping.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6078,6 +6078,17 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = {
60786078
},
60796079
"operationResponseType": "Attachment",
60806080
},
6081+
"v2.CreateIncidentPostmortemAttachment": {
6082+
"incidentId": {
6083+
"type": "string",
6084+
"format": "",
6085+
},
6086+
"body": {
6087+
"type": "PostmortemAttachmentRequest",
6088+
"format": "",
6089+
},
6090+
"operationResponseType": "Attachment",
6091+
},
60816092
"v2.DeleteIncidentAttachment": {
60826093
"incidentId": {
60836094
"type": "string",

features/v2/incidents.feature

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,24 @@ Feature: Incidents
253253
When the request is sent
254254
Then the response status is 404 Not Found
255255

256+
@generated @skip @team:DataDog/incident-app
257+
Scenario: Create postmortem attachment returns "Bad Request" response
258+
Given operation "CreateIncidentPostmortemAttachment" enabled
259+
And new "CreateIncidentPostmortemAttachment" request
260+
And request contains "incident_id" parameter from "REPLACE.ME"
261+
And body with value {"data": {"attributes": {"cells": [{"attributes": {"definition": {"content": "## Incident Summary\nThis incident was caused by..."}}, "id": "cell-1", "type": "markdown"}], "content": "# Incident Report - IR-123\n[...]", "postmortem_template_id": "93645509-874e-45c4-adfa-623bfeaead89-123", "title": "Postmortem-IR-123"}, "type": "incident_attachments"}}
262+
When the request is sent
263+
Then the response status is 400 Bad Request
264+
265+
@generated @skip @team:DataDog/incident-app
266+
Scenario: Create postmortem attachment returns "Created" response
267+
Given operation "CreateIncidentPostmortemAttachment" enabled
268+
And new "CreateIncidentPostmortemAttachment" request
269+
And request contains "incident_id" parameter from "REPLACE.ME"
270+
And body with value {"data": {"attributes": {"cells": [{"attributes": {"definition": {"content": "## Incident Summary\nThis incident was caused by..."}}, "id": "cell-1", "type": "markdown"}], "content": "# Incident Report - IR-123\n[...]", "postmortem_template_id": "93645509-874e-45c4-adfa-623bfeaead89-123", "title": "Postmortem-IR-123"}, "type": "incident_attachments"}}
271+
When the request is sent
272+
Then the response status is 201 Created
273+
256274
@generated @skip @team:Datadog/incident-app
257275
Scenario: Delete a notification template returns "Bad Request" response
258276
Given operation "DeleteIncidentNotificationTemplate" enabled

features/v2/undo.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,6 +1734,14 @@
17341734
"type": "unsafe"
17351735
}
17361736
},
1737+
"CreateIncidentPostmortemAttachment": {
1738+
"tag": "Incidents",
1739+
"undo": {
1740+
"operationId": "TODO",
1741+
"parameters": [],
1742+
"type": "unsafe"
1743+
}
1744+
},
17371745
"DeleteIncidentAttachment": {
17381746
"tag": "Incidents",
17391747
"undo": {

packages/datadog-api-client-common/configuration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ export function createConfiguration(
286286
"v2.createIncidentIntegration": false,
287287
"v2.createIncidentNotificationRule": false,
288288
"v2.createIncidentNotificationTemplate": false,
289+
"v2.createIncidentPostmortemAttachment": false,
289290
"v2.createIncidentTodo": false,
290291
"v2.createIncidentType": false,
291292
"v2.deleteIncident": false,

0 commit comments

Comments
 (0)