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
116 changes: 116 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32004,6 +32004,53 @@ components:
required:
- type
type: object
CreateOnCallPageCommentRequest:
description: Request to create a comment on an On-Call Page.
properties:
data:
$ref: "#/components/schemas/CreateOnCallPageCommentRequestData"
required:
- data
type: object
CreateOnCallPageCommentRequestAttributes:
description: Attributes for creating a comment on an On-Call Page.
properties:
body:
description: The content of the comment.
example: Investigating the database latency.
maxLength: 20000
minLength: 1
type: string
mentioned_user_ids:
description: The IDs of the users mentioned in the comment.
example:
- 00000000-0000-0000-0000-000000000001
items:
description: The ID of a mentioned user.
format: uuid
type: string
type: array
required:
- body
type: object
CreateOnCallPageCommentRequestData:
description: Data for creating a comment on an On-Call Page.
properties:
attributes:
$ref: "#/components/schemas/CreateOnCallPageCommentRequestAttributes"
id:
description: |-
A client-generated UUID that makes the request idempotent: retrying with the same ID
does not create a duplicate comment. If omitted or not a valid UUID, a random one is generated.
example: 3c5f5b5e-3a3e-4f8c-9b1d-2f6a7e8d9c0b
format: uuid
type: string
type:
$ref: "#/components/schemas/OnCallPageCommentType"
required:
- type
- attributes
type: object
CreateOpenAPIResponse:
description: Response for `CreateOpenAPI` operation.
properties:
Expand Down Expand Up @@ -100070,6 +100117,15 @@ components:
- id
- type
type: object
OnCallPageCommentType:
default: comments
description: "Indicates that the resource is of type `comments`."
enum:
- comments
example: comments
type: string
x-enum-varnames:
- COMMENTS
OnCallPageData:
description: An On-Call Page.
properties:
Expand Down Expand Up @@ -221129,6 +221185,66 @@ paths:
summary: Acknowledge On-Call Page
tags:
- On-Call Paging
/api/v2/on-call/pages/{page_id}/comment:
post:
description: Add a comment to the timeline of an On-Call Page.
operationId: CreateOnCallPageComment
parameters:
- description: The ID of the Page, or its key.
in: path
name: page_id
required: true
schema:
example: 15e74b8b-f865-48d0-bcc5-453323ed2c8f
type: string
requestBody:
content:
application/json:
examples:
default:
value:
data:
attributes:
body: Investigating the database latency.
mentioned_user_ids:
- 00000000-0000-0000-0000-000000000001
id: 3c5f5b5e-3a3e-4f8c-9b1d-2f6a7e8d9c0b
type: comments
schema:
$ref: "#/components/schemas/CreateOnCallPageCommentRequest"
required: true
responses:
"204":
description: No Content
"400":
content:
application/json:
schema:
$ref: "#/components/schemas/JSONAPIErrorResponse"
description: Bad Request
"401":
$ref: "#/components/responses/UnauthorizedResponse"
"403":
$ref: "#/components/responses/ForbiddenResponse"
"404":
content:
application/json:
schema:
$ref: "#/components/schemas/JSONAPIErrorResponse"
description: Not Found
"429":
$ref: "#/components/responses/TooManyRequestsResponse"
security:
- apiKeyAuth: []
appKeyAuth: []
- AuthZ: []
summary: Create On-Call Page Comment
tags:
- On-Call
"x-permission":
operator: AND
permissions:
- on_call_respond
/api/v2/on-call/pages/{page_id}/escalate:
post:
description: |-
Expand Down
30 changes: 30 additions & 0 deletions examples/v2/on-call/CreateOnCallPageComment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
Create On-Call Page Comment returns "No Content" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.on_call_api import OnCallApi
from datadog_api_client.v2.model.create_on_call_page_comment_request import CreateOnCallPageCommentRequest
from datadog_api_client.v2.model.create_on_call_page_comment_request_attributes import (
CreateOnCallPageCommentRequestAttributes,
)
from datadog_api_client.v2.model.create_on_call_page_comment_request_data import CreateOnCallPageCommentRequestData
from datadog_api_client.v2.model.on_call_page_comment_type import OnCallPageCommentType
from uuid import UUID

body = CreateOnCallPageCommentRequest(
data=CreateOnCallPageCommentRequestData(
attributes=CreateOnCallPageCommentRequestAttributes(
body="Comment from the API client integration tests.",
),
id=UUID("3c5f5b5e-3a3e-4f8c-9b1d-2f6a7e8d9c0b"),
type=OnCallPageCommentType.COMMENTS,
),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = OnCallApi(api_client)
api_instance.create_on_call_page_comment(page_id="f63eb677-07ce-46ab-b2e0-80ca1ffe91bf", body=body)
48 changes: 48 additions & 0 deletions src/datadog_api_client/v2/api/on_call_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from datadog_api_client.v2.model.on_call_pages_sort import OnCallPagesSort
from datadog_api_client.v2.model.on_call_page_data import OnCallPageData
from datadog_api_client.v2.model.on_call_page_response import OnCallPageResponse
from datadog_api_client.v2.model.create_on_call_page_comment_request import CreateOnCallPageCommentRequest
from datadog_api_client.v2.model.schedules import Schedules
from datadog_api_client.v2.model.schedule_list_item import ScheduleListItem
from datadog_api_client.v2.model.schedule import Schedule
Expand Down Expand Up @@ -84,6 +85,32 @@ def __init__(self, api_client=None):
api_client=api_client,
)

self._create_on_call_page_comment_endpoint = _Endpoint(
settings={
"response_type": None,
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/on-call/pages/{page_id}/comment",
"operation_id": "create_on_call_page_comment",
"http_method": "POST",
"version": "v2",
},
params_map={
"page_id": {
"required": True,
"openapi_types": (str,),
"attribute": "page_id",
"location": "path",
},
"body": {
"required": True,
"openapi_types": (CreateOnCallPageCommentRequest,),
"location": "body",
},
},
headers_map={"accept": ["*/*"], "content_type": ["application/json"]},
api_client=api_client,
)

self._create_on_call_schedule_endpoint = _Endpoint(
settings={
"response_type": (Schedule,),
Expand Down Expand Up @@ -996,6 +1023,27 @@ def create_on_call_escalation_policy(

return self._create_on_call_escalation_policy_endpoint.call_with_http_info(**kwargs)

def create_on_call_page_comment(
self,
page_id: str,
body: CreateOnCallPageCommentRequest,
) -> None:
"""Create On-Call Page Comment.

Add a comment to the timeline of an On-Call Page.

:param page_id: The ID of the Page, or its key.
:type page_id: str
:type body: CreateOnCallPageCommentRequest
:rtype: None
"""
kwargs: Dict[str, Any] = {}
kwargs["page_id"] = page_id

kwargs["body"] = body

return self._create_on_call_page_comment_endpoint.call_with_http_info(**kwargs)

def create_on_call_schedule(
self,
body: ScheduleCreateRequest,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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.
from __future__ import annotations

from typing import TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
)


if TYPE_CHECKING:
from datadog_api_client.v2.model.create_on_call_page_comment_request_data import CreateOnCallPageCommentRequestData


class CreateOnCallPageCommentRequest(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.create_on_call_page_comment_request_data import (
CreateOnCallPageCommentRequestData,
)

return {
"data": (CreateOnCallPageCommentRequestData,),
}

attribute_map = {
"data": "data",
}

def __init__(self_, data: CreateOnCallPageCommentRequestData, **kwargs):
"""
Request to create a comment on an On-Call Page.

:param data: Data for creating a comment on an On-Call Page.
:type data: CreateOnCallPageCommentRequestData
"""
super().__init__(kwargs)

self_.data = data
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# 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.
from __future__ import annotations

from typing import List, Union

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
unset,
UnsetType,
UUID,
)


class CreateOnCallPageCommentRequestAttributes(ModelNormal):
validations = {
"body": {
"max_length": 20000,
"min_length": 1,
},
}

@cached_property
def openapi_types(_):
return {
"body": (str,),
"mentioned_user_ids": ([UUID],),
}

attribute_map = {
"body": "body",
"mentioned_user_ids": "mentioned_user_ids",
}

def __init__(self_, body: str, mentioned_user_ids: Union[List[UUID], UnsetType] = unset, **kwargs):
"""
Attributes for creating a comment on an On-Call Page.

:param body: The content of the comment.
:type body: str

:param mentioned_user_ids: The IDs of the users mentioned in the comment.
:type mentioned_user_ids: [UUID], optional
"""
if mentioned_user_ids is not unset:
kwargs["mentioned_user_ids"] = mentioned_user_ids
super().__init__(kwargs)

self_.body = body
Loading
Loading