Skip to content

Commit 95fc9fd

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

15 files changed

+640
-0
lines changed

.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:

docs/datadog_api_client.v2.model.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18183,6 +18183,55 @@ datadog\_api\_client.v2.model.permissions\_type module
1818318183
:members:
1818418184
:show-inheritance:
1818518185

18186+
datadog\_api\_client.v2.model.postmortem\_attachment\_request module
18187+
--------------------------------------------------------------------
18188+
18189+
.. automodule:: datadog_api_client.v2.model.postmortem_attachment_request
18190+
:members:
18191+
:show-inheritance:
18192+
18193+
datadog\_api\_client.v2.model.postmortem\_attachment\_request\_attributes module
18194+
--------------------------------------------------------------------------------
18195+
18196+
.. automodule:: datadog_api_client.v2.model.postmortem_attachment_request_attributes
18197+
:members:
18198+
:show-inheritance:
18199+
18200+
datadog\_api\_client.v2.model.postmortem\_attachment\_request\_data module
18201+
--------------------------------------------------------------------------
18202+
18203+
.. automodule:: datadog_api_client.v2.model.postmortem_attachment_request_data
18204+
:members:
18205+
:show-inheritance:
18206+
18207+
datadog\_api\_client.v2.model.postmortem\_cell module
18208+
-----------------------------------------------------
18209+
18210+
.. automodule:: datadog_api_client.v2.model.postmortem_cell
18211+
:members:
18212+
:show-inheritance:
18213+
18214+
datadog\_api\_client.v2.model.postmortem\_cell\_attributes module
18215+
-----------------------------------------------------------------
18216+
18217+
.. automodule:: datadog_api_client.v2.model.postmortem_cell_attributes
18218+
:members:
18219+
:show-inheritance:
18220+
18221+
datadog\_api\_client.v2.model.postmortem\_cell\_definition module
18222+
-----------------------------------------------------------------
18223+
18224+
.. automodule:: datadog_api_client.v2.model.postmortem_cell_definition
18225+
:members:
18226+
:show-inheritance:
18227+
18228+
datadog\_api\_client.v2.model.postmortem\_cell\_type module
18229+
-----------------------------------------------------------
18230+
18231+
.. automodule:: datadog_api_client.v2.model.postmortem_cell_type
18232+
:members:
18233+
:show-inheritance:
18234+
1818618235
datadog\_api\_client.v2.model.powerpack module
1818718236
----------------------------------------------
1818818237

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"""
2+
Create postmortem attachment returns "Created" response
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v2.api.incidents_api import IncidentsApi
7+
from datadog_api_client.v2.model.incident_attachment_type import IncidentAttachmentType
8+
from datadog_api_client.v2.model.postmortem_attachment_request import PostmortemAttachmentRequest
9+
from datadog_api_client.v2.model.postmortem_attachment_request_attributes import PostmortemAttachmentRequestAttributes
10+
from datadog_api_client.v2.model.postmortem_attachment_request_data import PostmortemAttachmentRequestData
11+
from datadog_api_client.v2.model.postmortem_cell import PostmortemCell
12+
from datadog_api_client.v2.model.postmortem_cell_attributes import PostmortemCellAttributes
13+
from datadog_api_client.v2.model.postmortem_cell_definition import PostmortemCellDefinition
14+
from datadog_api_client.v2.model.postmortem_cell_type import PostmortemCellType
15+
16+
body = PostmortemAttachmentRequest(
17+
data=PostmortemAttachmentRequestData(
18+
attributes=PostmortemAttachmentRequestAttributes(
19+
cells=[
20+
PostmortemCell(
21+
attributes=PostmortemCellAttributes(
22+
definition=PostmortemCellDefinition(
23+
content="## Incident Summary\nThis incident was caused by...",
24+
),
25+
),
26+
id="cell-1",
27+
type=PostmortemCellType.MARKDOWN,
28+
),
29+
],
30+
content="# Incident Report - IR-123\n[...]",
31+
postmortem_template_id="93645509-874e-45c4-adfa-623bfeaead89-123",
32+
title="Postmortem-IR-123",
33+
),
34+
type=IncidentAttachmentType.INCIDENT_ATTACHMENTS,
35+
),
36+
)
37+
38+
configuration = Configuration()
39+
configuration.unstable_operations["create_incident_postmortem_attachment"] = True
40+
with ApiClient(configuration) as api_client:
41+
api_instance = IncidentsApi(api_client)
42+
response = api_instance.create_incident_postmortem_attachment(
43+
incident_id="00000000-0000-0000-0000-000000000000", body=body
44+
)
45+
46+
print(response)

src/datadog_api_client/configuration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ def __init__(
311311
"v2.create_incident_integration": False,
312312
"v2.create_incident_notification_rule": False,
313313
"v2.create_incident_notification_template": False,
314+
"v2.create_incident_postmortem_attachment": False,
314315
"v2.create_incident_todo": False,
315316
"v2.create_incident_type": False,
316317
"v2.delete_incident": False,

src/datadog_api_client/v2/api/incidents_api.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
from datadog_api_client.v2.model.attachment_array import AttachmentArray
4747
from datadog_api_client.v2.model.attachment import Attachment
4848
from datadog_api_client.v2.model.create_attachment_request import CreateAttachmentRequest
49+
from datadog_api_client.v2.model.postmortem_attachment_request import PostmortemAttachmentRequest
4950
from datadog_api_client.v2.model.patch_attachment_request import PatchAttachmentRequest
5051
from datadog_api_client.v2.model.incident_impacts_response import IncidentImpactsResponse
5152
from datadog_api_client.v2.model.incident_impact_related_object import IncidentImpactRelatedObject
@@ -226,6 +227,32 @@ def __init__(self, api_client=None):
226227
api_client=api_client,
227228
)
228229

230+
self._create_incident_postmortem_attachment_endpoint = _Endpoint(
231+
settings={
232+
"response_type": (Attachment,),
233+
"auth": ["apiKeyAuth", "appKeyAuth"],
234+
"endpoint_path": "/api/v2/incidents/{incident_id}/attachments/postmortems",
235+
"operation_id": "create_incident_postmortem_attachment",
236+
"http_method": "POST",
237+
"version": "v2",
238+
},
239+
params_map={
240+
"incident_id": {
241+
"required": True,
242+
"openapi_types": (str,),
243+
"attribute": "incident_id",
244+
"location": "path",
245+
},
246+
"body": {
247+
"required": True,
248+
"openapi_types": (PostmortemAttachmentRequest,),
249+
"location": "body",
250+
},
251+
},
252+
headers_map={"accept": ["application/json"], "content_type": ["application/json"]},
253+
api_client=api_client,
254+
)
255+
229256
self._create_incident_todo_endpoint = _Endpoint(
230257
settings={
231258
"response_type": (IncidentTodoResponse,),
@@ -1282,6 +1309,27 @@ def create_incident_notification_template(
12821309

12831310
return self._create_incident_notification_template_endpoint.call_with_http_info(**kwargs)
12841311

1312+
def create_incident_postmortem_attachment(
1313+
self,
1314+
incident_id: str,
1315+
body: PostmortemAttachmentRequest,
1316+
) -> Attachment:
1317+
"""Create postmortem attachment.
1318+
1319+
Create a postmortem attachment for an incident.
1320+
1321+
:param incident_id: The ID of the incident
1322+
:type incident_id: str
1323+
:type body: PostmortemAttachmentRequest
1324+
:rtype: Attachment
1325+
"""
1326+
kwargs: Dict[str, Any] = {}
1327+
kwargs["incident_id"] = incident_id
1328+
1329+
kwargs["body"] = body
1330+
1331+
return self._create_incident_postmortem_attachment_endpoint.call_with_http_info(**kwargs)
1332+
12851333
def create_incident_todo(
12861334
self,
12871335
incident_id: str,
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
from __future__ import annotations
5+
6+
from typing import TYPE_CHECKING
7+
8+
from datadog_api_client.model_utils import (
9+
ModelNormal,
10+
cached_property,
11+
)
12+
13+
14+
if TYPE_CHECKING:
15+
from datadog_api_client.v2.model.postmortem_attachment_request_data import PostmortemAttachmentRequestData
16+
17+
18+
class PostmortemAttachmentRequest(ModelNormal):
19+
@cached_property
20+
def openapi_types(_):
21+
from datadog_api_client.v2.model.postmortem_attachment_request_data import PostmortemAttachmentRequestData
22+
23+
return {
24+
"data": (PostmortemAttachmentRequestData,),
25+
}
26+
27+
attribute_map = {
28+
"data": "data",
29+
}
30+
31+
def __init__(self_, data: PostmortemAttachmentRequestData, **kwargs):
32+
"""
33+
34+
35+
:param data: Postmortem attachment data
36+
:type data: PostmortemAttachmentRequestData
37+
"""
38+
super().__init__(kwargs)
39+
40+
self_.data = data

0 commit comments

Comments
 (0)