diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 9bceb715496..746ddbe0fcb 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -16644,6 +16644,14 @@ components: required: - id type: object + DeploymentGateRulesResponse: + description: Response for a deployment gate rules. + properties: + data: + items: + $ref: '#/components/schemas/DeploymentRuleResponseData' + type: array + type: object DeploymentMetadata: description: Metadata object containing the publication creation information. properties: @@ -64391,6 +64399,50 @@ paths: If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/deployment_gates/{gate_id}/rules: + get: + description: Endpoint to get rules for a deployment gate. + operationId: GetDeploymentGateRules + parameters: + - description: The ID of the deployment gate. + in: path + name: gate_id + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/DeploymentGateRulesResponse' + description: OK + '400': + $ref: '#/components/responses/HTTPCDGatesBadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPCIAppErrors' + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Get rules for a deployment gate + tags: + - Deployment Gates + x-permission: + operator: OR + permissions: + - deployment_gates_read + x-unstable: '**Note**: This endpoint is in preview and may be subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' post: description: Endpoint to create a deployment rule. A gate for the rule must already exist. diff --git a/examples/v2/deployment-gates/GetDeploymentGateRules.rb b/examples/v2/deployment-gates/GetDeploymentGateRules.rb new file mode 100644 index 00000000000..b1fa5b9623d --- /dev/null +++ b/examples/v2/deployment-gates/GetDeploymentGateRules.rb @@ -0,0 +1,11 @@ +# Get rules for a deployment gate returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.get_deployment_gate_rules".to_sym] = true +end +api_instance = DatadogAPIClient::V2::DeploymentGatesAPI.new + +# there is a valid "deployment_gate" in the system +DEPLOYMENT_GATE_DATA_ID = ENV["DEPLOYMENT_GATE_DATA_ID"] +p api_instance.get_deployment_gate_rules(DEPLOYMENT_GATE_DATA_ID) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 15e1897d6c5..d2b43d9a882 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -1862,6 +1862,9 @@ "v2.CreateDeploymentGate" => { "body" => "CreateDeploymentGateParams", }, + "v2.GetDeploymentGateRules" => { + "gate_id" => "String", + }, "v2.CreateDeploymentRule" => { "gate_id" => "String", "body" => "CreateDeploymentRuleParams", diff --git a/features/v2/deployment_gates.feature b/features/v2/deployment_gates.feature index e4023c5650b..cb0c5a1262d 100644 --- a/features/v2/deployment_gates.feature +++ b/features/v2/deployment_gates.feature @@ -207,6 +207,23 @@ Feature: Deployment Gates When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/ci-app-backend + Scenario: Get rules for a deployment gate returns "Bad request." response + Given operation "GetDeploymentGateRules" enabled + And new "GetDeploymentGateRules" request + And request contains "gate_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad request. + + @team:DataDog/ci-app-backend + Scenario: Get rules for a deployment gate returns "OK" response + Given there is a valid "deployment_gate" in the system + And operation "GetDeploymentGateRules" enabled + And new "GetDeploymentGateRules" request + And request contains "gate_id" parameter from "deployment_gate.data.id" + When the request is sent + Then the response status is 200 OK + @team:DataDog/ci-app-backend Scenario: Update deployment gate returns "Bad Request" response Given operation "UpdateDeploymentGate" enabled diff --git a/features/v2/undo.json b/features/v2/undo.json index 3799e64e630..619834eec83 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -1323,6 +1323,12 @@ "type": "unsafe" } }, + "GetDeploymentGateRules": { + "tag": "Deployment Gates", + "undo": { + "type": "safe" + } + }, "CreateDeploymentRule": { "tag": "Deployment Gates", "undo": { diff --git a/lib/datadog_api_client/configuration.rb b/lib/datadog_api_client/configuration.rb index 63e87298198..2705beaab22 100644 --- a/lib/datadog_api_client/configuration.rb +++ b/lib/datadog_api_client/configuration.rb @@ -240,6 +240,7 @@ def initialize "v2.delete_deployment_gate": false, "v2.delete_deployment_rule": false, "v2.get_deployment_gate": false, + "v2.get_deployment_gate_rules": false, "v2.get_deployment_rule": false, "v2.update_deployment_gate": false, "v2.update_deployment_rule": false, diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 427fdcf8659..93c504a27df 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -1892,6 +1892,7 @@ def overrides "v2.deployment_gate_response_data_attributes" => "DeploymentGateResponseDataAttributes", "v2.deployment_gate_response_data_attributes_created_by" => "DeploymentGateResponseDataAttributesCreatedBy", "v2.deployment_gate_response_data_attributes_updated_by" => "DeploymentGateResponseDataAttributesUpdatedBy", + "v2.deployment_gate_rules_response" => "DeploymentGateRulesResponse", "v2.deployment_metadata" => "DeploymentMetadata", "v2.deployment_relationship" => "DeploymentRelationship", "v2.deployment_relationship_data" => "DeploymentRelationshipData", diff --git a/lib/datadog_api_client/v2/api/deployment_gates_api.rb b/lib/datadog_api_client/v2/api/deployment_gates_api.rb index 440f29bc1d4..e81fc32f44b 100644 --- a/lib/datadog_api_client/v2/api/deployment_gates_api.rb +++ b/lib/datadog_api_client/v2/api/deployment_gates_api.rb @@ -392,6 +392,77 @@ def get_deployment_gate_with_http_info(id, opts = {}) return data, status_code, headers end + # Get rules for a deployment gate. + # + # @see #get_deployment_gate_rules_with_http_info + def get_deployment_gate_rules(gate_id, opts = {}) + data, _status_code, _headers = get_deployment_gate_rules_with_http_info(gate_id, opts) + data + end + + # Get rules for a deployment gate. + # + # Endpoint to get rules for a deployment gate. + # + # @param gate_id [String] The ID of the deployment gate. + # @param opts [Hash] the optional parameters + # @return [Array<(DeploymentGateRulesResponse, Integer, Hash)>] DeploymentGateRulesResponse data, response status code and response headers + def get_deployment_gate_rules_with_http_info(gate_id, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.get_deployment_gate_rules".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.get_deployment_gate_rules") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.get_deployment_gate_rules")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: DeploymentGatesAPI.get_deployment_gate_rules ...' + end + # verify the required parameter 'gate_id' is set + if @api_client.config.client_side_validation && gate_id.nil? + fail ArgumentError, "Missing the required parameter 'gate_id' when calling DeploymentGatesAPI.get_deployment_gate_rules" + end + # resource path + local_var_path = '/api/v2/deployment_gates/{gate_id}/rules'.sub('{gate_id}', CGI.escape(gate_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']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'DeploymentGateRulesResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :get_deployment_gate_rules, + :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::Get, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: DeploymentGatesAPI#get_deployment_gate_rules\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Get deployment rule. # # @see #get_deployment_rule_with_http_info diff --git a/lib/datadog_api_client/v2/models/deployment_gate_rules_response.rb b/lib/datadog_api_client/v2/models/deployment_gate_rules_response.rb new file mode 100644 index 00000000000..9fff11a6a76 --- /dev/null +++ b/lib/datadog_api_client/v2/models/deployment_gate_rules_response.rb @@ -0,0 +1,107 @@ +=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 + # Response for a deployment gate rules. + class DeploymentGateRulesResponse + include BaseGenericModel + + # + attr_accessor :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'Array' + } + 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::DeploymentGateRulesResponse` 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?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + 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 && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end