From cdeccf6805d5a9a01429e52c8a5ad9fc2cf41b29 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Tue, 15 Apr 2025 21:55:19 +0000 Subject: [PATCH] Regenerate client from commit 808cf2c3 of spec repo --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 446 ++++++++++++++++++ docs/datadog_api_client.v2.model.rst | 112 +++++ .../monitors/CreateMonitorNotificationRule.py | 39 ++ .../monitors/DeleteMonitorNotificationRule.py | 18 + .../v2/monitors/GetMonitorNotificationRule.py | 20 + .../monitors/GetMonitorNotificationRules.py | 14 + .../monitors/UpdateMonitorNotificationRule.py | 44 ++ src/datadog_api_client/configuration.py | 5 + src/datadog_api_client/v2/api/monitors_api.py | 230 ++++++++- .../monitor_notification_rule_attributes.py | 77 +++ ...onitor_notification_rule_create_request.py | 44 ++ ...r_notification_rule_create_request_data.py | 58 +++ .../model/monitor_notification_rule_data.py | 82 ++++ .../model/monitor_notification_rule_filter.py | 38 ++ .../monitor_notification_rule_filter_tags.py | 45 ++ ...monitor_notification_rule_list_response.py | 61 +++ ...monitor_notification_rule_relationships.py | 46 ++ ...ification_rule_relationships_created_by.py | 49 ++ ...tion_rule_relationships_created_by_data.py | 51 ++ ...monitor_notification_rule_resource_type.py | 37 ++ .../monitor_notification_rule_response.py | 61 +++ ...r_notification_rule_response_attributes.py | 91 ++++ ...otification_rule_response_included_item.py | 47 ++ ...onitor_notification_rule_update_request.py | 44 ++ ...r_notification_rule_update_request_data.py | 65 +++ src/datadog_api_client/v2/models/__init__.py | 44 ++ ...n_rule_returns_bad_request_response.frozen | 1 + ...ion_rule_returns_bad_request_response.yaml | 22 + ...tification_rule_returns_ok_response.frozen | 1 + ...notification_rule_returns_ok_response.yaml | 40 ++ ...ion_rule_returns_not_found_response.frozen | 1 + ...ation_rule_returns_not_found_response.yaml | 18 + ...tification_rule_returns_ok_response.frozen | 1 + ...notification_rule_returns_ok_response.yaml | 56 +++ ...ion_rule_returns_not_found_response.frozen | 1 + ...ation_rule_returns_not_found_response.yaml | 18 + ...tification_rule_returns_ok_response.frozen | 1 + ...notification_rule_returns_ok_response.yaml | 59 +++ ...ification_rules_returns_ok_response.frozen | 1 + ...otification_rules_returns_ok_response.yaml | 59 +++ ...n_rule_returns_bad_request_response.frozen | 1 + ...ion_rule_returns_bad_request_response.yaml | 60 +++ ...ion_rule_returns_not_found_response.frozen | 1 + ...ation_rule_returns_not_found_response.yaml | 21 + ...tification_rule_returns_ok_response.frozen | 1 + ...notification_rule_returns_ok_response.yaml | 62 +++ tests/v2/features/given.json | 12 + tests/v2/features/monitors.feature | 92 ++++ tests/v2/features/undo.json | 37 ++ 50 files changed, 2437 insertions(+), 5 deletions(-) create mode 100644 examples/v2/monitors/CreateMonitorNotificationRule.py create mode 100644 examples/v2/monitors/DeleteMonitorNotificationRule.py create mode 100644 examples/v2/monitors/GetMonitorNotificationRule.py create mode 100644 examples/v2/monitors/GetMonitorNotificationRules.py create mode 100644 examples/v2/monitors/UpdateMonitorNotificationRule.py create mode 100644 src/datadog_api_client/v2/model/monitor_notification_rule_attributes.py create mode 100644 src/datadog_api_client/v2/model/monitor_notification_rule_create_request.py create mode 100644 src/datadog_api_client/v2/model/monitor_notification_rule_create_request_data.py create mode 100644 src/datadog_api_client/v2/model/monitor_notification_rule_data.py create mode 100644 src/datadog_api_client/v2/model/monitor_notification_rule_filter.py create mode 100644 src/datadog_api_client/v2/model/monitor_notification_rule_filter_tags.py create mode 100644 src/datadog_api_client/v2/model/monitor_notification_rule_list_response.py create mode 100644 src/datadog_api_client/v2/model/monitor_notification_rule_relationships.py create mode 100644 src/datadog_api_client/v2/model/monitor_notification_rule_relationships_created_by.py create mode 100644 src/datadog_api_client/v2/model/monitor_notification_rule_relationships_created_by_data.py create mode 100644 src/datadog_api_client/v2/model/monitor_notification_rule_resource_type.py create mode 100644 src/datadog_api_client/v2/model/monitor_notification_rule_response.py create mode 100644 src/datadog_api_client/v2/model/monitor_notification_rule_response_attributes.py create mode 100644 src/datadog_api_client/v2/model/monitor_notification_rule_response_included_item.py create mode 100644 src/datadog_api_client/v2/model/monitor_notification_rule_update_request.py create mode 100644 src/datadog_api_client/v2/model/monitor_notification_rule_update_request_data.py create mode 100644 tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_returns_bad_request_response.frozen create mode 100644 tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_returns_bad_request_response.yaml create mode 100644 tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_returns_ok_response.frozen create mode 100644 tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_returns_ok_response.yaml create mode 100644 tests/v2/cassettes/test_scenarios/test_delete_a_monitor_notification_rule_returns_not_found_response.frozen create mode 100644 tests/v2/cassettes/test_scenarios/test_delete_a_monitor_notification_rule_returns_not_found_response.yaml create mode 100644 tests/v2/cassettes/test_scenarios/test_delete_a_monitor_notification_rule_returns_ok_response.frozen create mode 100644 tests/v2/cassettes/test_scenarios/test_delete_a_monitor_notification_rule_returns_ok_response.yaml create mode 100644 tests/v2/cassettes/test_scenarios/test_get_a_monitor_notification_rule_returns_not_found_response.frozen create mode 100644 tests/v2/cassettes/test_scenarios/test_get_a_monitor_notification_rule_returns_not_found_response.yaml create mode 100644 tests/v2/cassettes/test_scenarios/test_get_a_monitor_notification_rule_returns_ok_response.frozen create mode 100644 tests/v2/cassettes/test_scenarios/test_get_a_monitor_notification_rule_returns_ok_response.yaml create mode 100644 tests/v2/cassettes/test_scenarios/test_get_all_monitor_notification_rules_returns_ok_response.frozen create mode 100644 tests/v2/cassettes/test_scenarios/test_get_all_monitor_notification_rules_returns_ok_response.yaml create mode 100644 tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_bad_request_response.frozen create mode 100644 tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_bad_request_response.yaml create mode 100644 tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_not_found_response.frozen create mode 100644 tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_not_found_response.yaml create mode 100644 tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_ok_response.frozen create mode 100644 tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_ok_response.yaml diff --git a/.apigentools-info b/.apigentools-info index 914de116b4..a488f4e4f6 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2025-04-15 16:46:15.093163", - "spec_repo_commit": "2d6e55b2" + "regenerated": "2025-04-15 21:54:40.688045", + "spec_repo_commit": "808cf2c3" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2025-04-15 16:46:15.147514", - "spec_repo_commit": "2d6e55b2" + "regenerated": "2025-04-15 21:54:40.703041", + "spec_repo_commit": "808cf2c3" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 6f7970cbbe..12445d0252 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -21371,6 +21371,201 @@ components: type: $ref: '#/components/schemas/MonitorDowntimeMatchResourceType' type: object + MonitorNotificationRuleAttributes: + additionalProperties: false + description: Attributes of the monitor notification rule. + properties: + filter: + $ref: '#/components/schemas/MonitorNotificationRuleFilter' + name: + $ref: '#/components/schemas/MonitorNotificationRuleName' + recipients: + $ref: '#/components/schemas/MonitorNotificationRuleRecipients' + required: + - name + - recipients + type: object + MonitorNotificationRuleCreateRequest: + description: Request for creating a monitor notification rule. + properties: + data: + $ref: '#/components/schemas/MonitorNotificationRuleCreateRequestData' + required: + - data + type: object + MonitorNotificationRuleCreateRequestData: + description: Object to create a monitor notification rule. + properties: + attributes: + $ref: '#/components/schemas/MonitorNotificationRuleAttributes' + type: + $ref: '#/components/schemas/MonitorNotificationRuleResourceType' + required: + - attributes + type: object + MonitorNotificationRuleData: + description: Monitor notification rule data. + properties: + attributes: + $ref: '#/components/schemas/MonitorNotificationRuleResponseAttributes' + id: + $ref: '#/components/schemas/MonitorNotificationRuleId' + relationships: + $ref: '#/components/schemas/MonitorNotificationRuleRelationships' + type: + $ref: '#/components/schemas/MonitorNotificationRuleResourceType' + type: object + MonitorNotificationRuleFilter: + description: Filter used to associate the notification rule with monitors. + oneOf: + - $ref: '#/components/schemas/MonitorNotificationRuleFilterTags' + MonitorNotificationRuleFilterTags: + additionalProperties: false + description: Filter monitors by tags. Monitors must match all tags. + properties: + tags: + description: A list of monitor tags. + example: + - team:product + - host:abc + items: + maxLength: 255 + type: string + maxItems: 20 + minItems: 1 + type: array + uniqueItems: true + required: + - tags + type: object + MonitorNotificationRuleId: + description: The ID of the monitor notification rule. + example: 00000000-0000-1234-0000-000000000000 + type: string + MonitorNotificationRuleListResponse: + description: Response for retrieving all monitor notification rules. + properties: + data: + description: A list of monitor notification rules. + items: + $ref: '#/components/schemas/MonitorNotificationRuleData' + type: array + included: + description: Array of objects related to the monitor notification rules. + items: + $ref: '#/components/schemas/MonitorNotificationRuleResponseIncludedItem' + type: array + type: object + MonitorNotificationRuleName: + description: The name of the monitor notification rule. + example: A notification rule name + maxLength: 1000 + minLength: 1 + type: string + MonitorNotificationRuleRecipients: + description: A list of recipients to notify. Uses the same format as the monitor + `message` field. Must not start with an '@'. + example: + - slack-test-channel + - jira-test + items: + description: individual recipient. + maxLength: 255 + type: string + maxItems: 20 + minItems: 1 + type: array + uniqueItems: true + MonitorNotificationRuleRelationships: + description: All relationships associated with monitor notification rule. + properties: + created_by: + $ref: '#/components/schemas/MonitorNotificationRuleRelationshipsCreatedBy' + type: object + MonitorNotificationRuleRelationshipsCreatedBy: + description: The user who created the monitor notification rule. + properties: + data: + $ref: '#/components/schemas/MonitorNotificationRuleRelationshipsCreatedByData' + type: object + MonitorNotificationRuleRelationshipsCreatedByData: + description: Data for the user who created the monitor notification rule. + nullable: true + properties: + id: + description: User ID of the monitor notification rule creator. + example: 00000000-0000-1234-0000-000000000000 + type: string + type: + $ref: '#/components/schemas/UsersType' + type: object + MonitorNotificationRuleResourceType: + default: monitor-notification-rule + description: Monitor notification rule resource type. + enum: + - monitor-notification-rule + example: monitor-notification-rule + type: string + x-enum-varnames: + - MONITOR_NOTIFICATION_RULE + MonitorNotificationRuleResponse: + description: A monitor notification rule. + properties: + data: + $ref: '#/components/schemas/MonitorNotificationRuleData' + included: + description: Array of objects related to the monitor notification rule that + the user requested. + items: + $ref: '#/components/schemas/MonitorNotificationRuleResponseIncludedItem' + type: array + type: object + MonitorNotificationRuleResponseAttributes: + additionalProperties: {} + description: Attributes of the monitor notification rule. + properties: + created: + description: Creation time of the monitor notification rule. + example: 2020-01-02 03:04:00+00:00 + format: date-time + type: string + filter: + $ref: '#/components/schemas/MonitorNotificationRuleFilter' + modified: + description: Time the monitor notification rule was last modified. + example: 2020-01-02 03:04:00+00:00 + format: date-time + type: string + name: + $ref: '#/components/schemas/MonitorNotificationRuleName' + recipients: + $ref: '#/components/schemas/MonitorNotificationRuleRecipients' + type: object + MonitorNotificationRuleResponseIncludedItem: + description: An object related to a monitor notification rule. + oneOf: + - $ref: '#/components/schemas/User' + MonitorNotificationRuleUpdateRequest: + description: Request for updating a monitor notification rule. + properties: + data: + $ref: '#/components/schemas/MonitorNotificationRuleUpdateRequestData' + required: + - data + type: object + MonitorNotificationRuleUpdateRequestData: + description: Object to update a monitor notification rule. + properties: + attributes: + $ref: '#/components/schemas/MonitorNotificationRuleAttributes' + id: + $ref: '#/components/schemas/MonitorNotificationRuleId' + type: + $ref: '#/components/schemas/MonitorNotificationRuleResourceType' + required: + - id + - attributes + type: object MonitorTrigger: description: Trigger a workflow from a Monitor. For automatic triggering a handle must be configured and the workflow must be published. @@ -35806,6 +36001,7 @@ components: incident_settings_write: Configure Incident Settings. incident_write: Create, view, and manage incidents in Datadog. metrics_read: View custom metrics. + monitor_config_policy_write: Edit and delete monitor configuration. monitors_downtime: Set downtimes to suppress alerts from any monitor in an organization. Mute and unmute monitors. The ability to write monitors is not required to set downtimes. @@ -45721,6 +45917,256 @@ paths: x-permission: operator: OPEN permissions: [] + /api/v2/monitor/notification_rule: + get: + description: Returns a list of all monitor notification rules. + operationId: GetMonitorNotificationRules + parameters: + - description: 'Comma-separated list of resource paths for related resources + to include in the response. Supported resource + + path is `created_by`.' + in: query + name: include + required: false + schema: + example: created_by + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/MonitorNotificationRuleListResponse' + description: OK + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - monitors_read + summary: Get all monitor notification rules + tags: + - Monitors + x-permission: + operator: OR + permissions: + - monitors_read + x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, + + contact [Datadog support](https://docs.datadoghq.com/help/).' + post: + description: Creates a monitor notification rule. + operationId: CreateMonitorNotificationRule + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/MonitorNotificationRuleCreateRequest' + description: Request body to create a monitor notification rule. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/MonitorNotificationRuleResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - monitor_config_policy_write + summary: Create a monitor notification rule + tags: + - Monitors + x-permission: + operator: OR + permissions: + - monitor_config_policy_write + x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, + + contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/monitor/notification_rule/{rule_id}: + delete: + description: Deletes a monitor notification rule by `rule_id`. + operationId: DeleteMonitorNotificationRule + parameters: + - description: ID of the monitor notification rule to delete. + in: path + name: rule_id + required: true + schema: + type: string + responses: + '204': + description: OK + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - monitor_config_policy_write + summary: Delete a monitor notification rule + tags: + - Monitors + x-permission: + operator: OR + permissions: + - monitor_config_policy_write + x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, + + contact [Datadog support](https://docs.datadoghq.com/help/).' + get: + description: Returns a monitor notification rule by `rule_id`. + operationId: GetMonitorNotificationRule + parameters: + - description: ID of the monitor notification rule to fetch. + in: path + name: rule_id + required: true + schema: + type: string + - description: 'Comma-separated list of resource paths for related resources + to include in the response. Supported resource + + path is `created_by`.' + in: query + name: include + required: false + schema: + example: created_by + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/MonitorNotificationRuleResponse' + description: OK + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - monitors_read + summary: Get a monitor notification rule + tags: + - Monitors + x-permission: + operator: OR + permissions: + - monitors_read + x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, + + contact [Datadog support](https://docs.datadoghq.com/help/).' + patch: + description: Updates a monitor notification rule by `rule_id`. + operationId: UpdateMonitorNotificationRule + parameters: + - description: ID of the monitor notification rule to update. + in: path + name: rule_id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/MonitorNotificationRuleUpdateRequest' + description: Request body to update the monitor notification rule. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/MonitorNotificationRuleResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - monitor_config_policy_write + summary: Update a monitor notification rule + tags: + - Monitors + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - monitor_config_policy_write + x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, + + contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/monitor/policy: get: description: Get all monitor configuration policies. diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index b723af7c4d..47abe88c21 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -9209,6 +9209,118 @@ datadog\_api\_client.v2.model.monitor\_downtime\_match\_response\_data module :members: :show-inheritance: +datadog\_api\_client.v2.model.monitor\_notification\_rule\_attributes module +---------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.monitor_notification_rule_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.monitor\_notification\_rule\_create\_request module +--------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.monitor_notification_rule_create_request + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.monitor\_notification\_rule\_create\_request\_data module +--------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.monitor_notification_rule_create_request_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.monitor\_notification\_rule\_data module +---------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.monitor_notification_rule_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.monitor\_notification\_rule\_filter module +------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.monitor_notification_rule_filter + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.monitor\_notification\_rule\_filter\_tags module +------------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.monitor_notification_rule_filter_tags + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.monitor\_notification\_rule\_list\_response module +-------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.monitor_notification_rule_list_response + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.monitor\_notification\_rule\_relationships module +------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.monitor_notification_rule_relationships + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.monitor\_notification\_rule\_relationships\_created\_by module +-------------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.monitor_notification_rule_relationships_created_by + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.monitor\_notification\_rule\_relationships\_created\_by\_data module +-------------------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.monitor_notification_rule_relationships_created_by_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.monitor\_notification\_rule\_resource\_type module +-------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.monitor_notification_rule_resource_type + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.monitor\_notification\_rule\_response module +-------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.monitor_notification_rule_response + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.monitor\_notification\_rule\_response\_attributes module +-------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.monitor_notification_rule_response_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.monitor\_notification\_rule\_response\_included\_item module +------------------------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.monitor_notification_rule_response_included_item + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.monitor\_notification\_rule\_update\_request module +--------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.monitor_notification_rule_update_request + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.monitor\_notification\_rule\_update\_request\_data module +--------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.monitor_notification_rule_update_request_data + :members: + :show-inheritance: + datadog\_api\_client.v2.model.monitor\_trigger module ----------------------------------------------------- diff --git a/examples/v2/monitors/CreateMonitorNotificationRule.py b/examples/v2/monitors/CreateMonitorNotificationRule.py new file mode 100644 index 0000000000..fd5cecf4e5 --- /dev/null +++ b/examples/v2/monitors/CreateMonitorNotificationRule.py @@ -0,0 +1,39 @@ +""" +Create a monitor notification rule returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.monitors_api import MonitorsApi +from datadog_api_client.v2.model.monitor_notification_rule_attributes import MonitorNotificationRuleAttributes +from datadog_api_client.v2.model.monitor_notification_rule_create_request import MonitorNotificationRuleCreateRequest +from datadog_api_client.v2.model.monitor_notification_rule_create_request_data import ( + MonitorNotificationRuleCreateRequestData, +) +from datadog_api_client.v2.model.monitor_notification_rule_filter_tags import MonitorNotificationRuleFilterTags +from datadog_api_client.v2.model.monitor_notification_rule_resource_type import MonitorNotificationRuleResourceType + +body = MonitorNotificationRuleCreateRequest( + data=MonitorNotificationRuleCreateRequestData( + attributes=MonitorNotificationRuleAttributes( + filter=MonitorNotificationRuleFilterTags( + tags=[ + "test:example-monitor", + ], + ), + name="test rule", + recipients=[ + "slack-test-channel", + "jira-test", + ], + ), + type=MonitorNotificationRuleResourceType.MONITOR_NOTIFICATION_RULE, + ), +) + +configuration = Configuration() +configuration.unstable_operations["create_monitor_notification_rule"] = True +with ApiClient(configuration) as api_client: + api_instance = MonitorsApi(api_client) + response = api_instance.create_monitor_notification_rule(body=body) + + print(response) diff --git a/examples/v2/monitors/DeleteMonitorNotificationRule.py b/examples/v2/monitors/DeleteMonitorNotificationRule.py new file mode 100644 index 0000000000..132f679033 --- /dev/null +++ b/examples/v2/monitors/DeleteMonitorNotificationRule.py @@ -0,0 +1,18 @@ +""" +Delete a monitor notification rule returns "OK" response +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.monitors_api import MonitorsApi + +# there is a valid "monitor_notification_rule" in the system +MONITOR_NOTIFICATION_RULE_DATA_ID = environ["MONITOR_NOTIFICATION_RULE_DATA_ID"] + +configuration = Configuration() +configuration.unstable_operations["delete_monitor_notification_rule"] = True +with ApiClient(configuration) as api_client: + api_instance = MonitorsApi(api_client) + api_instance.delete_monitor_notification_rule( + rule_id=MONITOR_NOTIFICATION_RULE_DATA_ID, + ) diff --git a/examples/v2/monitors/GetMonitorNotificationRule.py b/examples/v2/monitors/GetMonitorNotificationRule.py new file mode 100644 index 0000000000..6d89b69af7 --- /dev/null +++ b/examples/v2/monitors/GetMonitorNotificationRule.py @@ -0,0 +1,20 @@ +""" +Get a monitor notification rule returns "OK" response +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.monitors_api import MonitorsApi + +# there is a valid "monitor_notification_rule" in the system +MONITOR_NOTIFICATION_RULE_DATA_ID = environ["MONITOR_NOTIFICATION_RULE_DATA_ID"] + +configuration = Configuration() +configuration.unstable_operations["get_monitor_notification_rule"] = True +with ApiClient(configuration) as api_client: + api_instance = MonitorsApi(api_client) + response = api_instance.get_monitor_notification_rule( + rule_id=MONITOR_NOTIFICATION_RULE_DATA_ID, + ) + + print(response) diff --git a/examples/v2/monitors/GetMonitorNotificationRules.py b/examples/v2/monitors/GetMonitorNotificationRules.py new file mode 100644 index 0000000000..7425d39c17 --- /dev/null +++ b/examples/v2/monitors/GetMonitorNotificationRules.py @@ -0,0 +1,14 @@ +""" +Get all monitor notification rules returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.monitors_api import MonitorsApi + +configuration = Configuration() +configuration.unstable_operations["get_monitor_notification_rules"] = True +with ApiClient(configuration) as api_client: + api_instance = MonitorsApi(api_client) + response = api_instance.get_monitor_notification_rules() + + print(response) diff --git a/examples/v2/monitors/UpdateMonitorNotificationRule.py b/examples/v2/monitors/UpdateMonitorNotificationRule.py new file mode 100644 index 0000000000..8ef0e3394f --- /dev/null +++ b/examples/v2/monitors/UpdateMonitorNotificationRule.py @@ -0,0 +1,44 @@ +""" +Update a monitor notification rule returns "OK" response +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.monitors_api import MonitorsApi +from datadog_api_client.v2.model.monitor_notification_rule_attributes import MonitorNotificationRuleAttributes +from datadog_api_client.v2.model.monitor_notification_rule_filter_tags import MonitorNotificationRuleFilterTags +from datadog_api_client.v2.model.monitor_notification_rule_resource_type import MonitorNotificationRuleResourceType +from datadog_api_client.v2.model.monitor_notification_rule_update_request import MonitorNotificationRuleUpdateRequest +from datadog_api_client.v2.model.monitor_notification_rule_update_request_data import ( + MonitorNotificationRuleUpdateRequestData, +) + +# there is a valid "monitor_notification_rule" in the system +MONITOR_NOTIFICATION_RULE_DATA_ID = environ["MONITOR_NOTIFICATION_RULE_DATA_ID"] + +body = MonitorNotificationRuleUpdateRequest( + data=MonitorNotificationRuleUpdateRequestData( + attributes=MonitorNotificationRuleAttributes( + filter=MonitorNotificationRuleFilterTags( + tags=[ + "test:example-monitor", + "host:abc", + ], + ), + name="updated rule", + recipients=[ + "slack-test-channel", + ], + ), + id=MONITOR_NOTIFICATION_RULE_DATA_ID, + type=MonitorNotificationRuleResourceType.MONITOR_NOTIFICATION_RULE, + ), +) + +configuration = Configuration() +configuration.unstable_operations["update_monitor_notification_rule"] = True +with ApiClient(configuration) as api_client: + api_instance = MonitorsApi(api_client) + response = api_instance.update_monitor_notification_rule(rule_id=MONITOR_NOTIFICATION_RULE_DATA_ID, body=body) + + print(response) diff --git a/src/datadog_api_client/configuration.py b/src/datadog_api_client/configuration.py index 2ee7d6bcff..532ce743e2 100644 --- a/src/datadog_api_client/configuration.py +++ b/src/datadog_api_client/configuration.py @@ -277,6 +277,11 @@ def __init__( "v2.list_aws_namespaces": False, "v2.update_aws_account": False, "v2.list_aws_logs_services": False, + "v2.create_monitor_notification_rule": False, + "v2.delete_monitor_notification_rule": False, + "v2.get_monitor_notification_rule": False, + "v2.get_monitor_notification_rules": False, + "v2.update_monitor_notification_rule": False, "v2.get_aggregated_connections": False, "v2.cancel_historical_job": False, "v2.convert_job_result_to_signal": False, diff --git a/src/datadog_api_client/v2/api/monitors_api.py b/src/datadog_api_client/v2/api/monitors_api.py index 1f9cb64b8a..a812f5d4cb 100644 --- a/src/datadog_api_client/v2/api/monitors_api.py +++ b/src/datadog_api_client/v2/api/monitors_api.py @@ -3,10 +3,18 @@ # Copyright 2019-Present Datadog, Inc. from __future__ import annotations -from typing import Any, Dict +from typing import Any, Dict, Union from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint from datadog_api_client.configuration import Configuration +from datadog_api_client.model_utils import ( + UnsetType, + unset, +) +from datadog_api_client.v2.model.monitor_notification_rule_list_response import MonitorNotificationRuleListResponse +from datadog_api_client.v2.model.monitor_notification_rule_response import MonitorNotificationRuleResponse +from datadog_api_client.v2.model.monitor_notification_rule_create_request import MonitorNotificationRuleCreateRequest +from datadog_api_client.v2.model.monitor_notification_rule_update_request import MonitorNotificationRuleUpdateRequest from datadog_api_client.v2.model.monitor_config_policy_list_response import MonitorConfigPolicyListResponse from datadog_api_client.v2.model.monitor_config_policy_response import MonitorConfigPolicyResponse from datadog_api_client.v2.model.monitor_config_policy_create_request import MonitorConfigPolicyCreateRequest @@ -47,6 +55,26 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._create_monitor_notification_rule_endpoint = _Endpoint( + settings={ + "response_type": (MonitorNotificationRuleResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/monitor/notification_rule", + "operation_id": "create_monitor_notification_rule", + "http_method": "POST", + "version": "v2", + }, + params_map={ + "body": { + "required": True, + "openapi_types": (MonitorNotificationRuleCreateRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + self._delete_monitor_config_policy_endpoint = _Endpoint( settings={ "response_type": None, @@ -70,6 +98,29 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._delete_monitor_notification_rule_endpoint = _Endpoint( + settings={ + "response_type": None, + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/monitor/notification_rule/{rule_id}", + "operation_id": "delete_monitor_notification_rule", + "http_method": "DELETE", + "version": "v2", + }, + params_map={ + "rule_id": { + "required": True, + "openapi_types": (str,), + "attribute": "rule_id", + "location": "path", + }, + }, + headers_map={ + "accept": ["*/*"], + }, + api_client=api_client, + ) + self._get_monitor_config_policy_endpoint = _Endpoint( settings={ "response_type": (MonitorConfigPolicyResponse,), @@ -93,6 +144,56 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._get_monitor_notification_rule_endpoint = _Endpoint( + settings={ + "response_type": (MonitorNotificationRuleResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/monitor/notification_rule/{rule_id}", + "operation_id": "get_monitor_notification_rule", + "http_method": "GET", + "version": "v2", + }, + params_map={ + "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._get_monitor_notification_rules_endpoint = _Endpoint( + settings={ + "response_type": (MonitorNotificationRuleListResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/monitor/notification_rule", + "operation_id": "get_monitor_notification_rules", + "http_method": "GET", + "version": "v2", + }, + params_map={ + "include": { + "openapi_types": (str,), + "attribute": "include", + "location": "query", + }, + }, + headers_map={ + "accept": ["application/json"], + }, + api_client=api_client, + ) + self._list_monitor_config_policies_endpoint = _Endpoint( settings={ "response_type": (MonitorConfigPolicyListResponse,), @@ -135,6 +236,32 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._update_monitor_notification_rule_endpoint = _Endpoint( + settings={ + "response_type": (MonitorNotificationRuleResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/monitor/notification_rule/{rule_id}", + "operation_id": "update_monitor_notification_rule", + "http_method": "PATCH", + "version": "v2", + }, + params_map={ + "rule_id": { + "required": True, + "openapi_types": (str,), + "attribute": "rule_id", + "location": "path", + }, + "body": { + "required": True, + "openapi_types": (MonitorNotificationRuleUpdateRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + def create_monitor_config_policy( self, body: MonitorConfigPolicyCreateRequest, @@ -152,6 +279,23 @@ def create_monitor_config_policy( return self._create_monitor_config_policy_endpoint.call_with_http_info(**kwargs) + def create_monitor_notification_rule( + self, + body: MonitorNotificationRuleCreateRequest, + ) -> MonitorNotificationRuleResponse: + """Create a monitor notification rule. + + Creates a monitor notification rule. + + :param body: Request body to create a monitor notification rule. + :type body: MonitorNotificationRuleCreateRequest + :rtype: MonitorNotificationRuleResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["body"] = body + + return self._create_monitor_notification_rule_endpoint.call_with_http_info(**kwargs) + def delete_monitor_config_policy( self, policy_id: str, @@ -169,6 +313,23 @@ def delete_monitor_config_policy( return self._delete_monitor_config_policy_endpoint.call_with_http_info(**kwargs) + def delete_monitor_notification_rule( + self, + rule_id: str, + ) -> None: + """Delete a monitor notification rule. + + Deletes a monitor notification rule by ``rule_id``. + + :param rule_id: ID of the monitor notification rule to delete. + :type rule_id: str + :rtype: None + """ + kwargs: Dict[str, Any] = {} + kwargs["rule_id"] = rule_id + + return self._delete_monitor_notification_rule_endpoint.call_with_http_info(**kwargs) + def get_monitor_config_policy( self, policy_id: str, @@ -186,6 +347,51 @@ def get_monitor_config_policy( return self._get_monitor_config_policy_endpoint.call_with_http_info(**kwargs) + def get_monitor_notification_rule( + self, + rule_id: str, + *, + include: Union[str, UnsetType] = unset, + ) -> MonitorNotificationRuleResponse: + """Get a monitor notification rule. + + Returns a monitor notification rule by ``rule_id``. + + :param rule_id: ID of the monitor notification rule to fetch. + :type rule_id: str + :param include: Comma-separated list of resource paths for related resources to include in the response. Supported resource + path is ``created_by``. + :type include: str, optional + :rtype: MonitorNotificationRuleResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["rule_id"] = rule_id + + if include is not unset: + kwargs["include"] = include + + return self._get_monitor_notification_rule_endpoint.call_with_http_info(**kwargs) + + def get_monitor_notification_rules( + self, + *, + include: Union[str, UnsetType] = unset, + ) -> MonitorNotificationRuleListResponse: + """Get all monitor notification rules. + + Returns a list of all monitor notification rules. + + :param include: Comma-separated list of resource paths for related resources to include in the response. Supported resource + path is ``created_by``. + :type include: str, optional + :rtype: MonitorNotificationRuleListResponse + """ + kwargs: Dict[str, Any] = {} + if include is not unset: + kwargs["include"] = include + + return self._get_monitor_notification_rules_endpoint.call_with_http_info(**kwargs) + def list_monitor_config_policies( self, ) -> MonitorConfigPolicyListResponse: @@ -219,3 +425,25 @@ def update_monitor_config_policy( kwargs["body"] = body return self._update_monitor_config_policy_endpoint.call_with_http_info(**kwargs) + + def update_monitor_notification_rule( + self, + rule_id: str, + body: MonitorNotificationRuleUpdateRequest, + ) -> MonitorNotificationRuleResponse: + """Update a monitor notification rule. + + Updates a monitor notification rule by ``rule_id``. + + :param rule_id: ID of the monitor notification rule to update. + :type rule_id: str + :param body: Request body to update the monitor notification rule. + :type body: MonitorNotificationRuleUpdateRequest + :rtype: MonitorNotificationRuleResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["rule_id"] = rule_id + + kwargs["body"] = body + + return self._update_monitor_notification_rule_endpoint.call_with_http_info(**kwargs) diff --git a/src/datadog_api_client/v2/model/monitor_notification_rule_attributes.py b/src/datadog_api_client/v2/model/monitor_notification_rule_attributes.py new file mode 100644 index 0000000000..23de90d18c --- /dev/null +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_attributes.py @@ -0,0 +1,77 @@ +# 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.monitor_notification_rule_filter import MonitorNotificationRuleFilter + from datadog_api_client.v2.model.monitor_notification_rule_filter_tags import MonitorNotificationRuleFilterTags + + +class MonitorNotificationRuleAttributes(ModelNormal): + validations = { + "name": { + "max_length": 1000, + "min_length": 1, + }, + "recipients": { + "max_items": 20, + "min_items": 1, + }, + } + + @cached_property + def additional_properties_type(_): + return None + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.monitor_notification_rule_filter import MonitorNotificationRuleFilter + + return { + "filter": (MonitorNotificationRuleFilter,), + "name": (str,), + "recipients": ([str],), + } + + attribute_map = { + "filter": "filter", + "name": "name", + "recipients": "recipients", + } + + def __init__( + self_, + name: str, + recipients: List[str], + filter: Union[MonitorNotificationRuleFilter, MonitorNotificationRuleFilterTags, UnsetType] = unset, + **kwargs, + ): + """ + Attributes of the monitor notification rule. + + :param filter: Filter used to associate the notification rule with monitors. + :type filter: MonitorNotificationRuleFilter, optional + + :param name: The name of the monitor notification rule. + :type name: str + + :param recipients: A list of recipients to notify. Uses the same format as the monitor ``message`` field. Must not start with an '@'. + :type recipients: [str] + """ + if filter is not unset: + kwargs["filter"] = filter + super().__init__(kwargs) + + self_.name = name + self_.recipients = recipients diff --git a/src/datadog_api_client/v2/model/monitor_notification_rule_create_request.py b/src/datadog_api_client/v2/model/monitor_notification_rule_create_request.py new file mode 100644 index 0000000000..26cc25db71 --- /dev/null +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_create_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.monitor_notification_rule_create_request_data import ( + MonitorNotificationRuleCreateRequestData, + ) + + +class MonitorNotificationRuleCreateRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.monitor_notification_rule_create_request_data import ( + MonitorNotificationRuleCreateRequestData, + ) + + return { + "data": (MonitorNotificationRuleCreateRequestData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: MonitorNotificationRuleCreateRequestData, **kwargs): + """ + Request for creating a monitor notification rule. + + :param data: Object to create a monitor notification rule. + :type data: MonitorNotificationRuleCreateRequestData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/monitor_notification_rule_create_request_data.py b/src/datadog_api_client/v2/model/monitor_notification_rule_create_request_data.py new file mode 100644 index 0000000000..e4ee73c8fd --- /dev/null +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_create_request_data.py @@ -0,0 +1,58 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.monitor_notification_rule_attributes import MonitorNotificationRuleAttributes + from datadog_api_client.v2.model.monitor_notification_rule_resource_type import MonitorNotificationRuleResourceType + + +class MonitorNotificationRuleCreateRequestData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.monitor_notification_rule_attributes import MonitorNotificationRuleAttributes + from datadog_api_client.v2.model.monitor_notification_rule_resource_type import ( + MonitorNotificationRuleResourceType, + ) + + return { + "attributes": (MonitorNotificationRuleAttributes,), + "type": (MonitorNotificationRuleResourceType,), + } + + attribute_map = { + "attributes": "attributes", + "type": "type", + } + + def __init__( + self_, + attributes: MonitorNotificationRuleAttributes, + type: Union[MonitorNotificationRuleResourceType, UnsetType] = unset, + **kwargs, + ): + """ + Object to create a monitor notification rule. + + :param attributes: Attributes of the monitor notification rule. + :type attributes: MonitorNotificationRuleAttributes + + :param type: Monitor notification rule resource type. + :type type: MonitorNotificationRuleResourceType, optional + """ + if type is not unset: + kwargs["type"] = type + super().__init__(kwargs) + + self_.attributes = attributes diff --git a/src/datadog_api_client/v2/model/monitor_notification_rule_data.py b/src/datadog_api_client/v2/model/monitor_notification_rule_data.py new file mode 100644 index 0000000000..09aa78ce54 --- /dev/null +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_data.py @@ -0,0 +1,82 @@ +# 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.monitor_notification_rule_response_attributes import ( + MonitorNotificationRuleResponseAttributes, + ) + from datadog_api_client.v2.model.monitor_notification_rule_relationships import MonitorNotificationRuleRelationships + from datadog_api_client.v2.model.monitor_notification_rule_resource_type import MonitorNotificationRuleResourceType + + +class MonitorNotificationRuleData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.monitor_notification_rule_response_attributes import ( + MonitorNotificationRuleResponseAttributes, + ) + from datadog_api_client.v2.model.monitor_notification_rule_relationships import ( + MonitorNotificationRuleRelationships, + ) + from datadog_api_client.v2.model.monitor_notification_rule_resource_type import ( + MonitorNotificationRuleResourceType, + ) + + return { + "attributes": (MonitorNotificationRuleResponseAttributes,), + "id": (str,), + "relationships": (MonitorNotificationRuleRelationships,), + "type": (MonitorNotificationRuleResourceType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "relationships": "relationships", + "type": "type", + } + + def __init__( + self_, + attributes: Union[MonitorNotificationRuleResponseAttributes, UnsetType] = unset, + id: Union[str, UnsetType] = unset, + relationships: Union[MonitorNotificationRuleRelationships, UnsetType] = unset, + type: Union[MonitorNotificationRuleResourceType, UnsetType] = unset, + **kwargs, + ): + """ + Monitor notification rule data. + + :param attributes: Attributes of the monitor notification rule. + :type attributes: MonitorNotificationRuleResponseAttributes, optional + + :param id: The ID of the monitor notification rule. + :type id: str, optional + + :param relationships: All relationships associated with monitor notification rule. + :type relationships: MonitorNotificationRuleRelationships, optional + + :param type: Monitor notification rule resource type. + :type type: MonitorNotificationRuleResourceType, optional + """ + if attributes is not unset: + kwargs["attributes"] = attributes + if id is not unset: + kwargs["id"] = id + if relationships is not unset: + kwargs["relationships"] = relationships + if type is not unset: + kwargs["type"] = type + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/monitor_notification_rule_filter.py b/src/datadog_api_client/v2/model/monitor_notification_rule_filter.py new file mode 100644 index 0000000000..07b693934f --- /dev/null +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_filter.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 ( + ModelComposed, + cached_property, +) + + +class MonitorNotificationRuleFilter(ModelComposed): + def __init__(self, **kwargs): + """ + Filter used to associate the notification rule with monitors. + + :param tags: A list of monitor tags. + :type tags: [str] + """ + super().__init__(kwargs) + + @cached_property + def _composed_schemas(_): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error because the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + from datadog_api_client.v2.model.monitor_notification_rule_filter_tags import MonitorNotificationRuleFilterTags + + return { + "oneOf": [ + MonitorNotificationRuleFilterTags, + ], + } diff --git a/src/datadog_api_client/v2/model/monitor_notification_rule_filter_tags.py b/src/datadog_api_client/v2/model/monitor_notification_rule_filter_tags.py new file mode 100644 index 0000000000..ee5a260331 --- /dev/null +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_filter_tags.py @@ -0,0 +1,45 @@ +# 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 + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +class MonitorNotificationRuleFilterTags(ModelNormal): + validations = { + "tags": { + "max_items": 20, + "min_items": 1, + }, + } + + @cached_property + def additional_properties_type(_): + return None + + @cached_property + def openapi_types(_): + return { + "tags": ([str],), + } + + attribute_map = { + "tags": "tags", + } + + def __init__(self_, tags: List[str], **kwargs): + """ + Filter monitors by tags. Monitors must match all tags. + + :param tags: A list of monitor tags. + :type tags: [str] + """ + super().__init__(kwargs) + + self_.tags = tags diff --git a/src/datadog_api_client/v2/model/monitor_notification_rule_list_response.py b/src/datadog_api_client/v2/model/monitor_notification_rule_list_response.py new file mode 100644 index 0000000000..d5c9067edf --- /dev/null +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_list_response.py @@ -0,0 +1,61 @@ +# 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.monitor_notification_rule_data import MonitorNotificationRuleData + from datadog_api_client.v2.model.monitor_notification_rule_response_included_item import ( + MonitorNotificationRuleResponseIncludedItem, + ) + from datadog_api_client.v2.model.user import User + + +class MonitorNotificationRuleListResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.monitor_notification_rule_data import MonitorNotificationRuleData + from datadog_api_client.v2.model.monitor_notification_rule_response_included_item import ( + MonitorNotificationRuleResponseIncludedItem, + ) + + return { + "data": ([MonitorNotificationRuleData],), + "included": ([MonitorNotificationRuleResponseIncludedItem],), + } + + attribute_map = { + "data": "data", + "included": "included", + } + + def __init__( + self_, + data: Union[List[MonitorNotificationRuleData], UnsetType] = unset, + included: Union[List[Union[MonitorNotificationRuleResponseIncludedItem, User]], UnsetType] = unset, + **kwargs, + ): + """ + Response for retrieving all monitor notification rules. + + :param data: A list of monitor notification rules. + :type data: [MonitorNotificationRuleData], optional + + :param included: Array of objects related to the monitor notification rules. + :type included: [MonitorNotificationRuleResponseIncludedItem], 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/monitor_notification_rule_relationships.py b/src/datadog_api_client/v2/model/monitor_notification_rule_relationships.py new file mode 100644 index 0000000000..178c636ef0 --- /dev/null +++ b/src/datadog_api_client/v2/model/monitor_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.monitor_notification_rule_relationships_created_by import ( + MonitorNotificationRuleRelationshipsCreatedBy, + ) + + +class MonitorNotificationRuleRelationships(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.monitor_notification_rule_relationships_created_by import ( + MonitorNotificationRuleRelationshipsCreatedBy, + ) + + return { + "created_by": (MonitorNotificationRuleRelationshipsCreatedBy,), + } + + attribute_map = { + "created_by": "created_by", + } + + def __init__(self_, created_by: Union[MonitorNotificationRuleRelationshipsCreatedBy, UnsetType] = unset, **kwargs): + """ + All relationships associated with monitor notification rule. + + :param created_by: The user who created the monitor notification rule. + :type created_by: MonitorNotificationRuleRelationshipsCreatedBy, optional + """ + if created_by is not unset: + kwargs["created_by"] = created_by + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/monitor_notification_rule_relationships_created_by.py b/src/datadog_api_client/v2/model/monitor_notification_rule_relationships_created_by.py new file mode 100644 index 0000000000..47d81f3efa --- /dev/null +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_relationships_created_by.py @@ -0,0 +1,49 @@ +# 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, + none_type, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.monitor_notification_rule_relationships_created_by_data import ( + MonitorNotificationRuleRelationshipsCreatedByData, + ) + + +class MonitorNotificationRuleRelationshipsCreatedBy(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.monitor_notification_rule_relationships_created_by_data import ( + MonitorNotificationRuleRelationshipsCreatedByData, + ) + + return { + "data": (MonitorNotificationRuleRelationshipsCreatedByData,), + } + + attribute_map = { + "data": "data", + } + + def __init__( + self_, data: Union[MonitorNotificationRuleRelationshipsCreatedByData, none_type, UnsetType] = unset, **kwargs + ): + """ + The user who created the monitor notification rule. + + :param data: Data for the user who created the monitor notification rule. + :type data: MonitorNotificationRuleRelationshipsCreatedByData, none_type, optional + """ + if data is not unset: + kwargs["data"] = data + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/monitor_notification_rule_relationships_created_by_data.py b/src/datadog_api_client/v2/model/monitor_notification_rule_relationships_created_by_data.py new file mode 100644 index 0000000000..4519646ae5 --- /dev/null +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_relationships_created_by_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.users_type import UsersType + + +class MonitorNotificationRuleRelationshipsCreatedByData(ModelNormal): + _nullable = True + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.users_type import UsersType + + return { + "id": (str,), + "type": (UsersType,), + } + + attribute_map = { + "id": "id", + "type": "type", + } + + def __init__(self_, id: Union[str, UnsetType] = unset, type: Union[UsersType, UnsetType] = unset, **kwargs): + """ + Data for the user who created the monitor notification rule. + + :param id: User ID of the monitor notification rule creator. + :type id: str, optional + + :param type: Users resource type. + :type type: UsersType, 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/monitor_notification_rule_resource_type.py b/src/datadog_api_client/v2/model/monitor_notification_rule_resource_type.py new file mode 100644 index 0000000000..2190b52510 --- /dev/null +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_resource_type.py @@ -0,0 +1,37 @@ +# 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 MonitorNotificationRuleResourceType(ModelSimple): + """ + Monitor notification rule resource type. + + :param value: If omitted defaults to "monitor-notification-rule". Must be one of ["monitor-notification-rule"]. + :type value: str + """ + + allowed_values = { + "monitor-notification-rule", + } + MONITOR_NOTIFICATION_RULE: ClassVar["MonitorNotificationRuleResourceType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +MonitorNotificationRuleResourceType.MONITOR_NOTIFICATION_RULE = MonitorNotificationRuleResourceType( + "monitor-notification-rule" +) diff --git a/src/datadog_api_client/v2/model/monitor_notification_rule_response.py b/src/datadog_api_client/v2/model/monitor_notification_rule_response.py new file mode 100644 index 0000000000..e9e96d0eaf --- /dev/null +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_response.py @@ -0,0 +1,61 @@ +# 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.monitor_notification_rule_data import MonitorNotificationRuleData + from datadog_api_client.v2.model.monitor_notification_rule_response_included_item import ( + MonitorNotificationRuleResponseIncludedItem, + ) + from datadog_api_client.v2.model.user import User + + +class MonitorNotificationRuleResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.monitor_notification_rule_data import MonitorNotificationRuleData + from datadog_api_client.v2.model.monitor_notification_rule_response_included_item import ( + MonitorNotificationRuleResponseIncludedItem, + ) + + return { + "data": (MonitorNotificationRuleData,), + "included": ([MonitorNotificationRuleResponseIncludedItem],), + } + + attribute_map = { + "data": "data", + "included": "included", + } + + def __init__( + self_, + data: Union[MonitorNotificationRuleData, UnsetType] = unset, + included: Union[List[Union[MonitorNotificationRuleResponseIncludedItem, User]], UnsetType] = unset, + **kwargs, + ): + """ + A monitor notification rule. + + :param data: Monitor notification rule data. + :type data: MonitorNotificationRuleData, optional + + :param included: Array of objects related to the monitor notification rule that the user requested. + :type included: [MonitorNotificationRuleResponseIncludedItem], 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/monitor_notification_rule_response_attributes.py b/src/datadog_api_client/v2/model/monitor_notification_rule_response_attributes.py new file mode 100644 index 0000000000..298ca6ce2f --- /dev/null +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_response_attributes.py @@ -0,0 +1,91 @@ +# 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, + datetime, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.monitor_notification_rule_filter import MonitorNotificationRuleFilter + from datadog_api_client.v2.model.monitor_notification_rule_filter_tags import MonitorNotificationRuleFilterTags + + +class MonitorNotificationRuleResponseAttributes(ModelNormal): + validations = { + "name": { + "max_length": 1000, + "min_length": 1, + }, + "recipients": { + "max_items": 20, + "min_items": 1, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.monitor_notification_rule_filter import MonitorNotificationRuleFilter + + return { + "created": (datetime,), + "filter": (MonitorNotificationRuleFilter,), + "modified": (datetime,), + "name": (str,), + "recipients": ([str],), + } + + attribute_map = { + "created": "created", + "filter": "filter", + "modified": "modified", + "name": "name", + "recipients": "recipients", + } + + def __init__( + self_, + created: Union[datetime, UnsetType] = unset, + filter: Union[MonitorNotificationRuleFilter, MonitorNotificationRuleFilterTags, UnsetType] = unset, + modified: Union[datetime, UnsetType] = unset, + name: Union[str, UnsetType] = unset, + recipients: Union[List[str], UnsetType] = unset, + **kwargs, + ): + """ + Attributes of the monitor notification rule. + + :param created: Creation time of the monitor notification rule. + :type created: datetime, optional + + :param filter: Filter used to associate the notification rule with monitors. + :type filter: MonitorNotificationRuleFilter, optional + + :param modified: Time the monitor notification rule was last modified. + :type modified: datetime, optional + + :param name: The name of the monitor notification rule. + :type name: str, optional + + :param recipients: A list of recipients to notify. Uses the same format as the monitor ``message`` field. Must not start with an '@'. + :type recipients: [str], optional + """ + if created is not unset: + kwargs["created"] = created + if filter is not unset: + kwargs["filter"] = filter + if modified is not unset: + kwargs["modified"] = modified + if name is not unset: + kwargs["name"] = name + if recipients is not unset: + kwargs["recipients"] = recipients + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/monitor_notification_rule_response_included_item.py b/src/datadog_api_client/v2/model/monitor_notification_rule_response_included_item.py new file mode 100644 index 0000000000..97f66307a5 --- /dev/null +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_response_included_item.py @@ -0,0 +1,47 @@ +# 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 MonitorNotificationRuleResponseIncludedItem(ModelComposed): + def __init__(self, **kwargs): + """ + An object related to a monitor notification rule. + + :param attributes: Attributes of user object returned by the API. + :type attributes: UserAttributes, optional + + :param id: ID of the user. + :type id: str, optional + + :param relationships: Relationships of the user object returned by the API. + :type relationships: UserResponseRelationships, optional + + :param type: Users resource type. + :type type: UsersType, optional + """ + 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.user import User + + return { + "oneOf": [ + User, + ], + } diff --git a/src/datadog_api_client/v2/model/monitor_notification_rule_update_request.py b/src/datadog_api_client/v2/model/monitor_notification_rule_update_request.py new file mode 100644 index 0000000000..8ca562690c --- /dev/null +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_update_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.monitor_notification_rule_update_request_data import ( + MonitorNotificationRuleUpdateRequestData, + ) + + +class MonitorNotificationRuleUpdateRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.monitor_notification_rule_update_request_data import ( + MonitorNotificationRuleUpdateRequestData, + ) + + return { + "data": (MonitorNotificationRuleUpdateRequestData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: MonitorNotificationRuleUpdateRequestData, **kwargs): + """ + Request for updating a monitor notification rule. + + :param data: Object to update a monitor notification rule. + :type data: MonitorNotificationRuleUpdateRequestData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/monitor_notification_rule_update_request_data.py b/src/datadog_api_client/v2/model/monitor_notification_rule_update_request_data.py new file mode 100644 index 0000000000..9e99290e4f --- /dev/null +++ b/src/datadog_api_client/v2/model/monitor_notification_rule_update_request_data.py @@ -0,0 +1,65 @@ +# 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.monitor_notification_rule_attributes import MonitorNotificationRuleAttributes + from datadog_api_client.v2.model.monitor_notification_rule_resource_type import MonitorNotificationRuleResourceType + + +class MonitorNotificationRuleUpdateRequestData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.monitor_notification_rule_attributes import MonitorNotificationRuleAttributes + from datadog_api_client.v2.model.monitor_notification_rule_resource_type import ( + MonitorNotificationRuleResourceType, + ) + + return { + "attributes": (MonitorNotificationRuleAttributes,), + "id": (str,), + "type": (MonitorNotificationRuleResourceType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__( + self_, + attributes: MonitorNotificationRuleAttributes, + id: str, + type: Union[MonitorNotificationRuleResourceType, UnsetType] = unset, + **kwargs, + ): + """ + Object to update a monitor notification rule. + + :param attributes: Attributes of the monitor notification rule. + :type attributes: MonitorNotificationRuleAttributes + + :param id: The ID of the monitor notification rule. + :type id: str + + :param type: Monitor notification rule resource type. + :type type: MonitorNotificationRuleResourceType, optional + """ + if type is not unset: + kwargs["type"] = type + super().__init__(kwargs) + + self_.attributes = attributes + self_.id = id diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 5cea85aa08..a2baede1f9 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -1677,6 +1677,34 @@ MonitorDowntimeMatchResponseAttributes, ) from datadog_api_client.v2.model.monitor_downtime_match_response_data import MonitorDowntimeMatchResponseData +from datadog_api_client.v2.model.monitor_notification_rule_attributes import MonitorNotificationRuleAttributes +from datadog_api_client.v2.model.monitor_notification_rule_create_request import MonitorNotificationRuleCreateRequest +from datadog_api_client.v2.model.monitor_notification_rule_create_request_data import ( + MonitorNotificationRuleCreateRequestData, +) +from datadog_api_client.v2.model.monitor_notification_rule_data import MonitorNotificationRuleData +from datadog_api_client.v2.model.monitor_notification_rule_filter import MonitorNotificationRuleFilter +from datadog_api_client.v2.model.monitor_notification_rule_filter_tags import MonitorNotificationRuleFilterTags +from datadog_api_client.v2.model.monitor_notification_rule_list_response import MonitorNotificationRuleListResponse +from datadog_api_client.v2.model.monitor_notification_rule_relationships import MonitorNotificationRuleRelationships +from datadog_api_client.v2.model.monitor_notification_rule_relationships_created_by import ( + MonitorNotificationRuleRelationshipsCreatedBy, +) +from datadog_api_client.v2.model.monitor_notification_rule_relationships_created_by_data import ( + MonitorNotificationRuleRelationshipsCreatedByData, +) +from datadog_api_client.v2.model.monitor_notification_rule_resource_type import MonitorNotificationRuleResourceType +from datadog_api_client.v2.model.monitor_notification_rule_response import MonitorNotificationRuleResponse +from datadog_api_client.v2.model.monitor_notification_rule_response_attributes import ( + MonitorNotificationRuleResponseAttributes, +) +from datadog_api_client.v2.model.monitor_notification_rule_response_included_item import ( + MonitorNotificationRuleResponseIncludedItem, +) +from datadog_api_client.v2.model.monitor_notification_rule_update_request import MonitorNotificationRuleUpdateRequest +from datadog_api_client.v2.model.monitor_notification_rule_update_request_data import ( + MonitorNotificationRuleUpdateRequestData, +) from datadog_api_client.v2.model.monitor_trigger import MonitorTrigger from datadog_api_client.v2.model.monitor_trigger_wrapper import MonitorTriggerWrapper from datadog_api_client.v2.model.monitor_type import MonitorType @@ -4198,6 +4226,22 @@ "MonitorDowntimeMatchResponse", "MonitorDowntimeMatchResponseAttributes", "MonitorDowntimeMatchResponseData", + "MonitorNotificationRuleAttributes", + "MonitorNotificationRuleCreateRequest", + "MonitorNotificationRuleCreateRequestData", + "MonitorNotificationRuleData", + "MonitorNotificationRuleFilter", + "MonitorNotificationRuleFilterTags", + "MonitorNotificationRuleListResponse", + "MonitorNotificationRuleRelationships", + "MonitorNotificationRuleRelationshipsCreatedBy", + "MonitorNotificationRuleRelationshipsCreatedByData", + "MonitorNotificationRuleResourceType", + "MonitorNotificationRuleResponse", + "MonitorNotificationRuleResponseAttributes", + "MonitorNotificationRuleResponseIncludedItem", + "MonitorNotificationRuleUpdateRequest", + "MonitorNotificationRuleUpdateRequestData", "MonitorTrigger", "MonitorTriggerWrapper", "MonitorType", diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_returns_bad_request_response.frozen b/tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_returns_bad_request_response.frozen new file mode 100644 index 0000000000..454c4bb29a --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_returns_bad_request_response.frozen @@ -0,0 +1 @@ +2025-04-10T10:29:43.940Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_returns_bad_request_response.yaml b/tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_returns_bad_request_response.yaml new file mode 100644 index 0000000000..cce8cd2cc1 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_returns_bad_request_response.yaml @@ -0,0 +1,22 @@ +interactions: +- request: + body: '{"data":{"attributes":{"filter":{"tags":["test:test-create_a_monitor_notification_rule_returns_bad_request_response-1744280983","host:abc"]},"name":"test + rule","recipients":["@slack-test-channel","@jira-test"]},"type":"monitor-notification-rule"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule + response: + body: + string: '{"errors":["Invalid recipients: Recipient handle should not start with + ''@''"]}' + headers: + content-type: + - application/json + status: + code: 400 + message: Bad Request +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_returns_ok_response.frozen new file mode 100644 index 0000000000..86ab3de39b --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_returns_ok_response.frozen @@ -0,0 +1 @@ +2025-04-10T10:29:44.273Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_returns_ok_response.yaml new file mode 100644 index 0000000000..dc45878038 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_monitor_notification_rule_returns_ok_response.yaml @@ -0,0 +1,40 @@ +interactions: +- request: + body: '{"data":{"attributes":{"filter":{"tags":["test:test-create_a_monitor_notification_rule_returns_ok_response-1744280984"]},"name":"test + rule","recipients":["slack-test-channel","jira-test"]},"type":"monitor-notification-rule"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule + response: + body: + string: '{"data":{"type":"monitor-notification-rule","attributes":{"filter":{"tags":["test:test-create_a_monitor_notification_rule_returns_ok_response-1744280984"]},"recipients":["slack-test-channel","jira-test"],"name":"test + rule","created_at":"2025-04-10T10:29:44.595607+00:00","modified_at":"1970-01-01T00:00:00+00:00"},"id":"a3323ef6-2a04-4ef9-8de8-cbcff5c3c203","relationships":{"created_by":{"data":{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0"}}}},"included":[{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0","attributes":{"name":"frog","handle":"frog@datadoghq.com","created_at":"2019-10-02T08:15:39.795051+00:00","modified_at":"2025-04-07T20:19:46.118466+00:00","email":"frog@datadoghq.com","icon":"https://secure.gravatar.com/avatar/28a16dfe36e73b60c1d55872cb0f1172?s=48&d=retro","title":null,"verified":true,"service_account":false,"disabled":false,"allowed_login_methods":[],"status":"Active"}}]} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule/a3323ef6-2a04-4ef9-8de8-cbcff5c3c203 + response: + body: + string: '' + headers: + content-type: + - text/html; charset=utf-8 + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_delete_a_monitor_notification_rule_returns_not_found_response.frozen b/tests/v2/cassettes/test_scenarios/test_delete_a_monitor_notification_rule_returns_not_found_response.frozen new file mode 100644 index 0000000000..2590d462ec --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_delete_a_monitor_notification_rule_returns_not_found_response.frozen @@ -0,0 +1 @@ +2025-04-10T10:29:46.694Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_delete_a_monitor_notification_rule_returns_not_found_response.yaml b/tests/v2/cassettes/test_scenarios/test_delete_a_monitor_notification_rule_returns_not_found_response.yaml new file mode 100644 index 0000000000..769387c1b7 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_delete_a_monitor_notification_rule_returns_not_found_response.yaml @@ -0,0 +1,18 @@ +interactions: +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule/00000000-0000-1234-0000-000000000000 + response: + body: + string: '{"errors":["Monitor Notification Rule not found"]}' + headers: + content-type: + - application/json + status: + code: 404 + message: Not Found +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_delete_a_monitor_notification_rule_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_delete_a_monitor_notification_rule_returns_ok_response.frozen new file mode 100644 index 0000000000..c1dc706f2c --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_delete_a_monitor_notification_rule_returns_ok_response.frozen @@ -0,0 +1 @@ +2025-04-10T10:29:47.053Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_delete_a_monitor_notification_rule_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_delete_a_monitor_notification_rule_returns_ok_response.yaml new file mode 100644 index 0000000000..63e33bbea1 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_delete_a_monitor_notification_rule_returns_ok_response.yaml @@ -0,0 +1,56 @@ +interactions: +- request: + body: '{"data":{"attributes":{"filter":{"tags":["app:test-delete_a_monitor_notification_rule_returns_ok_response-1744280987"]},"name":"test + rule","recipients":["slack-monitor-app"]},"type":"monitor-notification-rule"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule + response: + body: + string: '{"data":{"type":"monitor-notification-rule","relationships":{"created_by":{"data":{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0"}}},"attributes":{"filter":{"tags":["app:test-delete_a_monitor_notification_rule_returns_ok_response-1744280987"]},"created_at":"2025-04-10T10:29:47.326243+00:00","name":"test + rule","recipients":["slack-monitor-app"],"modified_at":"1970-01-01T00:00:00+00:00"},"id":"66e399af-c07e-414d-b4f2-93e196d7b7b7"},"included":[{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0","attributes":{"name":"frog","handle":"frog@datadoghq.com","created_at":"2019-10-02T08:15:39.795051+00:00","modified_at":"2025-04-07T20:19:46.118466+00:00","email":"frog@datadoghq.com","icon":"https://secure.gravatar.com/avatar/28a16dfe36e73b60c1d55872cb0f1172?s=48&d=retro","title":null,"verified":true,"service_account":false,"disabled":false,"allowed_login_methods":[],"status":"Active"}}]} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule/66e399af-c07e-414d-b4f2-93e196d7b7b7 + response: + body: + string: '' + headers: + content-type: + - text/html; charset=utf-8 + status: + code: 204 + message: No Content +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule/66e399af-c07e-414d-b4f2-93e196d7b7b7 + response: + body: + string: '{"errors":["Monitor Notification Rule not found"]}' + headers: + content-type: + - application/json + status: + code: 404 + message: Not Found +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_get_a_monitor_notification_rule_returns_not_found_response.frozen b/tests/v2/cassettes/test_scenarios/test_get_a_monitor_notification_rule_returns_not_found_response.frozen new file mode 100644 index 0000000000..4d52b4ac38 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_get_a_monitor_notification_rule_returns_not_found_response.frozen @@ -0,0 +1 @@ +2025-04-10T10:29:52.213Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_get_a_monitor_notification_rule_returns_not_found_response.yaml b/tests/v2/cassettes/test_scenarios/test_get_a_monitor_notification_rule_returns_not_found_response.yaml new file mode 100644 index 0000000000..2373ba2783 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_get_a_monitor_notification_rule_returns_not_found_response.yaml @@ -0,0 +1,18 @@ +interactions: +- request: + body: null + headers: + accept: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule/00000000-0000-1234-0000-000000000000 + response: + body: + string: '{"errors":["Monitor Notification Rule not found"]}' + headers: + content-type: + - application/json + status: + code: 404 + message: Not Found +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_get_a_monitor_notification_rule_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_get_a_monitor_notification_rule_returns_ok_response.frozen new file mode 100644 index 0000000000..23fa2591c9 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_get_a_monitor_notification_rule_returns_ok_response.frozen @@ -0,0 +1 @@ +2025-04-10T10:29:52.537Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_get_a_monitor_notification_rule_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_get_a_monitor_notification_rule_returns_ok_response.yaml new file mode 100644 index 0000000000..4735413fb7 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_get_a_monitor_notification_rule_returns_ok_response.yaml @@ -0,0 +1,59 @@ +interactions: +- request: + body: '{"data":{"attributes":{"filter":{"tags":["app:test-get_a_monitor_notification_rule_returns_ok_response-1744280992"]},"name":"test + rule","recipients":["slack-monitor-app"]},"type":"monitor-notification-rule"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule + response: + body: + string: '{"data":{"type":"monitor-notification-rule","attributes":{"created_at":"2025-04-10T10:29:52.938158+00:00","filter":{"tags":["app:test-get_a_monitor_notification_rule_returns_ok_response-1744280992"]},"recipients":["slack-monitor-app"],"name":"test + rule","modified_at":"1970-01-01T00:00:00+00:00"},"id":"97afb4ac-6953-445f-9a0a-d225673449a6","relationships":{"created_by":{"data":{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0"}}}},"included":[{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0","attributes":{"name":"frog","handle":"frog@datadoghq.com","created_at":"2019-10-02T08:15:39.795051+00:00","modified_at":"2025-04-07T20:19:46.118466+00:00","email":"frog@datadoghq.com","icon":"https://secure.gravatar.com/avatar/28a16dfe36e73b60c1d55872cb0f1172?s=48&d=retro","title":null,"verified":true,"service_account":false,"disabled":false,"allowed_login_methods":[],"status":"Active"}}]} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +- request: + body: null + headers: + accept: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule/97afb4ac-6953-445f-9a0a-d225673449a6 + response: + body: + string: '{"data":{"type":"monitor-notification-rule","attributes":{"name":"test + rule","created_at":"2025-04-10T10:29:52.938158+00:00","recipients":["slack-monitor-app"],"filter":{"tags":["app:test-get_a_monitor_notification_rule_returns_ok_response-1744280992"]},"modified_at":"2025-04-10T10:29:52.948837+00:00"},"id":"97afb4ac-6953-445f-9a0a-d225673449a6"}} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule/97afb4ac-6953-445f-9a0a-d225673449a6 + response: + body: + string: '' + headers: + content-type: + - text/html; charset=utf-8 + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_get_all_monitor_notification_rules_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_get_all_monitor_notification_rules_returns_ok_response.frozen new file mode 100644 index 0000000000..2681e36773 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_get_all_monitor_notification_rules_returns_ok_response.frozen @@ -0,0 +1 @@ +2025-04-10T10:29:54.937Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_get_all_monitor_notification_rules_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_get_all_monitor_notification_rules_returns_ok_response.yaml new file mode 100644 index 0000000000..240a547129 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_get_all_monitor_notification_rules_returns_ok_response.yaml @@ -0,0 +1,59 @@ +interactions: +- request: + body: '{"data":{"attributes":{"filter":{"tags":["app:test-get_all_monitor_notification_rules_returns_ok_response-1744280994"]},"name":"test + rule","recipients":["slack-monitor-app"]},"type":"monitor-notification-rule"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule + response: + body: + string: '{"data":{"type":"monitor-notification-rule","attributes":{"name":"test + rule","filter":{"tags":["app:test-get_all_monitor_notification_rules_returns_ok_response-1744280994"]},"recipients":["slack-monitor-app"],"modified_at":"1970-01-01T00:00:00+00:00","created_at":"2025-04-10T10:29:55.362004+00:00"},"relationships":{"created_by":{"data":{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0"}}},"id":"b7122864-6517-45d3-8dc1-f226a08dd8f4"},"included":[{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0","attributes":{"name":"frog","handle":"frog@datadoghq.com","created_at":"2019-10-02T08:15:39.795051+00:00","modified_at":"2025-04-07T20:19:46.118466+00:00","email":"frog@datadoghq.com","icon":"https://secure.gravatar.com/avatar/28a16dfe36e73b60c1d55872cb0f1172?s=48&d=retro","title":null,"verified":true,"service_account":false,"disabled":false,"allowed_login_methods":[],"status":"Active"}}]} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +- request: + body: null + headers: + accept: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule + response: + body: + string: '{"data":[{"type":"monitor-notification-rule","attributes":{"filter":{"tags":["app:test-get_all_monitor_notification_rules_returns_ok_response-1744280994"]},"name":"test + rule","recipients":["slack-monitor-app"],"modified_at":"2025-04-10T10:29:55.373154+00:00","created_at":"2025-04-10T10:29:55.362004+00:00"},"id":"b7122864-6517-45d3-8dc1-f226a08dd8f4"}]} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule/b7122864-6517-45d3-8dc1-f226a08dd8f4 + response: + body: + string: '' + headers: + content-type: + - text/html; charset=utf-8 + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_bad_request_response.frozen b/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_bad_request_response.frozen new file mode 100644 index 0000000000..c547acf2ee --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_bad_request_response.frozen @@ -0,0 +1 @@ +2025-04-10T10:29:56.210Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_bad_request_response.yaml b/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_bad_request_response.yaml new file mode 100644 index 0000000000..525bb7b3ef --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_bad_request_response.yaml @@ -0,0 +1,60 @@ +interactions: +- request: + body: '{"data":{"attributes":{"filter":{"tags":["app:test-update_a_monitor_notification_rule_returns_bad_request_response-1744280996"]},"name":"test + rule","recipients":["slack-monitor-app"]},"type":"monitor-notification-rule"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule + response: + body: + string: '{"data":{"type":"monitor-notification-rule","attributes":{"filter":{"tags":["app:test-update_a_monitor_notification_rule_returns_bad_request_response-1744280996"]},"created_at":"2025-04-10T10:29:56.523436+00:00","recipients":["slack-monitor-app"],"name":"test + rule","modified_at":"1970-01-01T00:00:00+00:00"},"id":"f26ba0a6-1e84-4984-b061-4172a25a1332","relationships":{"created_by":{"data":{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0"}}}},"included":[{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0","attributes":{"name":"frog","handle":"frog@datadoghq.com","created_at":"2019-10-02T08:15:39.795051+00:00","modified_at":"2025-04-07T20:19:46.118466+00:00","email":"frog@datadoghq.com","icon":"https://secure.gravatar.com/avatar/28a16dfe36e73b60c1d55872cb0f1172?s=48&d=retro","title":null,"verified":true,"service_account":false,"disabled":false,"allowed_login_methods":[],"status":"Active"}}]} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +- request: + body: '{"data":{"attributes":{"filter":{"tags":["test:test-update_a_monitor_notification_rule_returns_bad_request_response-1744280996","host:abc"]},"name":"updated + rule","recipients":["@slack-test-channel"]},"id":"f26ba0a6-1e84-4984-b061-4172a25a1332","type":"monitor-notification-rule"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: PATCH + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule/f26ba0a6-1e84-4984-b061-4172a25a1332 + response: + body: + string: '{"errors":["Invalid recipients: Recipient handle should not start with + ''@''"]}' + headers: + content-type: + - application/json + status: + code: 400 + message: Bad Request +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule/f26ba0a6-1e84-4984-b061-4172a25a1332 + response: + body: + string: '' + headers: + content-type: + - text/html; charset=utf-8 + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_not_found_response.frozen b/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_not_found_response.frozen new file mode 100644 index 0000000000..2eae355308 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_not_found_response.frozen @@ -0,0 +1 @@ +2025-04-10T10:29:57.263Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_not_found_response.yaml b/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_not_found_response.yaml new file mode 100644 index 0000000000..8464bd0b74 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_not_found_response.yaml @@ -0,0 +1,21 @@ +interactions: +- request: + body: '{"data":{"attributes":{"filter":{"tags":["test:test-update_a_monitor_notification_rule_returns_not_found_response-1744280997","host:abc"]},"name":"updated + rule","recipients":["slack-test-channel","jira-test"]},"id":"00000000-0000-1234-0000-000000000000","type":"monitor-notification-rule"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: PATCH + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule/00000000-0000-1234-0000-000000000000 + response: + body: + string: '{"errors":["Monitor Notification Rule not found"]}' + headers: + content-type: + - application/json + status: + code: 404 + message: Not Found +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_ok_response.frozen new file mode 100644 index 0000000000..b7d42a4489 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_ok_response.frozen @@ -0,0 +1 @@ +2025-04-10T10:29:57.629Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_ok_response.yaml new file mode 100644 index 0000000000..917ed73291 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_update_a_monitor_notification_rule_returns_ok_response.yaml @@ -0,0 +1,62 @@ +interactions: +- request: + body: '{"data":{"attributes":{"filter":{"tags":["app:test-update_a_monitor_notification_rule_returns_ok_response-1744280997"]},"name":"test + rule","recipients":["slack-monitor-app"]},"type":"monitor-notification-rule"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule + response: + body: + string: '{"data":{"type":"monitor-notification-rule","attributes":{"name":"test + rule","recipients":["slack-monitor-app"],"modified_at":"1970-01-01T00:00:00+00:00","filter":{"tags":["app:test-update_a_monitor_notification_rule_returns_ok_response-1744280997"]},"created_at":"2025-04-10T10:29:57.930349+00:00"},"id":"da2c8a3b-94ea-49be-a85b-39c5eff99d6a","relationships":{"created_by":{"data":{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0"}}}},"included":[{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0","attributes":{"name":"frog","handle":"frog@datadoghq.com","created_at":"2019-10-02T08:15:39.795051+00:00","modified_at":"2025-04-07T20:19:46.118466+00:00","email":"frog@datadoghq.com","icon":"https://secure.gravatar.com/avatar/28a16dfe36e73b60c1d55872cb0f1172?s=48&d=retro","title":null,"verified":true,"service_account":false,"disabled":false,"allowed_login_methods":[],"status":"Active"}}]} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +- request: + body: '{"data":{"attributes":{"filter":{"tags":["test:test-update_a_monitor_notification_rule_returns_ok_response-1744280997","host:abc"]},"name":"updated + rule","recipients":["slack-test-channel"]},"id":"da2c8a3b-94ea-49be-a85b-39c5eff99d6a","type":"monitor-notification-rule"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: PATCH + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule/da2c8a3b-94ea-49be-a85b-39c5eff99d6a + response: + body: + string: '{"data":{"type":"monitor-notification-rule","id":"da2c8a3b-94ea-49be-a85b-39c5eff99d6a","attributes":{"modified_at":"2025-04-10T10:29:58.320928+00:00","recipients":["slack-test-channel"],"name":"updated + rule","filter":{"tags":["test:test-update_a_monitor_notification_rule_returns_ok_response-1744280997","host:abc"]},"created_at":"2025-04-10T10:29:57.930349+00:00"},"relationships":{"created_by":{"data":{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0"}}}},"included":[{"type":"users","id":"3ad549bf-eba0-11e9-a77a-0705486660d0","attributes":{"name":"frog","handle":"frog@datadoghq.com","created_at":"2019-10-02T08:15:39.795051+00:00","modified_at":"2025-04-07T20:19:46.118466+00:00","email":"frog@datadoghq.com","icon":"https://secure.gravatar.com/avatar/28a16dfe36e73b60c1d55872cb0f1172?s=48&d=retro","title":null,"verified":true,"service_account":false,"disabled":false,"allowed_login_methods":[],"status":"Active"}}]} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule/da2c8a3b-94ea-49be-a85b-39c5eff99d6a + response: + body: + string: '' + headers: + content-type: + - text/html; charset=utf-8 + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/features/given.json b/tests/v2/features/given.json index 96c49b6166..9cd4b0450a 100644 --- a/tests/v2/features/given.json +++ b/tests/v2/features/given.json @@ -436,6 +436,18 @@ "tag": "Metrics", "operationId": "CreateTagConfiguration" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"monitor-notification-rule\",\n \"attributes\": {\n \"name\":\"test rule\",\n \"filter\": {\n \"tags\": [\n \"app:{{ unique_lower }}\"\n ]\n },\n \"recipients\":[\n \"slack-monitor-app\"\n ]\n }\n }\n}" + } + ], + "step": "there is a valid \"monitor_notification_rule\" in the system", + "key": "monitor_notification_rule", + "tag": "Monitors", + "operationId": "CreateMonitorNotificationRule" + }, { "parameters": [ { diff --git a/tests/v2/features/monitors.feature b/tests/v2/features/monitors.feature index 7585d0663d..5620258697 100644 --- a/tests/v2/features/monitors.feature +++ b/tests/v2/features/monitors.feature @@ -29,6 +29,23 @@ Feature: Monitors And the response "data.attributes.policy.tag_key" is equal to "{{ unique_lower_alnum }}" And the response "data.attributes.policy.valid_tag_values" is equal to ["prod", "staging"] + @skip-validation @team:DataDog/monitor-app + Scenario: Create a monitor notification rule returns "Bad Request" response + Given operation "CreateMonitorNotificationRule" enabled + And new "CreateMonitorNotificationRule" request + And body with value {"data": {"attributes": {"filter": {"tags": ["test:{{ unique_lower }}", "host:abc"]}, "name": "test rule", "recipients": ["@slack-test-channel", "@jira-test"]}, "type": "monitor-notification-rule"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/monitor-app + Scenario: Create a monitor notification rule returns "OK" response + Given operation "CreateMonitorNotificationRule" enabled + And new "CreateMonitorNotificationRule" request + And body with value {"data": {"attributes": {"filter": {"tags": ["test:{{ unique_lower }}"]}, "name": "test rule", "recipients": ["slack-test-channel", "jira-test"]}, "type": "monitor-notification-rule"}} + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.name" is equal to "test rule" + @team:DataDog/monitor-app Scenario: Delete a monitor configuration policy returns "Bad Request" response Given new "DeleteMonitorConfigPolicy" request @@ -51,6 +68,23 @@ Feature: Monitors When the request is sent Then the response status is 204 OK + @team:DataDog/monitor-app + Scenario: Delete a monitor notification rule returns "Not Found" response + Given operation "DeleteMonitorNotificationRule" enabled + And new "DeleteMonitorNotificationRule" request + And request contains "rule_id" parameter with value "00000000-0000-1234-0000-000000000000" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/monitor-app + Scenario: Delete a monitor notification rule returns "OK" response + Given operation "DeleteMonitorNotificationRule" enabled + And there is a valid "monitor_notification_rule" in the system + And new "DeleteMonitorNotificationRule" request + And request contains "rule_id" parameter from "monitor_notification_rule.data.id" + When the request is sent + Then the response status is 204 OK + @team:DataDog/monitor-app Scenario: Edit a monitor configuration policy returns "Not Found" response Given new "UpdateMonitorConfigPolicy" request @@ -102,6 +136,24 @@ Feature: Monitors And the response "data.attributes.policy.tag_key" is equal to "{{ unique_lower_alnum }}" And the response "data.attributes.policy.valid_tag_values" is equal to ["prod", "staging"] + @team:DataDog/monitor-app + Scenario: Get a monitor notification rule returns "Not Found" response + Given operation "GetMonitorNotificationRule" enabled + And new "GetMonitorNotificationRule" request + And request contains "rule_id" parameter with value "00000000-0000-1234-0000-000000000000" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/monitor-app + Scenario: Get a monitor notification rule returns "OK" response + Given operation "GetMonitorNotificationRule" enabled + And there is a valid "monitor_notification_rule" in the system + And new "GetMonitorNotificationRule" request + And request contains "rule_id" parameter from "monitor_notification_rule.data.id" + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.name" is equal to "test rule" + @team:DataDog/monitor-app Scenario: Get all monitor configuration policies returns "OK" response Given there is a valid "monitor_configuration_policy" in the system @@ -113,3 +165,43 @@ Feature: Monitors And the response "data" has item with field "attributes.policy_type" with value "tag" And the response "data" has item with field "attributes.policy.tag_key" with value "{{ unique_lower_alnum }}" And the response "data" has item with field "attributes.policy.valid_tag_values" with value ["prod", "staging"] + + @team:DataDog/monitor-app + Scenario: Get all monitor notification rules returns "OK" response + Given operation "GetMonitorNotificationRules" enabled + And there is a valid "monitor_notification_rule" in the system + And new "GetMonitorNotificationRules" request + When the request is sent + Then the response status is 200 OK + And the response "data" has length 1 + And the response "data" has item with field "attributes.name" with value "test rule" + + @skip-validation @team:DataDog/monitor-app + Scenario: Update a monitor notification rule returns "Bad Request" response + Given operation "UpdateMonitorNotificationRule" enabled + And there is a valid "monitor_notification_rule" in the system + And new "UpdateMonitorNotificationRule" request + And request contains "rule_id" parameter from "monitor_notification_rule.data.id" + And body with value {"data": {"attributes": {"filter": {"tags": ["test:{{ unique_lower }}", "host:abc"]}, "name": "updated rule", "recipients": ["@slack-test-channel"]}, "id": "{{ monitor_notification_rule.data.id }}", "type": "monitor-notification-rule"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/monitor-app + Scenario: Update a monitor notification rule returns "Not Found" response + Given operation "UpdateMonitorNotificationRule" enabled + And new "UpdateMonitorNotificationRule" request + And request contains "rule_id" parameter with value "00000000-0000-1234-0000-000000000000" + And body with value {"data": {"attributes": {"filter": {"tags": ["test:{{ unique_lower }}", "host:abc"]}, "name": "updated rule", "recipients": ["slack-test-channel", "jira-test"]}, "id": "00000000-0000-1234-0000-000000000000", "type": "monitor-notification-rule"}} + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/monitor-app + Scenario: Update a monitor notification rule returns "OK" response + Given operation "UpdateMonitorNotificationRule" enabled + And there is a valid "monitor_notification_rule" in the system + And new "UpdateMonitorNotificationRule" request + And request contains "rule_id" parameter from "monitor_notification_rule.data.id" + And body with value {"data": {"attributes": {"filter": {"tags": ["test:{{ unique_lower }}", "host:abc"]}, "name": "updated rule", "recipients": ["slack-test-channel"]}, "id": "{{ monitor_notification_rule.data.id }}", "type": "monitor-notification-rule"}} + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.name" is equal to "updated rule" diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index 333884a2f3..86a9a72855 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -1671,6 +1671,43 @@ "type": "safe" } }, + "GetMonitorNotificationRules": { + "tag": "Monitors", + "undo": { + "type": "safe" + } + }, + "CreateMonitorNotificationRule": { + "tag": "Monitors", + "undo": { + "operationId": "DeleteMonitorNotificationRule", + "parameters": [ + { + "name": "rule_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteMonitorNotificationRule": { + "tag": "Monitors", + "undo": { + "type": "idempotent" + } + }, + "GetMonitorNotificationRule": { + "tag": "Monitors", + "undo": { + "type": "safe" + } + }, + "UpdateMonitorNotificationRule": { + "tag": "Monitors", + "undo": { + "type": "idempotent" + } + }, "ListMonitorConfigPolicies": { "tag": "Monitors", "undo": {