From 1c6bf4d5205244beb2eaf61596776c69a4ce41f5 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Tue, 23 Jun 2026 19:48:51 +0000 Subject: [PATCH] Regenerate client from commit 281891e of spec repo --- .generator/schemas/v2/openapi.yaml | 232 ++++++++ .../CreateVariantForFeatureFlag.java | 31 + .../DeleteVariantFromFeatureFlag.java | 25 + .../UpdateVariantForFeatureFlag.java | 33 ++ .../api/client/v2/api/FeatureFlagsApi.java | 542 ++++++++++++++++++ .../client/v2/model/UpdateVariantRequest.java | 164 ++++++ .../api/client/v2/api/feature_flags.feature | 100 ++++ .../com/datadog/api/client/v2/api/undo.json | 18 + 8 files changed, 1145 insertions(+) create mode 100644 examples/v2/feature-flags/CreateVariantForFeatureFlag.java create mode 100644 examples/v2/feature-flags/DeleteVariantFromFeatureFlag.java create mode 100644 examples/v2/feature-flags/UpdateVariantForFeatureFlag.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/UpdateVariantRequest.java diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 99b25f0ac87..954f75f844f 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1966,6 +1966,15 @@ components: example: "550e8400-e29b-41d4-a716-446655440000" format: uuid type: string + variant_id: + description: The ID of the variant. + in: path + name: variant_id + required: true + schema: + example: "550e8400-e29b-41d4-a716-446655440002" + format: uuid + type: string requestBodies: {} responses: BadRequestResponse: @@ -105626,6 +105635,18 @@ components: required: - data type: object + UpdateVariantRequest: + description: Request to update an existing variant's name and value. + properties: + name: + description: The display name of the variant. + example: "Variant ABC123 Updated" + type: string + value: + description: The value of the variant as a string. + example: "new_value" + type: string + type: object UpdateWorkflowRequest: description: A request object for updating an existing workflow. example: @@ -132923,6 +132944,217 @@ paths: permissions: - feature_flag_config_write - feature_flag_environment_config_read + /api/v2/feature-flags/{feature_flag_id}/variants: + post: + description: |- + Adds a single new variant to an existing feature flag. This endpoint is + additive-only: it never modifies existing variants. A request whose `key` + already exists on the flag is rejected with `409 Conflict`; a `value` + whose type does not match the flag's `value_type` is rejected with `400`. + The server generates the variant UUID and returns it in the response body; + callers (for example, the flag-migration tool) need this UUID to reference + the new variant in subsequent allocation syncs. + operationId: CreateVariantForFeatureFlag + parameters: + - $ref: "#/components/parameters/feature_flag_id" + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + key: dark + name: Dark Theme + value: dark + type: variants + schema: + $ref: "#/components/schemas/CreateVariant" + required: true + responses: + "201": + content: + application/json: + examples: + default: + value: + data: + attributes: + created_at: "2024-01-01T00:00:00+00:00" + key: dark + name: Dark Theme + updated_at: "2024-01-01T00:00:00+00:00" + value: dark + id: "550e8400-e29b-41d4-a716-446655440002" + type: variants + schema: + $ref: "#/components/schemas/Variant" + description: Created + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Not Found + "409": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Conflict - A variant with this key already exists on the flag. + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Add a variant to a feature flag + tags: + - Feature Flags + x-permission: + operator: AND + permissions: + - feature_flag_config_write + /api/v2/feature-flags/{feature_flag_id}/variants/{variant_id}: + delete: + description: |- + Deletes a variant from a feature flag. + + When backend approvals are enabled and the flag requires approval, this endpoint creates and returns a `FlagSuggestion` with `201 Created` instead of deleting the variant immediately. If a pending suggestion already exists for this flag's variant property, the endpoint returns `409 Conflict`. + operationId: DeleteVariantFromFeatureFlag + parameters: + - $ref: "#/components/parameters/feature_flag_id" + - $ref: "#/components/parameters/variant_id" + responses: + "204": + description: No Content + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Not Found + "409": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Conflict - A pending suggestion already exists for this property. + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Delete a variant + tags: + - Feature Flags + x-permission: + operator: AND + permissions: + - feature_flag_config_write + put: + description: |- + Updates the name and value of an existing variant on a feature flag. + + When backend approvals are enabled and the flag requires approval, this endpoint creates and returns a `FlagSuggestion` with `201 Created` instead of applying the change immediately. Use the returned suggestion `id` to approve or reject the change. If a pending suggestion already exists for this flag's variant property, the endpoint returns `409 Conflict`. + operationId: UpdateVariantForFeatureFlag + parameters: + - $ref: "#/components/parameters/feature_flag_id" + - $ref: "#/components/parameters/variant_id" + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + name: Dark Theme Updated + value: dark_v2 + id: "550e8400-e29b-41d4-a716-446655440002" + type: variants + schema: + $ref: "#/components/schemas/UpdateVariantRequest" + 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: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Not Found + "409": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Conflict - A pending suggestion already exists for this property. + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Update a variant + tags: + - Feature Flags + x-permission: + operator: AND + permissions: + - feature_flag_config_write /api/v2/forms: get: description: Get all forms for the authenticated user's organization. diff --git a/examples/v2/feature-flags/CreateVariantForFeatureFlag.java b/examples/v2/feature-flags/CreateVariantForFeatureFlag.java new file mode 100644 index 00000000000..5a75501f4ca --- /dev/null +++ b/examples/v2/feature-flags/CreateVariantForFeatureFlag.java @@ -0,0 +1,31 @@ +// Add a variant to a feature flag returns "Created" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.FeatureFlagsApi; +import com.datadog.api.client.v2.model.CreateVariant; +import com.datadog.api.client.v2.model.Variant; +import java.util.UUID; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + FeatureFlagsApi apiInstance = new FeatureFlagsApi(defaultClient); + + CreateVariant body = + new CreateVariant().key("variant-abc123").name("Variant ABC123").value("true"); + + try { + Variant result = + apiInstance.createVariantForFeatureFlag( + UUID.fromString("550e8400-e29b-41d4-a716-446655440000"), body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling FeatureFlagsApi#createVariantForFeatureFlag"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/feature-flags/DeleteVariantFromFeatureFlag.java b/examples/v2/feature-flags/DeleteVariantFromFeatureFlag.java new file mode 100644 index 00000000000..fa77dae849b --- /dev/null +++ b/examples/v2/feature-flags/DeleteVariantFromFeatureFlag.java @@ -0,0 +1,25 @@ +// Delete a variant returns "No Content" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.FeatureFlagsApi; +import java.util.UUID; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + FeatureFlagsApi apiInstance = new FeatureFlagsApi(defaultClient); + + try { + apiInstance.deleteVariantFromFeatureFlag( + UUID.fromString("550e8400-e29b-41d4-a716-446655440000"), + UUID.fromString("550e8400-e29b-41d4-a716-446655440002")); + } catch (ApiException e) { + System.err.println("Exception when calling FeatureFlagsApi#deleteVariantFromFeatureFlag"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/feature-flags/UpdateVariantForFeatureFlag.java b/examples/v2/feature-flags/UpdateVariantForFeatureFlag.java new file mode 100644 index 00000000000..761c7cdce8d --- /dev/null +++ b/examples/v2/feature-flags/UpdateVariantForFeatureFlag.java @@ -0,0 +1,33 @@ +// Update a variant returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.FeatureFlagsApi; +import com.datadog.api.client.v2.model.UpdateVariantRequest; +import com.datadog.api.client.v2.model.Variant; +import java.util.UUID; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + FeatureFlagsApi apiInstance = new FeatureFlagsApi(defaultClient); + + UpdateVariantRequest body = + new UpdateVariantRequest().name("Variant ABC123 Updated").value("new_value"); + + try { + Variant result = + apiInstance.updateVariantForFeatureFlag( + UUID.fromString("550e8400-e29b-41d4-a716-446655440000"), + UUID.fromString("550e8400-e29b-41d4-a716-446655440002"), + body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling FeatureFlagsApi#updateVariantForFeatureFlag"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/v2/api/FeatureFlagsApi.java b/src/main/java/com/datadog/api/client/v2/api/FeatureFlagsApi.java index f237f027eac..43cf9f3f704 100644 --- a/src/main/java/com/datadog/api/client/v2/api/FeatureFlagsApi.java +++ b/src/main/java/com/datadog/api/client/v2/api/FeatureFlagsApi.java @@ -9,6 +9,7 @@ import com.datadog.api.client.v2.model.CreateAllocationsRequest; import com.datadog.api.client.v2.model.CreateEnvironmentRequest; import com.datadog.api.client.v2.model.CreateFeatureFlagRequest; +import com.datadog.api.client.v2.model.CreateVariant; import com.datadog.api.client.v2.model.EnvironmentResponse; import com.datadog.api.client.v2.model.FeatureFlagResponse; import com.datadog.api.client.v2.model.ListAllocationsResponse; @@ -17,6 +18,8 @@ import com.datadog.api.client.v2.model.OverwriteAllocationsRequest; import com.datadog.api.client.v2.model.UpdateEnvironmentRequest; import com.datadog.api.client.v2.model.UpdateFeatureFlagRequest; +import com.datadog.api.client.v2.model.UpdateVariantRequest; +import com.datadog.api.client.v2.model.Variant; import jakarta.ws.rs.client.Invocation; import jakarta.ws.rs.core.GenericType; import java.util.ArrayList; @@ -668,6 +671,178 @@ public ApiResponse createFeatureFlagsEnvironmentWithHttpInf new GenericType() {}); } + /** + * Add a variant to a feature flag. + * + *

See {@link #createVariantForFeatureFlagWithHttpInfo}. + * + * @param featureFlagId The ID of the feature flag. (required) + * @param body (required) + * @return Variant + * @throws ApiException if fails to make API call + */ + public Variant createVariantForFeatureFlag(UUID featureFlagId, CreateVariant body) + throws ApiException { + return createVariantForFeatureFlagWithHttpInfo(featureFlagId, body).getData(); + } + + /** + * Add a variant to a feature flag. + * + *

See {@link #createVariantForFeatureFlagWithHttpInfoAsync}. + * + * @param featureFlagId The ID of the feature flag. (required) + * @param body (required) + * @return CompletableFuture<Variant> + */ + public CompletableFuture createVariantForFeatureFlagAsync( + UUID featureFlagId, CreateVariant body) { + return createVariantForFeatureFlagWithHttpInfoAsync(featureFlagId, body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Adds a single new variant to an existing feature flag. This endpoint is additive-only: it never + * modifies existing variants. A request whose key already exists on the flag is + * rejected with 409 Conflict; a value whose type does not match the + * flag's value_type is rejected with 400. The server generates the + * variant UUID and returns it in the response body; callers (for example, the flag-migration + * tool) need this UUID to reference the new variant in subsequent allocation syncs. + * + * @param featureFlagId The ID of the feature flag. (required) + * @param body (required) + * @return ApiResponse<Variant> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
201 Created -
400 Bad Request -
403 Forbidden -
404 Not Found -
409 Conflict - A variant with this key already exists on the flag. -
429 Too many requests -
+ */ + public ApiResponse createVariantForFeatureFlagWithHttpInfo( + UUID featureFlagId, CreateVariant body) throws ApiException { + Object localVarPostBody = body; + + // verify the required parameter 'featureFlagId' is set + if (featureFlagId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'featureFlagId' when calling" + + " createVariantForFeatureFlag"); + } + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling createVariantForFeatureFlag"); + } + // create path and map variables + String localVarPath = + "/api/v2/feature-flags/{feature_flag_id}/variants" + .replaceAll( + "\\{" + "feature_flag_id" + "\\}", + apiClient.escapeString(featureFlagId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.FeatureFlagsApi.createVariantForFeatureFlag", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Add a variant to a feature flag. + * + *

See {@link #createVariantForFeatureFlagWithHttpInfo}. + * + * @param featureFlagId The ID of the feature flag. (required) + * @param body (required) + * @return CompletableFuture<ApiResponse<Variant>> + */ + public CompletableFuture> createVariantForFeatureFlagWithHttpInfoAsync( + UUID featureFlagId, CreateVariant body) { + Object localVarPostBody = body; + + // verify the required parameter 'featureFlagId' is set + if (featureFlagId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'featureFlagId' when calling" + + " createVariantForFeatureFlag")); + return result; + } + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'body' when calling createVariantForFeatureFlag")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/feature-flags/{feature_flag_id}/variants" + .replaceAll( + "\\{" + "feature_flag_id" + "\\}", + apiClient.escapeString(featureFlagId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.FeatureFlagsApi.createVariantForFeatureFlag", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** * Delete an environment. * @@ -808,6 +983,178 @@ public CompletableFuture> deleteFeatureFlagsEnvironmentWithHtt null); } + /** + * Delete a variant. + * + *

See {@link #deleteVariantFromFeatureFlagWithHttpInfo}. + * + * @param featureFlagId The ID of the feature flag. (required) + * @param variantId The ID of the variant. (required) + * @throws ApiException if fails to make API call + */ + public void deleteVariantFromFeatureFlag(UUID featureFlagId, UUID variantId) throws ApiException { + deleteVariantFromFeatureFlagWithHttpInfo(featureFlagId, variantId); + } + + /** + * Delete a variant. + * + *

See {@link #deleteVariantFromFeatureFlagWithHttpInfoAsync}. + * + * @param featureFlagId The ID of the feature flag. (required) + * @param variantId The ID of the variant. (required) + * @return CompletableFuture + */ + public CompletableFuture deleteVariantFromFeatureFlagAsync( + UUID featureFlagId, UUID variantId) { + return deleteVariantFromFeatureFlagWithHttpInfoAsync(featureFlagId, variantId) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Deletes a variant from a feature flag. + * + *

When backend approvals are enabled and the flag requires approval, this endpoint creates and + * returns a FlagSuggestion with 201 Created instead of deleting the + * variant immediately. If a pending suggestion already exists for this flag's variant property, + * the endpoint returns 409 Conflict. + * + * @param featureFlagId The ID of the feature flag. (required) + * @param variantId The ID of the variant. (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
204 No Content -
400 Bad Request -
403 Forbidden -
404 Not Found -
409 Conflict - A pending suggestion already exists for this property. -
429 Too many requests -
+ */ + public ApiResponse deleteVariantFromFeatureFlagWithHttpInfo( + UUID featureFlagId, UUID variantId) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'featureFlagId' is set + if (featureFlagId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'featureFlagId' when calling" + + " deleteVariantFromFeatureFlag"); + } + + // verify the required parameter 'variantId' is set + if (variantId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'variantId' when calling deleteVariantFromFeatureFlag"); + } + // create path and map variables + String localVarPath = + "/api/v2/feature-flags/{feature_flag_id}/variants/{variant_id}" + .replaceAll( + "\\{" + "feature_flag_id" + "\\}", apiClient.escapeString(featureFlagId.toString())) + .replaceAll("\\{" + "variant_id" + "\\}", apiClient.escapeString(variantId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.FeatureFlagsApi.deleteVariantFromFeatureFlag", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "DELETE", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + null); + } + + /** + * Delete a variant. + * + *

See {@link #deleteVariantFromFeatureFlagWithHttpInfo}. + * + * @param featureFlagId The ID of the feature flag. (required) + * @param variantId The ID of the variant. (required) + * @return CompletableFuture<ApiResponse<Void>> + */ + public CompletableFuture> deleteVariantFromFeatureFlagWithHttpInfoAsync( + UUID featureFlagId, UUID variantId) { + Object localVarPostBody = null; + + // verify the required parameter 'featureFlagId' is set + if (featureFlagId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'featureFlagId' when calling" + + " deleteVariantFromFeatureFlag")); + return result; + } + + // verify the required parameter 'variantId' is set + if (variantId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'variantId' when calling" + + " deleteVariantFromFeatureFlag")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/feature-flags/{feature_flag_id}/variants/{variant_id}" + .replaceAll( + "\\{" + "feature_flag_id" + "\\}", apiClient.escapeString(featureFlagId.toString())) + .replaceAll("\\{" + "variant_id" + "\\}", apiClient.escapeString(variantId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.FeatureFlagsApi.deleteVariantFromFeatureFlag", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "DELETE", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + null); + } + /** * Disable a feature flag in an environment. * @@ -3131,4 +3478,199 @@ public ApiResponse updateFeatureFlagsEnvironmentWithHttpInf false, new GenericType() {}); } + + /** + * Update a variant. + * + *

See {@link #updateVariantForFeatureFlagWithHttpInfo}. + * + * @param featureFlagId The ID of the feature flag. (required) + * @param variantId The ID of the variant. (required) + * @param body (required) + * @return Variant + * @throws ApiException if fails to make API call + */ + public Variant updateVariantForFeatureFlag( + UUID featureFlagId, UUID variantId, UpdateVariantRequest body) throws ApiException { + return updateVariantForFeatureFlagWithHttpInfo(featureFlagId, variantId, body).getData(); + } + + /** + * Update a variant. + * + *

See {@link #updateVariantForFeatureFlagWithHttpInfoAsync}. + * + * @param featureFlagId The ID of the feature flag. (required) + * @param variantId The ID of the variant. (required) + * @param body (required) + * @return CompletableFuture<Variant> + */ + public CompletableFuture updateVariantForFeatureFlagAsync( + UUID featureFlagId, UUID variantId, UpdateVariantRequest body) { + return updateVariantForFeatureFlagWithHttpInfoAsync(featureFlagId, variantId, body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Updates the name and value of an existing variant on a feature flag. + * + *

When backend approvals are enabled and the flag requires approval, this endpoint creates and + * returns a FlagSuggestion with 201 Created instead of applying the + * change immediately. Use the returned suggestion id to approve or reject the + * change. If a pending suggestion already exists for this flag's variant property, the endpoint + * returns 409 Conflict. + * + * @param featureFlagId The ID of the feature flag. (required) + * @param variantId The ID of the variant. (required) + * @param body (required) + * @return ApiResponse<Variant> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
404 Not Found -
409 Conflict - A pending suggestion already exists for this property. -
429 Too many requests -
+ */ + public ApiResponse updateVariantForFeatureFlagWithHttpInfo( + UUID featureFlagId, UUID variantId, UpdateVariantRequest body) throws ApiException { + Object localVarPostBody = body; + + // verify the required parameter 'featureFlagId' is set + if (featureFlagId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'featureFlagId' when calling" + + " updateVariantForFeatureFlag"); + } + + // verify the required parameter 'variantId' is set + if (variantId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'variantId' when calling updateVariantForFeatureFlag"); + } + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling updateVariantForFeatureFlag"); + } + // create path and map variables + String localVarPath = + "/api/v2/feature-flags/{feature_flag_id}/variants/{variant_id}" + .replaceAll( + "\\{" + "feature_flag_id" + "\\}", apiClient.escapeString(featureFlagId.toString())) + .replaceAll("\\{" + "variant_id" + "\\}", apiClient.escapeString(variantId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.FeatureFlagsApi.updateVariantForFeatureFlag", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "PUT", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Update a variant. + * + *

See {@link #updateVariantForFeatureFlagWithHttpInfo}. + * + * @param featureFlagId The ID of the feature flag. (required) + * @param variantId The ID of the variant. (required) + * @param body (required) + * @return CompletableFuture<ApiResponse<Variant>> + */ + public CompletableFuture> updateVariantForFeatureFlagWithHttpInfoAsync( + UUID featureFlagId, UUID variantId, UpdateVariantRequest body) { + Object localVarPostBody = body; + + // verify the required parameter 'featureFlagId' is set + if (featureFlagId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'featureFlagId' when calling" + + " updateVariantForFeatureFlag")); + return result; + } + + // verify the required parameter 'variantId' is set + if (variantId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'variantId' when calling" + + " updateVariantForFeatureFlag")); + return result; + } + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'body' when calling updateVariantForFeatureFlag")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/feature-flags/{feature_flag_id}/variants/{variant_id}" + .replaceAll( + "\\{" + "feature_flag_id" + "\\}", apiClient.escapeString(featureFlagId.toString())) + .replaceAll("\\{" + "variant_id" + "\\}", apiClient.escapeString(variantId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.FeatureFlagsApi.updateVariantForFeatureFlag", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "PUT", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } } diff --git a/src/main/java/com/datadog/api/client/v2/model/UpdateVariantRequest.java b/src/main/java/com/datadog/api/client/v2/model/UpdateVariantRequest.java new file mode 100644 index 00000000000..f1550e0a3b8 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UpdateVariantRequest.java @@ -0,0 +1,164 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Request to update an existing variant's name and value. */ +@JsonPropertyOrder({ + UpdateVariantRequest.JSON_PROPERTY_NAME, + UpdateVariantRequest.JSON_PROPERTY_VALUE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UpdateVariantRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_VALUE = "value"; + private String value; + + public UpdateVariantRequest name(String name) { + this.name = name; + return this; + } + + /** + * The display name of the variant. + * + * @return name + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public UpdateVariantRequest value(String value) { + this.value = value; + return this; + } + + /** + * The value of the variant as a string. + * + * @return value + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_VALUE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return UpdateVariantRequest + */ + @JsonAnySetter + public UpdateVariantRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this UpdateVariantRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateVariantRequest updateVariantRequest = (UpdateVariantRequest) o; + return Objects.equals(this.name, updateVariantRequest.name) + && Objects.equals(this.value, updateVariantRequest.value) + && Objects.equals(this.additionalProperties, updateVariantRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(name, value, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateVariantRequest {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/test/resources/com/datadog/api/client/v2/api/feature_flags.feature b/src/test/resources/com/datadog/api/client/v2/api/feature_flags.feature index df31d246a42..c98cd04f77c 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/feature_flags.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/feature_flags.feature @@ -7,6 +7,38 @@ Feature: Feature Flags And a valid "appKeyAuth" key in the system And an instance of "FeatureFlags" API + @generated @skip @team:DataDog/feature-flags + Scenario: Add a variant to a feature flag returns "Bad Request" response + Given new "CreateVariantForFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And body with value {"key": "variant-abc123", "name": "Variant ABC123", "value": "true"} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/feature-flags + Scenario: Add a variant to a feature flag returns "Conflict - A variant with this key already exists on the flag." response + Given new "CreateVariantForFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And body with value {"key": "variant-abc123", "name": "Variant ABC123", "value": "true"} + When the request is sent + Then the response status is 409 Conflict - A variant with this key already exists on the flag. + + @generated @skip @team:DataDog/feature-flags + Scenario: Add a variant to a feature flag returns "Created" response + Given new "CreateVariantForFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And body with value {"key": "variant-abc123", "name": "Variant ABC123", "value": "true"} + When the request is sent + Then the response status is 201 Created + + @generated @skip @team:DataDog/feature-flags + Scenario: Add a variant to a feature flag returns "Not Found" response + Given new "CreateVariantForFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And body with value {"key": "variant-abc123", "name": "Variant ABC123", "value": "true"} + When the request is sent + Then the response status is 404 Not Found + @skip @team:DataDog/feature-flags Scenario: Archive a feature flag returns "Bad Request" response Given new "ArchiveFeatureFlag" request @@ -130,6 +162,38 @@ Feature: Feature Flags When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/feature-flags + Scenario: Delete a variant returns "Bad Request" response + Given new "DeleteVariantFromFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "variant_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/feature-flags + Scenario: Delete a variant returns "Conflict - A pending suggestion already exists for this property." response + Given new "DeleteVariantFromFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "variant_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 409 Conflict - A pending suggestion already exists for this property. + + @generated @skip @team:DataDog/feature-flags + Scenario: Delete a variant returns "No Content" response + Given new "DeleteVariantFromFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "variant_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/feature-flags + Scenario: Delete a variant returns "Not Found" response + Given new "DeleteVariantFromFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "variant_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @skip @team:DataDog/feature-flags Scenario: Delete an environment returns "No Content" response Given there is a valid "environment" in the system @@ -408,6 +472,42 @@ Feature: Feature Flags And the response "data.attributes.name" is equal to "Updated Test Feature Flag {{ unique }}" And the response "data.attributes.description" is equal to "Updated description for the feature flag" + @generated @skip @team:DataDog/feature-flags + Scenario: Update a variant returns "Bad Request" response + Given new "UpdateVariantForFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "variant_id" parameter from "REPLACE.ME" + And body with value {"name": "Variant ABC123 Updated", "value": "new_value"} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/feature-flags + Scenario: Update a variant returns "Conflict - A pending suggestion already exists for this property." response + Given new "UpdateVariantForFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "variant_id" parameter from "REPLACE.ME" + And body with value {"name": "Variant ABC123 Updated", "value": "new_value"} + When the request is sent + Then the response status is 409 Conflict - A pending suggestion already exists for this property. + + @generated @skip @team:DataDog/feature-flags + Scenario: Update a variant returns "Not Found" response + Given new "UpdateVariantForFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "variant_id" parameter from "REPLACE.ME" + And body with value {"name": "Variant ABC123 Updated", "value": "new_value"} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/feature-flags + Scenario: Update a variant returns "OK" response + Given new "UpdateVariantForFeatureFlag" request + And request contains "feature_flag_id" parameter from "REPLACE.ME" + And request contains "variant_id" parameter from "REPLACE.ME" + And body with value {"name": "Variant ABC123 Updated", "value": "new_value"} + When the request is sent + Then the response status is 200 OK + @skip @team:DataDog/feature-flags Scenario: Update an environment returns "Bad Request" response Given new "UpdateFeatureFlagsEnvironment" request diff --git a/src/test/resources/com/datadog/api/client/v2/api/undo.json b/src/test/resources/com/datadog/api/client/v2/api/undo.json index a5c43f6c0f2..b0dab3582ba 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/undo.json +++ b/src/test/resources/com/datadog/api/client/v2/api/undo.json @@ -2675,6 +2675,24 @@ "type": "unsafe" } }, + "CreateVariantForFeatureFlag": { + "tag": "Feature Flags", + "undo": { + "type": "unsafe" + } + }, + "DeleteVariantFromFeatureFlag": { + "tag": "Feature Flags", + "undo": { + "type": "unsafe" + } + }, + "UpdateVariantForFeatureFlag": { + "tag": "Feature Flags", + "undo": { + "type": "idempotent" + } + }, "ListForms": { "tag": "Forms", "undo": {