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
132 changes: 111 additions & 21 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28217,7 +28217,7 @@ components:
- data
type: object
CreateVariant:
description: Request to create a variant.
description: Attributes for creating a variant.
properties:
key:
description: The unique key of the variant.
Expand All @@ -28236,6 +28236,25 @@ components:
- name
- value
type: object
CreateVariantData:
description: Data for adding a variant to a feature flag.
properties:
attributes:
$ref: "#/components/schemas/CreateVariant"
type:
$ref: "#/components/schemas/VariantDataType"
required:
- type
- attributes
type: object
CreateVariantRequest:
description: Request to add a variant to a feature flag.
properties:
data:
$ref: "#/components/schemas/CreateVariantData"
required:
- data
type: object
CreateWorkflowRequest:
description: A request object for creating a new workflow.
example:
Expand Down Expand Up @@ -141665,8 +141684,8 @@ components:
required:
- data
type: object
UpdateVariantRequest:
description: Request to update an existing variant's name and value.
UpdateVariantAttributes:
description: Attributes for updating a variant.
properties:
name:
description: The display name of the variant.
Expand All @@ -141677,6 +141696,30 @@ components:
example: "new_value"
type: string
type: object
UpdateVariantData:
description: Data for updating a variant.
properties:
attributes:
$ref: "#/components/schemas/UpdateVariantAttributes"
id:
description: The ID of the variant. If you include it, use the same value as the `variant_id` path parameter.
example: "550e8400-e29b-41d4-a716-446655440002"
format: uuid
type: string
type:
$ref: "#/components/schemas/VariantDataType"
required:
- type
- attributes
type: object
UpdateVariantRequest:
description: Request to update an existing variant's name and value.
properties:
data:
$ref: "#/components/schemas/UpdateVariantData"
required:
- data
type: object
UpdateWorkflowRequest:
description: A request object for updating an existing workflow.
example:
Expand Down Expand Up @@ -143625,6 +143668,69 @@ components:
- name
- value
type: object
VariantDataType:
description: The resource type for variants.
enum:
- "variants"
example: "variants"
type: string
x-enum-varnames:
- VARIANTS
VariantResponse:
description: Response containing a variant.
properties:
data:
$ref: "#/components/schemas/VariantResponseData"
required:
- data
type: object
VariantResponseAttributes:
description: Attributes of a variant.
properties:
created_at:
description: The timestamp when the variant was created.
example: "2023-01-01T00:00:00Z"
format: date-time
type: string
key:
description: The unique key of the variant.
example: "variant-abc123"
type: string
name:
description: The name of the variant.
example: "Variant ABC123"
type: string
updated_at:
description: The timestamp when the variant was last updated.
example: "2023-01-01T00:00:00Z"
format: date-time
type: string
value:
description: The value of the variant as a string.
example: "true"
type: string
required:
- key
- name
- value
type: object
VariantResponseData:
description: A variant resource.
properties:
attributes:
$ref: "#/components/schemas/VariantResponseAttributes"
id:
description: The unique identifier of the variant.
example: "550e8400-e29b-41d4-a716-446655440002"
format: uuid
type: string
type:
$ref: "#/components/schemas/VariantDataType"
required:
- id
- type
- attributes
type: object
VariantWeight:
description: Variant weight details.
properties:
Expand Down Expand Up @@ -177827,7 +177933,7 @@ paths:
value: dark
type: variants
schema:
$ref: "#/components/schemas/CreateVariant"
$ref: "#/components/schemas/CreateVariantRequest"
required: true
responses:
"201":
Expand All @@ -177846,7 +177952,7 @@ paths:
id: "550e8400-e29b-41d4-a716-446655440002"
type: variants
schema:
$ref: "#/components/schemas/Variant"
$ref: "#/components/schemas/VariantResponse"
description: Created
"400":
content:
Expand Down Expand Up @@ -177963,22 +178069,6 @@ paths:
required: true
responses:
"200":
content:
application/json:
examples:
default:
value:
data:
attributes:
created_at: "2024-01-01T00:00:00+00:00"
key: dark
name: Dark Theme Updated
updated_at: "2024-06-01T00:00:00+00:00"
value: dark_v2
id: "550e8400-e29b-41d4-a716-446655440002"
type: variants
schema:
$ref: "#/components/schemas/Variant"
description: OK
"400":
content:
Expand Down
16 changes: 12 additions & 4 deletions examples/v2/feature-flags/CreateVariantForFeatureFlag.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@
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_variant import CreateVariant
from datadog_api_client.v2.model.create_variant_data import CreateVariantData
from datadog_api_client.v2.model.create_variant_request import CreateVariantRequest
from datadog_api_client.v2.model.variant_data_type import VariantDataType
from uuid import UUID

body = CreateVariant(
key="variant-abc123",
name="Variant ABC123",
value="true",
body = CreateVariantRequest(
data=CreateVariantData(
attributes=CreateVariant(
key="variant-abc123",
name="Variant ABC123",
value="true",
),
type=VariantDataType.VARIANTS,
),
)

configuration = Configuration()
Expand Down
17 changes: 12 additions & 5 deletions examples/v2/feature-flags/UpdateVariantForFeatureFlag.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,29 @@
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_variant_attributes import UpdateVariantAttributes
from datadog_api_client.v2.model.update_variant_data import UpdateVariantData
from datadog_api_client.v2.model.update_variant_request import UpdateVariantRequest
from datadog_api_client.v2.model.variant_data_type import VariantDataType
from uuid import UUID

body = UpdateVariantRequest(
name="Variant ABC123 Updated",
value="new_value",
data=UpdateVariantData(
attributes=UpdateVariantAttributes(
name="Variant ABC123 Updated",
value="new_value",
),
id=UUID("550e8400-e29b-41d4-a716-446655440002"),
type=VariantDataType.VARIANTS,
),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = FeatureFlagsApi(api_client)
response = api_instance.update_variant_for_feature_flag(
api_instance.update_variant_for_feature_flag(
feature_flag_id=UUID("550e8400-e29b-41d4-a716-446655440000"),
variant_id=UUID("550e8400-e29b-41d4-a716-446655440002"),
body=body,
)

print(response)
24 changes: 12 additions & 12 deletions src/datadog_api_client/v2/api/feature_flags_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
from datadog_api_client.v2.model.create_allocations_request import CreateAllocationsRequest
from datadog_api_client.v2.model.list_allocations_response import ListAllocationsResponse
from datadog_api_client.v2.model.overwrite_allocations_request import OverwriteAllocationsRequest
from datadog_api_client.v2.model.variant import Variant
from datadog_api_client.v2.model.create_variant import CreateVariant
from datadog_api_client.v2.model.variant_response import VariantResponse
from datadog_api_client.v2.model.create_variant_request import CreateVariantRequest
from datadog_api_client.v2.model.update_variant_request import UpdateVariantRequest


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

self._create_variant_for_feature_flag_endpoint = _Endpoint(
settings={
"response_type": (Variant,),
"response_type": (VariantResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/feature-flags/{feature_flag_id}/variants",
"operation_id": "create_variant_for_feature_flag",
Expand All @@ -159,7 +159,7 @@ def __init__(self, api_client=None):
},
"body": {
"required": True,
"openapi_types": (CreateVariant,),
"openapi_types": (CreateVariantRequest,),
"location": "body",
},
},
Expand Down Expand Up @@ -744,7 +744,7 @@ def __init__(self, api_client=None):

self._update_variant_for_feature_flag_endpoint = _Endpoint(
settings={
"response_type": (Variant,),
"response_type": None,
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/feature-flags/{feature_flag_id}/variants/{variant_id}",
"operation_id": "update_variant_for_feature_flag",
Expand All @@ -770,7 +770,7 @@ def __init__(self, api_client=None):
"location": "body",
},
},
headers_map={"accept": ["application/json"], "content_type": ["application/json"]},
headers_map={"accept": ["*/*"], "content_type": ["application/json"]},
api_client=api_client,
)

Expand Down Expand Up @@ -853,8 +853,8 @@ def create_feature_flags_environment(
def create_variant_for_feature_flag(
self,
feature_flag_id: UUID,
body: CreateVariant,
) -> Variant:
body: CreateVariantRequest,
) -> VariantResponse:
"""Add a variant to a feature flag.

Adds a single new variant to an existing feature flag. This endpoint is
Expand All @@ -867,8 +867,8 @@ def create_variant_for_feature_flag(

:param feature_flag_id: The ID of the feature flag.
:type feature_flag_id: UUID
:type body: CreateVariant
:rtype: Variant
:type body: CreateVariantRequest
:rtype: VariantResponse
"""
kwargs: Dict[str, Any] = {}
kwargs["feature_flag_id"] = feature_flag_id
Expand Down Expand Up @@ -1374,7 +1374,7 @@ def update_variant_for_feature_flag(
feature_flag_id: UUID,
variant_id: UUID,
body: UpdateVariantRequest,
) -> Variant:
) -> None:
"""Update a variant.

Updates the name and value of an existing variant on a feature flag.
Expand All @@ -1386,7 +1386,7 @@ def update_variant_for_feature_flag(
:param variant_id: The ID of the variant.
:type variant_id: UUID
:type body: UpdateVariantRequest
:rtype: Variant
:rtype: None
"""
kwargs: Dict[str, Any] = {}
kwargs["feature_flag_id"] = feature_flag_id
Expand Down
2 changes: 1 addition & 1 deletion src/datadog_api_client/v2/model/create_variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def openapi_types(_):

def __init__(self_, key: str, name: str, value: str, **kwargs):
"""
Request to create a variant.
Attributes for creating a variant.

:param key: The unique key of the variant.
:type key: str
Expand Down
48 changes: 48 additions & 0 deletions src/datadog_api_client/v2/model/create_variant_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 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.create_variant import CreateVariant
from datadog_api_client.v2.model.variant_data_type import VariantDataType


class CreateVariantData(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.create_variant import CreateVariant
from datadog_api_client.v2.model.variant_data_type import VariantDataType

return {
"attributes": (CreateVariant,),
"type": (VariantDataType,),
}

attribute_map = {
"attributes": "attributes",
"type": "type",
}

def __init__(self_, attributes: CreateVariant, type: VariantDataType, **kwargs):
"""
Data for adding a variant to a feature flag.

:param attributes: Attributes for creating a variant.
:type attributes: CreateVariant

:param type: The resource type for variants.
:type type: VariantDataType
"""
super().__init__(kwargs)

self_.attributes = attributes
self_.type = type
Loading
Loading