Skip to content
Open
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
102 changes: 102 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24463,6 +24463,19 @@ components:
description: The name of the feature flag.
example: "Feature Flag ABC123"
type: string
notification_rule_query:
description: |-
Query used to determine which change events on this feature flag trigger notifications to `rule_targets`. Uses Datadog's standard log search syntax (`AND`, `OR`, `NOT`, parentheses) to match against the `notification_type` facet.

Supported `notification_type` values for a feature flag are: `flag_enabled_disabled`, `flag_archived`, `flag_approval_required`, `rollout_started`, `rollout_scheduled`, `rollout_step_started`, `rollout_paused_guardrail`, `rollout_paused_user`, `rollout_aborted_guardrail`, `rollout_aborted_user`, `targeting_rule_created`, `targeting_rule_updated`, `targeting_rule_updated_via_filter`, and `targeting_rule_deleted`.
example: "notification_type:rollout_started OR notification_type:targeting_rule_updated"
nullable: true
type: string
rule_targets:
description: Targets to notify about changes to this feature flag that match `notification_rule_query`.
items:
$ref: "#/components/schemas/NotificationRuleTarget"
type: array
value_type:
$ref: "#/components/schemas/ValueType"
variants:
Expand Down Expand Up @@ -69161,6 +69174,95 @@ components:
type: string
x-enum-varnames:
- MANUAL
NotificationRuleTarget:
description: A notification target that receives change alerts for a feature flag.
properties:
configuration:
$ref: "#/components/schemas/NotificationRuleTargetConfiguration"
type:
$ref: "#/components/schemas/NotificationRuleTargetType"
version:
description: Schema version of `configuration`.
example: 1
format: int64
type: integer
required:
- type
- version
- configuration
type: object
NotificationRuleTargetConfiguration:
description: "Configuration for a notification target. Which fields apply depends on the target's `type`."
properties:
channel:
description: Slack channel name, for a `SLACK_CHANNEL` target.
example: "#feature-flags"
type: string
channel_id:
description: Slack channel ID, for a `SLACK_CHANNEL` target, or Microsoft Teams channel ID, for an `MS_TEAMS_CHANNEL` target.
type: string
channel_name:
description: Microsoft Teams channel name, for an `MS_TEAMS_CHANNEL` target.
type: string
connector_name:
description: Microsoft Teams connector name, for an `MS_TEAMS_CHANNEL` target.
type: string
recipient:
$ref: "#/components/schemas/NotificationRuleTargetConfigurationRecipient"
service_name:
description: PagerDuty service name, for a `PAGERDUTY_SERVICE` target.
type: string
team_id:
description: Microsoft Teams team ID, for an `MS_TEAMS_CHANNEL` target.
type: string
team_name:
description: Microsoft Teams team name, for an `MS_TEAMS_CHANNEL` target.
type: string
tenant_id:
description: Microsoft Teams tenant ID, for an `MS_TEAMS_CHANNEL` target.
type: string
tenant_name:
description: Microsoft Teams tenant name, for an `MS_TEAMS_CHANNEL` target.
type: string
username:
description: Slack username, for a `SLACK_USER` target.
type: string
webhook_name:
description: Name of the configured webhook, for a `WEBHOOK` target.
type: string
workspace:
description: Slack workspace name, for a `SLACK_CHANNEL` or `SLACK_USER` target.
type: string
workspace_id:
description: Slack workspace ID, for a `SLACK_CHANNEL` target.
type: string
type: object
NotificationRuleTargetConfigurationRecipient:
description: Recipient for an `EMAIL` target.
properties:
email:
description: Email address to notify.
example: "user@example.com"
type: string
type: object
NotificationRuleTargetType:
description: The type of notification target.
enum:
- "EMAIL"
- "SLACK_CHANNEL"
- "SLACK_USER"
- "WEBHOOK"
- "PAGERDUTY_SERVICE"
- "MS_TEAMS_CHANNEL"
example: "SLACK_CHANNEL"
type: string
x-enum-varnames:
- EMAIL
- SLACK_CHANNEL
- SLACK_USER
- WEBHOOK
- PAGERDUTY_SERVICE
- MS_TEAMS_CHANNEL
NotificationRulesListResponse:
description: The list of notification rules.
properties:
Expand Down
41 changes: 41 additions & 0 deletions examples/v2/feature-flags/CreateFeatureFlag_2426084719.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Create a feature flag with notification rule targets returns "Created" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::FeatureFlagsAPI.new

body = DatadogAPIClient::V2::CreateFeatureFlagRequest.new({
data: DatadogAPIClient::V2::CreateFeatureFlagData.new({
type: DatadogAPIClient::V2::CreateFeatureFlagDataType::FEATURE_FLAGS,
attributes: DatadogAPIClient::V2::CreateFeatureFlagAttributes.new({
default_variant_key: "variant-Example-Feature-Flag-1",
description: "Test feature flag with notification rule targets for BDD scenarios",
key: "test-feature-flag-notify-Example-Feature-Flag",
name: "Test Feature Flag Notify Example-Feature-Flag",
value_type: DatadogAPIClient::V2::ValueType::BOOLEAN,
variants: [
DatadogAPIClient::V2::CreateVariant.new({
key: "variant-Example-Feature-Flag-1",
name: "Variant Example-Feature-Flag A",
value: "true",
}),
DatadogAPIClient::V2::CreateVariant.new({
key: "variant-Example-Feature-Flag-2",
name: "Variant Example-Feature-Flag B",
value: "false",
}),
],
notification_rule_query: "notification_type:rollout_started",
rule_targets: [
DatadogAPIClient::V2::NotificationRuleTarget.new({
type: DatadogAPIClient::V2::NotificationRuleTargetType::SLACK_CHANNEL,
version: 1,
configuration: DatadogAPIClient::V2::NotificationRuleTargetConfiguration.new({
channel: "#feature-flags-test",
workspace: "datadoghq",
}),
}),
],
}),
}),
})
p api_instance.create_feature_flag(body)
9 changes: 9 additions & 0 deletions features/v2/feature_flags.feature
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ Feature: Feature Flags
And the response "data.attributes.name" is equal to "Test Feature Flag {{ unique }}"
And the response "data.attributes.value_type" is equal to "BOOLEAN"

@team:DataDog/feature-flags
Scenario: Create a feature flag with notification rule targets returns "Created" response
Given new "CreateFeatureFlag" request
And body with value {"data": {"type": "feature-flags", "attributes": {"default_variant_key": "variant-{{ unique }}-1", "description": "Test feature flag with notification rule targets for BDD scenarios", "key": "test-feature-flag-notify-{{ unique }}", "name": "Test Feature Flag Notify {{ unique }}", "value_type": "BOOLEAN", "variants": [{"key": "variant-{{ unique }}-1", "name": "Variant {{ unique }} A", "value": "true"}, {"key": "variant-{{ unique }}-2", "name": "Variant {{ unique }} B", "value": "false"}], "notification_rule_query": "notification_type:rollout_started", "rule_targets": [{"type": "SLACK_CHANNEL", "version": 1, "configuration": {"channel": "#feature-flags-test", "workspace": "datadoghq"}}]}}}
When the request is sent
Then the response status is 201 Created
And the response "data.attributes.key" is equal to "test-feature-flag-notify-{{ unique }}"
And the response "data.attributes.name" is equal to "Test Feature Flag Notify {{ unique }}"

@team:DataDog/feature-flags
Scenario: Create allocation for a flag in an environment returns "Created" response
Given there is a valid "feature_flag" in the system
Expand Down
4 changes: 4 additions & 0 deletions lib/datadog_api_client/inflector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5254,6 +5254,10 @@ def overrides
"v2.notification_rule_routing_mode" => "NotificationRuleRoutingMode",
"v2.notification_rules_list_response" => "NotificationRulesListResponse",
"v2.notification_rules_type" => "NotificationRulesType",
"v2.notification_rule_target" => "NotificationRuleTarget",
"v2.notification_rule_target_configuration" => "NotificationRuleTargetConfiguration",
"v2.notification_rule_target_configuration_recipient" => "NotificationRuleTargetConfigurationRecipient",
"v2.notification_rule_target_type" => "NotificationRuleTargetType",
"v2.notion_api_key" => "NotionAPIKey",
"v2.notion_api_key_type" => "NotionAPIKeyType",
"v2.notion_api_key_update" => "NotionAPIKeyUpdate",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ class CreateFeatureFlagAttributes
# The name of the feature flag.
attr_reader :name

# Query used to determine which change events on this feature flag trigger notifications to `rule_targets`. Uses Datadog's standard log search syntax (`AND`, `OR`, `NOT`, parentheses) to match against the `notification_type` facet.
#
# Supported `notification_type` values for a feature flag are: `flag_enabled_disabled`, `flag_archived`, `flag_approval_required`, `rollout_started`, `rollout_scheduled`, `rollout_step_started`, `rollout_paused_guardrail`, `rollout_paused_user`, `rollout_aborted_guardrail`, `rollout_aborted_user`, `targeting_rule_created`, `targeting_rule_updated`, `targeting_rule_updated_via_filter`, and `targeting_rule_deleted`.
attr_accessor :notification_rule_query

# Targets to notify about changes to this feature flag that match `notification_rule_query`.
attr_accessor :rule_targets

# The type of values for the feature flag variants.
attr_reader :value_type

Expand All @@ -53,6 +61,8 @@ def self.attribute_map
:'json_schema' => :'json_schema',
:'key' => :'key',
:'name' => :'name',
:'notification_rule_query' => :'notification_rule_query',
:'rule_targets' => :'rule_targets',
:'value_type' => :'value_type',
:'variants' => :'variants'
}
Expand All @@ -67,6 +77,8 @@ def self.openapi_types
:'json_schema' => :'String',
:'key' => :'String',
:'name' => :'String',
:'notification_rule_query' => :'String',
:'rule_targets' => :'Array<NotificationRuleTarget>',
:'value_type' => :'ValueType',
:'variants' => :'Array<CreateVariant>'
}
Expand All @@ -78,6 +90,7 @@ def self.openapi_nullable
Set.new([
:'default_variant_key',
:'json_schema',
:'notification_rule_query',
])
end

Expand Down Expand Up @@ -119,6 +132,16 @@ def initialize(attributes = {})
self.name = attributes[:'name']
end

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

if attributes.key?(:'rule_targets')
if (value = attributes[:'rule_targets']).is_a?(Array)
self.rule_targets = value
end
end

if attributes.key?(:'value_type')
self.value_type = attributes[:'value_type']
end
Expand Down Expand Up @@ -223,6 +246,8 @@ def ==(o)
json_schema == o.json_schema &&
key == o.key &&
name == o.name &&
notification_rule_query == o.notification_rule_query &&
rule_targets == o.rule_targets &&
value_type == o.value_type &&
variants == o.variants &&
additional_properties == o.additional_properties
Expand All @@ -232,7 +257,7 @@ def ==(o)
# @return [Integer] Hash code
# @!visibility private
def hash
[default_variant_key, description, json_schema, key, name, value_type, variants, additional_properties].hash
[default_variant_key, description, json_schema, key, name, notification_rule_query, rule_targets, value_type, variants, additional_properties].hash
end
end
end
Loading
Loading