diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 196165112d..f2a1dc5e08 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -13374,6 +13374,40 @@ components: - name - targets type: object + CreateOnCallNotificationRuleRequest: + description: A top-level wrapper for creating a notification rule for a user + example: + data: + attributes: + category: high_urgency + channel_settings: + method: sms + type: phone + delay_minutes: 1 + relationships: + channel: + data: + id: 1562fab3-a8c2-49e2-8f3a-28dcda2405e2 + type: notification_channels + type: notification_rules + properties: + data: + $ref: '#/components/schemas/CreateOnCallNotificationRuleRequestData' + required: + - data + type: object + CreateOnCallNotificationRuleRequestData: + description: Data for creating an on-call notification rule + properties: + attributes: + $ref: '#/components/schemas/OnCallNotificationRuleRequestAttributes' + relationships: + $ref: '#/components/schemas/OnCallNotificationRuleRelationships' + type: + $ref: '#/components/schemas/OnCallNotificationRuleType' + required: + - type + type: object CreateOpenAPIResponse: description: Response for `CreateOpenAPI` operation. properties: @@ -30599,6 +30633,18 @@ components: $ref: '#/components/schemas/NotificationChannelData' type: array type: object + ListOnCallNotificationRulesResponse: + description: Response type for listing notification rules for a user + properties: + data: + items: + $ref: '#/components/schemas/OnCallNotificationRuleData' + type: array + included: + items: + $ref: '#/components/schemas/OnCallNotificationRulesIncluded' + type: array + type: object ListPipelinesResponse: description: Represents the response payload containing a list of pipelines and associated metadata. @@ -39053,6 +39099,130 @@ components: required: - type type: object + OnCallNotificationRule: + description: A top-level wrapper for a notification rule + example: + data: + attributes: + category: high_urgency + channel_settings: + method: sms + type: phone + delay_minutes: 1 + id: 27590dae-47be-4a7d-9abf-8f4e45124020 + relationships: + channel: + data: + id: 1562fab3-a8c2-49e2-8f3a-28dcda2405e2 + type: notification_channels + type: notification_rules + properties: + data: + $ref: '#/components/schemas/OnCallNotificationRuleData' + included: + items: + $ref: '#/components/schemas/OnCallNotificationRulesIncluded' + type: array + required: + - data + type: object + OnCallNotificationRuleAttributes: + description: Attributes for an on-call notification rule. + properties: + category: + $ref: '#/components/schemas/OnCallNotificationRuleCategory' + channel_settings: + $ref: '#/components/schemas/OnCallNotificationRuleChannelSettings' + description: Configuration for the associated channel, if necessary + nullable: true + delay_minutes: + description: The number of minutes that will elapse before this rule is + evaluated. 0 indicates immediate evaluation + format: int64 + type: integer + type: object + OnCallNotificationRuleCategory: + default: high_urgency + description: Specifies the category a notification rule will apply to + enum: + - high_urgency + - low_urgency + type: string + x-enum-varnames: + - HIGH_URGENCY + - LOW_URGENCY + OnCallNotificationRuleChannelRelationship: + description: Relationship object for creating a notification rule + properties: + data: + $ref: '#/components/schemas/OnCallNotificationRuleChannelRelationshipData' + required: + - data + type: object + OnCallNotificationRuleChannelRelationshipData: + description: Channel relationship data for creating a notification rule + properties: + id: + description: ID of the notification channel + type: string + type: + $ref: '#/components/schemas/NotificationChannelType' + type: object + OnCallNotificationRuleChannelSettings: + description: Defines the configuration for a channel associated with a notification + rule + oneOf: + - $ref: '#/components/schemas/OnCallPhoneNotificationRuleSettings' + OnCallNotificationRuleData: + description: Data for an on-call notification rule + properties: + attributes: + $ref: '#/components/schemas/OnCallNotificationRuleAttributes' + id: + description: Unique identifier for the rule + type: string + relationships: + $ref: '#/components/schemas/OnCallNotificationRuleRelationships' + type: + $ref: '#/components/schemas/OnCallNotificationRuleType' + required: + - type + type: object + OnCallNotificationRuleRelationships: + description: Relationship object for creating a notification rule + properties: + channel: + $ref: '#/components/schemas/OnCallNotificationRuleChannelRelationship' + type: object + OnCallNotificationRuleRequestAttributes: + description: Attributes for creating or modifying an on-call notification rule. + properties: + category: + $ref: '#/components/schemas/OnCallNotificationRuleCategory' + channel_settings: + $ref: '#/components/schemas/OnCallNotificationRuleChannelSettings' + description: Configuration for the associated channel, if necessary + nullable: true + delay_minutes: + description: The number of minutes that will elapse before this rule is + evaluated. 0 indicates immediate evaluation + format: int64 + type: integer + type: object + OnCallNotificationRuleType: + default: notification_rules + description: Indicates that the resource is of type 'notification_rules'. + enum: + - notification_rules + example: notification_rules + type: string + x-enum-varnames: + - NOTIFICATION_RULES + OnCallNotificationRulesIncluded: + description: Represents additional included resources for a on-call notification + rules + oneOf: + - $ref: '#/components/schemas/NotificationChannelData' OnCallPageTargetType: description: The kind of target, `team_id` | `team_handle` | `user_id`. enum: @@ -39065,6 +39235,29 @@ components: - TEAM_ID - TEAM_HANDLE - USER_ID + OnCallPhoneNotificationRuleMethod: + description: Specifies the method in which a phone is used in a notification + rule + enum: + - sms + - voice + example: sms + type: string + x-enum-varnames: + - SMS + - VOICE + OnCallPhoneNotificationRuleSettings: + description: Configuration for using a phone notification channel in a notification + rule + properties: + method: + $ref: '#/components/schemas/OnCallPhoneNotificationRuleMethod' + type: + $ref: '#/components/schemas/NotificationChannelPhoneConfigType' + required: + - type + - method + type: object OnDemandConcurrencyCap: description: On-demand concurrency cap. properties: @@ -56304,6 +56497,59 @@ components: - name - options type: object + UpdateOnCallNotificationRuleRequest: + description: A top-level wrapper for updating a notification rule for a user + example: + data: + attributes: + category: high_urgency + channel_settings: + method: sms + type: phone + delay_minutes: 1 + id: 2462ace1-49e2-aab1-xc4f-29cc4ae1105n7 + relationships: + channel: + data: + id: 1562fab3-a8c2-49e2-8f3a-28dcda2405e2 + type: notification_channels + type: notification_rules + properties: + data: + $ref: '#/components/schemas/UpdateOnCallNotificationRuleRequestData' + required: + - data + type: object + UpdateOnCallNotificationRuleRequestAttributes: + description: Attributes for creating or modifying an on-call notification rule. + properties: + category: + $ref: '#/components/schemas/OnCallNotificationRuleCategory' + channel_settings: + $ref: '#/components/schemas/OnCallNotificationRuleChannelSettings' + description: Configuration for the associated channel, if necessary + nullable: true + delay_minutes: + description: The number of minutes that will elapse before this rule is + evaluated. 0 indicates immediate evaluation + format: int64 + type: integer + type: object + UpdateOnCallNotificationRuleRequestData: + description: Data for updating an on-call notification rule + properties: + attributes: + $ref: '#/components/schemas/UpdateOnCallNotificationRuleRequestAttributes' + id: + description: Unique identifier for the rule + type: string + relationships: + $ref: '#/components/schemas/OnCallNotificationRuleRelationships' + type: + $ref: '#/components/schemas/OnCallNotificationRuleType' + required: + - type + type: object UpdateOpenAPIResponse: description: Response for `UpdateOpenAPI`. properties: @@ -76343,6 +76589,255 @@ paths: operator: AND permissions: - on_call_read + /api/v2/on-call/users/{user_id}/notification-rules: + get: + description: List the notification rules for a user. The authenticated user + must be the target user or have the `on_call_admin` permission + operationId: ListUserNotificationRules + parameters: + - description: 'Comma-separated list of included relationships to be returned. + Allowed values: `channel`.' + in: query + name: include + schema: + type: string + - 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/ListOnCallNotificationRulesResponse' + 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 rules for a user + tags: + - On-Call + x-permission: + operator: AND + permissions: + - on_call_read + post: + description: Create a new notification rule for a user. The authenticated user + must be the target user or have the `on_call_admin` permission + operationId: CreateUserNotificationRule + 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/CreateOnCallNotificationRuleRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/OnCallNotificationRule' + 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 rule for a user + tags: + - On-Call + x-permission: + operator: AND + permissions: + - on_call_respond + /api/v2/on-call/users/{user_id}/notification-rules/{rule_id}: + delete: + description: Delete a notification rule for a user. The authenticated user must + be the target user or have the `on_call_admin` permission + operationId: DeleteUserNotificationRule + parameters: + - description: The user ID + in: path + name: user_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + - description: The rule ID + in: path + name: rule_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 rule for a user + tags: + - On-Call + x-permission: + operator: OR + permissions: + - on_call_respond + get: + description: Get a notification rule for a user. The authenticated user must + be the target user or have the `on_call_admin` permission + operationId: GetUserNotificationRule + parameters: + - description: The user ID + in: path + name: user_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + - description: The rule ID + in: path + name: rule_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + - description: 'Comma-separated list of included relationships to be returned. + Allowed values: `channel`.' + in: query + name: include + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/OnCallNotificationRule' + 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 rule for a user + tags: + - On-Call + x-permission: + operator: OR + permissions: + - on_call_read + put: + description: Update a notification rule for a user. The authenticated user must + be the target user or have the `on_call_admin` permission + operationId: UpdateUserNotificationRule + parameters: + - description: The user ID + in: path + name: user_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + - description: The rule ID + in: path + name: rule_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string + - description: 'Comma-separated list of included relationships to be returned. + Allowed values: `channel`.' + in: query + name: include + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateOnCallNotificationRuleRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/OnCallNotificationRule' + 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: Update an On-Call notification rule for a user + tags: + - On-Call + x-permission: + operator: OR + 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 6220d558aa..afe7c33af1 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -5366,6 +5366,20 @@ datadog\_api\_client.v2.model.create\_notification\_rule\_parameters\_data\_attr :members: :show-inheritance: +datadog\_api\_client.v2.model.create\_on\_call\_notification\_rule\_request module +---------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.create_on_call_notification_rule_request + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.create\_on\_call\_notification\_rule\_request\_data module +---------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.create_on_call_notification_rule_request_data + :members: + :show-inheritance: + datadog\_api\_client.v2.model.create\_open\_api\_response module ---------------------------------------------------------------- @@ -13101,6 +13115,13 @@ datadog\_api\_client.v2.model.list\_notification\_channels\_response module :members: :show-inheritance: +datadog\_api\_client.v2.model.list\_on\_call\_notification\_rules\_response module +---------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.list_on_call_notification_rules_response + :members: + :show-inheritance: + datadog\_api\_client.v2.model.list\_pipelines\_response module -------------------------------------------------------------- @@ -16993,6 +17014,83 @@ datadog\_api\_client.v2.model.okta\_integration\_update module :members: :show-inheritance: +datadog\_api\_client.v2.model.on\_call\_notification\_rule module +----------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.on_call_notification_rule + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.on\_call\_notification\_rule\_attributes module +----------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.on_call_notification_rule_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.on\_call\_notification\_rule\_category module +--------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.on_call_notification_rule_category + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.on\_call\_notification\_rule\_channel\_relationship module +---------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.on_call_notification_rule_channel_relationship + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.on\_call\_notification\_rule\_channel\_relationship\_data module +---------------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.on_call_notification_rule_channel_relationship_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.on\_call\_notification\_rule\_channel\_settings module +------------------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.on_call_notification_rule_channel_settings + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.on\_call\_notification\_rule\_data module +----------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.on_call_notification_rule_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.on\_call\_notification\_rule\_relationships module +-------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.on_call_notification_rule_relationships + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.on\_call\_notification\_rule\_request\_attributes module +-------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.on_call_notification_rule_request_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.on\_call\_notification\_rule\_type module +----------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.on_call_notification_rule_type + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.on\_call\_notification\_rules\_included module +---------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.on_call_notification_rules_included + :members: + :show-inheritance: + datadog\_api\_client.v2.model.on\_call\_page\_target\_type module ----------------------------------------------------------------- @@ -17000,6 +17098,20 @@ datadog\_api\_client.v2.model.on\_call\_page\_target\_type module :members: :show-inheritance: +datadog\_api\_client.v2.model.on\_call\_phone\_notification\_rule\_method module +-------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.on_call_phone_notification_rule_method + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.on\_call\_phone\_notification\_rule\_settings module +---------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.on_call_phone_notification_rule_settings + :members: + :show-inheritance: + datadog\_api\_client.v2.model.on\_demand\_concurrency\_cap module ----------------------------------------------------------------- @@ -24917,6 +25029,27 @@ datadog\_api\_client.v2.model.update\_deployment\_rule\_params\_data\_attributes :members: :show-inheritance: +datadog\_api\_client.v2.model.update\_on\_call\_notification\_rule\_request module +---------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.update_on_call_notification_rule_request + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.update\_on\_call\_notification\_rule\_request\_attributes module +---------------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.update_on_call_notification_rule_request_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.update\_on\_call\_notification\_rule\_request\_data module +---------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.update_on_call_notification_rule_request_data + :members: + :show-inheritance: + datadog\_api\_client.v2.model.update\_open\_api\_response module ---------------------------------------------------------------- diff --git a/examples/v2/on-call/CreateUserNotificationRule.py b/examples/v2/on-call/CreateUserNotificationRule.py new file mode 100644 index 0000000000..491bc5f027 --- /dev/null +++ b/examples/v2/on-call/CreateUserNotificationRule.py @@ -0,0 +1,55 @@ +""" +Create an On-Call notification rule 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_on_call_notification_rule_request import CreateOnCallNotificationRuleRequest +from datadog_api_client.v2.model.create_on_call_notification_rule_request_data import ( + CreateOnCallNotificationRuleRequestData, +) +from datadog_api_client.v2.model.notification_channel_type import NotificationChannelType +from datadog_api_client.v2.model.on_call_notification_rule_category import OnCallNotificationRuleCategory +from datadog_api_client.v2.model.on_call_notification_rule_channel_relationship import ( + OnCallNotificationRuleChannelRelationship, +) +from datadog_api_client.v2.model.on_call_notification_rule_channel_relationship_data import ( + OnCallNotificationRuleChannelRelationshipData, +) +from datadog_api_client.v2.model.on_call_notification_rule_relationships import OnCallNotificationRuleRelationships +from datadog_api_client.v2.model.on_call_notification_rule_request_attributes import ( + OnCallNotificationRuleRequestAttributes, +) +from datadog_api_client.v2.model.on_call_notification_rule_type import OnCallNotificationRuleType + +# 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"] + +body = CreateOnCallNotificationRuleRequest( + data=CreateOnCallNotificationRuleRequestData( + attributes=OnCallNotificationRuleRequestAttributes( + category=OnCallNotificationRuleCategory.HIGH_URGENCY, + delay_minutes=0, + ), + relationships=OnCallNotificationRuleRelationships( + channel=OnCallNotificationRuleChannelRelationship( + data=OnCallNotificationRuleChannelRelationshipData( + id=ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID, + type=NotificationChannelType.NOTIFICATION_CHANNELS, + ), + ), + ), + type=OnCallNotificationRuleType.NOTIFICATION_RULES, + ), +) + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = OnCallApi(api_client) + response = api_instance.create_user_notification_rule(user_id=USER_DATA_ID, body=body) + + print(response) diff --git a/examples/v2/on-call/DeleteUserNotificationRule.py b/examples/v2/on-call/DeleteUserNotificationRule.py new file mode 100644 index 0000000000..266ac85fba --- /dev/null +++ b/examples/v2/on-call/DeleteUserNotificationRule.py @@ -0,0 +1,21 @@ +""" +Delete an On-Call notification rule 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_rule" in the system +ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID = environ["ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID"] + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = OnCallApi(api_client) + api_instance.delete_user_notification_rule( + user_id=USER_DATA_ID, + rule_id=ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID, + ) diff --git a/examples/v2/on-call/GetUserNotificationRule.py b/examples/v2/on-call/GetUserNotificationRule.py new file mode 100644 index 0000000000..945247050d --- /dev/null +++ b/examples/v2/on-call/GetUserNotificationRule.py @@ -0,0 +1,24 @@ +""" +Get an On-Call notification rule 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_rule" in the system +ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID = environ["ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID"] + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = OnCallApi(api_client) + response = api_instance.get_user_notification_rule( + user_id=USER_DATA_ID, + rule_id=ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID, + include="channel", + ) + + print(response) diff --git a/examples/v2/on-call/ListUserNotificationRules.py b/examples/v2/on-call/ListUserNotificationRules.py new file mode 100644 index 0000000000..ca178f4f80 --- /dev/null +++ b/examples/v2/on-call/ListUserNotificationRules.py @@ -0,0 +1,20 @@ +""" +List On-Call notification rules 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_rules( + include="channel", + user_id=USER_DATA_ID, + ) + + print(response) diff --git a/examples/v2/on-call/UpdateUserNotificationRule.py b/examples/v2/on-call/UpdateUserNotificationRule.py new file mode 100644 index 0000000000..dd212a9325 --- /dev/null +++ b/examples/v2/on-call/UpdateUserNotificationRule.py @@ -0,0 +1,61 @@ +""" +Update an On-Call notification rule 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 +from datadog_api_client.v2.model.notification_channel_type import NotificationChannelType +from datadog_api_client.v2.model.on_call_notification_rule_category import OnCallNotificationRuleCategory +from datadog_api_client.v2.model.on_call_notification_rule_channel_relationship import ( + OnCallNotificationRuleChannelRelationship, +) +from datadog_api_client.v2.model.on_call_notification_rule_channel_relationship_data import ( + OnCallNotificationRuleChannelRelationshipData, +) +from datadog_api_client.v2.model.on_call_notification_rule_relationships import OnCallNotificationRuleRelationships +from datadog_api_client.v2.model.on_call_notification_rule_type import OnCallNotificationRuleType +from datadog_api_client.v2.model.update_on_call_notification_rule_request import UpdateOnCallNotificationRuleRequest +from datadog_api_client.v2.model.update_on_call_notification_rule_request_attributes import ( + UpdateOnCallNotificationRuleRequestAttributes, +) +from datadog_api_client.v2.model.update_on_call_notification_rule_request_data import ( + UpdateOnCallNotificationRuleRequestData, +) + +# there is a valid "user" in the system +USER_DATA_ID = environ["USER_DATA_ID"] + +# there is a valid "oncall_email_notification_rule" in the system +ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID = environ["ONCALL_EMAIL_NOTIFICATION_RULE_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"] + +body = UpdateOnCallNotificationRuleRequest( + data=UpdateOnCallNotificationRuleRequestData( + attributes=UpdateOnCallNotificationRuleRequestAttributes( + category=OnCallNotificationRuleCategory.HIGH_URGENCY, + delay_minutes=1, + ), + id=ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID, + relationships=OnCallNotificationRuleRelationships( + channel=OnCallNotificationRuleChannelRelationship( + data=OnCallNotificationRuleChannelRelationshipData( + id=ONCALL_EMAIL_NOTIFICATION_CHANNEL_DATA_ID, + type=NotificationChannelType.NOTIFICATION_CHANNELS, + ), + ), + ), + type=OnCallNotificationRuleType.NOTIFICATION_RULES, + ), +) + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = OnCallApi(api_client) + response = api_instance.update_user_notification_rule( + user_id=USER_DATA_ID, rule_id=ONCALL_EMAIL_NOTIFICATION_RULE_DATA_ID, include="channel", body=body + ) + + 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 92d82e2b71..c2565ada20 100644 --- a/src/datadog_api_client/v2/api/on_call_api.py +++ b/src/datadog_api_client/v2/api/on_call_api.py @@ -24,6 +24,10 @@ 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 +from datadog_api_client.v2.model.list_on_call_notification_rules_response import ListOnCallNotificationRulesResponse +from datadog_api_client.v2.model.on_call_notification_rule import OnCallNotificationRule +from datadog_api_client.v2.model.create_on_call_notification_rule_request import CreateOnCallNotificationRuleRequest +from datadog_api_client.v2.model.update_on_call_notification_rule_request import UpdateOnCallNotificationRuleRequest class OnCallApi: @@ -113,6 +117,32 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._create_user_notification_rule_endpoint = _Endpoint( + settings={ + "response_type": (OnCallNotificationRule,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/on-call/users/{user_id}/notification-rules", + "operation_id": "create_user_notification_rule", + "http_method": "POST", + "version": "v2", + }, + params_map={ + "user_id": { + "required": True, + "openapi_types": (str,), + "attribute": "user_id", + "location": "path", + }, + "body": { + "required": True, + "openapi_types": (CreateOnCallNotificationRuleRequest,), + "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, @@ -188,6 +218,35 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._delete_user_notification_rule_endpoint = _Endpoint( + settings={ + "response_type": None, + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/on-call/users/{user_id}/notification-rules/{rule_id}", + "operation_id": "delete_user_notification_rule", + "http_method": "DELETE", + "version": "v2", + }, + params_map={ + "user_id": { + "required": True, + "openapi_types": (str,), + "attribute": "user_id", + "location": "path", + }, + "rule_id": { + "required": True, + "openapi_types": (str,), + "attribute": "rule_id", + "location": "path", + }, + }, + headers_map={ + "accept": ["*/*"], + }, + api_client=api_client, + ) + self._get_on_call_escalation_policy_endpoint = _Endpoint( settings={ "response_type": (EscalationPolicy,), @@ -362,6 +421,40 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._get_user_notification_rule_endpoint = _Endpoint( + settings={ + "response_type": (OnCallNotificationRule,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/on-call/users/{user_id}/notification-rules/{rule_id}", + "operation_id": "get_user_notification_rule", + "http_method": "GET", + "version": "v2", + }, + params_map={ + "user_id": { + "required": True, + "openapi_types": (str,), + "attribute": "user_id", + "location": "path", + }, + "rule_id": { + "required": True, + "openapi_types": (str,), + "attribute": "rule_id", + "location": "path", + }, + "include": { + "openapi_types": (str,), + "attribute": "include", + "location": "query", + }, + }, + headers_map={ + "accept": ["application/json"], + }, + api_client=api_client, + ) + self._list_user_notification_channels_endpoint = _Endpoint( settings={ "response_type": (ListNotificationChannelsResponse,), @@ -385,6 +478,34 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._list_user_notification_rules_endpoint = _Endpoint( + settings={ + "response_type": (ListOnCallNotificationRulesResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/on-call/users/{user_id}/notification-rules", + "operation_id": "list_user_notification_rules", + "http_method": "GET", + "version": "v2", + }, + params_map={ + "include": { + "openapi_types": (str,), + "attribute": "include", + "location": "query", + }, + "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,), @@ -478,6 +599,43 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._update_user_notification_rule_endpoint = _Endpoint( + settings={ + "response_type": (OnCallNotificationRule,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/on-call/users/{user_id}/notification-rules/{rule_id}", + "operation_id": "update_user_notification_rule", + "http_method": "PUT", + "version": "v2", + }, + params_map={ + "user_id": { + "required": True, + "openapi_types": (str,), + "attribute": "user_id", + "location": "path", + }, + "rule_id": { + "required": True, + "openapi_types": (str,), + "attribute": "rule_id", + "location": "path", + }, + "include": { + "openapi_types": (str,), + "attribute": "include", + "location": "query", + }, + "body": { + "required": True, + "openapi_types": (UpdateOnCallNotificationRuleRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + def create_on_call_escalation_policy( self, body: EscalationPolicyCreateRequest, @@ -545,6 +703,27 @@ def create_user_notification_channel( return self._create_user_notification_channel_endpoint.call_with_http_info(**kwargs) + def create_user_notification_rule( + self, + user_id: str, + body: CreateOnCallNotificationRuleRequest, + ) -> OnCallNotificationRule: + """Create an On-Call notification rule for a user. + + Create a new notification rule 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: CreateOnCallNotificationRuleRequest + :rtype: OnCallNotificationRule + """ + kwargs: Dict[str, Any] = {} + kwargs["user_id"] = user_id + + kwargs["body"] = body + + return self._create_user_notification_rule_endpoint.call_with_http_info(**kwargs) + def delete_on_call_escalation_policy( self, policy_id: str, @@ -601,6 +780,28 @@ def delete_user_notification_channel( return self._delete_user_notification_channel_endpoint.call_with_http_info(**kwargs) + def delete_user_notification_rule( + self, + user_id: str, + rule_id: str, + ) -> None: + """Delete an On-Call notification rule for a user. + + Delete a notification rule 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 rule_id: The rule ID + :type rule_id: str + :rtype: None + """ + kwargs: Dict[str, Any] = {} + kwargs["user_id"] = user_id + + kwargs["rule_id"] = rule_id + + return self._delete_user_notification_rule_endpoint.call_with_http_info(**kwargs) + def get_on_call_escalation_policy( self, policy_id: str, @@ -749,6 +950,35 @@ def get_user_notification_channel( return self._get_user_notification_channel_endpoint.call_with_http_info(**kwargs) + def get_user_notification_rule( + self, + user_id: str, + rule_id: str, + *, + include: Union[str, UnsetType] = unset, + ) -> OnCallNotificationRule: + """Get an On-Call notification rule for a user. + + Get a notification rule 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 rule_id: The rule ID + :type rule_id: str + :param include: Comma-separated list of included relationships to be returned. Allowed values: ``channel``. + :type include: str, optional + :rtype: OnCallNotificationRule + """ + kwargs: Dict[str, Any] = {} + kwargs["user_id"] = user_id + + kwargs["rule_id"] = rule_id + + if include is not unset: + kwargs["include"] = include + + return self._get_user_notification_rule_endpoint.call_with_http_info(**kwargs) + def list_user_notification_channels( self, user_id: str, @@ -766,6 +996,30 @@ def list_user_notification_channels( return self._list_user_notification_channels_endpoint.call_with_http_info(**kwargs) + def list_user_notification_rules( + self, + user_id: str, + *, + include: Union[str, UnsetType] = unset, + ) -> ListOnCallNotificationRulesResponse: + """List On-Call notification rules for a user. + + List the notification rules 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 include: Comma-separated list of included relationships to be returned. Allowed values: ``channel``. + :type include: str, optional + :rtype: ListOnCallNotificationRulesResponse + """ + kwargs: Dict[str, Any] = {} + if include is not unset: + kwargs["include"] = include + + kwargs["user_id"] = user_id + + return self._list_user_notification_rules_endpoint.call_with_http_info(**kwargs) + def set_on_call_team_routing_rules( self, team_id: str, @@ -849,3 +1103,36 @@ def update_on_call_schedule( kwargs["body"] = body return self._update_on_call_schedule_endpoint.call_with_http_info(**kwargs) + + def update_user_notification_rule( + self, + user_id: str, + rule_id: str, + body: UpdateOnCallNotificationRuleRequest, + *, + include: Union[str, UnsetType] = unset, + ) -> OnCallNotificationRule: + """Update an On-Call notification rule for a user. + + Update a notification rule 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 rule_id: The rule ID + :type rule_id: str + :type body: UpdateOnCallNotificationRuleRequest + :param include: Comma-separated list of included relationships to be returned. Allowed values: ``channel``. + :type include: str, optional + :rtype: OnCallNotificationRule + """ + kwargs: Dict[str, Any] = {} + kwargs["user_id"] = user_id + + kwargs["rule_id"] = rule_id + + if include is not unset: + kwargs["include"] = include + + kwargs["body"] = body + + return self._update_user_notification_rule_endpoint.call_with_http_info(**kwargs) diff --git a/src/datadog_api_client/v2/model/create_on_call_notification_rule_request.py b/src/datadog_api_client/v2/model/create_on_call_notification_rule_request.py new file mode 100644 index 0000000000..63576105b4 --- /dev/null +++ b/src/datadog_api_client/v2/model/create_on_call_notification_rule_request.py @@ -0,0 +1,44 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.create_on_call_notification_rule_request_data import ( + CreateOnCallNotificationRuleRequestData, + ) + + +class CreateOnCallNotificationRuleRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.create_on_call_notification_rule_request_data import ( + CreateOnCallNotificationRuleRequestData, + ) + + return { + "data": (CreateOnCallNotificationRuleRequestData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: CreateOnCallNotificationRuleRequestData, **kwargs): + """ + A top-level wrapper for creating a notification rule for a user + + :param data: Data for creating an on-call notification rule + :type data: CreateOnCallNotificationRuleRequestData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/create_on_call_notification_rule_request_data.py b/src/datadog_api_client/v2/model/create_on_call_notification_rule_request_data.py new file mode 100644 index 0000000000..0fa9a3ac48 --- /dev/null +++ b/src/datadog_api_client/v2/model/create_on_call_notification_rule_request_data.py @@ -0,0 +1,72 @@ +# 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.on_call_notification_rule_request_attributes import ( + OnCallNotificationRuleRequestAttributes, + ) + from datadog_api_client.v2.model.on_call_notification_rule_relationships import OnCallNotificationRuleRelationships + from datadog_api_client.v2.model.on_call_notification_rule_type import OnCallNotificationRuleType + + +class CreateOnCallNotificationRuleRequestData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.on_call_notification_rule_request_attributes import ( + OnCallNotificationRuleRequestAttributes, + ) + from datadog_api_client.v2.model.on_call_notification_rule_relationships import ( + OnCallNotificationRuleRelationships, + ) + from datadog_api_client.v2.model.on_call_notification_rule_type import OnCallNotificationRuleType + + return { + "attributes": (OnCallNotificationRuleRequestAttributes,), + "relationships": (OnCallNotificationRuleRelationships,), + "type": (OnCallNotificationRuleType,), + } + + attribute_map = { + "attributes": "attributes", + "relationships": "relationships", + "type": "type", + } + + def __init__( + self_, + type: OnCallNotificationRuleType, + attributes: Union[OnCallNotificationRuleRequestAttributes, UnsetType] = unset, + relationships: Union[OnCallNotificationRuleRelationships, UnsetType] = unset, + **kwargs, + ): + """ + Data for creating an on-call notification rule + + :param attributes: Attributes for creating or modifying an on-call notification rule. + :type attributes: OnCallNotificationRuleRequestAttributes, optional + + :param relationships: Relationship object for creating a notification rule + :type relationships: OnCallNotificationRuleRelationships, optional + + :param type: Indicates that the resource is of type 'notification_rules'. + :type type: OnCallNotificationRuleType + """ + if attributes is not unset: + kwargs["attributes"] = attributes + if relationships is not unset: + kwargs["relationships"] = relationships + super().__init__(kwargs) + + self_.type = type diff --git a/src/datadog_api_client/v2/model/list_on_call_notification_rules_response.py b/src/datadog_api_client/v2/model/list_on_call_notification_rules_response.py new file mode 100644 index 0000000000..ef9a6bf1b9 --- /dev/null +++ b/src/datadog_api_client/v2/model/list_on_call_notification_rules_response.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 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.on_call_notification_rule_data import OnCallNotificationRuleData + from datadog_api_client.v2.model.on_call_notification_rules_included import OnCallNotificationRulesIncluded + from datadog_api_client.v2.model.notification_channel_data import NotificationChannelData + + +class ListOnCallNotificationRulesResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.on_call_notification_rule_data import OnCallNotificationRuleData + from datadog_api_client.v2.model.on_call_notification_rules_included import OnCallNotificationRulesIncluded + + return { + "data": ([OnCallNotificationRuleData],), + "included": ([OnCallNotificationRulesIncluded],), + } + + attribute_map = { + "data": "data", + "included": "included", + } + + def __init__( + self_, + data: Union[List[OnCallNotificationRuleData], UnsetType] = unset, + included: Union[List[Union[OnCallNotificationRulesIncluded, NotificationChannelData]], UnsetType] = unset, + **kwargs, + ): + """ + Response type for listing notification rules for a user + + :param data: + :type data: [OnCallNotificationRuleData], optional + + :param included: + :type included: [OnCallNotificationRulesIncluded], optional + """ + if data is not unset: + kwargs["data"] = data + if included is not unset: + kwargs["included"] = included + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/on_call_notification_rule.py b/src/datadog_api_client/v2/model/on_call_notification_rule.py new file mode 100644 index 0000000000..792a37a6ce --- /dev/null +++ b/src/datadog_api_client/v2/model/on_call_notification_rule.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 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.on_call_notification_rule_data import OnCallNotificationRuleData + from datadog_api_client.v2.model.on_call_notification_rules_included import OnCallNotificationRulesIncluded + from datadog_api_client.v2.model.notification_channel_data import NotificationChannelData + + +class OnCallNotificationRule(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.on_call_notification_rule_data import OnCallNotificationRuleData + from datadog_api_client.v2.model.on_call_notification_rules_included import OnCallNotificationRulesIncluded + + return { + "data": (OnCallNotificationRuleData,), + "included": ([OnCallNotificationRulesIncluded],), + } + + attribute_map = { + "data": "data", + "included": "included", + } + + def __init__( + self_, + data: OnCallNotificationRuleData, + included: Union[List[Union[OnCallNotificationRulesIncluded, NotificationChannelData]], UnsetType] = unset, + **kwargs, + ): + """ + A top-level wrapper for a notification rule + + :param data: Data for an on-call notification rule + :type data: OnCallNotificationRuleData + + :param included: + :type included: [OnCallNotificationRulesIncluded], optional + """ + if included is not unset: + kwargs["included"] = included + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/on_call_notification_rule_attributes.py b/src/datadog_api_client/v2/model/on_call_notification_rule_attributes.py new file mode 100644 index 0000000000..1d9b8030ac --- /dev/null +++ b/src/datadog_api_client/v2/model/on_call_notification_rule_attributes.py @@ -0,0 +1,71 @@ +# 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.on_call_notification_rule_category import OnCallNotificationRuleCategory + from datadog_api_client.v2.model.on_call_notification_rule_channel_settings import ( + OnCallNotificationRuleChannelSettings, + ) + from datadog_api_client.v2.model.on_call_phone_notification_rule_settings import OnCallPhoneNotificationRuleSettings + + +class OnCallNotificationRuleAttributes(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.on_call_notification_rule_category import OnCallNotificationRuleCategory + from datadog_api_client.v2.model.on_call_notification_rule_channel_settings import ( + OnCallNotificationRuleChannelSettings, + ) + + return { + "category": (OnCallNotificationRuleCategory,), + "channel_settings": (OnCallNotificationRuleChannelSettings,), + "delay_minutes": (int,), + } + + attribute_map = { + "category": "category", + "channel_settings": "channel_settings", + "delay_minutes": "delay_minutes", + } + + def __init__( + self_, + category: Union[OnCallNotificationRuleCategory, UnsetType] = unset, + channel_settings: Union[ + OnCallNotificationRuleChannelSettings, OnCallPhoneNotificationRuleSettings, UnsetType + ] = unset, + delay_minutes: Union[int, UnsetType] = unset, + **kwargs, + ): + """ + Attributes for an on-call notification rule. + + :param category: Specifies the category a notification rule will apply to + :type category: OnCallNotificationRuleCategory, optional + + :param channel_settings: Defines the configuration for a channel associated with a notification rule + :type channel_settings: OnCallNotificationRuleChannelSettings, optional + + :param delay_minutes: The number of minutes that will elapse before this rule is evaluated. 0 indicates immediate evaluation + :type delay_minutes: int, optional + """ + if category is not unset: + kwargs["category"] = category + if channel_settings is not unset: + kwargs["channel_settings"] = channel_settings + if delay_minutes is not unset: + kwargs["delay_minutes"] = delay_minutes + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/on_call_notification_rule_category.py b/src/datadog_api_client/v2/model/on_call_notification_rule_category.py new file mode 100644 index 0000000000..4a9c2f7b8e --- /dev/null +++ b/src/datadog_api_client/v2/model/on_call_notification_rule_category.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 OnCallNotificationRuleCategory(ModelSimple): + """ + Specifies the category a notification rule will apply to + + :param value: If omitted defaults to "high_urgency". Must be one of ["high_urgency", "low_urgency"]. + :type value: str + """ + + allowed_values = { + "high_urgency", + "low_urgency", + } + HIGH_URGENCY: ClassVar["OnCallNotificationRuleCategory"] + LOW_URGENCY: ClassVar["OnCallNotificationRuleCategory"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +OnCallNotificationRuleCategory.HIGH_URGENCY = OnCallNotificationRuleCategory("high_urgency") +OnCallNotificationRuleCategory.LOW_URGENCY = OnCallNotificationRuleCategory("low_urgency") diff --git a/src/datadog_api_client/v2/model/on_call_notification_rule_channel_relationship.py b/src/datadog_api_client/v2/model/on_call_notification_rule_channel_relationship.py new file mode 100644 index 0000000000..fb4b8d362a --- /dev/null +++ b/src/datadog_api_client/v2/model/on_call_notification_rule_channel_relationship.py @@ -0,0 +1,44 @@ +# 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.on_call_notification_rule_channel_relationship_data import ( + OnCallNotificationRuleChannelRelationshipData, + ) + + +class OnCallNotificationRuleChannelRelationship(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.on_call_notification_rule_channel_relationship_data import ( + OnCallNotificationRuleChannelRelationshipData, + ) + + return { + "data": (OnCallNotificationRuleChannelRelationshipData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: OnCallNotificationRuleChannelRelationshipData, **kwargs): + """ + Relationship object for creating a notification rule + + :param data: Channel relationship data for creating a notification rule + :type data: OnCallNotificationRuleChannelRelationshipData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/on_call_notification_rule_channel_relationship_data.py b/src/datadog_api_client/v2/model/on_call_notification_rule_channel_relationship_data.py new file mode 100644 index 0000000000..cf6cdfe68c --- /dev/null +++ b/src/datadog_api_client/v2/model/on_call_notification_rule_channel_relationship_data.py @@ -0,0 +1,51 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import 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_type import NotificationChannelType + + +class OnCallNotificationRuleChannelRelationshipData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.notification_channel_type import NotificationChannelType + + return { + "id": (str,), + "type": (NotificationChannelType,), + } + + attribute_map = { + "id": "id", + "type": "type", + } + + def __init__( + self_, id: Union[str, UnsetType] = unset, type: Union[NotificationChannelType, UnsetType] = unset, **kwargs + ): + """ + Channel relationship data for creating a notification rule + + :param id: ID of the notification channel + :type id: str, optional + + :param type: Indicates that the resource is of type 'notification_channels'. + :type type: NotificationChannelType, optional + """ + if id is not unset: + kwargs["id"] = id + if type is not unset: + kwargs["type"] = type + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/on_call_notification_rule_channel_settings.py b/src/datadog_api_client/v2/model/on_call_notification_rule_channel_settings.py new file mode 100644 index 0000000000..cb503f3e7c --- /dev/null +++ b/src/datadog_api_client/v2/model/on_call_notification_rule_channel_settings.py @@ -0,0 +1,43 @@ +# 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 OnCallNotificationRuleChannelSettings(ModelComposed): + def __init__(self, **kwargs): + """ + Defines the configuration for a channel associated with a notification rule + + :param method: Specifies the method in which a phone is used in a notification rule + :type method: OnCallPhoneNotificationRuleMethod + + :param type: Indicates that the notification channel is a phone + :type type: NotificationChannelPhoneConfigType + """ + 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.on_call_phone_notification_rule_settings import ( + OnCallPhoneNotificationRuleSettings, + ) + + return { + "oneOf": [ + OnCallPhoneNotificationRuleSettings, + ], + } diff --git a/src/datadog_api_client/v2/model/on_call_notification_rule_data.py b/src/datadog_api_client/v2/model/on_call_notification_rule_data.py new file mode 100644 index 0000000000..b6c6be6bbd --- /dev/null +++ b/src/datadog_api_client/v2/model/on_call_notification_rule_data.py @@ -0,0 +1,76 @@ +# 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.on_call_notification_rule_attributes import OnCallNotificationRuleAttributes + from datadog_api_client.v2.model.on_call_notification_rule_relationships import OnCallNotificationRuleRelationships + from datadog_api_client.v2.model.on_call_notification_rule_type import OnCallNotificationRuleType + + +class OnCallNotificationRuleData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.on_call_notification_rule_attributes import OnCallNotificationRuleAttributes + from datadog_api_client.v2.model.on_call_notification_rule_relationships import ( + OnCallNotificationRuleRelationships, + ) + from datadog_api_client.v2.model.on_call_notification_rule_type import OnCallNotificationRuleType + + return { + "attributes": (OnCallNotificationRuleAttributes,), + "id": (str,), + "relationships": (OnCallNotificationRuleRelationships,), + "type": (OnCallNotificationRuleType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "relationships": "relationships", + "type": "type", + } + + def __init__( + self_, + type: OnCallNotificationRuleType, + attributes: Union[OnCallNotificationRuleAttributes, UnsetType] = unset, + id: Union[str, UnsetType] = unset, + relationships: Union[OnCallNotificationRuleRelationships, UnsetType] = unset, + **kwargs, + ): + """ + Data for an on-call notification rule + + :param attributes: Attributes for an on-call notification rule. + :type attributes: OnCallNotificationRuleAttributes, optional + + :param id: Unique identifier for the rule + :type id: str, optional + + :param relationships: Relationship object for creating a notification rule + :type relationships: OnCallNotificationRuleRelationships, optional + + :param type: Indicates that the resource is of type 'notification_rules'. + :type type: OnCallNotificationRuleType + """ + if attributes is not unset: + kwargs["attributes"] = attributes + if id is not unset: + kwargs["id"] = id + if relationships is not unset: + kwargs["relationships"] = relationships + super().__init__(kwargs) + + self_.type = type diff --git a/src/datadog_api_client/v2/model/on_call_notification_rule_relationships.py b/src/datadog_api_client/v2/model/on_call_notification_rule_relationships.py new file mode 100644 index 0000000000..9049b5c58e --- /dev/null +++ b/src/datadog_api_client/v2/model/on_call_notification_rule_relationships.py @@ -0,0 +1,46 @@ +# 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.on_call_notification_rule_channel_relationship import ( + OnCallNotificationRuleChannelRelationship, + ) + + +class OnCallNotificationRuleRelationships(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.on_call_notification_rule_channel_relationship import ( + OnCallNotificationRuleChannelRelationship, + ) + + return { + "channel": (OnCallNotificationRuleChannelRelationship,), + } + + attribute_map = { + "channel": "channel", + } + + def __init__(self_, channel: Union[OnCallNotificationRuleChannelRelationship, UnsetType] = unset, **kwargs): + """ + Relationship object for creating a notification rule + + :param channel: Relationship object for creating a notification rule + :type channel: OnCallNotificationRuleChannelRelationship, optional + """ + if channel is not unset: + kwargs["channel"] = channel + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/on_call_notification_rule_request_attributes.py b/src/datadog_api_client/v2/model/on_call_notification_rule_request_attributes.py new file mode 100644 index 0000000000..e294e240e5 --- /dev/null +++ b/src/datadog_api_client/v2/model/on_call_notification_rule_request_attributes.py @@ -0,0 +1,71 @@ +# 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.on_call_notification_rule_category import OnCallNotificationRuleCategory + from datadog_api_client.v2.model.on_call_notification_rule_channel_settings import ( + OnCallNotificationRuleChannelSettings, + ) + from datadog_api_client.v2.model.on_call_phone_notification_rule_settings import OnCallPhoneNotificationRuleSettings + + +class OnCallNotificationRuleRequestAttributes(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.on_call_notification_rule_category import OnCallNotificationRuleCategory + from datadog_api_client.v2.model.on_call_notification_rule_channel_settings import ( + OnCallNotificationRuleChannelSettings, + ) + + return { + "category": (OnCallNotificationRuleCategory,), + "channel_settings": (OnCallNotificationRuleChannelSettings,), + "delay_minutes": (int,), + } + + attribute_map = { + "category": "category", + "channel_settings": "channel_settings", + "delay_minutes": "delay_minutes", + } + + def __init__( + self_, + category: Union[OnCallNotificationRuleCategory, UnsetType] = unset, + channel_settings: Union[ + OnCallNotificationRuleChannelSettings, OnCallPhoneNotificationRuleSettings, UnsetType + ] = unset, + delay_minutes: Union[int, UnsetType] = unset, + **kwargs, + ): + """ + Attributes for creating or modifying an on-call notification rule. + + :param category: Specifies the category a notification rule will apply to + :type category: OnCallNotificationRuleCategory, optional + + :param channel_settings: Defines the configuration for a channel associated with a notification rule + :type channel_settings: OnCallNotificationRuleChannelSettings, optional + + :param delay_minutes: The number of minutes that will elapse before this rule is evaluated. 0 indicates immediate evaluation + :type delay_minutes: int, optional + """ + if category is not unset: + kwargs["category"] = category + if channel_settings is not unset: + kwargs["channel_settings"] = channel_settings + if delay_minutes is not unset: + kwargs["delay_minutes"] = delay_minutes + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/on_call_notification_rule_type.py b/src/datadog_api_client/v2/model/on_call_notification_rule_type.py new file mode 100644 index 0000000000..9c02bc25d7 --- /dev/null +++ b/src/datadog_api_client/v2/model/on_call_notification_rule_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 OnCallNotificationRuleType(ModelSimple): + """ + Indicates that the resource is of type 'notification_rules'. + + :param value: If omitted defaults to "notification_rules". Must be one of ["notification_rules"]. + :type value: str + """ + + allowed_values = { + "notification_rules", + } + NOTIFICATION_RULES: ClassVar["OnCallNotificationRuleType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +OnCallNotificationRuleType.NOTIFICATION_RULES = OnCallNotificationRuleType("notification_rules") diff --git a/src/datadog_api_client/v2/model/on_call_notification_rules_included.py b/src/datadog_api_client/v2/model/on_call_notification_rules_included.py new file mode 100644 index 0000000000..8cd1327fa9 --- /dev/null +++ b/src/datadog_api_client/v2/model/on_call_notification_rules_included.py @@ -0,0 +1,44 @@ +# 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 OnCallNotificationRulesIncluded(ModelComposed): + def __init__(self, **kwargs): + """ + Represents additional included resources for a on-call notification rules + + :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 + """ + 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_data import NotificationChannelData + + return { + "oneOf": [ + NotificationChannelData, + ], + } diff --git a/src/datadog_api_client/v2/model/on_call_phone_notification_rule_method.py b/src/datadog_api_client/v2/model/on_call_phone_notification_rule_method.py new file mode 100644 index 0000000000..35db249147 --- /dev/null +++ b/src/datadog_api_client/v2/model/on_call_phone_notification_rule_method.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 OnCallPhoneNotificationRuleMethod(ModelSimple): + """ + Specifies the method in which a phone is used in a notification rule + + :param value: Must be one of ["sms", "voice"]. + :type value: str + """ + + allowed_values = { + "sms", + "voice", + } + SMS: ClassVar["OnCallPhoneNotificationRuleMethod"] + VOICE: ClassVar["OnCallPhoneNotificationRuleMethod"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +OnCallPhoneNotificationRuleMethod.SMS = OnCallPhoneNotificationRuleMethod("sms") +OnCallPhoneNotificationRuleMethod.VOICE = OnCallPhoneNotificationRuleMethod("voice") diff --git a/src/datadog_api_client/v2/model/on_call_phone_notification_rule_settings.py b/src/datadog_api_client/v2/model/on_call_phone_notification_rule_settings.py new file mode 100644 index 0000000000..5404ef7efa --- /dev/null +++ b/src/datadog_api_client/v2/model/on_call_phone_notification_rule_settings.py @@ -0,0 +1,50 @@ +# 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.on_call_phone_notification_rule_method import OnCallPhoneNotificationRuleMethod + from datadog_api_client.v2.model.notification_channel_phone_config_type import NotificationChannelPhoneConfigType + + +class OnCallPhoneNotificationRuleSettings(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.on_call_phone_notification_rule_method import OnCallPhoneNotificationRuleMethod + from datadog_api_client.v2.model.notification_channel_phone_config_type import ( + NotificationChannelPhoneConfigType, + ) + + return { + "method": (OnCallPhoneNotificationRuleMethod,), + "type": (NotificationChannelPhoneConfigType,), + } + + attribute_map = { + "method": "method", + "type": "type", + } + + def __init__(self_, method: OnCallPhoneNotificationRuleMethod, type: NotificationChannelPhoneConfigType, **kwargs): + """ + Configuration for using a phone notification channel in a notification rule + + :param method: Specifies the method in which a phone is used in a notification rule + :type method: OnCallPhoneNotificationRuleMethod + + :param type: Indicates that the notification channel is a phone + :type type: NotificationChannelPhoneConfigType + """ + super().__init__(kwargs) + + self_.method = method + self_.type = type diff --git a/src/datadog_api_client/v2/model/update_on_call_notification_rule_request.py b/src/datadog_api_client/v2/model/update_on_call_notification_rule_request.py new file mode 100644 index 0000000000..a4c1598448 --- /dev/null +++ b/src/datadog_api_client/v2/model/update_on_call_notification_rule_request.py @@ -0,0 +1,44 @@ +# 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.update_on_call_notification_rule_request_data import ( + UpdateOnCallNotificationRuleRequestData, + ) + + +class UpdateOnCallNotificationRuleRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.update_on_call_notification_rule_request_data import ( + UpdateOnCallNotificationRuleRequestData, + ) + + return { + "data": (UpdateOnCallNotificationRuleRequestData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: UpdateOnCallNotificationRuleRequestData, **kwargs): + """ + A top-level wrapper for updating a notification rule for a user + + :param data: Data for updating an on-call notification rule + :type data: UpdateOnCallNotificationRuleRequestData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/update_on_call_notification_rule_request_attributes.py b/src/datadog_api_client/v2/model/update_on_call_notification_rule_request_attributes.py new file mode 100644 index 0000000000..e342b17a6b --- /dev/null +++ b/src/datadog_api_client/v2/model/update_on_call_notification_rule_request_attributes.py @@ -0,0 +1,71 @@ +# 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.on_call_notification_rule_category import OnCallNotificationRuleCategory + from datadog_api_client.v2.model.on_call_notification_rule_channel_settings import ( + OnCallNotificationRuleChannelSettings, + ) + from datadog_api_client.v2.model.on_call_phone_notification_rule_settings import OnCallPhoneNotificationRuleSettings + + +class UpdateOnCallNotificationRuleRequestAttributes(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.on_call_notification_rule_category import OnCallNotificationRuleCategory + from datadog_api_client.v2.model.on_call_notification_rule_channel_settings import ( + OnCallNotificationRuleChannelSettings, + ) + + return { + "category": (OnCallNotificationRuleCategory,), + "channel_settings": (OnCallNotificationRuleChannelSettings,), + "delay_minutes": (int,), + } + + attribute_map = { + "category": "category", + "channel_settings": "channel_settings", + "delay_minutes": "delay_minutes", + } + + def __init__( + self_, + category: Union[OnCallNotificationRuleCategory, UnsetType] = unset, + channel_settings: Union[ + OnCallNotificationRuleChannelSettings, OnCallPhoneNotificationRuleSettings, UnsetType + ] = unset, + delay_minutes: Union[int, UnsetType] = unset, + **kwargs, + ): + """ + Attributes for creating or modifying an on-call notification rule. + + :param category: Specifies the category a notification rule will apply to + :type category: OnCallNotificationRuleCategory, optional + + :param channel_settings: Defines the configuration for a channel associated with a notification rule + :type channel_settings: OnCallNotificationRuleChannelSettings, optional + + :param delay_minutes: The number of minutes that will elapse before this rule is evaluated. 0 indicates immediate evaluation + :type delay_minutes: int, optional + """ + if category is not unset: + kwargs["category"] = category + if channel_settings is not unset: + kwargs["channel_settings"] = channel_settings + if delay_minutes is not unset: + kwargs["delay_minutes"] = delay_minutes + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/update_on_call_notification_rule_request_data.py b/src/datadog_api_client/v2/model/update_on_call_notification_rule_request_data.py new file mode 100644 index 0000000000..348b6f5449 --- /dev/null +++ b/src/datadog_api_client/v2/model/update_on_call_notification_rule_request_data.py @@ -0,0 +1,80 @@ +# 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.update_on_call_notification_rule_request_attributes import ( + UpdateOnCallNotificationRuleRequestAttributes, + ) + from datadog_api_client.v2.model.on_call_notification_rule_relationships import OnCallNotificationRuleRelationships + from datadog_api_client.v2.model.on_call_notification_rule_type import OnCallNotificationRuleType + + +class UpdateOnCallNotificationRuleRequestData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.update_on_call_notification_rule_request_attributes import ( + UpdateOnCallNotificationRuleRequestAttributes, + ) + from datadog_api_client.v2.model.on_call_notification_rule_relationships import ( + OnCallNotificationRuleRelationships, + ) + from datadog_api_client.v2.model.on_call_notification_rule_type import OnCallNotificationRuleType + + return { + "attributes": (UpdateOnCallNotificationRuleRequestAttributes,), + "id": (str,), + "relationships": (OnCallNotificationRuleRelationships,), + "type": (OnCallNotificationRuleType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "relationships": "relationships", + "type": "type", + } + + def __init__( + self_, + type: OnCallNotificationRuleType, + attributes: Union[UpdateOnCallNotificationRuleRequestAttributes, UnsetType] = unset, + id: Union[str, UnsetType] = unset, + relationships: Union[OnCallNotificationRuleRelationships, UnsetType] = unset, + **kwargs, + ): + """ + Data for updating an on-call notification rule + + :param attributes: Attributes for creating or modifying an on-call notification rule. + :type attributes: UpdateOnCallNotificationRuleRequestAttributes, optional + + :param id: Unique identifier for the rule + :type id: str, optional + + :param relationships: Relationship object for creating a notification rule + :type relationships: OnCallNotificationRuleRelationships, optional + + :param type: Indicates that the resource is of type 'notification_rules'. + :type type: OnCallNotificationRuleType + """ + if attributes is not unset: + kwargs["attributes"] = attributes + if id is not unset: + kwargs["id"] = id + if relationships is not unset: + kwargs["relationships"] = relationships + super().__init__(kwargs) + + self_.type = type diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 8217f826ec..ef1902cb43 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -1023,6 +1023,10 @@ from datadog_api_client.v2.model.create_notification_rule_parameters_data_attributes import ( CreateNotificationRuleParametersDataAttributes, ) +from datadog_api_client.v2.model.create_on_call_notification_rule_request import CreateOnCallNotificationRuleRequest +from datadog_api_client.v2.model.create_on_call_notification_rule_request_data import ( + CreateOnCallNotificationRuleRequestData, +) from datadog_api_client.v2.model.create_open_api_response import CreateOpenAPIResponse from datadog_api_client.v2.model.create_open_api_response_attributes import CreateOpenAPIResponseAttributes from datadog_api_client.v2.model.create_open_api_response_data import CreateOpenAPIResponseData @@ -2456,6 +2460,7 @@ 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_on_call_notification_rules_response import ListOnCallNotificationRulesResponse 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 @@ -3467,7 +3472,26 @@ from datadog_api_client.v2.model.okta_integration import OktaIntegration from datadog_api_client.v2.model.okta_integration_type import OktaIntegrationType from datadog_api_client.v2.model.okta_integration_update import OktaIntegrationUpdate +from datadog_api_client.v2.model.on_call_notification_rule import OnCallNotificationRule +from datadog_api_client.v2.model.on_call_notification_rule_attributes import OnCallNotificationRuleAttributes +from datadog_api_client.v2.model.on_call_notification_rule_category import OnCallNotificationRuleCategory +from datadog_api_client.v2.model.on_call_notification_rule_channel_relationship import ( + OnCallNotificationRuleChannelRelationship, +) +from datadog_api_client.v2.model.on_call_notification_rule_channel_relationship_data import ( + OnCallNotificationRuleChannelRelationshipData, +) +from datadog_api_client.v2.model.on_call_notification_rule_channel_settings import OnCallNotificationRuleChannelSettings +from datadog_api_client.v2.model.on_call_notification_rule_data import OnCallNotificationRuleData +from datadog_api_client.v2.model.on_call_notification_rule_relationships import OnCallNotificationRuleRelationships +from datadog_api_client.v2.model.on_call_notification_rule_request_attributes import ( + OnCallNotificationRuleRequestAttributes, +) +from datadog_api_client.v2.model.on_call_notification_rule_type import OnCallNotificationRuleType +from datadog_api_client.v2.model.on_call_notification_rules_included import OnCallNotificationRulesIncluded from datadog_api_client.v2.model.on_call_page_target_type import OnCallPageTargetType +from datadog_api_client.v2.model.on_call_phone_notification_rule_method import OnCallPhoneNotificationRuleMethod +from datadog_api_client.v2.model.on_call_phone_notification_rule_settings import OnCallPhoneNotificationRuleSettings from datadog_api_client.v2.model.on_demand_concurrency_cap import OnDemandConcurrencyCap from datadog_api_client.v2.model.on_demand_concurrency_cap_attributes import OnDemandConcurrencyCapAttributes from datadog_api_client.v2.model.on_demand_concurrency_cap_response import OnDemandConcurrencyCapResponse @@ -4938,6 +4962,13 @@ from datadog_api_client.v2.model.update_deployment_rule_params_data_attributes import ( UpdateDeploymentRuleParamsDataAttributes, ) +from datadog_api_client.v2.model.update_on_call_notification_rule_request import UpdateOnCallNotificationRuleRequest +from datadog_api_client.v2.model.update_on_call_notification_rule_request_attributes import ( + UpdateOnCallNotificationRuleRequestAttributes, +) +from datadog_api_client.v2.model.update_on_call_notification_rule_request_data import ( + UpdateOnCallNotificationRuleRequestData, +) from datadog_api_client.v2.model.update_open_api_response import UpdateOpenAPIResponse from datadog_api_client.v2.model.update_open_api_response_attributes import UpdateOpenAPIResponseAttributes from datadog_api_client.v2.model.update_open_api_response_data import UpdateOpenAPIResponseData @@ -5887,6 +5918,8 @@ "CreateNotificationRuleParameters", "CreateNotificationRuleParametersData", "CreateNotificationRuleParametersDataAttributes", + "CreateOnCallNotificationRuleRequest", + "CreateOnCallNotificationRuleRequestData", "CreateOpenAPIResponse", "CreateOpenAPIResponseAttributes", "CreateOpenAPIResponseData", @@ -6992,6 +7025,7 @@ "ListFindingsResponse", "ListKindCatalogResponse", "ListNotificationChannelsResponse", + "ListOnCallNotificationRulesResponse", "ListPipelinesResponse", "ListPipelinesResponseMeta", "ListPowerpacksResponse", @@ -7549,7 +7583,20 @@ "OktaIntegration", "OktaIntegrationType", "OktaIntegrationUpdate", + "OnCallNotificationRule", + "OnCallNotificationRuleAttributes", + "OnCallNotificationRuleCategory", + "OnCallNotificationRuleChannelRelationship", + "OnCallNotificationRuleChannelRelationshipData", + "OnCallNotificationRuleChannelSettings", + "OnCallNotificationRuleData", + "OnCallNotificationRuleRelationships", + "OnCallNotificationRuleRequestAttributes", + "OnCallNotificationRuleType", + "OnCallNotificationRulesIncluded", "OnCallPageTargetType", + "OnCallPhoneNotificationRuleMethod", + "OnCallPhoneNotificationRuleSettings", "OnDemandConcurrencyCap", "OnDemandConcurrencyCapAttributes", "OnDemandConcurrencyCapResponse", @@ -8686,6 +8733,9 @@ "UpdateDeploymentRuleParams", "UpdateDeploymentRuleParamsData", "UpdateDeploymentRuleParamsDataAttributes", + "UpdateOnCallNotificationRuleRequest", + "UpdateOnCallNotificationRuleRequestAttributes", + "UpdateOnCallNotificationRuleRequestData", "UpdateOpenAPIResponse", "UpdateOpenAPIResponseAttributes", "UpdateOpenAPIResponseData", diff --git a/tests/v2/cassettes/test_scenarios/test_create_an_oncall_notification_rule_for_a_user_returns_created_response.frozen b/tests/v2/cassettes/test_scenarios/test_create_an_oncall_notification_rule_for_a_user_returns_created_response.frozen new file mode 100644 index 0000000000..fd26d2eef2 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_an_oncall_notification_rule_for_a_user_returns_created_response.frozen @@ -0,0 +1 @@ +2025-12-16T19:30:04.834Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_create_an_oncall_notification_rule_for_a_user_returns_created_response.yaml b/tests/v2/cassettes/test_scenarios/test_create_an_oncall_notification_rule_for_a_user_returns_created_response.yaml new file mode 100644 index 0000000000..7003fc8534 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_an_oncall_notification_rule_for_a_user_returns_created_response.yaml @@ -0,0 +1,74 @@ +interactions: +- request: + body: '{"data":{"attributes":{"email":"Test-Create_an_On_Call_notification_rule_for_a_user_returns_Created_response-1765913404@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":"2ab53f07-289f-4060-b21a-3d704096aadf","attributes":{"name":null,"handle":"test-create_an_on_call_notification_rule_for_a_user_returns_created_response-1765913404@datadoghq.com","created_at":"2025-12-16T19:30:05.014723+00:00","modified_at":"2025-12-16T19:30:05.014723+00:00","email":"test-create_an_on_call_notification_rule_for_a_user_returns_created_response-1765913404@datadoghq.com","icon":"https://secure.gravatar.com/avatar/c5ddb15c50d998db06711e0a31591216?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-create_an_on_call_notification_rule_for_a_user_returns_created_response-1765913404@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/2ab53f07-289f-4060-b21a-3d704096aadf/notification-channels + response: + body: + string: '{"data":{"id":"ca8520ce-27e0-4bba-997f-004047cda45d","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-create_an_on_call_notification_rule_for_a_user_returns_created_response-1765913404@datadoghq.com","formats":["html"]}}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 201 + message: Created +- request: + body: '{"data":{"attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"ca8520ce-27e0-4bba-997f-004047cda45d","type":"notification_channels"}}},"type":"notification_rules"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/on-call/users/2ab53f07-289f-4060-b21a-3d704096aadf/notification-rules + response: + body: + string: '{"data":{"id":"4e551e4f-d1aa-4fce-8cc7-c6bf98925efe","type":"notification_rules","attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"ca8520ce-27e0-4bba-997f-004047cda45d","type":"notification_channels"}}}}}' + 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/2ab53f07-289f-4060-b21a-3d704096aadf + 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_rule_for_a_user_returns_no_content_response.frozen b/tests/v2/cassettes/test_scenarios/test_delete_an_oncall_notification_rule_for_a_user_returns_no_content_response.frozen new file mode 100644 index 0000000000..3b1ee11b9e --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_delete_an_oncall_notification_rule_for_a_user_returns_no_content_response.frozen @@ -0,0 +1 @@ +2025-12-16T19:29:36.256Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_delete_an_oncall_notification_rule_for_a_user_returns_no_content_response.yaml b/tests/v2/cassettes/test_scenarios/test_delete_an_oncall_notification_rule_for_a_user_returns_no_content_response.yaml new file mode 100644 index 0000000000..1342789e2c --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_delete_an_oncall_notification_rule_for_a_user_returns_no_content_response.yaml @@ -0,0 +1,88 @@ +interactions: +- request: + body: '{"data":{"attributes":{"email":"Test-Delete_an_On_Call_notification_rule_for_a_user_returns_No_Content_response-1765913376@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":"5ebbe76d-c072-4909-ba24-ffa71f4597a0","attributes":{"name":null,"handle":"test-delete_an_on_call_notification_rule_for_a_user_returns_no_content_response-1765913376@datadoghq.com","created_at":"2025-12-16T19:29:36.461504+00:00","modified_at":"2025-12-16T19:29:36.461504+00:00","email":"test-delete_an_on_call_notification_rule_for_a_user_returns_no_content_response-1765913376@datadoghq.com","icon":"https://secure.gravatar.com/avatar/dad7a8a5508730e67ad8dea90bcc189c?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_rule_for_a_user_returns_no_content_response-1765913376@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/5ebbe76d-c072-4909-ba24-ffa71f4597a0/notification-channels + response: + body: + string: '{"data":{"id":"a557eb68-8b0a-48cf-ac65-73aede790994","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-delete_an_on_call_notification_rule_for_a_user_returns_no_content_response-1765913376@datadoghq.com","formats":["html"]}}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 201 + message: Created +- request: + body: '{"data":{"attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"a557eb68-8b0a-48cf-ac65-73aede790994","type":"notification_channels"}}},"type":"notification_rules"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/on-call/users/5ebbe76d-c072-4909-ba24-ffa71f4597a0/notification-rules + response: + body: + string: '{"data":{"id":"71e9f009-5a69-4946-992e-d76b05d1ae61","type":"notification_rules","attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"a557eb68-8b0a-48cf-ac65-73aede790994","type":"notification_channels"}}}}}' + 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/5ebbe76d-c072-4909-ba24-ffa71f4597a0/notification-rules/71e9f009-5a69-4946-992e-d76b05d1ae61 + 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/5ebbe76d-c072-4909-ba24-ffa71f4597a0 + 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_rule_for_a_user_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_get_an_oncall_notification_rule_for_a_user_returns_ok_response.frozen new file mode 100644 index 0000000000..d938f1a43e --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_get_an_oncall_notification_rule_for_a_user_returns_ok_response.frozen @@ -0,0 +1 @@ +2025-12-16T21:16:24.271Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_get_an_oncall_notification_rule_for_a_user_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_get_an_oncall_notification_rule_for_a_user_returns_ok_response.yaml new file mode 100644 index 0000000000..ec343919fa --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_get_an_oncall_notification_rule_for_a_user_returns_ok_response.yaml @@ -0,0 +1,90 @@ +interactions: +- request: + body: '{"data":{"attributes":{"email":"Test-Get_an_On_Call_notification_rule_for_a_user_returns_OK_response-1765919784@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":"b2a555c9-ac2d-430d-b321-10e4c0201ce3","attributes":{"name":null,"handle":"test-get_an_on_call_notification_rule_for_a_user_returns_ok_response-1765919784@datadoghq.com","created_at":"2025-12-16T21:16:24.480454+00:00","modified_at":"2025-12-16T21:16:24.480454+00:00","email":"test-get_an_on_call_notification_rule_for_a_user_returns_ok_response-1765919784@datadoghq.com","icon":"https://secure.gravatar.com/avatar/8e38ab440c2cdd2808a61dfa83f734d7?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_rule_for_a_user_returns_ok_response-1765919784@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/b2a555c9-ac2d-430d-b321-10e4c0201ce3/notification-channels + response: + body: + string: '{"data":{"id":"767234b0-0c79-4092-9b44-a8963021795b","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-get_an_on_call_notification_rule_for_a_user_returns_ok_response-1765919784@datadoghq.com","formats":["html"]}}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 201 + message: Created +- request: + body: '{"data":{"attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"767234b0-0c79-4092-9b44-a8963021795b","type":"notification_channels"}}},"type":"notification_rules"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/on-call/users/b2a555c9-ac2d-430d-b321-10e4c0201ce3/notification-rules + response: + body: + string: '{"data":{"id":"d07cc90b-4fc5-455f-8f57-45d48a658bc6","type":"notification_rules","attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"767234b0-0c79-4092-9b44-a8963021795b","type":"notification_channels"}}}}}' + 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/b2a555c9-ac2d-430d-b321-10e4c0201ce3/notification-rules/d07cc90b-4fc5-455f-8f57-45d48a658bc6?include=channel + response: + body: + string: '{"data":{"id":"d07cc90b-4fc5-455f-8f57-45d48a658bc6","type":"notification_rules","attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"767234b0-0c79-4092-9b44-a8963021795b","type":"notification_channels"}}}},"included":[{"id":"767234b0-0c79-4092-9b44-a8963021795b","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-get_an_on_call_notification_rule_for_a_user_returns_ok_response-1765919784@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/b2a555c9-ac2d-430d-b321-10e4c0201ce3 + response: + body: + string: '' + headers: {} + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_list_oncall_notification_rules_for_a_user_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_list_oncall_notification_rules_for_a_user_returns_ok_response.frozen new file mode 100644 index 0000000000..11e9c7c90b --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_list_oncall_notification_rules_for_a_user_returns_ok_response.frozen @@ -0,0 +1 @@ +2025-12-16T21:16:48.356Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_list_oncall_notification_rules_for_a_user_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_list_oncall_notification_rules_for_a_user_returns_ok_response.yaml new file mode 100644 index 0000000000..a980284b18 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_list_oncall_notification_rules_for_a_user_returns_ok_response.yaml @@ -0,0 +1,90 @@ +interactions: +- request: + body: '{"data":{"attributes":{"email":"Test-List_On_Call_notification_rules_for_a_user_returns_OK_response-1765919808@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":"0730802a-ee45-404b-a21d-5908d4c6b3c4","attributes":{"name":null,"handle":"test-list_on_call_notification_rules_for_a_user_returns_ok_response-1765919808@datadoghq.com","created_at":"2025-12-16T21:16:48.579239+00:00","modified_at":"2025-12-16T21:16:48.579239+00:00","email":"test-list_on_call_notification_rules_for_a_user_returns_ok_response-1765919808@datadoghq.com","icon":"https://secure.gravatar.com/avatar/c2f584fb6a42fbc0f0aad204ea40c0fc?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_rules_for_a_user_returns_ok_response-1765919808@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/0730802a-ee45-404b-a21d-5908d4c6b3c4/notification-channels + response: + body: + string: '{"data":{"id":"3073e724-15e8-4aec-897a-478e31cca3a8","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-list_on_call_notification_rules_for_a_user_returns_ok_response-1765919808@datadoghq.com","formats":["html"]}}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 201 + message: Created +- request: + body: '{"data":{"attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"3073e724-15e8-4aec-897a-478e31cca3a8","type":"notification_channels"}}},"type":"notification_rules"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/on-call/users/0730802a-ee45-404b-a21d-5908d4c6b3c4/notification-rules + response: + body: + string: '{"data":{"id":"d93215d1-85c1-4528-a92f-1b604c1f4b2a","type":"notification_rules","attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"3073e724-15e8-4aec-897a-478e31cca3a8","type":"notification_channels"}}}}}' + 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/0730802a-ee45-404b-a21d-5908d4c6b3c4/notification-rules?include=channel + response: + body: + string: '{"data":[{"id":"d93215d1-85c1-4528-a92f-1b604c1f4b2a","type":"notification_rules","attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"3073e724-15e8-4aec-897a-478e31cca3a8","type":"notification_channels"}}}}],"included":[{"id":"3073e724-15e8-4aec-897a-478e31cca3a8","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-list_on_call_notification_rules_for_a_user_returns_ok_response-1765919808@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/0730802a-ee45-404b-a21d-5908d4c6b3c4 + response: + body: + string: '' + headers: {} + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_update_an_oncall_notification_rule_for_a_user_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_update_an_oncall_notification_rule_for_a_user_returns_ok_response.frozen new file mode 100644 index 0000000000..f55a35ff1b --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_update_an_oncall_notification_rule_for_a_user_returns_ok_response.frozen @@ -0,0 +1 @@ +2025-12-17T01:04:35.713Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_update_an_oncall_notification_rule_for_a_user_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_update_an_oncall_notification_rule_for_a_user_returns_ok_response.yaml new file mode 100644 index 0000000000..aa2e55be71 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_update_an_oncall_notification_rule_for_a_user_returns_ok_response.yaml @@ -0,0 +1,92 @@ +interactions: +- request: + body: '{"data":{"attributes":{"email":"Test-Update_an_On_Call_notification_rule_for_a_user_returns_OK_response-1765933475@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":"4ef9cf45-30a8-4117-9b56-adba96671dff","attributes":{"name":null,"handle":"test-update_an_on_call_notification_rule_for_a_user_returns_ok_response-1765933475@datadoghq.com","created_at":"2025-12-17T01:04:36.246950+00:00","modified_at":"2025-12-17T01:04:36.246950+00:00","email":"test-update_an_on_call_notification_rule_for_a_user_returns_ok_response-1765933475@datadoghq.com","icon":"https://secure.gravatar.com/avatar/53cbcba1803f4569f759fcc6b3f90bb6?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-update_an_on_call_notification_rule_for_a_user_returns_ok_response-1765933475@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/4ef9cf45-30a8-4117-9b56-adba96671dff/notification-channels + response: + body: + string: '{"data":{"id":"7fc326c9-f3dc-4858-80c2-d88c24dcf54b","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-update_an_on_call_notification_rule_for_a_user_returns_ok_response-1765933475@datadoghq.com","formats":["html"]}}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 201 + message: Created +- request: + body: '{"data":{"attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"7fc326c9-f3dc-4858-80c2-d88c24dcf54b","type":"notification_channels"}}},"type":"notification_rules"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/on-call/users/4ef9cf45-30a8-4117-9b56-adba96671dff/notification-rules + response: + body: + string: '{"data":{"id":"c7b724f1-eb73-43d4-889f-d8f3e6fbe664","type":"notification_rules","attributes":{"category":"high_urgency","delay_minutes":0},"relationships":{"channel":{"data":{"id":"7fc326c9-f3dc-4858-80c2-d88c24dcf54b","type":"notification_channels"}}}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 201 + message: Created +- request: + body: '{"data":{"attributes":{"category":"high_urgency","delay_minutes":1},"id":"c7b724f1-eb73-43d4-889f-d8f3e6fbe664","relationships":{"channel":{"data":{"id":"7fc326c9-f3dc-4858-80c2-d88c24dcf54b","type":"notification_channels"}}},"type":"notification_rules"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: PUT + uri: https://api.datadoghq.com/api/v2/on-call/users/4ef9cf45-30a8-4117-9b56-adba96671dff/notification-rules/c7b724f1-eb73-43d4-889f-d8f3e6fbe664?include=channel + response: + body: + string: '{"data":{"id":"c7b724f1-eb73-43d4-889f-d8f3e6fbe664","type":"notification_rules","attributes":{"category":"high_urgency","delay_minutes":1},"relationships":{"channel":{"data":{"id":"7fc326c9-f3dc-4858-80c2-d88c24dcf54b","type":"notification_channels"}}}},"included":[{"id":"7fc326c9-f3dc-4858-80c2-d88c24dcf54b","type":"notification_channels","attributes":{"active":true,"config":{"type":"email","address":"test-update_an_on_call_notification_rule_for_a_user_returns_ok_response-1765933475@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/4ef9cf45-30a8-4117-9b56-adba96671dff + 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 8cf1925f45..4651a346eb 100644 --- a/tests/v2/features/given.json +++ b/tests/v2/features/given.json @@ -799,6 +799,22 @@ "tag": "On-Call", "operationId": "CreateUserNotificationChannel" }, + { + "parameters": [ + { + "name": "user_id", + "source": "user.data.id" + }, + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"notification_rules\",\n \"attributes\": {\n \"delay_minutes\": 0,\n \"category\": \"high_urgency\"\n },\n \"relationships\": {\n \"channel\": {\n \"data\": {\n \"id\": \"{{ oncall_email_notification_channel.data.id }}\",\n \"type\": \"notification_channels\"\n }\n }\n }\n }\n}" + } + ], + "step": "there is a valid \"oncall_email_notification_rule\" in the system", + "key": "oncall_email_notification_rule", + "tag": "On-Call", + "operationId": "CreateUserNotificationRule" + }, { "parameters": [ { diff --git a/tests/v2/features/on-call.feature b/tests/v2/features/on-call.feature index 9f4750eef7..0f4b2a0e34 100644 --- a/tests/v2/features/on-call.feature +++ b/tests/v2/features/on-call.feature @@ -70,6 +70,32 @@ Feature: On-Call When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/on-call + Scenario: Create an On-Call notification rule for a user returns "Bad Request" response + Given new "CreateUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"category": "high_urgency", "channel_settings": {"method": "sms", "type": "phone"}, "delay_minutes": 1}, "relationships": {"channel": {"data": {"id": "1562fab3-a8c2-49e2-8f3a-28dcda2405e2", "type": "notification_channels"}}}, "type": "notification_rules"}} + 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 rule for a user returns "Created" response + Given new "CreateUserNotificationRule" request + And there is a valid "user" in the system + And request contains "user_id" parameter from "user.data.id" + And there is a valid "oncall_email_notification_channel" in the system + And body with value {"data": {"attributes": {"category": "high_urgency", "delay_minutes": 0}, "relationships": {"channel": {"data": {"id": "{{ oncall_email_notification_channel.data.id }}", "type": "notification_channels"}}}, "type": "notification_rules"}} + When the request is sent + Then the response status is 201 Created + + @generated @skip @team:DataDog/on-call + Scenario: Create an On-Call notification rule for a user returns "Not Found" response + Given new "CreateUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"category": "high_urgency", "channel_settings": {"method": "sms", "type": "phone"}, "delay_minutes": 1}, "relationships": {"channel": {"data": {"id": "1562fab3-a8c2-49e2-8f3a-28dcda2405e2", "type": "notification_channels"}}}, "type": "notification_rules"}} + 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 @@ -130,6 +156,33 @@ 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 rule for a user returns "Bad Request" response + Given new "DeleteUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "rule_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 rule for a user returns "No Content" response + Given new "DeleteUserNotificationRule" request + And there is a valid "user" in the system + And there is a valid "oncall_email_notification_channel" in the system + And there is a valid "oncall_email_notification_rule" in the system + And request contains "user_id" parameter from "user.data.id" + And request contains "rule_id" parameter from "oncall_email_notification_rule.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 rule for a user returns "Not Found" response + Given new "DeleteUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "rule_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 @@ -207,6 +260,36 @@ Feature: On-Call 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 an On-Call notification rule for a user returns "Bad Request" response + Given new "GetUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "rule_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 rule for a user returns "Not Found" response + Given new "GetUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "rule_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 rule for a user returns "OK" response + Given new "GetUserNotificationRule" request + And there is a valid "user" in the system + And there is a valid "oncall_email_notification_channel" in the system + And there is a valid "oncall_email_notification_rule" in the system + And request contains "user_id" parameter from "user.data.id" + And request contains "rule_id" parameter from "oncall_email_notification_rule.data.id" + And request contains "include" parameter with value "channel" + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.category" is equal to "high_urgency" + And the response "included" has length 1 + @generated @skip @team:DataDog/on-call Scenario: Get scheduled on-call user returns "Bad Request" response Given new "GetScheduleOnCallUser" request @@ -283,6 +366,33 @@ Feature: On-Call 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 }}" + @generated @skip @team:DataDog/on-call + Scenario: List On-Call notification rules for a user returns "Bad Request" response + Given new "ListUserNotificationRules" 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 rules for a user returns "Not Found" response + Given new "ListUserNotificationRules" 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 rules for a user returns "OK" response + Given new "ListUserNotificationRules" request + And there is a valid "user" in the system + And there is a valid "oncall_email_notification_channel" in the system + And there is a valid "oncall_email_notification_rule" in the system + And request contains "user_id" parameter from "user.data.id" + And request contains "include" parameter with value "channel" + When the request is sent + Then the response status is 200 OK + And the response "data" has length 1 + And the response "included" has length 1 + @skip-python @team:DataDog/on-call Scenario: Set On-Call team routing rules returns "OK" response Given new "SetOnCallTeamRoutingRules" request @@ -350,3 +460,36 @@ Feature: On-Call And body with value {"data": { "id": "{{ schedule.data.id }}", "attributes": {"layers": [{"id": "{{ schedule.data.relationships.layers.data[0].id }}" , "effective_date": "{{ timeISO('now - 10d') }}", "end_date": "{{ timeISO('now + 10d') }}", "interval": {"seconds": 3600}, "members": [{"user": {"id": "{{user.data.id}}"}}], "name": "Layer 1", "restrictions": [{"end_day": "friday", "end_time": "17:00:00", "start_day": "monday", "start_time": "09:00:00"}], "rotation_start": "{{ timeISO('now - 5d') }}"}], "name": "{{ unique }}", "time_zone": "America/New_York"}, "relationships": {"teams": {"data": [{"id": "{{dd_team.data.id}}", "type": "teams"}]}}, "type": "schedules"}} When the request is sent Then the response status is 200 OK + + @generated @skip @team:DataDog/on-call + Scenario: Update an On-Call notification rule for a user returns "Bad Request" response + Given new "UpdateUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "rule_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"category": "high_urgency", "channel_settings": {"method": "sms", "type": "phone"}, "delay_minutes": 1}, "id": "2462ace1-49e2-aab1-xc4f-29cc4ae1105n7", "relationships": {"channel": {"data": {"id": "1562fab3-a8c2-49e2-8f3a-28dcda2405e2", "type": "notification_channels"}}}, "type": "notification_rules"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/on-call + Scenario: Update an On-Call notification rule for a user returns "Not Found" response + Given new "UpdateUserNotificationRule" request + And request contains "user_id" parameter from "REPLACE.ME" + And request contains "rule_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"category": "high_urgency", "channel_settings": {"method": "sms", "type": "phone"}, "delay_minutes": 1}, "id": "2462ace1-49e2-aab1-xc4f-29cc4ae1105n7", "relationships": {"channel": {"data": {"id": "1562fab3-a8c2-49e2-8f3a-28dcda2405e2", "type": "notification_channels"}}}, "type": "notification_rules"}} + When the request is sent + Then the response status is 404 Not Found + + @replay-only @team:DataDog/on-call + Scenario: Update an On-Call notification rule for a user returns "OK" response + Given new "UpdateUserNotificationRule" request + And there is a valid "user" in the system + And there is a valid "oncall_email_notification_channel" in the system + And there is a valid "oncall_email_notification_rule" in the system + And request contains "user_id" parameter from "user.data.id" + And request contains "rule_id" parameter from "oncall_email_notification_rule.data.id" + And body with value {"data": {"attributes": {"category": "high_urgency", "delay_minutes": 1}, "id": "{{ oncall_email_notification_rule.data.id }}", "relationships": {"channel": {"data": {"id": "{{ oncall_email_notification_channel.data.id }}", "type": "notification_channels"}}}, "type": "notification_rules"}} + And request contains "include" parameter with value "channel" + When the request is sent + Then the response status is 200 OK + And the response "included" has length 1 + And the response "data.attributes.delay_minutes" is equal to 1 diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index e0f0b98d0c..d398c05fc1 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -2964,6 +2964,36 @@ "type": "safe" } }, + "ListUserNotificationRules": { + "tag": "On-Call", + "undo": { + "type": "safe" + } + }, + "CreateUserNotificationRule": { + "tag": "On-Call", + "undo": { + "type": "safe" + } + }, + "DeleteUserNotificationRule": { + "tag": "On-Call", + "undo": { + "type": "idempotent" + } + }, + "GetUserNotificationRule": { + "tag": "On-Call", + "undo": { + "type": "safe" + } + }, + "UpdateUserNotificationRule": { + "tag": "On-Call", + "undo": { + "type": "safe" + } + }, "ListOrgConfigs": { "tag": "Organizations", "undo": {