From b66a3ce34109fc4e050a37dd048f918eb341946e Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Thu, 20 Nov 2025 20:37:41 +0000 Subject: [PATCH] Add filter.scope to Monitor Notification Rules (#2774) Co-authored-by: ci.datadog-api-spec --- .generator/schemas/v2/openapi.yaml | 42 +++++-- ...rule-with-scope-returns-OK-response.frozen | 1 + ...on-rule-with-scope-returns-OK-response.yml | 47 ++++++++ ...rule-with-scope-returns-OK-response.frozen | 1 + ...on-rule-with-scope-returns-OK-response.yml | 74 ++++++++++++ ...reateMonitorNotificationRule_1379932371.rb | 21 ++++ ...pdateMonitorNotificationRule_1446058210.rb | 24 ++++ features/v2/monitors.feature | 18 +++ lib/datadog_api_client/inflector.rb | 1 + .../monitor_notification_rule_attributes.rb | 4 +- .../monitor_notification_rule_condition.rb | 2 +- ...otification_rule_conditional_recipients.rb | 4 +- .../monitor_notification_rule_filter.rb | 3 +- .../monitor_notification_rule_filter_scope.rb | 106 ++++++++++++++++++ .../monitor_notification_rule_filter_tags.rb | 4 +- ...r_notification_rule_response_attributes.rb | 4 +- 16 files changed, 335 insertions(+), 21 deletions(-) create mode 100644 cassettes/features/v2/monitors/Create-a-monitor-notification-rule-with-scope-returns-OK-response.frozen create mode 100644 cassettes/features/v2/monitors/Create-a-monitor-notification-rule-with-scope-returns-OK-response.yml create mode 100644 cassettes/features/v2/monitors/Update-a-monitor-notification-rule-with-scope-returns-OK-response.frozen create mode 100644 cassettes/features/v2/monitors/Update-a-monitor-notification-rule-with-scope-returns-OK-response.yml create mode 100644 examples/v2/monitors/CreateMonitorNotificationRule_1379932371.rb create mode 100644 examples/v2/monitors/UpdateMonitorNotificationRule_1446058210.rb create mode 100644 lib/datadog_api_client/v2/models/monitor_notification_rule_filter_scope.rb diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index d2781f328c87..6e4cbaacff99 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -32691,15 +32691,23 @@ components: properties: recipients: $ref: '#/components/schemas/MonitorNotificationRuleRecipients' + description: A list of recipients to notify. Uses the same format as the + monitor `message` field. Must not start with an '@'. scope: - $ref: '#/components/schemas/MonitorNotificationRuleScope' + $ref: '#/components/schemas/MonitorNotificationRuleConditionScope' required: - scope - recipients type: object + MonitorNotificationRuleConditionScope: + description: The scope to which the monitor applied. + example: transition_type:alert + maxLength: 3000 + minLength: 1 + type: string MonitorNotificationRuleConditionalRecipients: description: Use conditional recipients to define different recipients for different - situations. + situations. Cannot be used with `recipients`. properties: conditions: description: Conditions of the notification rule. @@ -32749,12 +32757,30 @@ components: description: Filter used to associate the notification rule with monitors. oneOf: - $ref: '#/components/schemas/MonitorNotificationRuleFilterTags' + - $ref: '#/components/schemas/MonitorNotificationRuleFilterScope' + MonitorNotificationRuleFilterScope: + additionalProperties: false + description: Filter monitor notifications. A monitor notification must match + the scope. + properties: + scope: + description: A scope composed of one or several key:value pairs, which can + be used to filter monitor notifications on monitor and group tags. + example: service:(foo OR bar) AND team:test NOT environment:staging + maxLength: 3000 + minLength: 1 + type: string + required: + - scope + type: object MonitorNotificationRuleFilterTags: additionalProperties: false - description: Filter monitors by tags. Monitors must match all tags. + description: Filter monitor notifications by tags. A monitor notification must + match all tags. properties: tags: - description: A list of monitor tags. + description: A list of tags (key:value pairs), which can be used to filter + monitor notifications on monitor and group tags. example: - team:product - host:abc @@ -32794,7 +32820,7 @@ components: type: string MonitorNotificationRuleRecipients: description: A list of recipients to notify. Uses the same format as the monitor - `message` field. Must not start with an '@'. + `message` field. Must not start with an '@'. Cannot be used with `conditional_recipients`. example: - slack-test-channel - jira-test @@ -32877,12 +32903,6 @@ components: description: An object related to a monitor notification rule. oneOf: - $ref: '#/components/schemas/User' - MonitorNotificationRuleScope: - description: The scope to which the monitor applied. - example: transition_type:alert - maxLength: 3000 - minLength: 1 - type: string MonitorNotificationRuleUpdateRequest: description: Request for updating a monitor notification rule. properties: diff --git a/cassettes/features/v2/monitors/Create-a-monitor-notification-rule-with-scope-returns-OK-response.frozen b/cassettes/features/v2/monitors/Create-a-monitor-notification-rule-with-scope-returns-OK-response.frozen new file mode 100644 index 000000000000..94917c9e8b9e --- /dev/null +++ b/cassettes/features/v2/monitors/Create-a-monitor-notification-rule-with-scope-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-11-11T21:28:39.129Z \ No newline at end of file diff --git a/cassettes/features/v2/monitors/Create-a-monitor-notification-rule-with-scope-returns-OK-response.yml b/cassettes/features/v2/monitors/Create-a-monitor-notification-rule-with-scope-returns-OK-response.yml new file mode 100644 index 000000000000..63232f63edf3 --- /dev/null +++ b/cassettes/features/v2/monitors/Create-a-monitor-notification-rule-with-scope-returns-OK-response.yml @@ -0,0 +1,47 @@ +http_interactions: +- recorded_at: Tue, 11 Nov 2025 21:28:39 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"filter":{"scope":"test:test-create_a_monitor_notification_rule_with_scope_returns_ok_response-1762896519"},"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: + encoding: UTF-8 + string: '{"data":{"type":"monitor-notification-rule","attributes":{"modified_at":"1970-01-01T00:00:00+00:00","filter":{"scope":"test:test-create_a_monitor_notification_rule_with_scope_returns_ok_response-1762896519"},"name":"test + rule","recipients":["slack-test-channel","jira-test"],"created_at":"2025-11-11T21:28:40.032148+00:00"},"relationships":{"created_by":{"data":{"type":"users","id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"}}},"id":"bbea2907-c191-48d0-9e0f-1ec5881ee37c"},"included":[{"type":"users","id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","attributes":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","created_at":"2020-12-29T22:58:44.733921+00:00","modified_at":"2021-04-27T13:54:01.547888+00:00","email":"team-intg-tools-libs-spam@datadoghq.com","icon":"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro","title":null,"verified":true,"service_account":true,"disabled":false,"allowed_login_methods":[],"status":"Active","last_login_time":null}}]} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +- recorded_at: Tue, 11 Nov 2025 21:28:39 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule/bbea2907-c191-48d0-9e0f-1ec5881ee37c + response: + body: + encoding: UTF-8 + string: '' + headers: + Content-Type: + - text/html; charset=utf-8 + status: + code: 204 + message: No Content +recorded_with: VCR 6.0.0 diff --git a/cassettes/features/v2/monitors/Update-a-monitor-notification-rule-with-scope-returns-OK-response.frozen b/cassettes/features/v2/monitors/Update-a-monitor-notification-rule-with-scope-returns-OK-response.frozen new file mode 100644 index 000000000000..ab91f3c3d086 --- /dev/null +++ b/cassettes/features/v2/monitors/Update-a-monitor-notification-rule-with-scope-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-11-11T21:28:40.357Z \ No newline at end of file diff --git a/cassettes/features/v2/monitors/Update-a-monitor-notification-rule-with-scope-returns-OK-response.yml b/cassettes/features/v2/monitors/Update-a-monitor-notification-rule-with-scope-returns-OK-response.yml new file mode 100644 index 000000000000..e4f7214e7171 --- /dev/null +++ b/cassettes/features/v2/monitors/Update-a-monitor-notification-rule-with-scope-returns-OK-response.yml @@ -0,0 +1,74 @@ +http_interactions: +- recorded_at: Tue, 11 Nov 2025 21:28:40 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"filter":{"tags":["app:test-update_a_monitor_notification_rule_with_scope_returns_ok_response-1762896520"]},"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: + encoding: UTF-8 + string: '{"data":{"type":"monitor-notification-rule","attributes":{"recipients":["slack-monitor-app"],"modified_at":"1970-01-01T00:00:00+00:00","created_at":"2025-11-11T21:28:40.540848+00:00","name":"test + rule","filter":{"tags":["app:test-update_a_monitor_notification_rule_with_scope_returns_ok_response-1762896520"]}},"relationships":{"created_by":{"data":{"type":"users","id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"}}},"id":"827442a0-5d3e-408c-a930-7ac44775fff1"},"included":[{"type":"users","id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","attributes":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","created_at":"2020-12-29T22:58:44.733921+00:00","modified_at":"2021-04-27T13:54:01.547888+00:00","email":"team-intg-tools-libs-spam@datadoghq.com","icon":"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro","title":null,"verified":true,"service_account":true,"disabled":false,"allowed_login_methods":[],"status":"Active","last_login_time":null}}]} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +- recorded_at: Tue, 11 Nov 2025 21:28:40 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"filter":{"scope":"test:test-update_a_monitor_notification_rule_with_scope_returns_ok_response-1762896520"},"name":"updated + rule","recipients":["slack-test-channel"]},"id":"827442a0-5d3e-408c-a930-7ac44775fff1","type":"monitor-notification-rule"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: PATCH + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule/827442a0-5d3e-408c-a930-7ac44775fff1 + response: + body: + encoding: UTF-8 + string: '{"data":{"type":"monitor-notification-rule","attributes":{"filter":{"scope":"test:test-update_a_monitor_notification_rule_with_scope_returns_ok_response-1762896520"},"recipients":["slack-test-channel"],"created_at":"2025-11-11T21:28:40.540848+00:00","name":"updated + rule","modified_at":"2025-11-11T21:28:40.815544+00:00"},"id":"827442a0-5d3e-408c-a930-7ac44775fff1","relationships":{"created_by":{"data":{"type":"users","id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"}}}},"included":[{"type":"users","id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","attributes":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","created_at":"2020-12-29T22:58:44.733921+00:00","modified_at":"2021-04-27T13:54:01.547888+00:00","email":"team-intg-tools-libs-spam@datadoghq.com","icon":"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro","title":null,"verified":true,"service_account":true,"disabled":false,"allowed_login_methods":[],"status":"Active","last_login_time":null}}]} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +- recorded_at: Tue, 11 Nov 2025 21:28:40 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/monitor/notification_rule/827442a0-5d3e-408c-a930-7ac44775fff1 + response: + body: + encoding: UTF-8 + string: '' + headers: + Content-Type: + - text/html; charset=utf-8 + status: + code: 204 + message: No Content +recorded_with: VCR 6.0.0 diff --git a/examples/v2/monitors/CreateMonitorNotificationRule_1379932371.rb b/examples/v2/monitors/CreateMonitorNotificationRule_1379932371.rb new file mode 100644 index 000000000000..8dd4f365f97b --- /dev/null +++ b/examples/v2/monitors/CreateMonitorNotificationRule_1379932371.rb @@ -0,0 +1,21 @@ +# Create a monitor notification rule with scope returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::MonitorsAPI.new + +body = DatadogAPIClient::V2::MonitorNotificationRuleCreateRequest.new({ + data: DatadogAPIClient::V2::MonitorNotificationRuleCreateRequestData.new({ + attributes: DatadogAPIClient::V2::MonitorNotificationRuleAttributes.new({ + filter: DatadogAPIClient::V2::MonitorNotificationRuleFilterScope.new({ + scope: "test:example-monitor", + }), + name: "test rule", + recipients: [ + "slack-test-channel", + "jira-test", + ], + }), + type: DatadogAPIClient::V2::MonitorNotificationRuleResourceType::MONITOR_NOTIFICATION_RULE, + }), +}) +p api_instance.create_monitor_notification_rule(body) diff --git a/examples/v2/monitors/UpdateMonitorNotificationRule_1446058210.rb b/examples/v2/monitors/UpdateMonitorNotificationRule_1446058210.rb new file mode 100644 index 000000000000..6a046cf0935b --- /dev/null +++ b/examples/v2/monitors/UpdateMonitorNotificationRule_1446058210.rb @@ -0,0 +1,24 @@ +# Update a monitor notification rule with scope returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::MonitorsAPI.new + +# there is a valid "monitor_notification_rule" in the system +MONITOR_NOTIFICATION_RULE_DATA_ID = ENV["MONITOR_NOTIFICATION_RULE_DATA_ID"] + +body = DatadogAPIClient::V2::MonitorNotificationRuleUpdateRequest.new({ + data: DatadogAPIClient::V2::MonitorNotificationRuleUpdateRequestData.new({ + attributes: DatadogAPIClient::V2::MonitorNotificationRuleAttributes.new({ + filter: DatadogAPIClient::V2::MonitorNotificationRuleFilterScope.new({ + scope: "test:example-monitor", + }), + name: "updated rule", + recipients: [ + "slack-test-channel", + ], + }), + id: MONITOR_NOTIFICATION_RULE_DATA_ID, + type: DatadogAPIClient::V2::MonitorNotificationRuleResourceType::MONITOR_NOTIFICATION_RULE, + }), +}) +p api_instance.update_monitor_notification_rule(MONITOR_NOTIFICATION_RULE_DATA_ID, body) diff --git a/features/v2/monitors.feature b/features/v2/monitors.feature index 346a646f83ba..e84062637c1a 100644 --- a/features/v2/monitors.feature +++ b/features/v2/monitors.feature @@ -52,6 +52,14 @@ Feature: Monitors Then the response status is 200 OK And the response "data.attributes.name" is equal to "test rule" + @team:DataDog/monitor-app + Scenario: Create a monitor notification rule with scope returns "OK" response + Given new "CreateMonitorNotificationRule" request + And body with value {"data": {"attributes": {"filter": {"scope": "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" + @skip-validation @team:DataDog/monitor-app Scenario: Create a monitor user template returns "Bad Request" response Given new "CreateMonitorUserTemplate" request @@ -272,6 +280,16 @@ Feature: Monitors Then the response status is 200 OK And the response "data.attributes.name" is equal to "updated rule" + @team:DataDog/monitor-app + Scenario: Update a monitor notification rule with scope returns "OK" response + Given 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": {"scope": "test:{{ unique_lower }}"}, "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" + @skip-validation @team:DataDog/monitor-app Scenario: Update a monitor user template to a new version returns "Bad Request" response Given there is a valid "monitor_user_template" in the system diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index bb8ef80c0422..427fdcf8659c 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -2981,6 +2981,7 @@ def overrides "v2.monitor_notification_rule_create_request_data" => "MonitorNotificationRuleCreateRequestData", "v2.monitor_notification_rule_data" => "MonitorNotificationRuleData", "v2.monitor_notification_rule_filter" => "MonitorNotificationRuleFilter", + "v2.monitor_notification_rule_filter_scope" => "MonitorNotificationRuleFilterScope", "v2.monitor_notification_rule_filter_tags" => "MonitorNotificationRuleFilterTags", "v2.monitor_notification_rule_list_response" => "MonitorNotificationRuleListResponse", "v2.monitor_notification_rule_relationships" => "MonitorNotificationRuleRelationships", diff --git a/lib/datadog_api_client/v2/models/monitor_notification_rule_attributes.rb b/lib/datadog_api_client/v2/models/monitor_notification_rule_attributes.rb index dc00970bc9fb..2afba013e71c 100644 --- a/lib/datadog_api_client/v2/models/monitor_notification_rule_attributes.rb +++ b/lib/datadog_api_client/v2/models/monitor_notification_rule_attributes.rb @@ -21,7 +21,7 @@ module DatadogAPIClient::V2 class MonitorNotificationRuleAttributes include BaseGenericModel - # Use conditional recipients to define different recipients for different situations. + # Use conditional recipients to define different recipients for different situations. Cannot be used with `recipients`. attr_accessor :conditional_recipients # Filter used to associate the notification rule with monitors. @@ -30,7 +30,7 @@ class MonitorNotificationRuleAttributes # The name of the monitor notification rule. attr_reader :name - # A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'. + # A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'. Cannot be used with `conditional_recipients`. attr_reader :recipients # Attribute mapping from ruby-style variable name to JSON key. diff --git a/lib/datadog_api_client/v2/models/monitor_notification_rule_condition.rb b/lib/datadog_api_client/v2/models/monitor_notification_rule_condition.rb index 484d7221815d..6775ce13e22b 100644 --- a/lib/datadog_api_client/v2/models/monitor_notification_rule_condition.rb +++ b/lib/datadog_api_client/v2/models/monitor_notification_rule_condition.rb @@ -21,7 +21,7 @@ module DatadogAPIClient::V2 class MonitorNotificationRuleCondition include BaseGenericModel - # A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'. + # A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'. Cannot be used with `conditional_recipients`. attr_reader :recipients # The scope to which the monitor applied. diff --git a/lib/datadog_api_client/v2/models/monitor_notification_rule_conditional_recipients.rb b/lib/datadog_api_client/v2/models/monitor_notification_rule_conditional_recipients.rb index 90cc142ac339..007d9b2689a0 100644 --- a/lib/datadog_api_client/v2/models/monitor_notification_rule_conditional_recipients.rb +++ b/lib/datadog_api_client/v2/models/monitor_notification_rule_conditional_recipients.rb @@ -17,14 +17,14 @@ require 'time' module DatadogAPIClient::V2 - # Use conditional recipients to define different recipients for different situations. + # Use conditional recipients to define different recipients for different situations. Cannot be used with `recipients`. class MonitorNotificationRuleConditionalRecipients include BaseGenericModel # Conditions of the notification rule. attr_reader :conditions - # A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'. + # A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'. Cannot be used with `conditional_recipients`. attr_reader :fallback_recipients attr_accessor :additional_properties diff --git a/lib/datadog_api_client/v2/models/monitor_notification_rule_filter.rb b/lib/datadog_api_client/v2/models/monitor_notification_rule_filter.rb index 85c38f33fad0..2787c559fd7d 100644 --- a/lib/datadog_api_client/v2/models/monitor_notification_rule_filter.rb +++ b/lib/datadog_api_client/v2/models/monitor_notification_rule_filter.rb @@ -26,7 +26,8 @@ class << self # List of class defined in oneOf (OpenAPI v3) def openapi_one_of [ - :'MonitorNotificationRuleFilterTags' + :'MonitorNotificationRuleFilterTags', + :'MonitorNotificationRuleFilterScope' ] end # Builds the object diff --git a/lib/datadog_api_client/v2/models/monitor_notification_rule_filter_scope.rb b/lib/datadog_api_client/v2/models/monitor_notification_rule_filter_scope.rb new file mode 100644 index 000000000000..438d9c5ac232 --- /dev/null +++ b/lib/datadog_api_client/v2/models/monitor_notification_rule_filter_scope.rb @@ -0,0 +1,106 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Filter monitor notifications. A monitor notification must match the scope. + class MonitorNotificationRuleFilterScope + include BaseGenericModel + + # A scope composed of one or several key:value pairs, which can be used to filter monitor notifications on monitor and group tags. + attr_reader :scope + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'scope' => :'scope' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'scope' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::MonitorNotificationRuleFilterScope` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::MonitorNotificationRuleFilterScope`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'scope') + self.scope = attributes[:'scope'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @scope.nil? + return false if @scope.to_s.length > 3000 + return false if @scope.to_s.length < 1 + true + end + + # Custom attribute writer method with validation + # @param scope [Object] Object to be assigned + # @!visibility private + def scope=(scope) + if scope.nil? + fail ArgumentError, 'invalid value for "scope", scope cannot be nil.' + end + if scope.to_s.length > 3000 + fail ArgumentError, 'invalid value for "scope", the character length must be smaller than or equal to 3000.' + end + if scope.to_s.length < 1 + fail ArgumentError, 'invalid value for "scope", the character length must be great than or equal to 1.' + end + @scope = scope + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + scope == o.scope + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [scope].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/monitor_notification_rule_filter_tags.rb b/lib/datadog_api_client/v2/models/monitor_notification_rule_filter_tags.rb index b330b1981ccc..1e1f57618b06 100644 --- a/lib/datadog_api_client/v2/models/monitor_notification_rule_filter_tags.rb +++ b/lib/datadog_api_client/v2/models/monitor_notification_rule_filter_tags.rb @@ -17,11 +17,11 @@ require 'time' module DatadogAPIClient::V2 - # Filter monitors by tags. Monitors must match all tags. + # Filter monitor notifications by tags. A monitor notification must match all tags. class MonitorNotificationRuleFilterTags include BaseGenericModel - # A list of monitor tags. + # A list of tags (key:value pairs), which can be used to filter monitor notifications on monitor and group tags. attr_reader :tags # Attribute mapping from ruby-style variable name to JSON key. diff --git a/lib/datadog_api_client/v2/models/monitor_notification_rule_response_attributes.rb b/lib/datadog_api_client/v2/models/monitor_notification_rule_response_attributes.rb index 3656f9818315..9a120e9c59fd 100644 --- a/lib/datadog_api_client/v2/models/monitor_notification_rule_response_attributes.rb +++ b/lib/datadog_api_client/v2/models/monitor_notification_rule_response_attributes.rb @@ -21,7 +21,7 @@ module DatadogAPIClient::V2 class MonitorNotificationRuleResponseAttributes include BaseGenericModel - # Use conditional recipients to define different recipients for different situations. + # Use conditional recipients to define different recipients for different situations. Cannot be used with `recipients`. attr_accessor :conditional_recipients # Creation time of the monitor notification rule. @@ -36,7 +36,7 @@ class MonitorNotificationRuleResponseAttributes # The name of the monitor notification rule. attr_reader :name - # A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'. + # A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'. Cannot be used with `conditional_recipients`. attr_reader :recipients attr_accessor :additional_properties