diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 7760d58c049a..52a93c634edc 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -17075,6 +17075,12 @@ components: required: - id type: object + DeploymentGateRulesResponse: + description: Response for a deployment gate rules. + properties: + data: + $ref: '#/components/schemas/ListDeploymentRuleResponseData' + type: object DeploymentMetadata: description: Metadata object containing the publication creation information. properties: @@ -30199,6 +30205,37 @@ components: type: string x-enum-varnames: - LIST_CONNECTIONS_RESPONSE + ListDeploymentRuleResponseData: + description: Data for a list of deployment rules. + properties: + attributes: + $ref: '#/components/schemas/ListDeploymentRulesResponseDataAttributes' + id: + description: Unique identifier of the deployment rule. + example: 1111-2222-3333-4444-555566667777 + type: string + type: + $ref: '#/components/schemas/ListDeploymentRulesDataType' + required: + - type + - attributes + - id + type: object + ListDeploymentRulesDataType: + description: List deployment rule resource type. + enum: + - list_deployment_rules + example: list_deployment_rules + type: string + x-enum-varnames: + - LIST_DEPLOYMENT_RULES + ListDeploymentRulesResponseDataAttributes: + properties: + rules: + items: + $ref: '#/components/schemas/DeploymentRuleResponseDataAttributes' + type: array + type: object ListDevicesResponse: description: List devices response. properties: @@ -66236,6 +66273,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/cassettes/features/v2/deployment_gates/Get-rules-for-a-deployment-gate-returns-OK-response.frozen b/cassettes/features/v2/deployment_gates/Get-rules-for-a-deployment-gate-returns-OK-response.frozen new file mode 100644 index 000000000000..5305f1cfe123 --- /dev/null +++ b/cassettes/features/v2/deployment_gates/Get-rules-for-a-deployment-gate-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-12-10T19:27:22.958Z \ No newline at end of file diff --git a/cassettes/features/v2/deployment_gates/Get-rules-for-a-deployment-gate-returns-OK-response.yml b/cassettes/features/v2/deployment_gates/Get-rules-for-a-deployment-gate-returns-OK-response.yml new file mode 100644 index 000000000000..5be59d99135c --- /dev/null +++ b/cassettes/features/v2/deployment_gates/Get-rules-for-a-deployment-gate-returns-OK-response.yml @@ -0,0 +1,60 @@ +http_interactions: +- recorded_at: Wed, 10 Dec 2025 19:27:22 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"dry_run":false,"env":"production","identifier":"my-gate-testgetrulesforadeploymentgatereturnsokresponse1765394842","service":"my-service"},"type":"deployment_gate"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/deployment_gates + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"718d7fb4-bbc4-4b69-8a1b-98dda014726d","type":"deployment_gate","attributes":{"created_at":"2025-12-10T19:27:24.004043Z","created_by":{"id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"dry_run":false,"env":"production","identifier":"my-gate-testgetrulesforadeploymentgatereturnsokresponse1765394842","service":"my-service","updated_at":"2025-12-10T19:27:24.004043Z","updated_by":{"id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"}}}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 200 + message: OK +- recorded_at: Wed, 10 Dec 2025 19:27:22 GMT + request: + body: null + headers: + Accept: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/deployment_gates/718d7fb4-bbc4-4b69-8a1b-98dda014726d/rules + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"718d7fb4-bbc4-4b69-8a1b-98dda014726d","type":"list_deployment_rules","attributes":{"rules":[]}}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 200 + message: OK +- recorded_at: Wed, 10 Dec 2025 19:27:22 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/deployment_gates/718d7fb4-bbc4-4b69-8a1b-98dda014726d + response: + body: + encoding: UTF-8 + string: '' + headers: {} + status: + code: 204 + message: No Content +recorded_with: VCR 6.0.0 diff --git a/examples/v2/deployment-gates/GetDeploymentGateRules.rb b/examples/v2/deployment-gates/GetDeploymentGateRules.rb new file mode 100644 index 000000000000..b1fa5b9623d9 --- /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 baa3e78df8de..9c9af472c3b5 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -1890,6 +1890,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 e4023c5650b1..cb0c5a1262d6 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 71dba8f3e387..396d52383628 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -1335,6 +1335,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 d69758b75761..4377c745f15e 100644 --- a/lib/datadog_api_client/configuration.rb +++ b/lib/datadog_api_client/configuration.rb @@ -244,6 +244,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 9a311d18bec0..424f3e51d6cf 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -1931,6 +1931,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", @@ -2794,6 +2795,9 @@ def overrides "v2.list_connections_response_data_attributes_connections_items" => "ListConnectionsResponseDataAttributesConnectionsItems", "v2.list_connections_response_data_attributes_connections_items_join" => "ListConnectionsResponseDataAttributesConnectionsItemsJoin", "v2.list_connections_response_data_type" => "ListConnectionsResponseDataType", + "v2.list_deployment_rule_response_data" => "ListDeploymentRuleResponseData", + "v2.list_deployment_rules_data_type" => "ListDeploymentRulesDataType", + "v2.list_deployment_rules_response_data_attributes" => "ListDeploymentRulesResponseDataAttributes", "v2.list_devices_response" => "ListDevicesResponse", "v2.list_devices_response_metadata" => "ListDevicesResponseMetadata", "v2.list_devices_response_metadata_page" => "ListDevicesResponseMetadataPage", 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 440f29bc1d48..e81fc32f44b7 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 000000000000..44bee921e1d5 --- /dev/null +++ b/lib/datadog_api_client/v2/models/deployment_gate_rules_response.rb @@ -0,0 +1,105 @@ +=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 + + # Data for a list of deployment rules. + 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' => :'ListDeploymentRuleResponseData' + } + 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') + self.data = attributes[:'data'] + 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 diff --git a/lib/datadog_api_client/v2/models/list_deployment_rule_response_data.rb b/lib/datadog_api_client/v2/models/list_deployment_rule_response_data.rb new file mode 100644 index 000000000000..465c8cbbee45 --- /dev/null +++ b/lib/datadog_api_client/v2/models/list_deployment_rule_response_data.rb @@ -0,0 +1,165 @@ +=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 + # Data for a list of deployment rules. + class ListDeploymentRuleResponseData + include BaseGenericModel + + # + attr_reader :attributes + + # Unique identifier of the deployment rule. + attr_reader :id + + # List deployment rule resource type. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'id' => :'id', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'ListDeploymentRulesResponseDataAttributes', + :'id' => :'String', + :'type' => :'ListDeploymentRulesDataType' + } + 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::ListDeploymentRuleResponseData` 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?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @attributes.nil? + return false if @id.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param attributes [Object] Object to be assigned + # @!visibility private + def attributes=(attributes) + if attributes.nil? + fail ArgumentError, 'invalid value for "attributes", attributes cannot be nil.' + end + @attributes = attributes + end + + # Custom attribute writer method with validation + # @param id [Object] Object to be assigned + # @!visibility private + def id=(id) + if id.nil? + fail ArgumentError, 'invalid value for "id", id cannot be nil.' + end + @id = id + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + 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 && + attributes == o.attributes && + id == o.id && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, id, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/list_deployment_rules_data_type.rb b/lib/datadog_api_client/v2/models/list_deployment_rules_data_type.rb new file mode 100644 index 000000000000..e1ac3e1406d3 --- /dev/null +++ b/lib/datadog_api_client/v2/models/list_deployment_rules_data_type.rb @@ -0,0 +1,26 @@ +=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 + # List deployment rule resource type. + class ListDeploymentRulesDataType + include BaseEnumModel + + LIST_DEPLOYMENT_RULES = "list_deployment_rules".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/list_deployment_rules_response_data_attributes.rb b/lib/datadog_api_client/v2/models/list_deployment_rules_response_data_attributes.rb new file mode 100644 index 000000000000..1e7cae726861 --- /dev/null +++ b/lib/datadog_api_client/v2/models/list_deployment_rules_response_data_attributes.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 + # + class ListDeploymentRulesResponseDataAttributes + include BaseGenericModel + + # + attr_accessor :rules + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'rules' => :'rules' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'rules' => :'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::ListDeploymentRulesResponseDataAttributes` 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?(:'rules') + if (value = attributes[:'rules']).is_a?(Array) + self.rules = 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 && + rules == o.rules && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [rules, additional_properties].hash + end + end +end