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
83 changes: 82 additions & 1 deletion .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6897,6 +6897,14 @@ components:
items:
$ref: "#/components/schemas/AllocationExposureRolloutStep"
type: array
scheduled_start_time:
description: |-
The resolved UTC start time computed from `scheduled_start`. This field is
read-only and cannot be set directly.
example: "2025-06-13T12:00:00Z"
format: date-time
nullable: true
type: string
updated_at:
description: The timestamp when the schedule was last updated.
example: "2024-01-01T12:00:00Z"
Expand Down Expand Up @@ -36788,6 +36796,10 @@ components:
description: The name of the environment.
example: "env-search-term"
type: string
observe_full_evaluation_data:
description: Indicates whether full evaluation data is observed for this environment.
example: false
type: boolean
queries:
description: List of queries to define the environment scope.
example: ["staging", "test"]
Expand Down Expand Up @@ -39095,6 +39107,10 @@ components:
items:
$ref: "#/components/schemas/FeatureFlagEnvironment"
type: array
is_favorite:
description: Indicates whether the feature flag is marked as a favorite by the current user.
example: false
type: boolean
json_schema:
description: JSON schema for validation when value_type is JSON.
example: '{"type": "object", "properties": {"enabled": {"type": "boolean"}}}'
Expand All @@ -39117,6 +39133,8 @@ components:
description: Indicates whether this feature flag requires approval for changes.
example: false
type: boolean
staleness_details:
$ref: "#/components/schemas/FeatureFlagAttributesStalenessDetails"
staleness_status:
description: Indicates the whether a feature flag is stale or not.
example: "ACTIVE"
Expand Down Expand Up @@ -39147,6 +39165,48 @@ components:
- value_type
- variants
type: object
FeatureFlagAttributesStalenessDetails:
description: Details about the feature flag's staleness status.
nullable: true
properties:
code_references:
description: Code references associated with the feature flag.
items:
additionalProperties: {}
type: object
nullable: true
type: array
dismissed_by:
description: The ID of the user who dismissed the staleness notification.
format: uuid
nullable: true
type: string
id:
description: The unique identifier of the staleness details record.
example: "550e8400-e29b-41d4-a716-446655440020"
format: uuid
type: string
recommended_actions:
description: Recommended actions to address the feature flag's staleness.
items:
additionalProperties: {}
type: object
nullable: true
type: array
skip_state_check_until:
description: The timestamp until which staleness checks are skipped.
format: date-time
nullable: true
type: string
stale_reason:
description: The reason the feature flag is considered stale.
nullable: true
type: string
staleness_status:
description: The staleness status of the feature flag.
example: "ACTIVE"
type: string
type: object
FeatureFlagEnvironment:
description: Environment-specific settings for a feature flag.
properties:
Expand Down Expand Up @@ -39186,6 +39246,10 @@ components:
description: Indicates whether the environment is production.
example: false
type: boolean
observe_full_evaluation_data:
description: Indicates whether full evaluation data is observed for this environment.
example: false
type: boolean
override_allocation_key:
description: The allocation key used for the override variant.
example: "allocation-override-123abc"
Expand Down Expand Up @@ -91810,10 +91874,27 @@ components:
description: Rollout options request payload.
properties:
autostart:
description: Whether the schedule should begin automatically.
deprecated: true
description: |-
Whether the schedule should begin automatically. Deprecated in favor of
`scheduled_start`, which takes precedence when both are set.
example: false
nullable: true
type: boolean
scheduled_start:
description: |-
Controls when the schedule starts. Supersedes `autostart`. One of:

- `none`: create the schedule without starting it.
- `now`: start the schedule immediately.
- `relative:<duration>`: start after a duration (for example `relative:2h`).
- `absolute:<RFC3339 timestamp>`: start at a specific time (for example `absolute:2025-06-13T12:00:00Z`).

An `absolute` timestamp in the past or present is treated as `now`. A future start time
is not supported for allocations linked to a standard experiment.
example: "absolute:2025-06-13T12:00:00Z"
pattern: ^(none|now|relative:([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+|absolute:\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2}))$
type: string
selection_interval_ms:
description: Interval in milliseconds for uniform interval strategies.
example: 3600000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
id=UUID("550e8400-e29b-41d4-a716-446655440010"),
rollout_options=RolloutOptionsRequest(
autostart=False,
scheduled_start="absolute:2025-06-13T12:00:00Z",
selection_interval_ms=3600000,
strategy=RolloutStrategy.UNIFORM_INTERVALS,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
id=UUID("550e8400-e29b-41d4-a716-446655440010"),
rollout_options=RolloutOptionsRequest(
autostart=False,
scheduled_start="absolute:2025-06-13T12:00:00Z",
selection_interval_ms=3600000,
strategy=RolloutStrategy.UNIFORM_INTERVALS,
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
"""
Update targeting rules for a flag in an environment with a scheduled start returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.feature_flags_api import FeatureFlagsApi
from datadog_api_client.v2.model.allocation_data_request import AllocationDataRequest
from datadog_api_client.v2.model.allocation_data_type import AllocationDataType
from datadog_api_client.v2.model.allocation_type import AllocationType
from datadog_api_client.v2.model.exposure_rollout_step_request import ExposureRolloutStepRequest
from datadog_api_client.v2.model.exposure_schedule_request import ExposureScheduleRequest
from datadog_api_client.v2.model.overwrite_allocations_request import OverwriteAllocationsRequest
from datadog_api_client.v2.model.rollout_options_request import RolloutOptionsRequest
from datadog_api_client.v2.model.rollout_strategy import RolloutStrategy
from datadog_api_client.v2.model.upsert_allocation_request import UpsertAllocationRequest
from datadog_api_client.v2.model.variant_weight_request import VariantWeightRequest

# there is a valid "feature_flag" in the system
FEATURE_FLAG_DATA_ATTRIBUTES_VARIANTS_0_ID = environ["FEATURE_FLAG_DATA_ATTRIBUTES_VARIANTS_0_ID"]
FEATURE_FLAG_DATA_ID = environ["FEATURE_FLAG_DATA_ID"]

# there is a valid "environment" in the system
ENVIRONMENT_DATA_ID = environ["ENVIRONMENT_DATA_ID"]

body = OverwriteAllocationsRequest(
data=[
AllocationDataRequest(
type=AllocationDataType.ALLOCATIONS,
attributes=UpsertAllocationRequest(
key="scheduled-start-allocation-example-feature-flag",
name="New targeting rule Example-Feature-Flag",
targeting_rules=[],
variant_weights=[
VariantWeightRequest(
variant_id=FEATURE_FLAG_DATA_ATTRIBUTES_VARIANTS_0_ID,
value=100.0,
),
],
exposure_schedule=ExposureScheduleRequest(
rollout_options=RolloutOptionsRequest(
strategy=RolloutStrategy.UNIFORM_INTERVALS,
scheduled_start="absolute:2021-11-12T11:11:11+00:00",
selection_interval_ms=86400000,
),
rollout_steps=[
ExposureRolloutStepRequest(
exposure_ratio=0.05,
interval_ms=None,
is_pause_record=False,
grouped_step_index=0,
),
ExposureRolloutStepRequest(
exposure_ratio=0.25,
interval_ms=None,
is_pause_record=False,
grouped_step_index=1,
),
ExposureRolloutStepRequest(
exposure_ratio=1.0,
interval_ms=None,
is_pause_record=False,
grouped_step_index=2,
),
],
),
guardrail_metrics=[],
type=AllocationType.CANARY,
),
),
],
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = FeatureFlagsApi(api_client)
response = api_instance.update_allocations_for_feature_flag_in_environment(
feature_flag_id=FEATURE_FLAG_DATA_ID, environment_id=ENVIRONMENT_DATA_ID, body=body
)

print(response)
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def openapi_types(_):
"id": (UUID,),
"rollout_options": (RolloutOptions,),
"rollout_steps": ([AllocationExposureRolloutStep],),
"scheduled_start_time": (datetime, none_type),
"updated_at": (datetime,),
}

Expand All @@ -52,6 +53,7 @@ def openapi_types(_):
"id": "id",
"rollout_options": "rollout_options",
"rollout_steps": "rollout_steps",
"scheduled_start_time": "scheduled_start_time",
"updated_at": "updated_at",
}

Expand All @@ -67,6 +69,7 @@ def __init__(
control_variant_id: Union[str, none_type, UnsetType] = unset,
guardrail_triggered_action: Union[str, none_type, UnsetType] = unset,
id: Union[UUID, UnsetType] = unset,
scheduled_start_time: Union[datetime, none_type, UnsetType] = unset,
**kwargs,
):
"""
Expand Down Expand Up @@ -99,6 +102,10 @@ def __init__(
:param rollout_steps: Ordered progression steps for exposure.
:type rollout_steps: [AllocationExposureRolloutStep]

:param scheduled_start_time: The resolved UTC start time computed from ``scheduled_start``. This field is
read-only and cannot be set directly.
:type scheduled_start_time: datetime, none_type, optional

:param updated_at: The timestamp when the schedule was last updated.
:type updated_at: datetime
"""
Expand All @@ -110,6 +117,8 @@ def __init__(
kwargs["guardrail_triggered_action"] = guardrail_triggered_action
if id is not unset:
kwargs["id"] = id
if scheduled_start_time is not unset:
kwargs["scheduled_start_time"] = scheduled_start_time
super().__init__(kwargs)

self_.allocation_id = allocation_id
Expand Down
8 changes: 8 additions & 0 deletions src/datadog_api_client/v2/model/environment_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def openapi_types(_):
"is_production": (bool,),
"key": (str,),
"name": (str,),
"observe_full_evaluation_data": (bool,),
"queries": ([str],),
"require_feature_flag_approval": (bool,),
"updated_at": (datetime,),
Expand All @@ -41,6 +42,7 @@ def openapi_types(_):
"is_production": "is_production",
"key": "key",
"name": "name",
"observe_full_evaluation_data": "observe_full_evaluation_data",
"queries": "queries",
"require_feature_flag_approval": "require_feature_flag_approval",
"updated_at": "updated_at",
Expand All @@ -53,6 +55,7 @@ def __init__(
description: Union[str, none_type, UnsetType] = unset,
is_production: Union[bool, UnsetType] = unset,
key: Union[str, UnsetType] = unset,
observe_full_evaluation_data: Union[bool, UnsetType] = unset,
queries: Union[List[str], UnsetType] = unset,
require_feature_flag_approval: Union[bool, UnsetType] = unset,
updated_at: Union[datetime, UnsetType] = unset,
Expand All @@ -76,6 +79,9 @@ def __init__(
:param name: The name of the environment.
:type name: str

:param observe_full_evaluation_data: Indicates whether full evaluation data is observed for this environment.
:type observe_full_evaluation_data: bool, optional

:param queries: List of queries to define the environment scope.
:type queries: [str], optional

Expand All @@ -93,6 +99,8 @@ def __init__(
kwargs["is_production"] = is_production
if key is not unset:
kwargs["key"] = key
if observe_full_evaluation_data is not unset:
kwargs["observe_full_evaluation_data"] = observe_full_evaluation_data
if queries is not unset:
kwargs["queries"] = queries
if require_feature_flag_approval is not unset:
Expand Down
Loading
Loading