diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 5d738d0d1f..42168cb0f3 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -13195,6 +13195,27 @@ components: - options - type type: object + CreateEmailNotificationChannelConfig: + description: Configuration to create an e-mail notification channel + properties: + address: + description: The e-mail address to be notified + example: '' + type: string + formats: + description: Preferred content formats for notifications. + example: + - html + items: + $ref: '#/components/schemas/NotificationChannelEmailFormatType' + type: array + type: + $ref: '#/components/schemas/NotificationChannelEmailConfigType' + required: + - type + - address + - formats + type: object CreateIncidentNotificationRuleRequest: description: Create request for a notification rule. properties: @@ -13282,6 +13303,29 @@ components: - findings - project type: object + CreateNotificationChannelAttributes: + description: Attributes for creating an on-call notification channel. + properties: + config: + $ref: '#/components/schemas/CreateNotificationChannelConfig' + description: Notification channel configuration + type: object + CreateNotificationChannelConfig: + description: Defines the configuration for creating an On-Call notification + channel + oneOf: + - $ref: '#/components/schemas/CreatePhoneNotificationChannelConfig' + - $ref: '#/components/schemas/CreateEmailNotificationChannelConfig' + CreateNotificationChannelData: + description: Data for creating an on-call notification channel + properties: + attributes: + $ref: '#/components/schemas/CreateNotificationChannelAttributes' + type: + $ref: '#/components/schemas/NotificationChannelType' + required: + - type + type: object CreateNotificationRuleParameters: description: Body of the notification rule create request. properties: @@ -13442,6 +13486,19 @@ components: type: string x-enum-varnames: - PAGES + CreatePhoneNotificationChannelConfig: + description: Configuration to create a phone notification channel + properties: + number: + description: The E-164 formatted phone number (e.g. +3371234567) + example: '' + type: string + type: + $ref: '#/components/schemas/NotificationChannelPhoneConfigType' + required: + - type + - number + type: object CreateRuleRequest: description: Scorecard create rule request. properties: @@ -14008,6 +14065,23 @@ components: type: string x-enum-varnames: - UPLOAD + CreateUserNotificationChannelRequest: + description: A top-level wrapper for creating a notification channel for a user + example: + data: + attributes: + config: + address: foo@bar.com + formats: + - html + type: email + type: notification_channels + properties: + data: + $ref: '#/components/schemas/CreateNotificationChannelData' + required: + - data + type: object CreateWorkflowRequest: description: A request object for creating a new workflow. example: @@ -30505,6 +30579,14 @@ components: meta: $ref: '#/components/schemas/KindResponseMeta' type: object + ListNotificationChannelsResponse: + description: Response type for listing notification channels for a user + properties: + data: + items: + $ref: '#/components/schemas/NotificationChannelData' + type: array + type: object ListPipelinesResponse: description: Represents the response payload containing a list of pipelines and associated metadata. @@ -34679,6 +34761,174 @@ components: required: - notebookTrigger type: object + NotificationChannel: + description: A top-level wrapper for a user notification channel + example: + data: + attributes: + config: + address: foo@bar.com + formats: + - html + type: email + id: 27590dae-47be-4a7d-9abf-8f4e45124020 + type: notification_channels + properties: + data: + $ref: '#/components/schemas/NotificationChannelData' + type: object + NotificationChannelAttributes: + description: Attributes for an on-call notification channel. + properties: + active: + description: Whether the notification channel is currently active. + type: boolean + config: + $ref: '#/components/schemas/NotificationChannelConfig' + description: Notification channel configuration + type: object + NotificationChannelConfig: + description: Defines the configuration for an On-Call notification channel + oneOf: + - $ref: '#/components/schemas/NotificationChannelPhoneConfig' + - $ref: '#/components/schemas/NotificationChannelEmailConfig' + - $ref: '#/components/schemas/NotificationChannelPushConfig' + NotificationChannelData: + description: Data for an on-call notification channel + properties: + attributes: + $ref: '#/components/schemas/NotificationChannelAttributes' + id: + description: Unique identifier for the channel + type: string + type: + $ref: '#/components/schemas/NotificationChannelType' + required: + - type + type: object + NotificationChannelEmailConfig: + description: Email notification channel configuration + properties: + address: + description: The e-mail address to be notified + example: '' + type: string + formats: + description: Preferred content formats for notifications. + example: + - html + items: + $ref: '#/components/schemas/NotificationChannelEmailFormatType' + type: array + type: + $ref: '#/components/schemas/NotificationChannelEmailConfigType' + required: + - type + - address + - formats + type: object + NotificationChannelEmailConfigType: + default: email + description: Indicates that the notification channel is an e-mail address + enum: + - email + example: email + type: string + x-enum-varnames: + - EMAIL + NotificationChannelEmailFormatType: + default: html + description: Specifies the format of the e-mail that is sent for On-Call notifications + enum: + - html + - text + example: html + type: string + x-enum-varnames: + - HTML + - TEXT + NotificationChannelPhoneConfig: + description: Phone notification channel configuration + properties: + formatted_number: + description: The formatted international version of Number (e.g. +33 7 1 + 23 45 67). + example: '' + type: string + number: + description: The E-164 formatted phone number (e.g. +3371234567) + example: '' + type: string + region: + description: The ISO 3166-1 alpha-2 two-letter country code. + example: '' + type: string + sms_subscribed_at: + description: If present, the date the user subscribed this number to SMS + messages + format: date-time + nullable: true + type: string + type: + $ref: '#/components/schemas/NotificationChannelPhoneConfigType' + verified: + description: Indicates whether this phone has been verified by the user + in Datadog On-Call + example: false + type: boolean + required: + - type + - number + - formatted_number + - region + - verified + type: object + NotificationChannelPhoneConfigType: + default: phone + description: Indicates that the notification channel is a phone + enum: + - phone + example: phone + type: string + x-enum-varnames: + - PHONE + NotificationChannelPushConfig: + description: Push notification channel configuration + properties: + application_name: + description: The name of the application used to receive push notifications + example: '' + type: string + device_name: + description: The name of the mobile device being used + example: '' + type: string + type: + $ref: '#/components/schemas/NotificationChannelPushConfigType' + required: + - type + - device_name + - application_name + type: object + NotificationChannelPushConfigType: + default: push + description: Indicates that the notification channel is a mobile device for + push notifications + enum: + - push + example: push + type: string + x-enum-varnames: + - PUSH + NotificationChannelType: + default: notification_channels + description: Indicates that the resource is of type 'notification_channels'. + enum: + - notification_channels + example: notification_channels + type: string + x-enum-varnames: + - NOTIFICATION_CHANNELS NotificationRule: description: 'Notification rules allow full control over notifications generated by the various Datadog security products. @@ -75741,6 +75991,184 @@ paths: operator: AND permissions: - on_call_write + /api/v2/on-call/users/{user_id}/notification-channels: + get: + description: List the notification channels for a user. The authenticated user + must be the target user or have the `on_call_admin` permission + operationId: ListUserNotificationChannels + parameters: + - description: The user ID + in: path + name: user_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ListNotificationChannelsResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: List On-Call notification channels for a user + tags: + - On-Call + x-permission: + operator: AND + permissions: + - on_call_read + post: + description: Create a new notification channel for a user. The authenticated + user must be the target user or have the `on_call_admin` permission + operationId: CreateUserNotificationChannel + parameters: + - description: The user ID + in: path + name: user_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateUserNotificationChannelRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationChannel' + description: Created + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Create an On-Call notification channel for a user + tags: + - On-Call + x-permission: + operator: AND + permissions: + - on_call_respond + /api/v2/on-call/users/{user_id}/notification-channels/{channel_id}: + delete: + description: Delete a notification channel for a user. The authenticated user + must be the target user or have the `on_call_admin` permission + operationId: DeleteUserNotificationChannel + parameters: + - description: The user ID + in: path + name: user_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + - description: The channel ID + in: path + name: channel_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + responses: + '204': + description: No Content + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Delete an On-Call notification channel for a user + tags: + - On-Call + x-permission: + operator: AND + permissions: + - on_call_respond + get: + description: Get a notification channel for a user. The authenticated user must + be the target user or have the `on_call_admin` permission + operationId: GetUserNotificationChannel + parameters: + - description: The user ID + in: path + name: user_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + - description: The channel ID + in: path + name: channel_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationChannel' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Get an On-Call notification channel for a user + tags: + - On-Call + x-permission: + operator: AND + permissions: + - on_call_read /api/v2/org_configs: get: description: Returns all Org Configs (name, description, and value). diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index 43287f22da..4560690bfe 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -5268,6 +5268,13 @@ datadog\_api\_client.v2.model.create\_deployment\_rule\_params\_data\_attributes :members: :show-inheritance: +datadog\_api\_client.v2.model.create\_email\_notification\_channel\_config module +--------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.create_email_notification_channel_config + :members: + :show-inheritance: + datadog\_api\_client.v2.model.create\_incident\_notification\_rule\_request module ---------------------------------------------------------------------------------- @@ -5310,6 +5317,27 @@ datadog\_api\_client.v2.model.create\_jira\_issue\_request\_data\_relationships :members: :show-inheritance: +datadog\_api\_client.v2.model.create\_notification\_channel\_attributes module +------------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.create_notification_channel_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.create\_notification\_channel\_config module +-------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.create_notification_channel_config + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.create\_notification\_channel\_data module +------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.create_notification_channel_data + :members: + :show-inheritance: + datadog\_api\_client.v2.model.create\_notification\_rule\_parameters module --------------------------------------------------------------------------- @@ -5408,6 +5436,13 @@ datadog\_api\_client.v2.model.create\_page\_response\_data\_type module :members: :show-inheritance: +datadog\_api\_client.v2.model.create\_phone\_notification\_channel\_config module +--------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.create_phone_notification_channel_config + :members: + :show-inheritance: + datadog\_api\_client.v2.model.create\_rule\_request module ---------------------------------------------------------- @@ -5653,6 +5688,13 @@ datadog\_api\_client.v2.model.create\_upload\_response\_data\_type module :members: :show-inheritance: +datadog\_api\_client.v2.model.create\_user\_notification\_channel\_request module +--------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.create_user_notification_channel_request + :members: + :show-inheritance: + datadog\_api\_client.v2.model.create\_workflow\_request module -------------------------------------------------------------- @@ -13045,6 +13087,13 @@ datadog\_api\_client.v2.model.list\_kind\_catalog\_response module :members: :show-inheritance: +datadog\_api\_client.v2.model.list\_notification\_channels\_response module +--------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.list_notification_channels_response + :members: + :show-inheritance: + datadog\_api\_client.v2.model.list\_pipelines\_response module -------------------------------------------------------------- @@ -15075,6 +15124,90 @@ datadog\_api\_client.v2.model.notebook\_trigger\_wrapper module :members: :show-inheritance: +datadog\_api\_client.v2.model.notification\_channel module +---------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.notification_channel + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.notification\_channel\_attributes module +---------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.notification_channel_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.notification\_channel\_config module +------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.notification_channel_config + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.notification\_channel\_data module +---------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.notification_channel_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.notification\_channel\_email\_config module +------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.notification_channel_email_config + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.notification\_channel\_email\_config\_type module +------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.notification_channel_email_config_type + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.notification\_channel\_email\_format\_type module +------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.notification_channel_email_format_type + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.notification\_channel\_phone\_config module +------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.notification_channel_phone_config + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.notification\_channel\_phone\_config\_type module +------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.notification_channel_phone_config_type + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.notification\_channel\_push\_config module +------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.notification_channel_push_config + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.notification\_channel\_push\_config\_type module +------------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.notification_channel_push_config_type + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.notification\_channel\_type module +---------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.notification_channel_type + :members: + :show-inheritance: + datadog\_api\_client.v2.model.notification\_rule module ------------------------------------------------------- diff --git a/examples/v2/on-call/CreateUserNotificationChannel.py b/examples/v2/on-call/CreateUserNotificationChannel.py new file mode 100644 index 0000000000..a7c6a8163c --- /dev/null +++ b/examples/v2/on-call/CreateUserNotificationChannel.py @@ -0,0 +1,39 @@ +""" +Create an On-Call notification channel for a user returns "Created" 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_email_notification_channel_config import CreateEmailNotificationChannelConfig +from datadog_api_client.v2.model.create_notification_channel_attributes import CreateNotificationChannelAttributes +from datadog_api_client.v2.model.create_notification_channel_data import CreateNotificationChannelData +from datadog_api_client.v2.model.create_user_notification_channel_request import CreateUserNotificationChannelRequest +from datadog_api_client.v2.model.notification_channel_email_config_type import NotificationChannelEmailConfigType +from datadog_api_client.v2.model.notification_channel_email_format_type import NotificationChannelEmailFormatType +from datadog_api_client.v2.model.notification_channel_type import NotificationChannelType + +# there is a valid "user" in the system +USER_DATA_ID = environ["USER_DATA_ID"] + +body = CreateUserNotificationChannelRequest( + data=CreateNotificationChannelData( + attributes=CreateNotificationChannelAttributes( + config=CreateEmailNotificationChannelConfig( + address="foo@bar.com", + formats=[ + NotificationChannelEmailFormatType.HTML, + ], + type=NotificationChannelEmailConfigType.EMAIL, + ), + ), + type=NotificationChannelType.NOTIFICATION_CHANNELS, + ), +) + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = OnCallApi(api_client) + response = api_instance.create_user_notification_channel(user_id=USER_DATA_ID, body=body) + + print(response) diff --git a/examples/v2/on-call/DeleteUserNotificationChannel.py b/examples/v2/on-call/DeleteUserNotificationChannel.py new file mode 100644 index 0000000000..169ca07980 --- /dev/null +++ b/examples/v2/on-call/DeleteUserNotificationChannel.py @@ -0,0 +1,21 @@ +""" +Delete an On-Call notification channel for a user 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 + +# there is a valid "user" in the system +USER_DATA_ID = environ["USER_DATA_ID"] + +# there is a valid "oncall_email_notification_channel" in the system +ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID = environ["ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID"] + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = OnCallApi(api_client) + api_instance.delete_user_notification_channel( + user_id=USER_DATA_ID, + channel_id=ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID, + ) diff --git a/examples/v2/on-call/GetUserNotificationChannel.py b/examples/v2/on-call/GetUserNotificationChannel.py new file mode 100644 index 0000000000..4675c1f8fd --- /dev/null +++ b/examples/v2/on-call/GetUserNotificationChannel.py @@ -0,0 +1,23 @@ +""" +Get an On-Call notification channel for a user returns "OK" response +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.on_call_api import OnCallApi + +# there is a valid "user" in the system +USER_DATA_ID = environ["USER_DATA_ID"] + +# there is a valid "oncall_email_notification_channel" in the system +ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID = environ["ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID"] + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = OnCallApi(api_client) + response = api_instance.get_user_notification_channel( + user_id=USER_DATA_ID, + channel_id=ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID, + ) + + print(response) diff --git a/examples/v2/on-call/ListUserNotificationChannels.py b/examples/v2/on-call/ListUserNotificationChannels.py new file mode 100644 index 0000000000..fe8ecbfb1e --- /dev/null +++ b/examples/v2/on-call/ListUserNotificationChannels.py @@ -0,0 +1,19 @@ +""" +List On-Call notification channels for a user returns "OK" response +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.on_call_api import OnCallApi + +# there is a valid "user" in the system +USER_DATA_ID = environ["USER_DATA_ID"] + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = OnCallApi(api_client) + response = api_instance.list_user_notification_channels( + user_id=USER_DATA_ID, + ) + + print(response) diff --git a/src/datadog_api_client/v2/api/on_call_api.py b/src/datadog_api_client/v2/api/on_call_api.py index cdebda07c1..92d82e2b71 100644 --- a/src/datadog_api_client/v2/api/on_call_api.py +++ b/src/datadog_api_client/v2/api/on_call_api.py @@ -21,6 +21,9 @@ from datadog_api_client.v2.model.team_on_call_responders import TeamOnCallResponders from datadog_api_client.v2.model.team_routing_rules import TeamRoutingRules from datadog_api_client.v2.model.team_routing_rules_request import TeamRoutingRulesRequest +from datadog_api_client.v2.model.list_notification_channels_response import ListNotificationChannelsResponse +from datadog_api_client.v2.model.notification_channel import NotificationChannel +from datadog_api_client.v2.model.create_user_notification_channel_request import CreateUserNotificationChannelRequest class OnCallApi: @@ -84,6 +87,32 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._create_user_notification_channel_endpoint = _Endpoint( + settings={ + "response_type": (NotificationChannel,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/on-call/users/{user_id}/notification-channels", + "operation_id": "create_user_notification_channel", + "http_method": "POST", + "version": "v2", + }, + params_map={ + "user_id": { + "required": True, + "openapi_types": (str,), + "attribute": "user_id", + "location": "path", + }, + "body": { + "required": True, + "openapi_types": (CreateUserNotificationChannelRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + self._delete_on_call_escalation_policy_endpoint = _Endpoint( settings={ "response_type": None, @@ -130,6 +159,35 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._delete_user_notification_channel_endpoint = _Endpoint( + settings={ + "response_type": None, + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/on-call/users/{user_id}/notification-channels/{channel_id}", + "operation_id": "delete_user_notification_channel", + "http_method": "DELETE", + "version": "v2", + }, + params_map={ + "user_id": { + "required": True, + "openapi_types": (str,), + "attribute": "user_id", + "location": "path", + }, + "channel_id": { + "required": True, + "openapi_types": (str,), + "attribute": "channel_id", + "location": "path", + }, + }, + headers_map={ + "accept": ["*/*"], + }, + api_client=api_client, + ) + self._get_on_call_escalation_policy_endpoint = _Endpoint( settings={ "response_type": (EscalationPolicy,), @@ -275,6 +333,58 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._get_user_notification_channel_endpoint = _Endpoint( + settings={ + "response_type": (NotificationChannel,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/on-call/users/{user_id}/notification-channels/{channel_id}", + "operation_id": "get_user_notification_channel", + "http_method": "GET", + "version": "v2", + }, + params_map={ + "user_id": { + "required": True, + "openapi_types": (str,), + "attribute": "user_id", + "location": "path", + }, + "channel_id": { + "required": True, + "openapi_types": (str,), + "attribute": "channel_id", + "location": "path", + }, + }, + headers_map={ + "accept": ["application/json"], + }, + api_client=api_client, + ) + + self._list_user_notification_channels_endpoint = _Endpoint( + settings={ + "response_type": (ListNotificationChannelsResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/on-call/users/{user_id}/notification-channels", + "operation_id": "list_user_notification_channels", + "http_method": "GET", + "version": "v2", + }, + params_map={ + "user_id": { + "required": True, + "openapi_types": (str,), + "attribute": "user_id", + "location": "path", + }, + }, + headers_map={ + "accept": ["application/json"], + }, + api_client=api_client, + ) + self._set_on_call_team_routing_rules_endpoint = _Endpoint( settings={ "response_type": (TeamRoutingRules,), @@ -414,6 +524,27 @@ def create_on_call_schedule( return self._create_on_call_schedule_endpoint.call_with_http_info(**kwargs) + def create_user_notification_channel( + self, + user_id: str, + body: CreateUserNotificationChannelRequest, + ) -> NotificationChannel: + """Create an On-Call notification channel for a user. + + Create a new notification channel for a user. The authenticated user must be the target user or have the ``on_call_admin`` permission + + :param user_id: The user ID + :type user_id: str + :type body: CreateUserNotificationChannelRequest + :rtype: NotificationChannel + """ + kwargs: Dict[str, Any] = {} + kwargs["user_id"] = user_id + + kwargs["body"] = body + + return self._create_user_notification_channel_endpoint.call_with_http_info(**kwargs) + def delete_on_call_escalation_policy( self, policy_id: str, @@ -448,6 +579,28 @@ def delete_on_call_schedule( return self._delete_on_call_schedule_endpoint.call_with_http_info(**kwargs) + def delete_user_notification_channel( + self, + user_id: str, + channel_id: str, + ) -> None: + """Delete an On-Call notification channel for a user. + + Delete a notification channel for a user. The authenticated user must be the target user or have the ``on_call_admin`` permission + + :param user_id: The user ID + :type user_id: str + :param channel_id: The channel ID + :type channel_id: str + :rtype: None + """ + kwargs: Dict[str, Any] = {} + kwargs["user_id"] = user_id + + kwargs["channel_id"] = channel_id + + return self._delete_user_notification_channel_endpoint.call_with_http_info(**kwargs) + def get_on_call_escalation_policy( self, policy_id: str, @@ -574,6 +727,45 @@ def get_team_on_call_users( return self._get_team_on_call_users_endpoint.call_with_http_info(**kwargs) + def get_user_notification_channel( + self, + user_id: str, + channel_id: str, + ) -> NotificationChannel: + """Get an On-Call notification channel for a user. + + Get a notification channel for a user. The authenticated user must be the target user or have the ``on_call_admin`` permission + + :param user_id: The user ID + :type user_id: str + :param channel_id: The channel ID + :type channel_id: str + :rtype: NotificationChannel + """ + kwargs: Dict[str, Any] = {} + kwargs["user_id"] = user_id + + kwargs["channel_id"] = channel_id + + return self._get_user_notification_channel_endpoint.call_with_http_info(**kwargs) + + def list_user_notification_channels( + self, + user_id: str, + ) -> ListNotificationChannelsResponse: + """List On-Call notification channels for a user. + + List the notification channels for a user. The authenticated user must be the target user or have the ``on_call_admin`` permission + + :param user_id: The user ID + :type user_id: str + :rtype: ListNotificationChannelsResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["user_id"] = user_id + + return self._list_user_notification_channels_endpoint.call_with_http_info(**kwargs) + def set_on_call_team_routing_rules( self, team_id: str, diff --git a/src/datadog_api_client/v2/model/create_email_notification_channel_config.py b/src/datadog_api_client/v2/model/create_email_notification_channel_config.py new file mode 100644 index 0000000000..8d6c5cdba7 --- /dev/null +++ b/src/datadog_api_client/v2/model/create_email_notification_channel_config.py @@ -0,0 +1,64 @@ +# 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, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.notification_channel_email_format_type import NotificationChannelEmailFormatType + from datadog_api_client.v2.model.notification_channel_email_config_type import NotificationChannelEmailConfigType + + +class CreateEmailNotificationChannelConfig(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.notification_channel_email_format_type import ( + NotificationChannelEmailFormatType, + ) + from datadog_api_client.v2.model.notification_channel_email_config_type import ( + NotificationChannelEmailConfigType, + ) + + return { + "address": (str,), + "formats": ([NotificationChannelEmailFormatType],), + "type": (NotificationChannelEmailConfigType,), + } + + attribute_map = { + "address": "address", + "formats": "formats", + "type": "type", + } + + def __init__( + self_, + address: str, + formats: List[NotificationChannelEmailFormatType], + type: NotificationChannelEmailConfigType, + **kwargs, + ): + """ + Configuration to create an e-mail notification channel + + :param address: The e-mail address to be notified + :type address: str + + :param formats: Preferred content formats for notifications. + :type formats: [NotificationChannelEmailFormatType] + + :param type: Indicates that the notification channel is an e-mail address + :type type: NotificationChannelEmailConfigType + """ + super().__init__(kwargs) + + self_.address = address + self_.formats = formats + self_.type = type diff --git a/src/datadog_api_client/v2/model/create_notification_channel_attributes.py b/src/datadog_api_client/v2/model/create_notification_channel_attributes.py new file mode 100644 index 0000000000..f687066d45 --- /dev/null +++ b/src/datadog_api_client/v2/model/create_notification_channel_attributes.py @@ -0,0 +1,57 @@ +# 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_notification_channel_config import CreateNotificationChannelConfig + from datadog_api_client.v2.model.create_phone_notification_channel_config import ( + CreatePhoneNotificationChannelConfig, + ) + from datadog_api_client.v2.model.create_email_notification_channel_config import ( + CreateEmailNotificationChannelConfig, + ) + + +class CreateNotificationChannelAttributes(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.create_notification_channel_config import CreateNotificationChannelConfig + + return { + "config": (CreateNotificationChannelConfig,), + } + + attribute_map = { + "config": "config", + } + + def __init__( + self_, + config: Union[ + CreateNotificationChannelConfig, + CreatePhoneNotificationChannelConfig, + CreateEmailNotificationChannelConfig, + UnsetType, + ] = unset, + **kwargs, + ): + """ + Attributes for creating an on-call notification channel. + + :param config: Defines the configuration for creating an On-Call notification channel + :type config: CreateNotificationChannelConfig, optional + """ + if config is not unset: + kwargs["config"] = config + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/create_notification_channel_config.py b/src/datadog_api_client/v2/model/create_notification_channel_config.py new file mode 100644 index 0000000000..5bd8481d35 --- /dev/null +++ b/src/datadog_api_client/v2/model/create_notification_channel_config.py @@ -0,0 +1,53 @@ +# 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 ( + ModelComposed, + cached_property, +) + + +class CreateNotificationChannelConfig(ModelComposed): + def __init__(self, **kwargs): + """ + Defines the configuration for creating an On-Call notification channel + + :param number: The E-164 formatted phone number (e.g. +3371234567) + :type number: str + + :param type: Indicates that the notification channel is a phone + :type type: NotificationChannelPhoneConfigType + + :param address: The e-mail address to be notified + :type address: str + + :param formats: Preferred content formats for notifications. + :type formats: [NotificationChannelEmailFormatType] + """ + super().__init__(kwargs) + + @cached_property + def _composed_schemas(_): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error because the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + from datadog_api_client.v2.model.create_phone_notification_channel_config import ( + CreatePhoneNotificationChannelConfig, + ) + from datadog_api_client.v2.model.create_email_notification_channel_config import ( + CreateEmailNotificationChannelConfig, + ) + + return { + "oneOf": [ + CreatePhoneNotificationChannelConfig, + CreateEmailNotificationChannelConfig, + ], + } diff --git a/src/datadog_api_client/v2/model/create_notification_channel_data.py b/src/datadog_api_client/v2/model/create_notification_channel_data.py new file mode 100644 index 0000000000..e6275c232b --- /dev/null +++ b/src/datadog_api_client/v2/model/create_notification_channel_data.py @@ -0,0 +1,58 @@ +# 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_notification_channel_attributes import CreateNotificationChannelAttributes + from datadog_api_client.v2.model.notification_channel_type import NotificationChannelType + + +class CreateNotificationChannelData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.create_notification_channel_attributes import ( + CreateNotificationChannelAttributes, + ) + from datadog_api_client.v2.model.notification_channel_type import NotificationChannelType + + return { + "attributes": (CreateNotificationChannelAttributes,), + "type": (NotificationChannelType,), + } + + attribute_map = { + "attributes": "attributes", + "type": "type", + } + + def __init__( + self_, + type: NotificationChannelType, + attributes: Union[CreateNotificationChannelAttributes, UnsetType] = unset, + **kwargs, + ): + """ + Data for creating an on-call notification channel + + :param attributes: Attributes for creating an on-call notification channel. + :type attributes: CreateNotificationChannelAttributes, optional + + :param type: Indicates that the resource is of type 'notification_channels'. + :type type: NotificationChannelType + """ + if attributes is not unset: + kwargs["attributes"] = attributes + super().__init__(kwargs) + + self_.type = type diff --git a/src/datadog_api_client/v2/model/create_phone_notification_channel_config.py b/src/datadog_api_client/v2/model/create_phone_notification_channel_config.py new file mode 100644 index 0000000000..3c0609612a --- /dev/null +++ b/src/datadog_api_client/v2/model/create_phone_notification_channel_config.py @@ -0,0 +1,48 @@ +# 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.notification_channel_phone_config_type import NotificationChannelPhoneConfigType + + +class CreatePhoneNotificationChannelConfig(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.notification_channel_phone_config_type import ( + NotificationChannelPhoneConfigType, + ) + + return { + "number": (str,), + "type": (NotificationChannelPhoneConfigType,), + } + + attribute_map = { + "number": "number", + "type": "type", + } + + def __init__(self_, number: str, type: NotificationChannelPhoneConfigType, **kwargs): + """ + Configuration to create a phone notification channel + + :param number: The E-164 formatted phone number (e.g. +3371234567) + :type number: str + + :param type: Indicates that the notification channel is a phone + :type type: NotificationChannelPhoneConfigType + """ + super().__init__(kwargs) + + self_.number = number + self_.type = type diff --git a/src/datadog_api_client/v2/model/create_user_notification_channel_request.py b/src/datadog_api_client/v2/model/create_user_notification_channel_request.py new file mode 100644 index 0000000000..f3838c9fd7 --- /dev/null +++ b/src/datadog_api_client/v2/model/create_user_notification_channel_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.create_notification_channel_data import CreateNotificationChannelData + + +class CreateUserNotificationChannelRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.create_notification_channel_data import CreateNotificationChannelData + + return { + "data": (CreateNotificationChannelData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: CreateNotificationChannelData, **kwargs): + """ + A top-level wrapper for creating a notification channel for a user + + :param data: Data for creating an on-call notification channel + :type data: CreateNotificationChannelData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/list_notification_channels_response.py b/src/datadog_api_client/v2/model/list_notification_channels_response.py new file mode 100644 index 0000000000..93d91b93d0 --- /dev/null +++ b/src/datadog_api_client/v2/model/list_notification_channels_response.py @@ -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 List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.notification_channel_data import NotificationChannelData + + +class ListNotificationChannelsResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.notification_channel_data import NotificationChannelData + + return { + "data": ([NotificationChannelData],), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: Union[List[NotificationChannelData], UnsetType] = unset, **kwargs): + """ + Response type for listing notification channels for a user + + :param data: + :type data: [NotificationChannelData], optional + """ + if data is not unset: + kwargs["data"] = data + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/notification_channel.py b/src/datadog_api_client/v2/model/notification_channel.py new file mode 100644 index 0000000000..c8b73067c2 --- /dev/null +++ b/src/datadog_api_client/v2/model/notification_channel.py @@ -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 Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.notification_channel_data import NotificationChannelData + + +class NotificationChannel(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.notification_channel_data import NotificationChannelData + + return { + "data": (NotificationChannelData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: Union[NotificationChannelData, UnsetType] = unset, **kwargs): + """ + A top-level wrapper for a user notification channel + + :param data: Data for an on-call notification channel + :type data: NotificationChannelData, optional + """ + if data is not unset: + kwargs["data"] = data + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/notification_channel_attributes.py b/src/datadog_api_client/v2/model/notification_channel_attributes.py new file mode 100644 index 0000000000..4950663547 --- /dev/null +++ b/src/datadog_api_client/v2/model/notification_channel_attributes.py @@ -0,0 +1,63 @@ +# 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.notification_channel_config import NotificationChannelConfig + from datadog_api_client.v2.model.notification_channel_phone_config import NotificationChannelPhoneConfig + from datadog_api_client.v2.model.notification_channel_email_config import NotificationChannelEmailConfig + from datadog_api_client.v2.model.notification_channel_push_config import NotificationChannelPushConfig + + +class NotificationChannelAttributes(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.notification_channel_config import NotificationChannelConfig + + return { + "active": (bool,), + "config": (NotificationChannelConfig,), + } + + attribute_map = { + "active": "active", + "config": "config", + } + + def __init__( + self_, + active: Union[bool, UnsetType] = unset, + config: Union[ + NotificationChannelConfig, + NotificationChannelPhoneConfig, + NotificationChannelEmailConfig, + NotificationChannelPushConfig, + UnsetType, + ] = unset, + **kwargs, + ): + """ + Attributes for an on-call notification channel. + + :param active: Whether the notification channel is currently active. + :type active: bool, optional + + :param config: Defines the configuration for an On-Call notification channel + :type config: NotificationChannelConfig, optional + """ + if active is not unset: + kwargs["active"] = active + if config is not unset: + kwargs["config"] = config + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/notification_channel_config.py b/src/datadog_api_client/v2/model/notification_channel_config.py new file mode 100644 index 0000000000..e11da6ede1 --- /dev/null +++ b/src/datadog_api_client/v2/model/notification_channel_config.py @@ -0,0 +1,69 @@ +# 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 ( + ModelComposed, + cached_property, +) + + +class NotificationChannelConfig(ModelComposed): + def __init__(self, **kwargs): + """ + Defines the configuration for an On-Call notification channel + + :param formatted_number: The formatted international version of Number (e.g. +33 7 1 23 45 67). + :type formatted_number: str + + :param number: The E-164 formatted phone number (e.g. +3371234567) + :type number: str + + :param region: The ISO 3166-1 alpha-2 two-letter country code. + :type region: str + + :param sms_subscribed_at: If present, the date the user subscribed this number to SMS messages + :type sms_subscribed_at: datetime, none_type, optional + + :param type: Indicates that the notification channel is a phone + :type type: NotificationChannelPhoneConfigType + + :param verified: Indicates whether this phone has been verified by the user in Datadog On-Call + :type verified: bool + + :param address: The e-mail address to be notified + :type address: str + + :param formats: Preferred content formats for notifications. + :type formats: [NotificationChannelEmailFormatType] + + :param application_name: The name of the application used to receive push notifications + :type application_name: str + + :param device_name: The name of the mobile device being used + :type device_name: str + """ + super().__init__(kwargs) + + @cached_property + def _composed_schemas(_): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error because the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + from datadog_api_client.v2.model.notification_channel_phone_config import NotificationChannelPhoneConfig + from datadog_api_client.v2.model.notification_channel_email_config import NotificationChannelEmailConfig + from datadog_api_client.v2.model.notification_channel_push_config import NotificationChannelPushConfig + + return { + "oneOf": [ + NotificationChannelPhoneConfig, + NotificationChannelEmailConfig, + NotificationChannelPushConfig, + ], + } diff --git a/src/datadog_api_client/v2/model/notification_channel_data.py b/src/datadog_api_client/v2/model/notification_channel_data.py new file mode 100644 index 0000000000..210b251de9 --- /dev/null +++ b/src/datadog_api_client/v2/model/notification_channel_data.py @@ -0,0 +1,64 @@ +# 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.notification_channel_attributes import NotificationChannelAttributes + from datadog_api_client.v2.model.notification_channel_type import NotificationChannelType + + +class NotificationChannelData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.notification_channel_attributes import NotificationChannelAttributes + from datadog_api_client.v2.model.notification_channel_type import NotificationChannelType + + return { + "attributes": (NotificationChannelAttributes,), + "id": (str,), + "type": (NotificationChannelType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__( + self_, + type: NotificationChannelType, + attributes: Union[NotificationChannelAttributes, UnsetType] = unset, + id: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + Data for an on-call notification channel + + :param attributes: Attributes for an on-call notification channel. + :type attributes: NotificationChannelAttributes, optional + + :param id: Unique identifier for the channel + :type id: str, optional + + :param type: Indicates that the resource is of type 'notification_channels'. + :type type: NotificationChannelType + """ + if attributes is not unset: + kwargs["attributes"] = attributes + if id is not unset: + kwargs["id"] = id + super().__init__(kwargs) + + self_.type = type diff --git a/src/datadog_api_client/v2/model/notification_channel_email_config.py b/src/datadog_api_client/v2/model/notification_channel_email_config.py new file mode 100644 index 0000000000..5fbdaff26f --- /dev/null +++ b/src/datadog_api_client/v2/model/notification_channel_email_config.py @@ -0,0 +1,64 @@ +# 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, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.notification_channel_email_format_type import NotificationChannelEmailFormatType + from datadog_api_client.v2.model.notification_channel_email_config_type import NotificationChannelEmailConfigType + + +class NotificationChannelEmailConfig(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.notification_channel_email_format_type import ( + NotificationChannelEmailFormatType, + ) + from datadog_api_client.v2.model.notification_channel_email_config_type import ( + NotificationChannelEmailConfigType, + ) + + return { + "address": (str,), + "formats": ([NotificationChannelEmailFormatType],), + "type": (NotificationChannelEmailConfigType,), + } + + attribute_map = { + "address": "address", + "formats": "formats", + "type": "type", + } + + def __init__( + self_, + address: str, + formats: List[NotificationChannelEmailFormatType], + type: NotificationChannelEmailConfigType, + **kwargs, + ): + """ + Email notification channel configuration + + :param address: The e-mail address to be notified + :type address: str + + :param formats: Preferred content formats for notifications. + :type formats: [NotificationChannelEmailFormatType] + + :param type: Indicates that the notification channel is an e-mail address + :type type: NotificationChannelEmailConfigType + """ + super().__init__(kwargs) + + self_.address = address + self_.formats = formats + self_.type = type diff --git a/src/datadog_api_client/v2/model/notification_channel_email_config_type.py b/src/datadog_api_client/v2/model/notification_channel_email_config_type.py new file mode 100644 index 0000000000..49c995342c --- /dev/null +++ b/src/datadog_api_client/v2/model/notification_channel_email_config_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 NotificationChannelEmailConfigType(ModelSimple): + """ + Indicates that the notification channel is an e-mail address + + :param value: If omitted defaults to "email". Must be one of ["email"]. + :type value: str + """ + + allowed_values = { + "email", + } + EMAIL: ClassVar["NotificationChannelEmailConfigType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +NotificationChannelEmailConfigType.EMAIL = NotificationChannelEmailConfigType("email") diff --git a/src/datadog_api_client/v2/model/notification_channel_email_format_type.py b/src/datadog_api_client/v2/model/notification_channel_email_format_type.py new file mode 100644 index 0000000000..d6e7faccca --- /dev/null +++ b/src/datadog_api_client/v2/model/notification_channel_email_format_type.py @@ -0,0 +1,38 @@ +# 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 NotificationChannelEmailFormatType(ModelSimple): + """ + Specifies the format of the e-mail that is sent for On-Call notifications + + :param value: If omitted defaults to "html". Must be one of ["html", "text"]. + :type value: str + """ + + allowed_values = { + "html", + "text", + } + HTML: ClassVar["NotificationChannelEmailFormatType"] + TEXT: ClassVar["NotificationChannelEmailFormatType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +NotificationChannelEmailFormatType.HTML = NotificationChannelEmailFormatType("html") +NotificationChannelEmailFormatType.TEXT = NotificationChannelEmailFormatType("text") diff --git a/src/datadog_api_client/v2/model/notification_channel_phone_config.py b/src/datadog_api_client/v2/model/notification_channel_phone_config.py new file mode 100644 index 0000000000..34eb783f02 --- /dev/null +++ b/src/datadog_api_client/v2/model/notification_channel_phone_config.py @@ -0,0 +1,86 @@ +# 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, + datetime, + none_type, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.notification_channel_phone_config_type import NotificationChannelPhoneConfigType + + +class NotificationChannelPhoneConfig(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.notification_channel_phone_config_type import ( + NotificationChannelPhoneConfigType, + ) + + return { + "formatted_number": (str,), + "number": (str,), + "region": (str,), + "sms_subscribed_at": (datetime, none_type), + "type": (NotificationChannelPhoneConfigType,), + "verified": (bool,), + } + + attribute_map = { + "formatted_number": "formatted_number", + "number": "number", + "region": "region", + "sms_subscribed_at": "sms_subscribed_at", + "type": "type", + "verified": "verified", + } + + def __init__( + self_, + formatted_number: str, + number: str, + region: str, + type: NotificationChannelPhoneConfigType, + verified: bool, + sms_subscribed_at: Union[datetime, none_type, UnsetType] = unset, + **kwargs, + ): + """ + Phone notification channel configuration + + :param formatted_number: The formatted international version of Number (e.g. +33 7 1 23 45 67). + :type formatted_number: str + + :param number: The E-164 formatted phone number (e.g. +3371234567) + :type number: str + + :param region: The ISO 3166-1 alpha-2 two-letter country code. + :type region: str + + :param sms_subscribed_at: If present, the date the user subscribed this number to SMS messages + :type sms_subscribed_at: datetime, none_type, optional + + :param type: Indicates that the notification channel is a phone + :type type: NotificationChannelPhoneConfigType + + :param verified: Indicates whether this phone has been verified by the user in Datadog On-Call + :type verified: bool + """ + if sms_subscribed_at is not unset: + kwargs["sms_subscribed_at"] = sms_subscribed_at + super().__init__(kwargs) + + self_.formatted_number = formatted_number + self_.number = number + self_.region = region + self_.type = type + self_.verified = verified diff --git a/src/datadog_api_client/v2/model/notification_channel_phone_config_type.py b/src/datadog_api_client/v2/model/notification_channel_phone_config_type.py new file mode 100644 index 0000000000..7990002395 --- /dev/null +++ b/src/datadog_api_client/v2/model/notification_channel_phone_config_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 NotificationChannelPhoneConfigType(ModelSimple): + """ + Indicates that the notification channel is a phone + + :param value: If omitted defaults to "phone". Must be one of ["phone"]. + :type value: str + """ + + allowed_values = { + "phone", + } + PHONE: ClassVar["NotificationChannelPhoneConfigType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +NotificationChannelPhoneConfigType.PHONE = NotificationChannelPhoneConfigType("phone") diff --git a/src/datadog_api_client/v2/model/notification_channel_push_config.py b/src/datadog_api_client/v2/model/notification_channel_push_config.py new file mode 100644 index 0000000000..3b054dbd6f --- /dev/null +++ b/src/datadog_api_client/v2/model/notification_channel_push_config.py @@ -0,0 +1,52 @@ +# 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.notification_channel_push_config_type import NotificationChannelPushConfigType + + +class NotificationChannelPushConfig(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.notification_channel_push_config_type import NotificationChannelPushConfigType + + return { + "application_name": (str,), + "device_name": (str,), + "type": (NotificationChannelPushConfigType,), + } + + attribute_map = { + "application_name": "application_name", + "device_name": "device_name", + "type": "type", + } + + def __init__(self_, application_name: str, device_name: str, type: NotificationChannelPushConfigType, **kwargs): + """ + Push notification channel configuration + + :param application_name: The name of the application used to receive push notifications + :type application_name: str + + :param device_name: The name of the mobile device being used + :type device_name: str + + :param type: Indicates that the notification channel is a mobile device for push notifications + :type type: NotificationChannelPushConfigType + """ + super().__init__(kwargs) + + self_.application_name = application_name + self_.device_name = device_name + self_.type = type diff --git a/src/datadog_api_client/v2/model/notification_channel_push_config_type.py b/src/datadog_api_client/v2/model/notification_channel_push_config_type.py new file mode 100644 index 0000000000..7aef2b18a2 --- /dev/null +++ b/src/datadog_api_client/v2/model/notification_channel_push_config_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 NotificationChannelPushConfigType(ModelSimple): + """ + Indicates that the notification channel is a mobile device for push notifications + + :param value: If omitted defaults to "push". Must be one of ["push"]. + :type value: str + """ + + allowed_values = { + "push", + } + PUSH: ClassVar["NotificationChannelPushConfigType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +NotificationChannelPushConfigType.PUSH = NotificationChannelPushConfigType("push") diff --git a/src/datadog_api_client/v2/model/notification_channel_type.py b/src/datadog_api_client/v2/model/notification_channel_type.py new file mode 100644 index 0000000000..4e3f72148c --- /dev/null +++ b/src/datadog_api_client/v2/model/notification_channel_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 NotificationChannelType(ModelSimple): + """ + Indicates that the resource is of type 'notification_channels'. + + :param value: If omitted defaults to "notification_channels". Must be one of ["notification_channels"]. + :type value: str + """ + + allowed_values = { + "notification_channels", + } + NOTIFICATION_CHANNELS: ClassVar["NotificationChannelType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +NotificationChannelType.NOTIFICATION_CHANNELS = NotificationChannelType("notification_channels") diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 945b37f3aa..26fa6d24bf 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -1001,6 +1001,7 @@ from datadog_api_client.v2.model.create_deployment_rule_params_data_attributes import ( CreateDeploymentRuleParamsDataAttributes, ) +from datadog_api_client.v2.model.create_email_notification_channel_config import CreateEmailNotificationChannelConfig from datadog_api_client.v2.model.create_incident_notification_rule_request import CreateIncidentNotificationRuleRequest from datadog_api_client.v2.model.create_incident_notification_template_request import ( CreateIncidentNotificationTemplateRequest, @@ -1011,6 +1012,9 @@ from datadog_api_client.v2.model.create_jira_issue_request_data_relationships import ( CreateJiraIssueRequestDataRelationships, ) +from datadog_api_client.v2.model.create_notification_channel_attributes import CreateNotificationChannelAttributes +from datadog_api_client.v2.model.create_notification_channel_config import CreateNotificationChannelConfig +from datadog_api_client.v2.model.create_notification_channel_data import CreateNotificationChannelData from datadog_api_client.v2.model.create_notification_rule_parameters import CreateNotificationRuleParameters from datadog_api_client.v2.model.create_notification_rule_parameters_data import CreateNotificationRuleParametersData from datadog_api_client.v2.model.create_notification_rule_parameters_data_attributes import ( @@ -1027,6 +1031,7 @@ from datadog_api_client.v2.model.create_page_response import CreatePageResponse from datadog_api_client.v2.model.create_page_response_data import CreatePageResponseData from datadog_api_client.v2.model.create_page_response_data_type import CreatePageResponseDataType +from datadog_api_client.v2.model.create_phone_notification_channel_config import CreatePhoneNotificationChannelConfig from datadog_api_client.v2.model.create_rule_request import CreateRuleRequest from datadog_api_client.v2.model.create_rule_request_data import CreateRuleRequestData from datadog_api_client.v2.model.create_rule_response import CreateRuleResponse @@ -1092,6 +1097,7 @@ from datadog_api_client.v2.model.create_upload_response_data import CreateUploadResponseData from datadog_api_client.v2.model.create_upload_response_data_attributes import CreateUploadResponseDataAttributes from datadog_api_client.v2.model.create_upload_response_data_type import CreateUploadResponseDataType +from datadog_api_client.v2.model.create_user_notification_channel_request import CreateUserNotificationChannelRequest from datadog_api_client.v2.model.create_workflow_request import CreateWorkflowRequest from datadog_api_client.v2.model.create_workflow_response import CreateWorkflowResponse from datadog_api_client.v2.model.creator import Creator @@ -2446,6 +2452,7 @@ from datadog_api_client.v2.model.list_findings_page import ListFindingsPage from datadog_api_client.v2.model.list_findings_response import ListFindingsResponse from datadog_api_client.v2.model.list_kind_catalog_response import ListKindCatalogResponse +from datadog_api_client.v2.model.list_notification_channels_response import ListNotificationChannelsResponse from datadog_api_client.v2.model.list_pipelines_response import ListPipelinesResponse from datadog_api_client.v2.model.list_pipelines_response_meta import ListPipelinesResponseMeta from datadog_api_client.v2.model.list_powerpacks_response import ListPowerpacksResponse @@ -2830,6 +2837,18 @@ from datadog_api_client.v2.model.monthly_cost_attribution_pagination import MonthlyCostAttributionPagination from datadog_api_client.v2.model.monthly_cost_attribution_response import MonthlyCostAttributionResponse from datadog_api_client.v2.model.notebook_trigger_wrapper import NotebookTriggerWrapper +from datadog_api_client.v2.model.notification_channel import NotificationChannel +from datadog_api_client.v2.model.notification_channel_attributes import NotificationChannelAttributes +from datadog_api_client.v2.model.notification_channel_config import NotificationChannelConfig +from datadog_api_client.v2.model.notification_channel_data import NotificationChannelData +from datadog_api_client.v2.model.notification_channel_email_config import NotificationChannelEmailConfig +from datadog_api_client.v2.model.notification_channel_email_config_type import NotificationChannelEmailConfigType +from datadog_api_client.v2.model.notification_channel_email_format_type import NotificationChannelEmailFormatType +from datadog_api_client.v2.model.notification_channel_phone_config import NotificationChannelPhoneConfig +from datadog_api_client.v2.model.notification_channel_phone_config_type import NotificationChannelPhoneConfigType +from datadog_api_client.v2.model.notification_channel_push_config import NotificationChannelPushConfig +from datadog_api_client.v2.model.notification_channel_push_config_type import NotificationChannelPushConfigType +from datadog_api_client.v2.model.notification_channel_type import NotificationChannelType from datadog_api_client.v2.model.notification_rule import NotificationRule from datadog_api_client.v2.model.notification_rule_attributes import NotificationRuleAttributes from datadog_api_client.v2.model.notification_rule_response import NotificationRuleResponse @@ -5832,12 +5851,16 @@ "CreateDeploymentRuleParams", "CreateDeploymentRuleParamsData", "CreateDeploymentRuleParamsDataAttributes", + "CreateEmailNotificationChannelConfig", "CreateIncidentNotificationRuleRequest", "CreateIncidentNotificationTemplateRequest", "CreateJiraIssueRequestArray", "CreateJiraIssueRequestData", "CreateJiraIssueRequestDataAttributes", "CreateJiraIssueRequestDataRelationships", + "CreateNotificationChannelAttributes", + "CreateNotificationChannelConfig", + "CreateNotificationChannelData", "CreateNotificationRuleParameters", "CreateNotificationRuleParametersData", "CreateNotificationRuleParametersDataAttributes", @@ -5852,6 +5875,7 @@ "CreatePageResponse", "CreatePageResponseData", "CreatePageResponseDataType", + "CreatePhoneNotificationChannelConfig", "CreateRuleRequest", "CreateRuleRequestData", "CreateRuleResponse", @@ -5887,6 +5911,7 @@ "CreateUploadResponseData", "CreateUploadResponseDataAttributes", "CreateUploadResponseDataType", + "CreateUserNotificationChannelRequest", "CreateWorkflowRequest", "CreateWorkflowResponse", "Creator", @@ -6943,6 +6968,7 @@ "ListFindingsPage", "ListFindingsResponse", "ListKindCatalogResponse", + "ListNotificationChannelsResponse", "ListPipelinesResponse", "ListPipelinesResponseMeta", "ListPowerpacksResponse", @@ -7233,6 +7259,18 @@ "MonthlyCostAttributionPagination", "MonthlyCostAttributionResponse", "NotebookTriggerWrapper", + "NotificationChannel", + "NotificationChannelAttributes", + "NotificationChannelConfig", + "NotificationChannelData", + "NotificationChannelEmailConfig", + "NotificationChannelEmailConfigType", + "NotificationChannelEmailFormatType", + "NotificationChannelPhoneConfig", + "NotificationChannelPhoneConfigType", + "NotificationChannelPushConfig", + "NotificationChannelPushConfigType", + "NotificationChannelType", "NotificationRule", "NotificationRuleAttributes", "NotificationRuleResponse", diff --git a/tests/v2/cassettes/test_scenarios/test_create_an_oncall_notification_channel_for_a_user_returns_created_response.frozen b/tests/v2/cassettes/test_scenarios/test_create_an_oncall_notification_channel_for_a_user_returns_created_response.frozen new file mode 100644 index 0000000000..d364f431df --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_an_oncall_notification_channel_for_a_user_returns_created_response.frozen @@ -0,0 +1 @@ +2025-12-12T14:05:32.425Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_create_an_oncall_notification_channel_for_a_user_returns_created_response.yaml b/tests/v2/cassettes/test_scenarios/test_create_an_oncall_notification_channel_for_a_user_returns_created_response.yaml new file mode 100644 index 0000000000..1177c91838 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_an_oncall_notification_channel_for_a_user_returns_created_response.yaml @@ -0,0 +1,56 @@ +interactions: +- request: + body: '{"data":{"attributes":{"email":"Test-Create_an_On_Call_notification_channel_for_a_user_returns_Created_response-1765548332@datadoghq.com","title":"user + title"},"type":"users"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/users + response: + body: + string: '{"data":{"type":"users","id":"5ba8ee87-4d71-458c-883d-a6016738f7ce","attributes":{"name":null,"handle":"test-create_an_on_call_notification_channel_for_a_user_returns_created_response-1765548332@datadoghq.com","created_at":"2025-12-12T14:05:32.704821+00:00","modified_at":"2025-12-12T14:05:32.704821+00:00","email":"test-create_an_on_call_notification_channel_for_a_user_returns_created_response-1765548332@datadoghq.com","icon":"https://secure.gravatar.com/avatar/01791216e0fc8e5e005271e285ad9760?s=48&d=retro","title":"user + title","verified":false,"service_account":false,"disabled":false,"allowed_login_methods":[],"status":"Pending","last_login_time":null},"relationships":{"roles":{"data":[]},"org":{"data":{"type":"orgs","id":"4dee724d-00cc-11ea-a77b-570c9d03c6c5"}}}}} + + ' + headers: + content-type: + - application/json + status: + code: 201 + message: Created +- request: + body: '{"data":{"attributes":{"config":{"address":"foo@bar.com","formats":["html"],"type":"email"}},"type":"notification_channels"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/on-call/users/5ba8ee87-4d71-458c-883d-a6016738f7ce/notification-channels + response: + body: + string: '{"data":{"id":"f944f63a-2606-43c0-9c0b-10a34b9b214a","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"foo@bar.com","formats":["html"]}}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 201 + message: Created +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/users/5ba8ee87-4d71-458c-883d-a6016738f7ce + response: + body: + string: '' + headers: {} + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_delete_an_oncall_notification_channel_for_a_user_returns_no_content_response.frozen b/tests/v2/cassettes/test_scenarios/test_delete_an_oncall_notification_channel_for_a_user_returns_no_content_response.frozen new file mode 100644 index 0000000000..065691eedf --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_delete_an_oncall_notification_channel_for_a_user_returns_no_content_response.frozen @@ -0,0 +1 @@ +2025-12-11T18:27:50.679Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_delete_an_oncall_notification_channel_for_a_user_returns_no_content_response.yaml b/tests/v2/cassettes/test_scenarios/test_delete_an_oncall_notification_channel_for_a_user_returns_no_content_response.yaml new file mode 100644 index 0000000000..2956d6aa1e --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_delete_an_oncall_notification_channel_for_a_user_returns_no_content_response.yaml @@ -0,0 +1,70 @@ +interactions: +- request: + body: '{"data":{"attributes":{"email":"Test-Delete_an_On_Call_notification_channel_for_a_user_returns_No_Content_response-1765477670@datadoghq.com","title":"user + title"},"type":"users"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/users + response: + body: + string: '{"data":{"type":"users","id":"1df33be3-5397-4aaf-95c0-00dd63819c80","attributes":{"name":null,"handle":"test-delete_an_on_call_notification_channel_for_a_user_returns_no_content_response-1765477670@datadoghq.com","created_at":"2025-12-11T18:27:50.837055+00:00","modified_at":"2025-12-11T18:27:50.837055+00:00","email":"test-delete_an_on_call_notification_channel_for_a_user_returns_no_content_response-1765477670@datadoghq.com","icon":"https://secure.gravatar.com/avatar/f0ef01f65aae0d49a442ade4a44a5a53?s=48&d=retro","title":"user + title","verified":false,"service_account":false,"disabled":false,"allowed_login_methods":[],"status":"Pending","last_login_time":null},"relationships":{"roles":{"data":[]},"org":{"data":{"type":"orgs","id":"4dee724d-00cc-11ea-a77b-570c9d03c6c5"}}}}} + + ' + headers: + content-type: + - application/json + status: + code: 201 + message: Created +- request: + body: '{"data":{"attributes":{"config":{"address":"test-delete_an_on_call_notification_channel_for_a_user_returns_no_content_response-1765477670@datadoghq.com","formats":["html"],"type":"email"}},"type":"notification_channels"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/on-call/users/1df33be3-5397-4aaf-95c0-00dd63819c80/notification-channels + response: + body: + string: '{"data":{"id":"dd22cf57-a576-4c7e-92f8-36c2171f5f99","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-delete_an_on_call_notification_channel_for_a_user_returns_no_content_response-1765477670@datadoghq.com","formats":["html"]}}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 201 + message: Created +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/on-call/users/1df33be3-5397-4aaf-95c0-00dd63819c80/notification-channels/dd22cf57-a576-4c7e-92f8-36c2171f5f99 + response: + body: + string: '' + headers: {} + status: + code: 204 + message: No Content +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/users/1df33be3-5397-4aaf-95c0-00dd63819c80 + response: + body: + string: '' + headers: {} + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_get_an_oncall_notification_channel_for_a_user_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_get_an_oncall_notification_channel_for_a_user_returns_ok_response.frozen new file mode 100644 index 0000000000..e6a81ebe05 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_get_an_oncall_notification_channel_for_a_user_returns_ok_response.frozen @@ -0,0 +1 @@ +2025-12-12T14:04:17.257Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_get_an_oncall_notification_channel_for_a_user_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_get_an_oncall_notification_channel_for_a_user_returns_ok_response.yaml new file mode 100644 index 0000000000..e272df6d7b --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_get_an_oncall_notification_channel_for_a_user_returns_ok_response.yaml @@ -0,0 +1,72 @@ +interactions: +- request: + body: '{"data":{"attributes":{"email":"Test-Get_an_On_Call_notification_channel_for_a_user_returns_OK_response-1765548257@datadoghq.com","title":"user + title"},"type":"users"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/users + response: + body: + string: '{"data":{"type":"users","id":"0131b53c-5aec-4c8a-a14f-9ef487448833","attributes":{"name":null,"handle":"test-get_an_on_call_notification_channel_for_a_user_returns_ok_response-1765548257@datadoghq.com","created_at":"2025-12-12T14:04:17.531988+00:00","modified_at":"2025-12-12T14:04:17.531988+00:00","email":"test-get_an_on_call_notification_channel_for_a_user_returns_ok_response-1765548257@datadoghq.com","icon":"https://secure.gravatar.com/avatar/cedb283c90667a7da02c585159b4eda3?s=48&d=retro","title":"user + title","verified":false,"service_account":false,"disabled":false,"allowed_login_methods":[],"status":"Pending","last_login_time":null},"relationships":{"roles":{"data":[]},"org":{"data":{"type":"orgs","id":"4dee724d-00cc-11ea-a77b-570c9d03c6c5"}}}}} + + ' + headers: + content-type: + - application/json + status: + code: 201 + message: Created +- request: + body: '{"data":{"attributes":{"config":{"address":"test-get_an_on_call_notification_channel_for_a_user_returns_ok_response-1765548257@datadoghq.com","formats":["html"],"type":"email"}},"type":"notification_channels"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/on-call/users/0131b53c-5aec-4c8a-a14f-9ef487448833/notification-channels + response: + body: + string: '{"data":{"id":"d5fc3f5a-a4b9-4972-80bb-cb4db7ec958b","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-get_an_on_call_notification_channel_for_a_user_returns_ok_response-1765548257@datadoghq.com","formats":["html"]}}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 201 + message: Created +- request: + body: null + headers: + accept: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/on-call/users/0131b53c-5aec-4c8a-a14f-9ef487448833/notification-channels/d5fc3f5a-a4b9-4972-80bb-cb4db7ec958b + response: + body: + string: '{"data":{"id":"d5fc3f5a-a4b9-4972-80bb-cb4db7ec958b","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-get_an_on_call_notification_channel_for_a_user_returns_ok_response-1765548257@datadoghq.com","formats":["html"]}}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 200 + message: OK +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/users/0131b53c-5aec-4c8a-a14f-9ef487448833 + response: + body: + string: '' + headers: {} + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_list_oncall_notification_channels_for_a_user_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_list_oncall_notification_channels_for_a_user_returns_ok_response.frozen new file mode 100644 index 0000000000..d77fcd86e2 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_list_oncall_notification_channels_for_a_user_returns_ok_response.frozen @@ -0,0 +1 @@ +2025-12-12T14:40:40.219Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_list_oncall_notification_channels_for_a_user_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_list_oncall_notification_channels_for_a_user_returns_ok_response.yaml new file mode 100644 index 0000000000..c0b806c3fc --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_list_oncall_notification_channels_for_a_user_returns_ok_response.yaml @@ -0,0 +1,72 @@ +interactions: +- request: + body: '{"data":{"attributes":{"email":"Test-List_On_Call_notification_channels_for_a_user_returns_OK_response-1765550440@datadoghq.com","title":"user + title"},"type":"users"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/users + response: + body: + string: '{"data":{"type":"users","id":"c7fe3658-67dd-4a91-bf86-3709728fd8a5","attributes":{"name":null,"handle":"test-list_on_call_notification_channels_for_a_user_returns_ok_response-1765550440@datadoghq.com","created_at":"2025-12-12T14:40:40.467657+00:00","modified_at":"2025-12-12T14:40:40.467657+00:00","email":"test-list_on_call_notification_channels_for_a_user_returns_ok_response-1765550440@datadoghq.com","icon":"https://secure.gravatar.com/avatar/c74061cf101e1fea18813bda82103b47?s=48&d=retro","title":"user + title","verified":false,"service_account":false,"disabled":false,"allowed_login_methods":[],"status":"Pending","last_login_time":null},"relationships":{"roles":{"data":[]},"org":{"data":{"type":"orgs","id":"4dee724d-00cc-11ea-a77b-570c9d03c6c5"}}}}} + + ' + headers: + content-type: + - application/json + status: + code: 201 + message: Created +- request: + body: '{"data":{"attributes":{"config":{"address":"test-list_on_call_notification_channels_for_a_user_returns_ok_response-1765550440@datadoghq.com","formats":["html"],"type":"email"}},"type":"notification_channels"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/on-call/users/c7fe3658-67dd-4a91-bf86-3709728fd8a5/notification-channels + response: + body: + string: '{"data":{"id":"8e9a9ded-ff10-4661-8d56-b4b789f54bf1","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-list_on_call_notification_channels_for_a_user_returns_ok_response-1765550440@datadoghq.com","formats":["html"]}}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 201 + message: Created +- request: + body: null + headers: + accept: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/on-call/users/c7fe3658-67dd-4a91-bf86-3709728fd8a5/notification-channels + response: + body: + string: '{"data":[{"id":"8e9a9ded-ff10-4661-8d56-b4b789f54bf1","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-list_on_call_notification_channels_for_a_user_returns_ok_response-1765550440@datadoghq.com","formats":["html"]}}}]}' + headers: + content-type: + - application/vnd.api+json + status: + code: 200 + message: OK +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/users/c7fe3658-67dd-4a91-bf86-3709728fd8a5 + response: + body: + string: '' + headers: {} + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/features/given.json b/tests/v2/features/given.json index 7725798de4..8cf1925f45 100644 --- a/tests/v2/features/given.json +++ b/tests/v2/features/given.json @@ -783,6 +783,22 @@ "tag": "On-Call", "operationId": "SetOnCallTeamRoutingRules" }, + { + "parameters": [ + { + "name": "user_id", + "source": "user.data.id" + }, + { + "name": "body", + "value": "{\n \"data\": {\n \"attributes\": {\n \"config\": {\n \"type\": \"email\",\n \"address\": \"{{ user.data.attributes.email }}\",\n \"formats\": [\n \"html\"\n ]\n }\n },\n \"type\": \"notification_channels\"\n }\n}" + } + ], + "step": "there is a valid \"oncall_email_notification_channel\" in the system", + "key": "oncall_email_notification_channel", + "tag": "On-Call", + "operationId": "CreateUserNotificationChannel" + }, { "parameters": [ { diff --git a/tests/v2/features/on-call.feature b/tests/v2/features/on-call.feature index c52e4291fc..9f4750eef7 100644 --- a/tests/v2/features/on-call.feature +++ b/tests/v2/features/on-call.feature @@ -43,6 +43,33 @@ Feature: On-Call When the request is sent Then the response status is 201 Created + @generated @skip @team:DataDog/on-call + Scenario: Create an On-Call notification channel for a user returns "Bad Request" response + Given new "CreateUserNotificationChannel" request + And request contains "user_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"config": {"address": "foo@bar.com", "formats": ["html"], "type": "email"}}, "type": "notification_channels"}} + When the request is sent + Then the response status is 400 Bad Request + + @replay-only @team:DataDog/on-call + Scenario: Create an On-Call notification channel for a user returns "Created" response + Given new "CreateUserNotificationChannel" request + And there is a valid "user" in the system + And request contains "user_id" parameter from "user.data.id" + And body with value {"data": {"attributes": {"config": {"address": "foo@bar.com", "formats": ["html"], "type": "email"}}, "type": "notification_channels"}} + When the request is sent + Then the response status is 201 Created + And the response "data.attributes.config.type" is equal to "email" + And the response "data.attributes.config.address" is equal to "foo@bar.com" + + @generated @skip @team:DataDog/on-call + Scenario: Create an On-Call notification channel for a user returns "Not Found" response + Given new "CreateUserNotificationChannel" request + And request contains "user_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"config": {"address": "foo@bar.com", "formats": ["html"], "type": "email"}}, "type": "notification_channels"}} + When the request is sent + Then the response status is 404 Not Found + @team:DataDog/on-call Scenario: Delete On-Call escalation policy returns "No Content" response Given new "DeleteOnCallEscalationPolicy" request @@ -77,6 +104,32 @@ Feature: On-Call When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/on-call + Scenario: Delete an On-Call notification channel for a user returns "Bad Request" response + Given new "DeleteUserNotificationChannel" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "channel_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @replay-only @team:DataDog/on-call + Scenario: Delete an On-Call notification channel for a user returns "No Content" response + Given new "DeleteUserNotificationChannel" request + And there is a valid "user" in the system + And there is a valid "oncall_email_notification_channel" in the system + And request contains "user_id" parameter from "user.data.id" + And request contains "channel_id" parameter from "oncall_email_notification_channel.data.id" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/on-call + Scenario: Delete an On-Call notification channel for a user returns "Not Found" response + Given new "DeleteUserNotificationChannel" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "channel_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @generated @skip @team:DataDog/on-call Scenario: Get On-Call escalation policy returns "Bad Request" response Given new "GetOnCallEscalationPolicy" request @@ -126,6 +179,34 @@ Feature: On-Call When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/on-call + Scenario: Get an On-Call notification channel for a user returns "Bad Request" response + Given new "GetUserNotificationChannel" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "channel_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/on-call + Scenario: Get an On-Call notification channel for a user returns "Not Found" response + Given new "GetUserNotificationChannel" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "channel_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @replay-only @team:DataDog/on-call + Scenario: Get an On-Call notification channel for a user returns "OK" response + Given new "GetUserNotificationChannel" request + And there is a valid "user" in the system + And there is a valid "oncall_email_notification_channel" in the system + And request contains "user_id" parameter from "user.data.id" + And request contains "channel_id" parameter from "oncall_email_notification_channel.data.id" + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.config.type" is equal to "email" + And the response "data.attributes.config.address" is equal to "{{ user.data.attributes.email }}" + @generated @skip @team:DataDog/on-call Scenario: Get scheduled on-call user returns "Bad Request" response Given new "GetScheduleOnCallUser" request @@ -176,6 +257,32 @@ Feature: On-Call When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/on-call + Scenario: List On-Call notification channels for a user returns "Bad Request" response + Given new "ListUserNotificationChannels" request + And request contains "user_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/on-call + Scenario: List On-Call notification channels for a user returns "Not Found" response + Given new "ListUserNotificationChannels" request + And request contains "user_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @replay-only @team:DataDog/on-call + Scenario: List On-Call notification channels for a user returns "OK" response + Given new "ListUserNotificationChannels" request + And there is a valid "user" in the system + And there is a valid "oncall_email_notification_channel" in the system + And request contains "user_id" parameter from "user.data.id" + When the request is sent + Then the response status is 200 OK + And the response "data" has length 1 + And the response "data[0].attributes.config.type" is equal to "email" + And the response "data[0].attributes.config.address" is equal to "{{ user.data.attributes.email }}" + @skip-python @team:DataDog/on-call Scenario: Set On-Call team routing rules returns "OK" response Given new "SetOnCallTeamRoutingRules" request diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index 56977a4c30..8aec373cdd 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -2934,6 +2934,30 @@ "type": "unsafe" } }, + "ListUserNotificationChannels": { + "tag": "On-Call", + "undo": { + "type": "safe" + } + }, + "CreateUserNotificationChannel": { + "tag": "On-Call", + "undo": { + "type": "safe" + } + }, + "DeleteUserNotificationChannel": { + "tag": "On-Call", + "undo": { + "type": "idempotent" + } + }, + "GetUserNotificationChannel": { + "tag": "On-Call", + "undo": { + "type": "safe" + } + }, "ListOrgConfigs": { "tag": "Organizations", "undo": {