diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 122c27ff508f..cc2d8329b08b 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -29382,6 +29382,25 @@ components: data: $ref: "#/components/schemas/ListDeploymentRuleResponseData" type: object + DeploymentGatesEvaluationConfiguration: + description: |- + Inline rule definitions for a deployment gate evaluation. When provided, rules are evaluated + directly from this configuration instead of using the pre-configured gate rules. + At least one rule is required. + properties: + dry_run: + description: Gate-level dry run. When enabled, the rules are evaluated normally but the gate always returns `pass`. The real result is visible in the Datadog UI. + example: false + type: boolean + rules: + description: The list of rules to evaluate. At least one rule is required. + items: + $ref: "#/components/schemas/DeploymentGatesEvaluationRule" + minItems: 1 + type: array + required: + - rules + type: object DeploymentGatesEvaluationRequest: description: Request body for triggering a deployment gate evaluation. properties: @@ -29391,8 +29410,13 @@ components: - data type: object DeploymentGatesEvaluationRequestAttributes: - description: Attributes for a deployment gate evaluation request. + description: |- + Attributes for a deployment gate evaluation request. + When `configuration` is provided, rules are evaluated inline from that configuration. + When omitted, rules are resolved from the pre-configured gate for the given service and environment. properties: + configuration: + $ref: "#/components/schemas/DeploymentGatesEvaluationConfiguration" env: description: The environment of the deployment. example: "staging" @@ -29562,6 +29586,60 @@ components: type: string x-enum-varnames: - DEPLOYMENT_GATES_EVALUATION_RESULT_RESPONSE + DeploymentGatesEvaluationRule: + description: A rule to evaluate as part of a deployment gate evaluation. + discriminator: + mapping: + faulty_deployment_detection: "#/components/schemas/DeploymentGatesFDDRule" + monitor: "#/components/schemas/DeploymentGatesMonitorRule" + propertyName: type + oneOf: + - $ref: "#/components/schemas/DeploymentGatesMonitorRule" + - $ref: "#/components/schemas/DeploymentGatesFDDRule" + DeploymentGatesFDDRule: + description: A faulty deployment detection rule to evaluate as part of a deployment gate evaluation. + properties: + dry_run: + description: Rule-level dry run. When enabled, the rule is evaluated normally but it always returns `pass`. The real result is visible in the Datadog UI. + example: false + type: boolean + name: + description: Human-readable name for this rule. + example: "apm faulty deployment" + type: string + options: + $ref: "#/components/schemas/DeploymentGatesFDDRuleOptions" + type: + $ref: "#/components/schemas/DeploymentGatesFDDRuleType" + required: + - type + - name + type: object + DeploymentGatesFDDRuleOptions: + description: Options for a `faulty_deployment_detection` rule. + properties: + duration: + description: Evaluation window in seconds. Maximum 7200 (2 hours). + example: 900 + format: int64 + maximum: 7200 + type: integer + excluded_resources: + description: APM resource names to exclude from analysis. + example: + - "GET /healthcheck" + items: + type: string + type: array + type: object + DeploymentGatesFDDRuleType: + description: The type identifier for a faulty deployment detection rule. + enum: + - faulty_deployment_detection + example: faulty_deployment_detection + type: string + x-enum-varnames: + - FAULTY_DEPLOYMENT_DETECTION DeploymentGatesListResponse: description: Response containing a paginated list of deployment gates. properties: @@ -29596,6 +29674,49 @@ components: minimum: 1 type: integer type: object + DeploymentGatesMonitorRule: + description: A monitor rule to evaluate as part of a deployment gate evaluation. + properties: + dry_run: + description: Rule-level dry run. When enabled, the rule is evaluated normally but it always returns `pass`. The real result is visible in the Datadog UI. + example: false + type: boolean + name: + description: Human-readable name for this rule. + example: "error rate monitors" + type: string + options: + $ref: "#/components/schemas/DeploymentGatesMonitorRuleOptions" + type: + $ref: "#/components/schemas/DeploymentGatesMonitorRuleType" + required: + - type + - name + type: object + DeploymentGatesMonitorRuleOptions: + description: Options for a `monitor` rule. + properties: + duration: + description: Evaluation window in seconds. Maximum 7200 (2 hours). + example: 300 + format: int64 + maximum: 7200 + type: integer + query: + description: Monitor search query. + example: "service:transaction-backend env:production" + type: string + required: + - query + type: object + DeploymentGatesMonitorRuleType: + description: The type identifier for a monitor rule. + enum: + - monitor + example: monitor + type: string + x-enum-varnames: + - MONITOR DeploymentGatesRuleResponse: description: The result of a single rule evaluation. properties: @@ -121740,12 +121861,17 @@ paths: Triggers an asynchronous deployment gate evaluation for the given service and environment. Returns an evaluation ID that can be used to poll for the result via the `GET /api/v2/deployments/gates/evaluation/{id}` endpoint. + + When the `configuration` attribute is provided, rules are evaluated inline from that configuration + and no pre-configured gate is required. When `configuration` is omitted, rules are resolved from the + gate pre-configured for the given service and environment via the Datadog UI, API, or Terraform. operationId: TriggerDeploymentGatesEvaluation requestBody: content: application/json: examples: default: + summary: Evaluate a pre-configured gate value: data: attributes: @@ -121755,6 +121881,31 @@ paths: service: transaction-backend version: v1.2.3 type: deployment_gates_evaluation_request + with-configuration: + summary: Evaluate with inline rule configuration + value: + data: + attributes: + configuration: + dry_run: false + rules: + - dry_run: false + name: error rate monitors + options: + duration: 300 + query: "service:transaction-backend env:production" + type: monitor + - dry_run: false + name: apm faulty deployment + options: + duration: 900 + excluded_resources: + - "GET /healthcheck" + type: faulty_deployment_detection + env: production + service: transaction-backend + version: 1.2.3 + type: deployment_gates_evaluation_request schema: $ref: "#/components/schemas/DeploymentGatesEvaluationRequest" required: true diff --git a/examples/v2/deployment-gates/TriggerDeploymentGatesEvaluation.rb b/examples/v2/deployment-gates/TriggerDeploymentGatesEvaluation.rb index 4bbeea630832..73061e58cfca 100644 --- a/examples/v2/deployment-gates/TriggerDeploymentGatesEvaluation.rb +++ b/examples/v2/deployment-gates/TriggerDeploymentGatesEvaluation.rb @@ -9,6 +9,20 @@ body = DatadogAPIClient::V2::DeploymentGatesEvaluationRequest.new({ data: DatadogAPIClient::V2::DeploymentGatesEvaluationRequestData.new({ attributes: DatadogAPIClient::V2::DeploymentGatesEvaluationRequestAttributes.new({ + configuration: DatadogAPIClient::V2::DeploymentGatesEvaluationConfiguration.new({ + dry_run: false, + rules: [ + DatadogAPIClient::V2::DeploymentGatesMonitorRule.new({ + dry_run: false, + name: "error rate monitors", + options: DatadogAPIClient::V2::DeploymentGatesMonitorRuleOptions.new({ + duration: 300, + query: "service:transaction-backend env:production", + }), + type: DatadogAPIClient::V2::DeploymentGatesMonitorRuleType::MONITOR, + }), + ], + }), env: "staging", identifier: "pre-deploy", primary_tag: "region:us-east-1", diff --git a/features/v2/deployment_gates.feature b/features/v2/deployment_gates.feature index df9494d2aed8..de5ceaeaa3d0 100644 --- a/features/v2/deployment_gates.feature +++ b/features/v2/deployment_gates.feature @@ -286,7 +286,7 @@ Feature: Deployment Gates Scenario: Trigger a deployment gate evaluation returns "Accepted" response Given operation "TriggerDeploymentGatesEvaluation" enabled And new "TriggerDeploymentGatesEvaluation" request - And body with value {"data": {"attributes": {"env": "staging", "identifier": "pre-deploy", "primary_tag": "region:us-east-1", "service": "transaction-backend", "version": "v1.2.3"}, "type": "deployment_gates_evaluation_request"}} + And body with value {"data": {"attributes": {"configuration": {"dry_run": false, "rules": [{"dry_run": false, "name": "error rate monitors", "options": {"duration": 300, "query": "service:transaction-backend env:production"}, "type": "monitor"}]}, "env": "staging", "identifier": "pre-deploy", "primary_tag": "region:us-east-1", "service": "transaction-backend", "version": "v1.2.3"}, "type": "deployment_gates_evaluation_request"}} When the request is sent Then the response status is 202 Accepted @@ -294,7 +294,7 @@ Feature: Deployment Gates Scenario: Trigger a deployment gate evaluation returns "Bad request." response Given operation "TriggerDeploymentGatesEvaluation" enabled And new "TriggerDeploymentGatesEvaluation" request - And body with value {"data": {"attributes": {"env": "staging", "identifier": "pre-deploy", "primary_tag": "region:us-east-1", "service": "transaction-backend", "version": "v1.2.3"}, "type": "deployment_gates_evaluation_request"}} + And body with value {"data": {"attributes": {"configuration": {"dry_run": false, "rules": [{"dry_run": false, "name": "error rate monitors", "options": {"duration": 300, "query": "service:transaction-backend env:production"}, "type": "monitor"}]}, "env": "staging", "identifier": "pre-deploy", "primary_tag": "region:us-east-1", "service": "transaction-backend", "version": "v1.2.3"}, "type": "deployment_gates_evaluation_request"}} When the request is sent Then the response status is 400 Bad request. @@ -302,7 +302,7 @@ Feature: Deployment Gates Scenario: Trigger a deployment gate evaluation returns "Deployment gate not found." response Given operation "TriggerDeploymentGatesEvaluation" enabled And new "TriggerDeploymentGatesEvaluation" request - And body with value {"data": {"attributes": {"env": "staging", "identifier": "pre-deploy", "primary_tag": "region:us-east-1", "service": "transaction-backend", "version": "v1.2.3"}, "type": "deployment_gates_evaluation_request"}} + And body with value {"data": {"attributes": {"configuration": {"dry_run": false, "rules": [{"dry_run": false, "name": "error rate monitors", "options": {"duration": 300, "query": "service:transaction-backend env:production"}, "type": "monitor"}]}, "env": "staging", "identifier": "pre-deploy", "primary_tag": "region:us-east-1", "service": "transaction-backend", "version": "v1.2.3"}, "type": "deployment_gates_evaluation_request"}} When the request is sent Then the response status is 404 Deployment gate not found. diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index d7f350831ca9..1605340e1229 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -2756,6 +2756,7 @@ def overrides "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_gates_evaluation_configuration" => "DeploymentGatesEvaluationConfiguration", "v2.deployment_gates_evaluation_request" => "DeploymentGatesEvaluationRequest", "v2.deployment_gates_evaluation_request_attributes" => "DeploymentGatesEvaluationRequestAttributes", "v2.deployment_gates_evaluation_request_data" => "DeploymentGatesEvaluationRequestData", @@ -2769,9 +2770,16 @@ def overrides "v2.deployment_gates_evaluation_result_response_attributes_gate_status" => "DeploymentGatesEvaluationResultResponseAttributesGateStatus", "v2.deployment_gates_evaluation_result_response_data" => "DeploymentGatesEvaluationResultResponseData", "v2.deployment_gates_evaluation_result_response_data_type" => "DeploymentGatesEvaluationResultResponseDataType", + "v2.deployment_gates_evaluation_rule" => "DeploymentGatesEvaluationRule", + "v2.deployment_gates_fdd_rule" => "DeploymentGatesFDDRule", + "v2.deployment_gates_fdd_rule_options" => "DeploymentGatesFDDRuleOptions", + "v2.deployment_gates_fdd_rule_type" => "DeploymentGatesFDDRuleType", "v2.deployment_gates_list_response" => "DeploymentGatesListResponse", "v2.deployment_gates_list_response_meta" => "DeploymentGatesListResponseMeta", "v2.deployment_gates_list_response_meta_page" => "DeploymentGatesListResponseMetaPage", + "v2.deployment_gates_monitor_rule" => "DeploymentGatesMonitorRule", + "v2.deployment_gates_monitor_rule_options" => "DeploymentGatesMonitorRuleOptions", + "v2.deployment_gates_monitor_rule_type" => "DeploymentGatesMonitorRuleType", "v2.deployment_gates_rule_response" => "DeploymentGatesRuleResponse", "v2.deployment_metadata" => "DeploymentMetadata", "v2.deployment_relationship" => "DeploymentRelationship", 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 ac38e2e41c71..2a636e99f057 100644 --- a/lib/datadog_api_client/v2/api/deployment_gates_api.rb +++ b/lib/datadog_api_client/v2/api/deployment_gates_api.rb @@ -705,6 +705,10 @@ def trigger_deployment_gates_evaluation(body, opts = {}) # Returns an evaluation ID that can be used to poll for the result via the # `GET /api/v2/deployments/gates/evaluation/{id}` endpoint. # + # When the `configuration` attribute is provided, rules are evaluated inline from that configuration + # and no pre-configured gate is required. When `configuration` is omitted, rules are resolved from the + # gate pre-configured for the given service and environment via the Datadog UI, API, or Terraform. + # # @param body [DeploymentGatesEvaluationRequest] # @param opts [Hash] the optional parameters # @return [Array<(DeploymentGatesEvaluationResponse, Integer, Hash)>] DeploymentGatesEvaluationResponse data, response status code and response headers diff --git a/lib/datadog_api_client/v2/models/deployment_gates_evaluation_configuration.rb b/lib/datadog_api_client/v2/models/deployment_gates_evaluation_configuration.rb new file mode 100644 index 000000000000..b3a92c898ca7 --- /dev/null +++ b/lib/datadog_api_client/v2/models/deployment_gates_evaluation_configuration.rb @@ -0,0 +1,141 @@ +=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 + # Inline rule definitions for a deployment gate evaluation. When provided, rules are evaluated + # directly from this configuration instead of using the pre-configured gate rules. + # At least one rule is required. + class DeploymentGatesEvaluationConfiguration + include BaseGenericModel + + # Gate-level dry run. When enabled, the rules are evaluated normally but the gate always returns `pass`. The real result is visible in the Datadog UI. + attr_accessor :dry_run + + # The list of rules to evaluate. At least one rule is required. + attr_reader :rules + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'dry_run' => :'dry_run', + :'rules' => :'rules' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'dry_run' => :'Boolean', + :'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::DeploymentGatesEvaluationConfiguration` 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?(:'dry_run') + self.dry_run = attributes[:'dry_run'] + end + + if attributes.key?(:'rules') + if (value = attributes[:'rules']).is_a?(Array) + self.rules = value + end + 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 @rules.nil? + return false if @rules.length < 1 + true + end + + # Custom attribute writer method with validation + # @param rules [Object] Object to be assigned + # @!visibility private + def rules=(rules) + if rules.nil? + fail ArgumentError, 'invalid value for "rules", rules cannot be nil.' + end + if rules.length < 1 + fail ArgumentError, 'invalid value for "rules", number of items must be greater than or equal to 1.' + end + @rules = rules + 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 && + dry_run == o.dry_run && + rules == o.rules && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [dry_run, rules, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/deployment_gates_evaluation_request_attributes.rb b/lib/datadog_api_client/v2/models/deployment_gates_evaluation_request_attributes.rb index b333e8677916..6225caf28894 100644 --- a/lib/datadog_api_client/v2/models/deployment_gates_evaluation_request_attributes.rb +++ b/lib/datadog_api_client/v2/models/deployment_gates_evaluation_request_attributes.rb @@ -18,9 +18,16 @@ module DatadogAPIClient::V2 # Attributes for a deployment gate evaluation request. + # When `configuration` is provided, rules are evaluated inline from that configuration. + # When omitted, rules are resolved from the pre-configured gate for the given service and environment. class DeploymentGatesEvaluationRequestAttributes include BaseGenericModel + # Inline rule definitions for a deployment gate evaluation. When provided, rules are evaluated + # directly from this configuration instead of using the pre-configured gate rules. + # At least one rule is required. + attr_accessor :configuration + # The environment of the deployment. attr_reader :env @@ -42,6 +49,7 @@ class DeploymentGatesEvaluationRequestAttributes # @!visibility private def self.attribute_map { + :'configuration' => :'configuration', :'env' => :'env', :'identifier' => :'identifier', :'primary_tag' => :'primary_tag', @@ -54,6 +62,7 @@ def self.attribute_map # @!visibility private def self.openapi_types { + :'configuration' => :'DeploymentGatesEvaluationConfiguration', :'env' => :'String', :'identifier' => :'String', :'primary_tag' => :'String', @@ -80,6 +89,10 @@ def initialize(attributes = {}) end } + if attributes.key?(:'configuration') + self.configuration = attributes[:'configuration'] + end + if attributes.key?(:'env') self.env = attributes[:'env'] end @@ -156,6 +169,7 @@ def to_hash def ==(o) return true if self.equal?(o) self.class == o.class && + configuration == o.configuration && env == o.env && identifier == o.identifier && primary_tag == o.primary_tag && @@ -168,7 +182,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [env, identifier, primary_tag, service, version, additional_properties].hash + [configuration, env, identifier, primary_tag, service, version, additional_properties].hash end end end diff --git a/lib/datadog_api_client/v2/models/deployment_gates_evaluation_request_data.rb b/lib/datadog_api_client/v2/models/deployment_gates_evaluation_request_data.rb index 233fc3df9525..e3bc30aa9275 100644 --- a/lib/datadog_api_client/v2/models/deployment_gates_evaluation_request_data.rb +++ b/lib/datadog_api_client/v2/models/deployment_gates_evaluation_request_data.rb @@ -22,6 +22,8 @@ class DeploymentGatesEvaluationRequestData include BaseGenericModel # Attributes for a deployment gate evaluation request. + # When `configuration` is provided, rules are evaluated inline from that configuration. + # When omitted, rules are resolved from the pre-configured gate for the given service and environment. attr_reader :attributes # JSON:API type for a deployment gate evaluation request. diff --git a/lib/datadog_api_client/v2/models/deployment_gates_evaluation_rule.rb b/lib/datadog_api_client/v2/models/deployment_gates_evaluation_rule.rb new file mode 100644 index 000000000000..5abee6237ac2 --- /dev/null +++ b/lib/datadog_api_client/v2/models/deployment_gates_evaluation_rule.rb @@ -0,0 +1,47 @@ +=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 + # A rule to evaluate as part of a deployment gate evaluation. + module DeploymentGatesEvaluationRule + class << self + include BaseOneOfModel + + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'DeploymentGatesMonitorRule', + :'DeploymentGatesFDDRule' + ] + end + # Discriminator's property name (OpenAPI v3) + def openapi_discriminator_name + :'type' + end + + # Builds the object + # @param data [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + discriminator_value = data[openapi_discriminator_name] + return nil unless discriminator_value + + end + end + end +end diff --git a/lib/datadog_api_client/v2/models/deployment_gates_fdd_rule.rb b/lib/datadog_api_client/v2/models/deployment_gates_fdd_rule.rb new file mode 100644 index 000000000000..63c504ab5aa0 --- /dev/null +++ b/lib/datadog_api_client/v2/models/deployment_gates_fdd_rule.rb @@ -0,0 +1,164 @@ +=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 + # A faulty deployment detection rule to evaluate as part of a deployment gate evaluation. + class DeploymentGatesFDDRule + include BaseGenericModel + + # Rule-level dry run. When enabled, the rule is evaluated normally but it always returns `pass`. The real result is visible in the Datadog UI. + attr_accessor :dry_run + + # Human-readable name for this rule. + attr_reader :name + + # Options for a `faulty_deployment_detection` rule. + attr_accessor :options + + # The type identifier for a faulty deployment detection rule. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'dry_run' => :'dry_run', + :'name' => :'name', + :'options' => :'options', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'dry_run' => :'Boolean', + :'name' => :'String', + :'options' => :'DeploymentGatesFDDRuleOptions', + :'type' => :'DeploymentGatesFDDRuleType' + } + 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::DeploymentGatesFDDRule` 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?(:'dry_run') + self.dry_run = attributes[:'dry_run'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'options') + self.options = attributes[:'options'] + 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 @name.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + @name = name + 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 && + dry_run == o.dry_run && + name == o.name && + options == o.options && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [dry_run, name, options, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/deployment_gates_fdd_rule_options.rb b/lib/datadog_api_client/v2/models/deployment_gates_fdd_rule_options.rb new file mode 100644 index 000000000000..7feaeeefbb8c --- /dev/null +++ b/lib/datadog_api_client/v2/models/deployment_gates_fdd_rule_options.rb @@ -0,0 +1,135 @@ +=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 + # Options for a `faulty_deployment_detection` rule. + class DeploymentGatesFDDRuleOptions + include BaseGenericModel + + # Evaluation window in seconds. Maximum 7200 (2 hours). + attr_reader :duration + + # APM resource names to exclude from analysis. + attr_accessor :excluded_resources + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'duration' => :'duration', + :'excluded_resources' => :'excluded_resources' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'duration' => :'Integer', + :'excluded_resources' => :'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::DeploymentGatesFDDRuleOptions` 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?(:'duration') + self.duration = attributes[:'duration'] + end + + if attributes.key?(:'excluded_resources') + if (value = attributes[:'excluded_resources']).is_a?(Array) + self.excluded_resources = value + end + 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 !@duration.nil? && @duration > 7200 + true + end + + # Custom attribute writer method with validation + # @param duration [Object] Object to be assigned + # @!visibility private + def duration=(duration) + if !duration.nil? && duration > 7200 + fail ArgumentError, 'invalid value for "duration", must be smaller than or equal to 7200.' + end + @duration = duration + 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 && + duration == o.duration && + excluded_resources == o.excluded_resources && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [duration, excluded_resources, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/deployment_gates_fdd_rule_type.rb b/lib/datadog_api_client/v2/models/deployment_gates_fdd_rule_type.rb new file mode 100644 index 000000000000..b72101727373 --- /dev/null +++ b/lib/datadog_api_client/v2/models/deployment_gates_fdd_rule_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 + # The type identifier for a faulty deployment detection rule. + class DeploymentGatesFDDRuleType + include BaseEnumModel + + FAULTY_DEPLOYMENT_DETECTION = "faulty_deployment_detection".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/deployment_gates_monitor_rule.rb b/lib/datadog_api_client/v2/models/deployment_gates_monitor_rule.rb new file mode 100644 index 000000000000..0d4118356fd8 --- /dev/null +++ b/lib/datadog_api_client/v2/models/deployment_gates_monitor_rule.rb @@ -0,0 +1,164 @@ +=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 + # A monitor rule to evaluate as part of a deployment gate evaluation. + class DeploymentGatesMonitorRule + include BaseGenericModel + + # Rule-level dry run. When enabled, the rule is evaluated normally but it always returns `pass`. The real result is visible in the Datadog UI. + attr_accessor :dry_run + + # Human-readable name for this rule. + attr_reader :name + + # Options for a `monitor` rule. + attr_accessor :options + + # The type identifier for a monitor rule. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'dry_run' => :'dry_run', + :'name' => :'name', + :'options' => :'options', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'dry_run' => :'Boolean', + :'name' => :'String', + :'options' => :'DeploymentGatesMonitorRuleOptions', + :'type' => :'DeploymentGatesMonitorRuleType' + } + 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::DeploymentGatesMonitorRule` 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?(:'dry_run') + self.dry_run = attributes[:'dry_run'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'options') + self.options = attributes[:'options'] + 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 @name.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + @name = name + 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 && + dry_run == o.dry_run && + name == o.name && + options == o.options && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [dry_run, name, options, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/deployment_gates_monitor_rule_options.rb b/lib/datadog_api_client/v2/models/deployment_gates_monitor_rule_options.rb new file mode 100644 index 000000000000..bdd0980e41c8 --- /dev/null +++ b/lib/datadog_api_client/v2/models/deployment_gates_monitor_rule_options.rb @@ -0,0 +1,144 @@ +=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 + # Options for a `monitor` rule. + class DeploymentGatesMonitorRuleOptions + include BaseGenericModel + + # Evaluation window in seconds. Maximum 7200 (2 hours). + attr_reader :duration + + # Monitor search query. + attr_reader :query + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'duration' => :'duration', + :'query' => :'query' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'duration' => :'Integer', + :'query' => :'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::DeploymentGatesMonitorRuleOptions` 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?(:'duration') + self.duration = attributes[:'duration'] + end + + if attributes.key?(:'query') + self.query = attributes[:'query'] + 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 !@duration.nil? && @duration > 7200 + return false if @query.nil? + true + end + + # Custom attribute writer method with validation + # @param duration [Object] Object to be assigned + # @!visibility private + def duration=(duration) + if !duration.nil? && duration > 7200 + fail ArgumentError, 'invalid value for "duration", must be smaller than or equal to 7200.' + end + @duration = duration + end + + # Custom attribute writer method with validation + # @param query [Object] Object to be assigned + # @!visibility private + def query=(query) + if query.nil? + fail ArgumentError, 'invalid value for "query", query cannot be nil.' + end + @query = query + 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 && + duration == o.duration && + query == o.query && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [duration, query, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/deployment_gates_monitor_rule_type.rb b/lib/datadog_api_client/v2/models/deployment_gates_monitor_rule_type.rb new file mode 100644 index 000000000000..67572b95befb --- /dev/null +++ b/lib/datadog_api_client/v2/models/deployment_gates_monitor_rule_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 + # The type identifier for a monitor rule. + class DeploymentGatesMonitorRuleType + include BaseEnumModel + + MONITOR = "monitor".freeze + end +end