Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41880,6 +41880,83 @@ components:
type: string
x-enum-varnames:
- PERMISSIONS
PostmortemAttachmentRequest:
properties:
data:
$ref: '#/components/schemas/PostmortemAttachmentRequestData'
required:
- data
type: object
PostmortemAttachmentRequestAttributes:
description: Postmortem attachment attributes
properties:
cells:
description: The cells of the postmortem
items:
$ref: '#/components/schemas/PostmortemCell'
type: array
content:
description: The content of the postmortem
example: '# Incident Report - IR-123

[...]'
type: string
postmortem_template_id:
description: The ID of the postmortem template
example: 93645509-874e-45c4-adfa-623bfeaead89-123
type: string
title:
description: The title of the postmortem
example: Postmortem-IR-123
type: string
type: object
PostmortemAttachmentRequestData:
description: Postmortem attachment data
properties:
attributes:
$ref: '#/components/schemas/PostmortemAttachmentRequestAttributes'
type:
$ref: '#/components/schemas/IncidentAttachmentType'
required:
- type
- attributes
type: object
PostmortemCell:
description: A cell in the postmortem
properties:
attributes:
$ref: '#/components/schemas/PostmortemCellAttributes'
id:
description: The unique identifier of the cell
example: cell-1
type: string
type:
$ref: '#/components/schemas/PostmortemCellType'
type: object
PostmortemCellAttributes:
description: Attributes of a postmortem cell
properties:
definition:
$ref: '#/components/schemas/PostmortemCellDefinition'
type: object
PostmortemCellDefinition:
description: Definition of a postmortem cell
properties:
content:
description: The content of the cell in markdown format
example: '## Incident Summary

This incident was caused by...'
type: string
type: object
PostmortemCellType:
description: The postmortem cell resource type.
enum:
- markdown
example: markdown
type: string
x-enum-varnames:
- MARKDOWN
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.
Expand Down Expand Up @@ -71685,6 +71762,46 @@ paths:
- incident_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/{incident_id}/attachments/postmortems:
post:
description: Create a postmortem attachment for an incident.
operationId: CreateIncidentPostmortemAttachment
parameters:
- description: The ID of the incident
in: path
name: incident_id
required: true
schema:
example: 00000000-0000-0000-0000-000000000000
type: string
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/PostmortemAttachmentRequest'
required: true
responses:
'201':
content:
application/json:
schema:
$ref: '#/components/schemas/Attachment'
description: Created
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/JSONAPIErrorResponse'
description: Bad Request
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
summary: Create postmortem attachment
tags:
- Incidents
x-unstable: '**Note**: This endpoint is in public beta and it''s subject to
change.

If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
/api/v2/incidents/{incident_id}/attachments/{attachment_id}:
delete:
Expand Down
30 changes: 30 additions & 0 deletions examples/v2/incidents/CreateIncidentPostmortemAttachment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Create postmortem attachment returns "Created" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.unstable_operations["v2.create_incident_postmortem_attachment".to_sym] = true
end
api_instance = DatadogAPIClient::V2::IncidentsAPI.new

body = DatadogAPIClient::V2::PostmortemAttachmentRequest.new({
data: DatadogAPIClient::V2::PostmortemAttachmentRequestData.new({
attributes: DatadogAPIClient::V2::PostmortemAttachmentRequestAttributes.new({
cells: [
DatadogAPIClient::V2::PostmortemCell.new({
attributes: DatadogAPIClient::V2::PostmortemCellAttributes.new({
definition: DatadogAPIClient::V2::PostmortemCellDefinition.new({
content: '## Incident Summary\nThis incident was caused by...',
}),
}),
id: "cell-1",
type: DatadogAPIClient::V2::PostmortemCellType::MARKDOWN,
}),
],
content: '# Incident Report - IR-123\n[...]',
postmortem_template_id: "93645509-874e-45c4-adfa-623bfeaead89-123",
title: "Postmortem-IR-123",
}),
type: DatadogAPIClient::V2::IncidentAttachmentType::INCIDENT_ATTACHMENTS,
}),
})
p api_instance.create_incident_postmortem_attachment("00000000-0000-0000-0000-000000000000", body)
4 changes: 4 additions & 0 deletions features/scenarios_model_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2140,6 +2140,10 @@
"include" => "String",
"body" => "CreateAttachmentRequest",
},
"v2.CreateIncidentPostmortemAttachment" => {
"incident_id" => "String",
"body" => "PostmortemAttachmentRequest",
},
"v2.DeleteIncidentAttachment" => {
"incident_id" => "String",
"attachment_id" => "Object",
Expand Down
18 changes: 18 additions & 0 deletions features/v2/incidents.feature
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,24 @@ Feature: Incidents
When the request is sent
Then the response status is 404 Not Found

@generated @skip @team:DataDog/incident-app
Scenario: Create postmortem attachment returns "Bad Request" response
Given operation "CreateIncidentPostmortemAttachment" enabled
And new "CreateIncidentPostmortemAttachment" request
And request contains "incident_id" parameter from "REPLACE.ME"
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"}}
When the request is sent
Then the response status is 400 Bad Request

@generated @skip @team:DataDog/incident-app
Scenario: Create postmortem attachment returns "Created" response
Given operation "CreateIncidentPostmortemAttachment" enabled
And new "CreateIncidentPostmortemAttachment" request
And request contains "incident_id" parameter from "REPLACE.ME"
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"}}
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
Expand Down
8 changes: 8 additions & 0 deletions features/v2/undo.json
Original file line number Diff line number Diff line change
Expand Up @@ -1734,6 +1734,14 @@
"type": "unsafe"
}
},
"CreateIncidentPostmortemAttachment": {
"tag": "Incidents",
"undo": {
"operationId": "TODO",
"parameters": [],
"type": "unsafe"
}
},
"DeleteIncidentAttachment": {
"tag": "Incidents",
"undo": {
Expand Down
1 change: 1 addition & 0 deletions lib/datadog_api_client/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ def initialize
"v2.create_incident_integration": false,
"v2.create_incident_notification_rule": false,
"v2.create_incident_notification_template": false,
"v2.create_incident_postmortem_attachment": false,
"v2.create_incident_todo": false,
"v2.create_incident_type": false,
"v2.delete_incident": false,
Expand Down
7 changes: 7 additions & 0 deletions lib/datadog_api_client/inflector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3561,6 +3561,13 @@ def overrides
"v2.permission_attributes" => "PermissionAttributes",
"v2.permissions_response" => "PermissionsResponse",
"v2.permissions_type" => "PermissionsType",
"v2.postmortem_attachment_request" => "PostmortemAttachmentRequest",
"v2.postmortem_attachment_request_attributes" => "PostmortemAttachmentRequestAttributes",
"v2.postmortem_attachment_request_data" => "PostmortemAttachmentRequestData",
"v2.postmortem_cell" => "PostmortemCell",
"v2.postmortem_cell_attributes" => "PostmortemCellAttributes",
"v2.postmortem_cell_definition" => "PostmortemCellDefinition",
"v2.postmortem_cell_type" => "PostmortemCellType",
"v2.powerpack" => "Powerpack",
"v2.powerpack_attributes" => "PowerpackAttributes",
"v2.powerpack_data" => "PowerpackData",
Expand Down
78 changes: 78 additions & 0 deletions lib/datadog_api_client/v2/api/incidents_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,84 @@ def create_incident_notification_template_with_http_info(body, opts = {})
return data, status_code, headers
end

# Create postmortem attachment.
#
# @see #create_incident_postmortem_attachment_with_http_info
def create_incident_postmortem_attachment(incident_id, body, opts = {})
data, _status_code, _headers = create_incident_postmortem_attachment_with_http_info(incident_id, body, opts)
data
end

# Create postmortem attachment.
#
# Create a postmortem attachment for an incident.
#
# @param incident_id [String] The ID of the incident
# @param body [PostmortemAttachmentRequest]
# @param opts [Hash] the optional parameters
# @return [Array<(Attachment, Integer, Hash)>] Attachment data, response status code and response headers
def create_incident_postmortem_attachment_with_http_info(incident_id, body, opts = {})
unstable_enabled = @api_client.config.unstable_operations["v2.create_incident_postmortem_attachment".to_sym]
if unstable_enabled
@api_client.config.logger.warn format("Using unstable operation '%s'", "v2.create_incident_postmortem_attachment")
else
raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.create_incident_postmortem_attachment"))
end

if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: IncidentsAPI.create_incident_postmortem_attachment ...'
end
# verify the required parameter 'incident_id' is set
if @api_client.config.client_side_validation && incident_id.nil?
fail ArgumentError, "Missing the required parameter 'incident_id' when calling IncidentsAPI.create_incident_postmortem_attachment"
end
# verify the required parameter 'body' is set
if @api_client.config.client_side_validation && body.nil?
fail ArgumentError, "Missing the required parameter 'body' when calling IncidentsAPI.create_incident_postmortem_attachment"
end
# resource path
local_var_path = '/api/v2/incidents/{incident_id}/attachments/postmortems'.sub('{incident_id}', CGI.escape(incident_id.to_s).gsub('%2F', '/'))

# query parameters
query_params = opts[:query_params] || {}

# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

# form parameters
form_params = opts[:form_params] || {}

# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(body)

# return_type
return_type = opts[:debug_return_type] || 'Attachment'

# auth_names
auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]

new_options = opts.merge(
:operation => :create_incident_postmortem_attachment,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type,
:api_version => "V2"
)

data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: IncidentsAPI#create_incident_postmortem_attachment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end

# Create an incident todo.
#
# @see #create_incident_todo_with_http_info
Expand Down
Loading
Loading