Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down
11 changes: 11 additions & 0 deletions examples/v2/deployment-gates/GetDeploymentGateRules.rb
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 3 additions & 0 deletions features/scenarios_model_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1862,6 +1862,9 @@
"v2.CreateDeploymentGate" => {
"body" => "CreateDeploymentGateParams",
},
"v2.GetDeploymentGateRules" => {
"gate_id" => "String",
},
"v2.CreateDeploymentRule" => {
"gate_id" => "String",
"body" => "CreateDeploymentRuleParams",
Expand Down
17 changes: 17 additions & 0 deletions features/v2/deployment_gates.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions features/v2/undo.json
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,12 @@
"type": "unsafe"
}
},
"GetDeploymentGateRules": {
"tag": "Deployment Gates",
"undo": {
"type": "safe"
}
},
"CreateDeploymentRule": {
"tag": "Deployment Gates",
"undo": {
Expand Down
1 change: 1 addition & 0 deletions lib/datadog_api_client/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions lib/datadog_api_client/inflector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
71 changes: 71 additions & 0 deletions lib/datadog_api_client/v2/api/deployment_gates_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
107 changes: 107 additions & 0 deletions lib/datadog_api_client/v2/models/deployment_gate_rules_response.rb
Original file line number Diff line number Diff line change
@@ -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<DeploymentRuleResponseData>'
}
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
Loading