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
38 changes: 38 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29565,6 +29565,8 @@ components:
additionalProperties: false
description: Attributes of the monitor notification rule.
properties:
conditional_recipients:
$ref: '#/components/schemas/MonitorNotificationRuleConditionalRecipients'
filter:
$ref: '#/components/schemas/MonitorNotificationRuleFilter'
name:
Expand All @@ -29573,8 +29575,36 @@ components:
$ref: '#/components/schemas/MonitorNotificationRuleRecipients'
required:
- name
type: object
MonitorNotificationRuleCondition:
description: Conditions for `conditional_recipients`.
properties:
recipients:
$ref: '#/components/schemas/MonitorNotificationRuleRecipients'
scope:
$ref: '#/components/schemas/MonitorNotificationRuleScope'
required:
- scope
- recipients
type: object
MonitorNotificationRuleConditionalRecipients:
description: Use conditional recipients to define different recipients for different
situations.
properties:
conditions:
description: Conditions of the notification rule.
items:
$ref: '#/components/schemas/MonitorNotificationRuleCondition'
maxItems: 10
minItems: 1
type: array
fallback_recipients:
$ref: '#/components/schemas/MonitorNotificationRuleRecipients'
description: If none of the `conditions` applied, `fallback_recipients`
will get notified.
required:
- conditions
type: object
MonitorNotificationRuleCreateRequest:
description: Request for creating a monitor notification rule.
properties:
Expand Down Expand Up @@ -29714,6 +29744,8 @@ components:
additionalProperties: {}
description: Attributes of the monitor notification rule.
properties:
conditional_recipients:
$ref: '#/components/schemas/MonitorNotificationRuleConditionalRecipients'
created:
description: Creation time of the monitor notification rule.
example: 2020-01-02 03:04:00+00:00
Expand All @@ -29735,6 +29767,12 @@ 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-09-26T01:50:59.027Z

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-09-26T01:51:00.504Z

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

30 changes: 30 additions & 0 deletions examples/v2/monitors/CreateMonitorNotificationRule_1181818787.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Create a monitor notification rule with conditional recipients 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::MonitorNotificationRuleFilterTags.new({
tags: [
"test:example-monitor",
],
}),
name: "test rule",
conditional_recipients: DatadogAPIClient::V2::MonitorNotificationRuleConditionalRecipients.new({
conditions: [
DatadogAPIClient::V2::MonitorNotificationRuleCondition.new({
scope: "transition_type:is_alert",
recipients: [
"slack-test-channel",
"jira-test",
],
}),
],
}),
}),
type: DatadogAPIClient::V2::MonitorNotificationRuleResourceType::MONITOR_NOTIFICATION_RULE,
}),
})
p api_instance.create_monitor_notification_rule(body)
35 changes: 35 additions & 0 deletions examples/v2/monitors/UpdateMonitorNotificationRule_1400905713.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Update a monitor notification rule with conditional_recipients 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::MonitorNotificationRuleFilterTags.new({
tags: [
"test:example-monitor",
"host:abc",
],
}),
name: "updated rule",
conditional_recipients: DatadogAPIClient::V2::MonitorNotificationRuleConditionalRecipients.new({
conditions: [
DatadogAPIClient::V2::MonitorNotificationRuleCondition.new({
scope: "transition_type:is_alert",
recipients: [
"slack-test-channel",
"jira-test",
],
}),
],
}),
}),
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 @@ -44,6 +44,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 conditional recipients returns "OK" response
Given new "CreateMonitorNotificationRule" request
And body with value {"data": {"attributes": {"filter": {"tags": ["test:{{ unique_lower }}"]}, "name": "test rule", "conditional_recipients": {"conditions": [{"scope": "transition_type:is_alert", "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 @@ -255,6 +263,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 conditional_recipients 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": {"tags": ["test:{{ unique_lower }}", "host:abc"]}, "name": "updated rule", "conditional_recipients": {"conditions": [{"scope": "transition_type:is_alert", "recipients": ["slack-test-channel", "jira-test"]}]}}, "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
2 changes: 2 additions & 0 deletions lib/datadog_api_client/inflector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2759,6 +2759,8 @@ def overrides
"v2.monitor_downtime_match_response_attributes" => "MonitorDowntimeMatchResponseAttributes",
"v2.monitor_downtime_match_response_data" => "MonitorDowntimeMatchResponseData",
"v2.monitor_notification_rule_attributes" => "MonitorNotificationRuleAttributes",
"v2.monitor_notification_rule_condition" => "MonitorNotificationRuleCondition",
"v2.monitor_notification_rule_conditional_recipients" => "MonitorNotificationRuleConditionalRecipients",
"v2.monitor_notification_rule_create_request" => "MonitorNotificationRuleCreateRequest",
"v2.monitor_notification_rule_create_request_data" => "MonitorNotificationRuleCreateRequestData",
"v2.monitor_notification_rule_data" => "MonitorNotificationRuleData",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ module DatadogAPIClient::V2
class MonitorNotificationRuleAttributes
include BaseGenericModel

# Use conditional recipients to define different recipients for different situations.
attr_accessor :conditional_recipients

# Filter used to associate the notification rule with monitors.
attr_accessor :filter

Expand All @@ -34,6 +37,7 @@ class MonitorNotificationRuleAttributes
# @!visibility private
def self.attribute_map
{
:'conditional_recipients' => :'conditional_recipients',
:'filter' => :'filter',
:'name' => :'name',
:'recipients' => :'recipients'
Expand All @@ -44,6 +48,7 @@ def self.attribute_map
# @!visibility private
def self.openapi_types
{
:'conditional_recipients' => :'MonitorNotificationRuleConditionalRecipients',
:'filter' => :'MonitorNotificationRuleFilter',
:'name' => :'String',
:'recipients' => :'Array<String>'
Expand All @@ -66,6 +71,10 @@ def initialize(attributes = {})
h[k.to_sym] = v
}

if attributes.key?(:'conditional_recipients')
self.conditional_recipients = attributes[:'conditional_recipients']
end

if attributes.key?(:'filter')
self.filter = attributes[:'filter']
end
Expand All @@ -88,9 +97,8 @@ def valid?
return false if @name.nil?
return false if @name.to_s.length > 1000
return false if @name.to_s.length < 1
return false if @recipients.nil?
return false if @recipients.length > 20
return false if @recipients.length < 1
return false if !@recipients.nil? && @recipients.length > 20
return false if !@recipients.nil? && @recipients.length < 1
true
end

Expand All @@ -114,13 +122,10 @@ def name=(name)
# @param recipients [Object] Object to be assigned
# @!visibility private
def recipients=(recipients)
if recipients.nil?
fail ArgumentError, 'invalid value for "recipients", recipients cannot be nil.'
end
if recipients.length > 20
if !recipients.nil? && recipients.length > 20
fail ArgumentError, 'invalid value for "recipients", number of items must be less than or equal to 20.'
end
if recipients.length < 1
if !recipients.nil? && recipients.length < 1
fail ArgumentError, 'invalid value for "recipients", number of items must be greater than or equal to 1.'
end
@recipients = recipients
Expand All @@ -132,6 +137,7 @@ def recipients=(recipients)
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
conditional_recipients == o.conditional_recipients &&
filter == o.filter &&
name == o.name &&
recipients == o.recipients
Expand All @@ -141,7 +147,7 @@ def ==(o)
# @return [Integer] Hash code
# @!visibility private
def hash
[filter, name, recipients].hash
[conditional_recipients, filter, name, recipients].hash
end
end
end
Loading
Loading