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
341 changes: 220 additions & 121 deletions .generator/schemas/v2/openapi.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Create an environment with full evaluation data true returns "Created" 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.create_environment_attributes import CreateEnvironmentAttributes
from datadog_api_client.v2.model.create_environment_data import CreateEnvironmentData
from datadog_api_client.v2.model.create_environment_data_type import CreateEnvironmentDataType
from datadog_api_client.v2.model.create_environment_request import CreateEnvironmentRequest

body = CreateEnvironmentRequest(
data=CreateEnvironmentData(
type=CreateEnvironmentDataType.ENVIRONMENTS,
attributes=CreateEnvironmentAttributes(
name="Evaluation Privacy Example-Feature-Flag",
queries=[
"privacy-example-feature-flag",
],
observe_full_evaluation_data=True,
),
),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = FeatureFlagsApi(api_client)
response = api_instance.create_feature_flags_environment(body=body)

print(response)
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Create an environment with full evaluation data false returns "Created" 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.create_environment_attributes import CreateEnvironmentAttributes
from datadog_api_client.v2.model.create_environment_data import CreateEnvironmentData
from datadog_api_client.v2.model.create_environment_data_type import CreateEnvironmentDataType
from datadog_api_client.v2.model.create_environment_request import CreateEnvironmentRequest

body = CreateEnvironmentRequest(
data=CreateEnvironmentData(
type=CreateEnvironmentDataType.ENVIRONMENTS,
attributes=CreateEnvironmentAttributes(
name="Evaluation Privacy Example-Feature-Flag",
queries=[
"privacy-example-feature-flag",
],
observe_full_evaluation_data=False,
),
),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = FeatureFlagsApi(api_client)
response = api_instance.create_feature_flags_environment(body=body)

print(response)
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
Update an environment to enable full evaluation data 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.update_environment_attributes import UpdateEnvironmentAttributes
from datadog_api_client.v2.model.update_environment_data import UpdateEnvironmentData
from datadog_api_client.v2.model.update_environment_data_type import UpdateEnvironmentDataType
from datadog_api_client.v2.model.update_environment_request import UpdateEnvironmentRequest

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

body = UpdateEnvironmentRequest(
data=UpdateEnvironmentData(
type=UpdateEnvironmentDataType.ENVIRONMENTS,
attributes=UpdateEnvironmentAttributes(
name="Updated Privacy Example-Feature-Flag",
queries=[
"updated-privacy-example-feature-flag",
],
observe_full_evaluation_data=True,
),
),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = FeatureFlagsApi(api_client)
response = api_instance.update_feature_flags_environment(environment_id=ENVIRONMENT_DATA_ID, body=body)

print(response)
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""
Update an environment to preserve enabled full evaluation data when omitted 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.update_environment_attributes import UpdateEnvironmentAttributes
from datadog_api_client.v2.model.update_environment_data import UpdateEnvironmentData
from datadog_api_client.v2.model.update_environment_data_type import UpdateEnvironmentDataType
from datadog_api_client.v2.model.update_environment_request import UpdateEnvironmentRequest

# there is a valid "environment_with_full_evaluation_data" in the system
ENVIRONMENT_WITH_FULL_EVALUATION_DATA_DATA_ID = environ["ENVIRONMENT_WITH_FULL_EVALUATION_DATA_DATA_ID"]

body = UpdateEnvironmentRequest(
data=UpdateEnvironmentData(
type=UpdateEnvironmentDataType.ENVIRONMENTS,
attributes=UpdateEnvironmentAttributes(
name="Updated Privacy Example-Feature-Flag",
queries=[
"updated-privacy-example-feature-flag",
],
),
),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = FeatureFlagsApi(api_client)
response = api_instance.update_feature_flags_environment(
environment_id=ENVIRONMENT_WITH_FULL_EVALUATION_DATA_DATA_ID, body=body
)

print(response)
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""
Update an environment to preserve disabled full evaluation data when omitted 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.update_environment_attributes import UpdateEnvironmentAttributes
from datadog_api_client.v2.model.update_environment_data import UpdateEnvironmentData
from datadog_api_client.v2.model.update_environment_data_type import UpdateEnvironmentDataType
from datadog_api_client.v2.model.update_environment_request import UpdateEnvironmentRequest

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

body = UpdateEnvironmentRequest(
data=UpdateEnvironmentData(
type=UpdateEnvironmentDataType.ENVIRONMENTS,
attributes=UpdateEnvironmentAttributes(
name="Updated Privacy Example-Feature-Flag",
queries=[
"updated-privacy-example-feature-flag",
],
),
),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = FeatureFlagsApi(api_client)
response = api_instance.update_feature_flags_environment(environment_id=ENVIRONMENT_DATA_ID, body=body)

print(response)
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""
Update an environment to disable full evaluation data 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.update_environment_attributes import UpdateEnvironmentAttributes
from datadog_api_client.v2.model.update_environment_data import UpdateEnvironmentData
from datadog_api_client.v2.model.update_environment_data_type import UpdateEnvironmentDataType
from datadog_api_client.v2.model.update_environment_request import UpdateEnvironmentRequest

# there is a valid "environment_with_full_evaluation_data" in the system
ENVIRONMENT_WITH_FULL_EVALUATION_DATA_DATA_ID = environ["ENVIRONMENT_WITH_FULL_EVALUATION_DATA_DATA_ID"]

body = UpdateEnvironmentRequest(
data=UpdateEnvironmentData(
type=UpdateEnvironmentDataType.ENVIRONMENTS,
attributes=UpdateEnvironmentAttributes(
name="Updated Privacy Example-Feature-Flag",
queries=[
"updated-privacy-example-feature-flag",
],
observe_full_evaluation_data=False,
),
),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = FeatureFlagsApi(api_client)
response = api_instance.update_feature_flags_environment(
environment_id=ENVIRONMENT_WITH_FULL_EVALUATION_DATA_DATA_ID, body=body
)

print(response)
4 changes: 2 additions & 2 deletions examples/v2/tag-rules/CreateTagRule.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
negated=False,
required=True,
rule_type=TagRuleCreateType.SURFACING,
scope="env",
scope="env:prod",
source=TagRuleSource.LOGS,
tag_key="service",
tag_value_patterns=[
"api",
"web",
],
),
type=TagRuleResourceType.TAG_RULE,
type=TagRuleResourceType.TAG_POLICY,
),
)

Expand Down
2 changes: 1 addition & 1 deletion examples/v2/tag-rules/UpdateTagRule.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
tag_value_patterns=[],
),
id="123",
type=TagRuleResourceType.TAG_RULE,
type=TagRuleResourceType.TAG_POLICY,
),
)

Expand Down
21 changes: 13 additions & 8 deletions src/datadog_api_client/v2/api/feature_flags_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1406,17 +1406,17 @@ def list_feature_flags_environments(
"""List environments.

Returns a list of environments for the organization.
Supports filtering by name, key, and DD_ENV.
Use ``dd_env`` to filter by an exact DD_ENV value in an environment's ``queries`` list.

:param name: Filter environments by name (partial matching).
:param name: This parameter is currently ignored. Use dd_env to filter environments.
:type name: str, optional
:param key: Filter environments by key (partial matching).
:param key: This parameter is currently ignored. Use dd_env to filter environments.
:type key: str, optional
:param dd_env: Filter environments by queries that contain the provided DD_ENV value.
:param dd_env: Filter environments whose queries list contains an exact match for the provided DD_ENV value.
:type dd_env: str, optional
:param limit: Maximum number of results to return.
:param limit: This parameter is currently ignored. All matching environments are returned.
:type limit: int, optional
:param offset: Number of results to skip.
:param offset: This parameter is currently ignored. All matching environments are returned.
:type offset: int, optional
:rtype: ListEnvironmentsResponse
"""
Expand Down Expand Up @@ -1585,8 +1585,13 @@ def update_feature_flags_environment(
) -> EnvironmentResponse:
"""Update an environment.

Updates an existing environment's metadata such as
name and description.
Updates an environment's name, DD_ENV values, and settings.

Every request must include ``name`` and ``queries`` , even when changing only ``observe_full_evaluation_data``.
To preserve the current name and DD_ENV values, get the environment first and include those values in the request.

Omitting ``is_production`` or ``require_feature_flag_approval`` resets that setting to ``false``.
Include their current values to preserve them. Omitting ``observe_full_evaluation_data`` preserves its current value.

:param environment_id: The ID of the environment.
:type environment_id: UUID
Expand Down
14 changes: 9 additions & 5 deletions src/datadog_api_client/v2/api/tag_rules_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TagRulesApi:
scoped to a particular telemetry source (such as logs, spans, or metrics). Rules can be
``blocking`` (data not matching the rule is rejected) or ``surfacing`` (matching data is
highlighted but not blocked). Each rule reports a compliance ``score`` derived from how
much recent telemetry adheres to the rule.
much recent telemetry adheres to the rule. RUM supports only ``surfacing`` rules.
"""

def __init__(self, api_client=None):
Expand Down Expand Up @@ -254,7 +254,8 @@ def delete_tag_rule(

Delete a tag rule. By default the rule is soft-deleted so it can be recovered later
and so that historical score data remains queryable. Pass ``hard_delete=true`` to remove
the rule permanently.
the rule permanently. Deleting a ``blocking`` rule additionally requires the
``telemetry_rules_activate`` permission.

:param rule_id: The unique identifier of the tag rule to delete.
:type rule_id: str
Expand Down Expand Up @@ -288,7 +289,7 @@ def get_tag_rule(
:type rule_id: str
:param include: Comma-separated list of related resources to include alongside the rule. Currently the only supported value is ``score``.
:type include: TagRuleInclude, optional
:param ts_start: Start of the time window used for compliance score computation, as a Unix timestamp in milliseconds.
:param ts_start: Start of the time window used for compliance score computation, as a Unix timestamp in milliseconds. Defaults to approximately 4 hours before the current time for metrics, or 24 hours before the current time for other sources. The API clamps earlier values to this default, regardless of ``ts_end``.
:type ts_start: int, optional
:param ts_end: End of the time window used for compliance score computation, as a Unix timestamp in milliseconds. Must be in the past and greater than ``ts_start``.
:type ts_end: int, optional
Expand Down Expand Up @@ -324,7 +325,7 @@ def get_tag_rule_score(

:param rule_id: The unique identifier of the tag rule.
:type rule_id: str
:param ts_start: Start of the time window used for compliance score computation, as a Unix timestamp in milliseconds.
:param ts_start: Start of the time window used for compliance score computation, as a Unix timestamp in milliseconds. Defaults to approximately 4 hours before the current time for metrics, or 24 hours before the current time for other sources. The API clamps earlier values to this default, regardless of ``ts_end``.
:type ts_start: int, optional
:param ts_end: End of the time window used for compliance score computation, as a Unix timestamp in milliseconds. Must be in the past and greater than ``ts_start``.
:type ts_end: int, optional
Expand Down Expand Up @@ -365,7 +366,7 @@ def list_tag_rules(
:type include: TagRuleInclude, optional
:param filter_source: Restrict the result set to rules whose source matches the given value.
:type filter_source: TagRuleSource, optional
:param ts_start: Start of the time window used for compliance score computation, as a Unix timestamp in milliseconds. Defaults to a recent window appropriate for the source.
:param ts_start: Start of the time window used for compliance score computation, as a Unix timestamp in milliseconds. Defaults to approximately 4 hours before the current time for metrics, or 24 hours before the current time for other sources. The API clamps earlier values to this default, regardless of ``ts_end``.
:type ts_start: int, optional
:param ts_end: End of the time window used for compliance score computation, as a Unix timestamp in milliseconds. Must be in the past and greater than ``ts_start``.
:type ts_end: int, optional
Expand Down Expand Up @@ -402,6 +403,9 @@ def update_tag_rule(
Update one or more attributes of an existing tag rule. Only the fields supplied in the
request body are modified; omitted fields retain their current values. The rule's
``source`` cannot be changed after creation.
Promoting a rule from ``surfacing`` to ``blocking`` additionally requires the
``telemetry_rules_activate`` permission, and your organization must have access to
blocking rules. You can't promote RUM rules to ``blocking``.

:param rule_id: The unique identifier of the tag rule to update.
:type rule_id: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ def openapi_types(_):
return {
"is_production": (bool,),
"name": (str,),
"observe_full_evaluation_data": (bool,),
"queries": ([str],),
"require_feature_flag_approval": (bool,),
}

attribute_map = {
"is_production": "is_production",
"name": "name",
"observe_full_evaluation_data": "observe_full_evaluation_data",
"queries": "queries",
"require_feature_flag_approval": "require_feature_flag_approval",
}
Expand All @@ -41,6 +43,7 @@ def __init__(
name: str,
queries: List[str],
is_production: Union[bool, UnsetType] = unset,
observe_full_evaluation_data: Union[bool, UnsetType] = unset,
require_feature_flag_approval: Union[bool, UnsetType] = unset,
**kwargs,
):
Expand All @@ -50,17 +53,22 @@ def __init__(
:param is_production: Indicates whether this is a production environment.
:type is_production: bool, optional

:param name: The name of the environment.
:param name: The name of the environment. Required on every request and unique within the organization. Must contain 1 to 200 ASCII characters, start with a letter or digit, and contain only letters, digits, spaces, underscores, hyphens, and periods.
:type name: str

:param queries: List of queries to define the environment scope.
:param observe_full_evaluation_data: Controls whether feature flag evaluation events may include original targeting identifiers and full evaluation context. When true, SDKs may include this data. When false, SDKs hash targeting identifiers and omit evaluation context. If omitted, defaults to false.
:type observe_full_evaluation_data: bool, optional

:param queries: Required list of at least one exact DD_ENV value associated with this environment. Values cannot be used by another environment in the same organization. Wildcards and search expressions are not supported.
:type queries: [str]

:param require_feature_flag_approval: Indicates whether feature flag changes require approval in this environment.
:type require_feature_flag_approval: bool, optional
"""
if is_production is not unset:
kwargs["is_production"] = is_production
if observe_full_evaluation_data is not unset:
kwargs["observe_full_evaluation_data"] = observe_full_evaluation_data
if require_feature_flag_approval is not unset:
kwargs["require_feature_flag_approval"] = require_feature_flag_approval
super().__init__(kwargs)
Expand Down
1 change: 1 addition & 0 deletions src/datadog_api_client/v2/model/tag_rule_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def __init__(

:param rule_type: How the rule is enforced. ``blocking`` rejects telemetry that violates the rule.
``surfacing`` only highlights non-compliant telemetry without blocking it.
RUM supports only ``surfacing`` rules.
:type rule_type: TagRuleType

:param scope: The scope the rule applies within.
Expand Down
Loading
Loading