|
| 1 | +""" |
| 2 | +Create a flag change suggestion returns "Created" response |
| 3 | +""" |
| 4 | + |
| 5 | +from os import environ |
| 6 | +from datadog_api_client import ApiClient, Configuration |
| 7 | +from datadog_api_client.v2.api.feature_flags_api import FeatureFlagsApi |
| 8 | +from datadog_api_client.v2.model.create_flag_suggestion_attributes import CreateFlagSuggestionAttributes |
| 9 | +from datadog_api_client.v2.model.create_flag_suggestion_data import CreateFlagSuggestionData |
| 10 | +from datadog_api_client.v2.model.create_flag_suggestion_request import CreateFlagSuggestionRequest |
| 11 | +from datadog_api_client.v2.model.feature_flag_suggestion_data_type import FeatureFlagSuggestionDataType |
| 12 | +from datadog_api_client.v2.model.feature_flag_suggestion_metadata_request import FeatureFlagSuggestionMetadataRequest |
| 13 | +from uuid import UUID |
| 14 | + |
| 15 | +body = CreateFlagSuggestionRequest( |
| 16 | + data=CreateFlagSuggestionData( |
| 17 | + attributes=CreateFlagSuggestionAttributes( |
| 18 | + action="updated", |
| 19 | + comment="Restrict this flag to server applications.", |
| 20 | + environment_id=UUID("550e8400-e29b-41d4-a716-446655440001"), |
| 21 | + notification_rule_targets=[ |
| 22 | + "requester@example.com", |
| 23 | + ], |
| 24 | + _property="DISTRIBUTION_CHANNEL", |
| 25 | + suggestion="SERVER", |
| 26 | + suggestion_metadata=FeatureFlagSuggestionMetadataRequest( |
| 27 | + variant_id=UUID("550e8400-e29b-41d4-a716-446655440002"), |
| 28 | + ), |
| 29 | + ), |
| 30 | + type=FeatureFlagSuggestionDataType.FLAG_SUGGESTIONS, |
| 31 | + ), |
| 32 | +) |
| 33 | + |
| 34 | +configuration = Configuration() |
| 35 | +configuration.access_token = environ["DD_BEARER_TOKEN"] |
| 36 | +with ApiClient(configuration) as api_client: |
| 37 | + api_instance = FeatureFlagsApi(api_client) |
| 38 | + response = api_instance.create_flag_suggestion( |
| 39 | + feature_flag_id=UUID("550e8400-e29b-41d4-a716-446655440000"), body=body |
| 40 | + ) |
| 41 | + |
| 42 | + print(response) |
0 commit comments