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
28 changes: 28 additions & 0 deletions docs/datadog_api_client.v2.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28767,6 +28767,34 @@ datadog\_api\_client.v2.model.notification\_rule\_routing\_mode module
:members:
:show-inheritance:

datadog\_api\_client.v2.model.notification\_rule\_target module
---------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.notification_rule_target
:members:
:show-inheritance:

datadog\_api\_client.v2.model.notification\_rule\_target\_configuration module
------------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.notification_rule_target_configuration
:members:
:show-inheritance:

datadog\_api\_client.v2.model.notification\_rule\_target\_configuration\_recipient module
-----------------------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.notification_rule_target_configuration_recipient
:members:
:show-inheritance:

datadog\_api\_client.v2.model.notification\_rule\_target\_type module
---------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.notification_rule_target_type
:members:
:show-inheritance:

datadog\_api\_client.v2.model.notification\_rules\_list\_response module
------------------------------------------------------------------------

Expand Down
58 changes: 58 additions & 0 deletions examples/v2/feature-flags/CreateFeatureFlag_2426084719.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""
Create a feature flag with notification rule targets returns "Created" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.feature_flags_api import FeatureFlagsApi
from datadog_api_client.v2.model.create_feature_flag_attributes import CreateFeatureFlagAttributes
from datadog_api_client.v2.model.create_feature_flag_data import CreateFeatureFlagData
from datadog_api_client.v2.model.create_feature_flag_data_type import CreateFeatureFlagDataType
from datadog_api_client.v2.model.create_feature_flag_request import CreateFeatureFlagRequest
from datadog_api_client.v2.model.create_variant import CreateVariant
from datadog_api_client.v2.model.notification_rule_target import NotificationRuleTarget
from datadog_api_client.v2.model.notification_rule_target_configuration import NotificationRuleTargetConfiguration
from datadog_api_client.v2.model.notification_rule_target_type import NotificationRuleTargetType
from datadog_api_client.v2.model.value_type import ValueType

body = CreateFeatureFlagRequest(
data=CreateFeatureFlagData(
type=CreateFeatureFlagDataType.FEATURE_FLAGS,
attributes=CreateFeatureFlagAttributes(
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=ValueType.BOOLEAN,
variants=[
CreateVariant(
key="variant-Example-Feature-Flag-1",
name="Variant Example-Feature-Flag A",
value="true",
),
CreateVariant(
key="variant-Example-Feature-Flag-2",
name="Variant Example-Feature-Flag B",
value="false",
),
],
notification_rule_query="notification_type:rollout_started",
rule_targets=[
NotificationRuleTarget(
type=NotificationRuleTargetType.SLACK_CHANNEL,
version=1,
configuration=NotificationRuleTargetConfiguration(
channel="#feature-flags-test",
workspace="datadoghq",
),
),
],
),
),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = FeatureFlagsApi(api_client)
response = api_instance.create_feature_flag(body=body)

print(response)
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@


if TYPE_CHECKING:
from datadog_api_client.v2.model.notification_rule_target import NotificationRuleTarget
from datadog_api_client.v2.model.value_type import ValueType
from datadog_api_client.v2.model.create_variant import CreateVariant


class CreateFeatureFlagAttributes(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.notification_rule_target import NotificationRuleTarget
from datadog_api_client.v2.model.value_type import ValueType
from datadog_api_client.v2.model.create_variant import CreateVariant

Expand All @@ -31,6 +33,8 @@ def openapi_types(_):
"json_schema": (str, none_type),
"key": (str,),
"name": (str,),
"notification_rule_query": (str, none_type),
"rule_targets": ([NotificationRuleTarget],),
"value_type": (ValueType,),
"variants": ([CreateVariant],),
}
Expand All @@ -41,6 +45,8 @@ def openapi_types(_):
"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 @@ -54,6 +60,8 @@ def __init__(
variants: List[CreateVariant],
default_variant_key: Union[str, none_type, UnsetType] = unset,
json_schema: Union[str, none_type, UnsetType] = unset,
notification_rule_query: Union[str, none_type, UnsetType] = unset,
rule_targets: Union[List[NotificationRuleTarget], UnsetType] = unset,
**kwargs,
):
"""
Expand All @@ -74,6 +82,14 @@ def __init__(
:param name: The name of the feature flag.
:type name: str

:param notification_rule_query: 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``.
:type notification_rule_query: str, none_type, optional

:param rule_targets: Targets to notify about changes to this feature flag that match ``notification_rule_query``.
:type rule_targets: [NotificationRuleTarget], optional

:param value_type: The type of values for the feature flag variants.
:type value_type: ValueType

Expand All @@ -84,6 +100,10 @@ def __init__(
kwargs["default_variant_key"] = default_variant_key
if json_schema is not unset:
kwargs["json_schema"] = json_schema
if notification_rule_query is not unset:
kwargs["notification_rule_query"] = notification_rule_query
if rule_targets is not unset:
kwargs["rule_targets"] = rule_targets
super().__init__(kwargs)

self_.description = description
Expand Down
62 changes: 62 additions & 0 deletions src/datadog_api_client/v2/model/notification_rule_target.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# 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.notification_rule_target_configuration import NotificationRuleTargetConfiguration
from datadog_api_client.v2.model.notification_rule_target_type import NotificationRuleTargetType


class NotificationRuleTarget(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.notification_rule_target_configuration import (
NotificationRuleTargetConfiguration,
)
from datadog_api_client.v2.model.notification_rule_target_type import NotificationRuleTargetType

return {
"configuration": (NotificationRuleTargetConfiguration,),
"type": (NotificationRuleTargetType,),
"version": (int,),
}

attribute_map = {
"configuration": "configuration",
"type": "type",
"version": "version",
}

def __init__(
self_,
configuration: NotificationRuleTargetConfiguration,
type: NotificationRuleTargetType,
version: int,
**kwargs,
):
"""
A notification target that receives change alerts for a feature flag.

:param configuration: Configuration for a notification target. Which fields apply depends on the target's ``type``.
:type configuration: NotificationRuleTargetConfiguration

:param type: The type of notification target.
:type type: NotificationRuleTargetType

:param version: Schema version of ``configuration``.
:type version: int
"""
super().__init__(kwargs)

self_.configuration = configuration
self_.type = type
self_.version = version
Loading
Loading