Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 31 additions & 11 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2025-11-11T21:28:39.129Z

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2025-11-11T21:28:40.357Z

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions examples/v2/monitors/CreateMonitorNotificationRule_1379932371.rb
Original file line number Diff line number Diff line change
@@ -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)
24 changes: 24 additions & 0 deletions examples/v2/monitors/UpdateMonitorNotificationRule_1446058210.rb
Original file line number Diff line number Diff line change
@@ -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)
18 changes: 18 additions & 0 deletions features/v2/monitors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/datadog_api_client/inflector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Loading