diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 99b25f0ac87f..954f75f844f8 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.rb b/examples/v2/feature-flags/CreateVariantForFeatureFlag.rb new file mode 100644 index 000000000000..02367661520f --- /dev/null +++ b/examples/v2/feature-flags/CreateVariantForFeatureFlag.rb @@ -0,0 +1,11 @@ +# Add a variant to a feature flag returns "Created" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::FeatureFlagsAPI.new + +body = DatadogAPIClient::V2::CreateVariant.new({ + key: "variant-abc123", + name: "Variant ABC123", + value: "true", +}) +p api_instance.create_variant_for_feature_flag("550e8400-e29b-41d4-a716-446655440000", body) diff --git a/examples/v2/feature-flags/DeleteVariantFromFeatureFlag.rb b/examples/v2/feature-flags/DeleteVariantFromFeatureFlag.rb new file mode 100644 index 000000000000..07e1770ea9de --- /dev/null +++ b/examples/v2/feature-flags/DeleteVariantFromFeatureFlag.rb @@ -0,0 +1,5 @@ +# Delete a variant returns "No Content" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::FeatureFlagsAPI.new +api_instance.delete_variant_from_feature_flag("550e8400-e29b-41d4-a716-446655440000", "550e8400-e29b-41d4-a716-446655440002") diff --git a/examples/v2/feature-flags/UpdateVariantForFeatureFlag.rb b/examples/v2/feature-flags/UpdateVariantForFeatureFlag.rb new file mode 100644 index 000000000000..a4b841bbe967 --- /dev/null +++ b/examples/v2/feature-flags/UpdateVariantForFeatureFlag.rb @@ -0,0 +1,10 @@ +# Update a variant returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::FeatureFlagsAPI.new + +body = DatadogAPIClient::V2::UpdateVariantRequest.new({ + name: "Variant ABC123 Updated", + value: "new_value", +}) +p api_instance.update_variant_for_feature_flag("550e8400-e29b-41d4-a716-446655440000", "550e8400-e29b-41d4-a716-446655440002", body) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 8d27a626e6cf..2182ae397869 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -3289,6 +3289,19 @@ "v2.UnarchiveFeatureFlag" => { "feature_flag_id" => "UUID", }, + "v2.CreateVariantForFeatureFlag" => { + "feature_flag_id" => "UUID", + "body" => "CreateVariant", + }, + "v2.DeleteVariantFromFeatureFlag" => { + "feature_flag_id" => "UUID", + "variant_id" => "UUID", + }, + "v2.UpdateVariantForFeatureFlag" => { + "feature_flag_id" => "UUID", + "variant_id" => "UUID", + "body" => "UpdateVariantRequest", + }, "v2.CreateForm" => { "body" => "CreateFormRequest", }, diff --git a/features/v2/feature_flags.feature b/features/v2/feature_flags.feature index df31d246a423..c98cd04f77ce 100644 --- a/features/v2/feature_flags.feature +++ b/features/v2/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/features/v2/undo.json b/features/v2/undo.json index a5c43f6c0f2c..b0dab3582baa 100644 --- a/features/v2/undo.json +++ b/features/v2/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": { diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index c168f8873c02..d57b2ab2d09d 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -7572,6 +7572,7 @@ def overrides "v2.update_tenancy_config_data_attributes_regions_config" => "UpdateTenancyConfigDataAttributesRegionsConfig", "v2.update_tenancy_config_data_type" => "UpdateTenancyConfigDataType", "v2.update_tenancy_config_request" => "UpdateTenancyConfigRequest", + "v2.update_variant_request" => "UpdateVariantRequest", "v2.update_workflow_request" => "UpdateWorkflowRequest", "v2.update_workflow_response" => "UpdateWorkflowResponse", "v2.upsert_allocation_request" => "UpsertAllocationRequest", diff --git a/lib/datadog_api_client/v2/api/feature_flags_api.rb b/lib/datadog_api_client/v2/api/feature_flags_api.rb index 95979845b986..b00356c8ee82 100644 --- a/lib/datadog_api_client/v2/api/feature_flags_api.rb +++ b/lib/datadog_api_client/v2/api/feature_flags_api.rb @@ -300,6 +300,84 @@ def create_feature_flags_environment_with_http_info(body, opts = {}) return data, status_code, headers end + # Add a variant to a feature flag. + # + # @see #create_variant_for_feature_flag_with_http_info + def create_variant_for_feature_flag(feature_flag_id, body, opts = {}) + data, _status_code, _headers = create_variant_for_feature_flag_with_http_info(feature_flag_id, body, opts) + data + end + + # Add a variant to a feature flag. + # + # 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 feature_flag_id [UUID] The ID of the feature flag. + # @param body [CreateVariant] + # @param opts [Hash] the optional parameters + # @return [Array<(Variant, Integer, Hash)>] Variant data, response status code and response headers + def create_variant_for_feature_flag_with_http_info(feature_flag_id, body, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FeatureFlagsAPI.create_variant_for_feature_flag ...' + end + # verify the required parameter 'feature_flag_id' is set + if @api_client.config.client_side_validation && feature_flag_id.nil? + fail ArgumentError, "Missing the required parameter 'feature_flag_id' when calling FeatureFlagsAPI.create_variant_for_feature_flag" + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling FeatureFlagsAPI.create_variant_for_feature_flag" + end + # resource path + local_var_path = '/api/v2/feature-flags/{feature_flag_id}/variants'.sub('{feature_flag_id}', CGI.escape(feature_flag_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'Variant' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :create_variant_for_feature_flag, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FeatureFlagsAPI#create_variant_for_feature_flag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Delete an environment. # # @see #delete_feature_flags_environment_with_http_info @@ -365,6 +443,78 @@ def delete_feature_flags_environment_with_http_info(environment_id, opts = {}) return data, status_code, headers end + # Delete a variant. + # + # @see #delete_variant_from_feature_flag_with_http_info + def delete_variant_from_feature_flag(feature_flag_id, variant_id, opts = {}) + delete_variant_from_feature_flag_with_http_info(feature_flag_id, variant_id, opts) + nil + end + + # Delete a variant. + # + # 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 feature_flag_id [UUID] The ID of the feature flag. + # @param variant_id [UUID] The ID of the variant. + # @param opts [Hash] the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_variant_from_feature_flag_with_http_info(feature_flag_id, variant_id, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FeatureFlagsAPI.delete_variant_from_feature_flag ...' + end + # verify the required parameter 'feature_flag_id' is set + if @api_client.config.client_side_validation && feature_flag_id.nil? + fail ArgumentError, "Missing the required parameter 'feature_flag_id' when calling FeatureFlagsAPI.delete_variant_from_feature_flag" + end + # verify the required parameter 'variant_id' is set + if @api_client.config.client_side_validation && variant_id.nil? + fail ArgumentError, "Missing the required parameter 'variant_id' when calling FeatureFlagsAPI.delete_variant_from_feature_flag" + end + # resource path + local_var_path = '/api/v2/feature-flags/{feature_flag_id}/variants/{variant_id}'.sub('{feature_flag_id}', CGI.escape(feature_flag_id.to_s).gsub('%2F', '/')).sub('{variant_id}', CGI.escape(variant_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['*/*']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :delete_variant_from_feature_flag, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Delete, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FeatureFlagsAPI#delete_variant_from_feature_flag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Disable a feature flag in an environment. # # @see #disable_feature_flag_environment_with_http_info @@ -1341,5 +1491,84 @@ def update_feature_flags_environment_with_http_info(environment_id, body, opts = end return data, status_code, headers end + + # Update a variant. + # + # @see #update_variant_for_feature_flag_with_http_info + def update_variant_for_feature_flag(feature_flag_id, variant_id, body, opts = {}) + data, _status_code, _headers = update_variant_for_feature_flag_with_http_info(feature_flag_id, variant_id, body, opts) + data + end + + # Update a variant. + # + # 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 feature_flag_id [UUID] The ID of the feature flag. + # @param variant_id [UUID] The ID of the variant. + # @param body [UpdateVariantRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(Variant, Integer, Hash)>] Variant data, response status code and response headers + def update_variant_for_feature_flag_with_http_info(feature_flag_id, variant_id, body, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FeatureFlagsAPI.update_variant_for_feature_flag ...' + end + # verify the required parameter 'feature_flag_id' is set + if @api_client.config.client_side_validation && feature_flag_id.nil? + fail ArgumentError, "Missing the required parameter 'feature_flag_id' when calling FeatureFlagsAPI.update_variant_for_feature_flag" + end + # verify the required parameter 'variant_id' is set + if @api_client.config.client_side_validation && variant_id.nil? + fail ArgumentError, "Missing the required parameter 'variant_id' when calling FeatureFlagsAPI.update_variant_for_feature_flag" + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling FeatureFlagsAPI.update_variant_for_feature_flag" + end + # resource path + local_var_path = '/api/v2/feature-flags/{feature_flag_id}/variants/{variant_id}'.sub('{feature_flag_id}', CGI.escape(feature_flag_id.to_s).gsub('%2F', '/')).sub('{variant_id}', CGI.escape(variant_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'Variant' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :update_variant_for_feature_flag, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Put, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FeatureFlagsAPI#update_variant_for_feature_flag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end end end diff --git a/lib/datadog_api_client/v2/models/update_variant_request.rb b/lib/datadog_api_client/v2/models/update_variant_request.rb new file mode 100644 index 000000000000..3a80b65f6244 --- /dev/null +++ b/lib/datadog_api_client/v2/models/update_variant_request.rb @@ -0,0 +1,115 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Request to update an existing variant's name and value. + class UpdateVariantRequest + include BaseGenericModel + + # The display name of the variant. + attr_accessor :name + + # The value of the variant as a string. + attr_accessor :value + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'name' => :'name', + :'value' => :'value' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'name' => :'String', + :'value' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::UpdateVariantRequest` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'value') + self.value = attributes[:'value'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + value == o.value && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [name, value, additional_properties].hash + end + end +end