diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index e0e9db98e4..9fb1437952 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -105453,6 +105453,54 @@ components: type: string x-enum-varnames: - SCHEDULE + RerouteOnCallPageRequest: + description: Full request to reroute an On-Call Page to a different team or user. + example: + data: + attributes: + comment: Rerouting to the database team. + target: + identifier: my-team + type: team_handle + type: reroute + properties: + data: + $ref: "#/components/schemas/RerouteOnCallPageRequestData" + required: + - data + type: object + RerouteOnCallPageRequestData: + description: The data for rerouting an On-Call Page, including attributes and resource type. + properties: + attributes: + $ref: "#/components/schemas/RerouteOnCallPageRequestDataAttributes" + type: + $ref: "#/components/schemas/RerouteOnCallPageRequestDataType" + required: + - attributes + - type + type: object + RerouteOnCallPageRequestDataAttributes: + description: Details about where to reroute the On-Call Page. + properties: + comment: + description: An optional comment explaining why the page is being rerouted. + example: Rerouting to the database team. + type: string + target: + $ref: "#/components/schemas/CreatePageRequestDataAttributesTarget" + required: + - target + type: object + RerouteOnCallPageRequestDataType: + default: reroute + description: The type of resource used when rerouting an On-Call Page. + enum: + - reroute + example: reroute + type: string + x-enum-varnames: + - REROUTE ResolveVulnerableSymbolsRequest: description: The top-level request object for resolving vulnerable symbols in a set of packages. properties: @@ -208728,6 +208776,142 @@ paths: summary: Escalate On-Call Page tags: - On-Call Paging + /api/v2/on-call/pages/{page_id}/reroute: + post: + description: |- + Reroutes an On-Call Page. + operationId: RerouteOnCallPage + parameters: + - description: The page ID. + in: path + name: page_id + required: true + schema: + example: 15e74b8b-f865-48d0-bcc5-453323ed2c8f + format: uuid + type: string + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + comment: Rerouting to the database team. + target: + identifier: my-team + type: team_handle + type: reroute + schema: + $ref: "#/components/schemas/RerouteOnCallPageRequest" + required: true + responses: + "204": + description: No Content. + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + servers: + - url: https://{site} + variables: + site: + default: navy.oncall.datadoghq.com + description: The globally available endpoint for On-Call. + enum: + - lava.oncall.datadoghq.com + - saffron.oncall.datadoghq.com + - navy.oncall.datadoghq.com + - coral.oncall.datadoghq.com + - teal.oncall.datadoghq.com + - beige.oncall.datadoghq.eu + - scarlet.oncall.datadoghq.com + x-enum-varnames: + - LAVA + - SAFFRON + - NAVY + - CORAL + - TEAL + - BEIGE + - SCARLET + - url: "{protocol}://{name}" + variables: + name: + default: navy.oncall.datadoghq.com + description: The full DNS name of the On-Call paging endpoint. + enum: + - lava.oncall.datadoghq.com + - saffron.oncall.datadoghq.com + - navy.oncall.datadoghq.com + - coral.oncall.datadoghq.com + - teal.oncall.datadoghq.com + - beige.oncall.datadoghq.eu + - scarlet.oncall.datadoghq.com + x-enum-varnames: + - LAVA + - SAFFRON + - NAVY + - CORAL + - TEAL + - BEIGE + - SCARLET + protocol: + default: https + description: The protocol for accessing the API. + - url: https://{subdomain}.{site} + variables: + site: + default: datadoghq.com + description: The Datadog site where the On-Call paging endpoint is deployed. + enum: + - datadoghq.com + - datadoghq.eu + x-enum-varnames: + - DATADOGHQ_COM + - DATADOGHQ_EU + subdomain: + default: navy.oncall + description: The On-Call paging subdomain. + enum: + - lava.oncall + - saffron.oncall + - navy.oncall + - coral.oncall + - teal.oncall + - beige.oncall + - scarlet.oncall + x-enum-varnames: + - LAVA + - SAFFRON + - NAVY + - CORAL + - TEAL + - BEIGE + - SCARLET + summary: Reroute On-Call Page + tags: + - On-Call Paging /api/v2/on-call/pages/{page_id}/resolve: post: description: |- diff --git a/examples/v2/on-call-paging/RerouteOnCallPage.py b/examples/v2/on-call-paging/RerouteOnCallPage.py new file mode 100644 index 0000000000..a2386d1cc7 --- /dev/null +++ b/examples/v2/on-call-paging/RerouteOnCallPage.py @@ -0,0 +1,35 @@ +""" +Reroute On-Call Page returns "No Content." response +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.on_call_paging_api import OnCallPagingApi +from datadog_api_client.v2.model.create_page_request_data_attributes_target import CreatePageRequestDataAttributesTarget +from datadog_api_client.v2.model.on_call_page_target_type import OnCallPageTargetType +from datadog_api_client.v2.model.reroute_on_call_page_request import RerouteOnCallPageRequest +from datadog_api_client.v2.model.reroute_on_call_page_request_data import RerouteOnCallPageRequestData +from datadog_api_client.v2.model.reroute_on_call_page_request_data_attributes import ( + RerouteOnCallPageRequestDataAttributes, +) +from datadog_api_client.v2.model.reroute_on_call_page_request_data_type import RerouteOnCallPageRequestDataType +from uuid import UUID + +body = RerouteOnCallPageRequest( + data=RerouteOnCallPageRequestData( + attributes=RerouteOnCallPageRequestDataAttributes( + comment="Rerouting to the database team.", + target=CreatePageRequestDataAttributesTarget( + identifier="my-team", + type=OnCallPageTargetType.TEAM_HANDLE, + ), + ), + type=RerouteOnCallPageRequestDataType.REROUTE, + ), +) + +configuration = Configuration() +configuration.access_token = environ["DD_BEARER_TOKEN"] +with ApiClient(configuration) as api_client: + api_instance = OnCallPagingApi(api_client) + api_instance.reroute_on_call_page(page_id=UUID("15e74b8b-f865-48d0-bcc5-453323ed2c8f"), body=body) diff --git a/src/datadog_api_client/v2/api/on_call_paging_api.py b/src/datadog_api_client/v2/api/on_call_paging_api.py index cb6e9cabfa..191012cc02 100644 --- a/src/datadog_api_client/v2/api/on_call_paging_api.py +++ b/src/datadog_api_client/v2/api/on_call_paging_api.py @@ -12,6 +12,7 @@ ) from datadog_api_client.v2.model.create_page_response import CreatePageResponse from datadog_api_client.v2.model.create_page_request import CreatePageRequest +from datadog_api_client.v2.model.reroute_on_call_page_request import RerouteOnCallPageRequest class OnCallPagingApi: @@ -295,6 +296,100 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._reroute_on_call_page_endpoint = _Endpoint( + settings={ + "response_type": None, + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/on-call/pages/{page_id}/reroute", + "operation_id": "reroute_on_call_page", + "http_method": "POST", + "version": "v2", + "servers": [ + { + "url": "https://{site}", + "variables": { + "site": { + "description": "The globally available endpoint for On-Call.", + "default_value": "navy.oncall.datadoghq.com", + "enum_values": [ + "lava.oncall.datadoghq.com", + "saffron.oncall.datadoghq.com", + "navy.oncall.datadoghq.com", + "coral.oncall.datadoghq.com", + "teal.oncall.datadoghq.com", + "beige.oncall.datadoghq.eu", + "scarlet.oncall.datadoghq.com", + ], + }, + }, + }, + { + "url": "{protocol}://{name}", + "variables": { + "name": { + "description": "The full DNS name of the On-Call paging endpoint.", + "default_value": "navy.oncall.datadoghq.com", + "enum_values": [ + "lava.oncall.datadoghq.com", + "saffron.oncall.datadoghq.com", + "navy.oncall.datadoghq.com", + "coral.oncall.datadoghq.com", + "teal.oncall.datadoghq.com", + "beige.oncall.datadoghq.eu", + "scarlet.oncall.datadoghq.com", + ], + }, + "protocol": { + "description": "The protocol for accessing the API.", + "default_value": "https", + }, + }, + }, + { + "url": "https://{subdomain}.{site}", + "variables": { + "site": { + "description": "The Datadog site where the On-Call paging endpoint is deployed.", + "default_value": "datadoghq.com", + "enum_values": [ + "datadoghq.com", + "datadoghq.eu", + ], + }, + "subdomain": { + "description": "The On-Call paging subdomain.", + "default_value": "navy.oncall", + "enum_values": [ + "lava.oncall", + "saffron.oncall", + "navy.oncall", + "coral.oncall", + "teal.oncall", + "beige.oncall", + "scarlet.oncall", + ], + }, + }, + }, + ], + }, + params_map={ + "page_id": { + "required": True, + "openapi_types": (UUID,), + "attribute": "page_id", + "location": "path", + }, + "body": { + "required": True, + "openapi_types": (RerouteOnCallPageRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["*/*"], "content_type": ["application/json"]}, + api_client=api_client, + ) + self._resolve_on_call_page_endpoint = _Endpoint( settings={ "response_type": None, @@ -436,6 +531,27 @@ def escalate_on_call_page( return self._escalate_on_call_page_endpoint.call_with_http_info(**kwargs) + def reroute_on_call_page( + self, + page_id: UUID, + body: RerouteOnCallPageRequest, + ) -> None: + """Reroute On-Call Page. + + Reroutes an On-Call Page. + + :param page_id: The page ID. + :type page_id: UUID + :type body: RerouteOnCallPageRequest + :rtype: None + """ + kwargs: Dict[str, Any] = {} + kwargs["page_id"] = page_id + + kwargs["body"] = body + + return self._reroute_on_call_page_endpoint.call_with_http_info(**kwargs) + def resolve_on_call_page( self, page_id: UUID, diff --git a/src/datadog_api_client/v2/model/reroute_on_call_page_request.py b/src/datadog_api_client/v2/model/reroute_on_call_page_request.py new file mode 100644 index 0000000000..9cb6b928f5 --- /dev/null +++ b/src/datadog_api_client/v2/model/reroute_on_call_page_request.py @@ -0,0 +1,40 @@ +# 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.reroute_on_call_page_request_data import RerouteOnCallPageRequestData + + +class RerouteOnCallPageRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.reroute_on_call_page_request_data import RerouteOnCallPageRequestData + + return { + "data": (RerouteOnCallPageRequestData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: RerouteOnCallPageRequestData, **kwargs): + """ + Full request to reroute an On-Call Page to a different team or user. + + :param data: The data for rerouting an On-Call Page, including attributes and resource type. + :type data: RerouteOnCallPageRequestData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/reroute_on_call_page_request_data.py b/src/datadog_api_client/v2/model/reroute_on_call_page_request_data.py new file mode 100644 index 0000000000..f95efe16ce --- /dev/null +++ b/src/datadog_api_client/v2/model/reroute_on_call_page_request_data.py @@ -0,0 +1,54 @@ +# 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.reroute_on_call_page_request_data_attributes import ( + RerouteOnCallPageRequestDataAttributes, + ) + from datadog_api_client.v2.model.reroute_on_call_page_request_data_type import RerouteOnCallPageRequestDataType + + +class RerouteOnCallPageRequestData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.reroute_on_call_page_request_data_attributes import ( + RerouteOnCallPageRequestDataAttributes, + ) + from datadog_api_client.v2.model.reroute_on_call_page_request_data_type import RerouteOnCallPageRequestDataType + + return { + "attributes": (RerouteOnCallPageRequestDataAttributes,), + "type": (RerouteOnCallPageRequestDataType,), + } + + attribute_map = { + "attributes": "attributes", + "type": "type", + } + + def __init__( + self_, attributes: RerouteOnCallPageRequestDataAttributes, type: RerouteOnCallPageRequestDataType, **kwargs + ): + """ + The data for rerouting an On-Call Page, including attributes and resource type. + + :param attributes: Details about where to reroute the On-Call Page. + :type attributes: RerouteOnCallPageRequestDataAttributes + + :param type: The type of resource used when rerouting an On-Call Page. + :type type: RerouteOnCallPageRequestDataType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.type = type diff --git a/src/datadog_api_client/v2/model/reroute_on_call_page_request_data_attributes.py b/src/datadog_api_client/v2/model/reroute_on_call_page_request_data_attributes.py new file mode 100644 index 0000000000..23dda14b64 --- /dev/null +++ b/src/datadog_api_client/v2/model/reroute_on_call_page_request_data_attributes.py @@ -0,0 +1,55 @@ +# 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 Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.create_page_request_data_attributes_target import ( + CreatePageRequestDataAttributesTarget, + ) + + +class RerouteOnCallPageRequestDataAttributes(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.create_page_request_data_attributes_target import ( + CreatePageRequestDataAttributesTarget, + ) + + return { + "comment": (str,), + "target": (CreatePageRequestDataAttributesTarget,), + } + + attribute_map = { + "comment": "comment", + "target": "target", + } + + def __init__( + self_, target: CreatePageRequestDataAttributesTarget, comment: Union[str, UnsetType] = unset, **kwargs + ): + """ + Details about where to reroute the On-Call Page. + + :param comment: An optional comment explaining why the page is being rerouted. + :type comment: str, optional + + :param target: Information about the target to notify (such as a team or user). + :type target: CreatePageRequestDataAttributesTarget + """ + if comment is not unset: + kwargs["comment"] = comment + super().__init__(kwargs) + + self_.target = target diff --git a/src/datadog_api_client/v2/model/reroute_on_call_page_request_data_type.py b/src/datadog_api_client/v2/model/reroute_on_call_page_request_data_type.py new file mode 100644 index 0000000000..6f2d132623 --- /dev/null +++ b/src/datadog_api_client/v2/model/reroute_on_call_page_request_data_type.py @@ -0,0 +1,35 @@ +# 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 datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class RerouteOnCallPageRequestDataType(ModelSimple): + """ + The type of resource used when rerouting an On-Call Page. + + :param value: If omitted defaults to "reroute". Must be one of ["reroute"]. + :type value: str + """ + + allowed_values = { + "reroute", + } + REROUTE: ClassVar["RerouteOnCallPageRequestDataType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +RerouteOnCallPageRequestDataType.REROUTE = RerouteOnCallPageRequestDataType("reroute") diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 7283ce9f45..9c76484cd8 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -9239,6 +9239,12 @@ from datadog_api_client.v2.model.report_schedule_toggle_request_attributes import ReportScheduleToggleRequestAttributes from datadog_api_client.v2.model.report_schedule_toggle_request_data import ReportScheduleToggleRequestData from datadog_api_client.v2.model.report_schedule_type import ReportScheduleType +from datadog_api_client.v2.model.reroute_on_call_page_request import RerouteOnCallPageRequest +from datadog_api_client.v2.model.reroute_on_call_page_request_data import RerouteOnCallPageRequestData +from datadog_api_client.v2.model.reroute_on_call_page_request_data_attributes import ( + RerouteOnCallPageRequestDataAttributes, +) +from datadog_api_client.v2.model.reroute_on_call_page_request_data_type import RerouteOnCallPageRequestDataType from datadog_api_client.v2.model.resolve_vulnerable_symbols_request import ResolveVulnerableSymbolsRequest from datadog_api_client.v2.model.resolve_vulnerable_symbols_request_data import ResolveVulnerableSymbolsRequestData from datadog_api_client.v2.model.resolve_vulnerable_symbols_request_data_attributes import ( @@ -19202,6 +19208,10 @@ "ReportScheduleToggleRequestAttributes", "ReportScheduleToggleRequestData", "ReportScheduleType", + "RerouteOnCallPageRequest", + "RerouteOnCallPageRequestData", + "RerouteOnCallPageRequestDataAttributes", + "RerouteOnCallPageRequestDataType", "ResolveVulnerableSymbolsRequest", "ResolveVulnerableSymbolsRequestData", "ResolveVulnerableSymbolsRequestDataAttributes", diff --git a/tests/v2/features/on-call_paging.feature b/tests/v2/features/on-call_paging.feature index fc26fabd4c..1a8b5a3b97 100644 --- a/tests/v2/features/on-call_paging.feature +++ b/tests/v2/features/on-call_paging.feature @@ -30,6 +30,22 @@ Feature: On-Call Paging When the request is sent Then the response status is 202 Accepted. + @generated @skip @team:ddoghq/on-call + Scenario: Reroute On-Call Page returns "Bad Request" response + Given new "RerouteOnCallPage" request + And request contains "page_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"comment": "Rerouting to the database team.", "target": {"identifier": "my-team", "type": "team_handle"}}, "type": "reroute"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:ddoghq/on-call + Scenario: Reroute On-Call Page returns "No Content." response + Given new "RerouteOnCallPage" request + And request contains "page_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"comment": "Rerouting to the database team.", "target": {"identifier": "my-team", "type": "team_handle"}}, "type": "reroute"}} + When the request is sent + Then the response status is 204 No Content. + @generated @skip @team:ddoghq/on-call Scenario: Resolve On-Call Page returns "Accepted." response Given new "ResolveOnCallPage" request diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index 8ce55668e7..fa3ab60a6b 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -6801,6 +6801,12 @@ "type": "unsafe" } }, + "RerouteOnCallPage": { + "tag": "On-Call Paging", + "undo": { + "type": "idempotent" + } + }, "ResolveOnCallPage": { "tag": "On-Call Paging", "undo": {