Skip to content

Commit a7628e0

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add new endpoint for listing rules for a gate (#2792)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 0a339c6 commit a7628e0

14 files changed

+658
-0
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17075,6 +17075,12 @@ components:
1707517075
required:
1707617076
- id
1707717077
type: object
17078+
DeploymentGateRulesResponse:
17079+
description: Response for a deployment gate rules.
17080+
properties:
17081+
data:
17082+
$ref: '#/components/schemas/ListDeploymentRuleResponseData'
17083+
type: object
1707817084
DeploymentMetadata:
1707917085
description: Metadata object containing the publication creation information.
1708017086
properties:
@@ -30199,6 +30205,37 @@ components:
3019930205
type: string
3020030206
x-enum-varnames:
3020130207
- LIST_CONNECTIONS_RESPONSE
30208+
ListDeploymentRuleResponseData:
30209+
description: Data for a list of deployment rules.
30210+
properties:
30211+
attributes:
30212+
$ref: '#/components/schemas/ListDeploymentRulesResponseDataAttributes'
30213+
id:
30214+
description: Unique identifier of the deployment rule.
30215+
example: 1111-2222-3333-4444-555566667777
30216+
type: string
30217+
type:
30218+
$ref: '#/components/schemas/ListDeploymentRulesDataType'
30219+
required:
30220+
- type
30221+
- attributes
30222+
- id
30223+
type: object
30224+
ListDeploymentRulesDataType:
30225+
description: List deployment rule resource type.
30226+
enum:
30227+
- list_deployment_rules
30228+
example: list_deployment_rules
30229+
type: string
30230+
x-enum-varnames:
30231+
- LIST_DEPLOYMENT_RULES
30232+
ListDeploymentRulesResponseDataAttributes:
30233+
properties:
30234+
rules:
30235+
items:
30236+
$ref: '#/components/schemas/DeploymentRuleResponseDataAttributes'
30237+
type: array
30238+
type: object
3020230239
ListDevicesResponse:
3020330240
description: List devices response.
3020430241
properties:
@@ -66236,6 +66273,50 @@ paths:
6623666273

6623766274
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
6623866275
/api/v2/deployment_gates/{gate_id}/rules:
66276+
get:
66277+
description: Endpoint to get rules for a deployment gate.
66278+
operationId: GetDeploymentGateRules
66279+
parameters:
66280+
- description: The ID of the deployment gate.
66281+
in: path
66282+
name: gate_id
66283+
required: true
66284+
schema:
66285+
type: string
66286+
responses:
66287+
'200':
66288+
content:
66289+
application/json:
66290+
schema:
66291+
$ref: '#/components/schemas/DeploymentGateRulesResponse'
66292+
description: OK
66293+
'400':
66294+
$ref: '#/components/responses/HTTPCDGatesBadRequestResponse'
66295+
'401':
66296+
$ref: '#/components/responses/UnauthorizedResponse'
66297+
'403':
66298+
$ref: '#/components/responses/ForbiddenResponse'
66299+
'429':
66300+
$ref: '#/components/responses/TooManyRequestsResponse'
66301+
'500':
66302+
content:
66303+
application/json:
66304+
schema:
66305+
$ref: '#/components/schemas/HTTPCIAppErrors'
66306+
description: Internal Server Error
66307+
security:
66308+
- apiKeyAuth: []
66309+
appKeyAuth: []
66310+
summary: Get rules for a deployment gate
66311+
tags:
66312+
- Deployment Gates
66313+
x-permission:
66314+
operator: OR
66315+
permissions:
66316+
- deployment_gates_read
66317+
x-unstable: '**Note**: This endpoint is in preview and may be subject to change.
66318+
66319+
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
6623966320
post:
6624066321
description: Endpoint to create a deployment rule. A gate for the rule must
6624166322
already exist.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2025-12-10T19:27:22.958Z

cassettes/features/v2/deployment_gates/Get-rules-for-a-deployment-gate-returns-OK-response.yml

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Get rules for a deployment gate returns "OK" response
2+
3+
require "datadog_api_client"
4+
DatadogAPIClient.configure do |config|
5+
config.unstable_operations["v2.get_deployment_gate_rules".to_sym] = true
6+
end
7+
api_instance = DatadogAPIClient::V2::DeploymentGatesAPI.new
8+
9+
# there is a valid "deployment_gate" in the system
10+
DEPLOYMENT_GATE_DATA_ID = ENV["DEPLOYMENT_GATE_DATA_ID"]
11+
p api_instance.get_deployment_gate_rules(DEPLOYMENT_GATE_DATA_ID)

features/scenarios_model_mapping.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,6 +1890,9 @@
18901890
"v2.CreateDeploymentGate" => {
18911891
"body" => "CreateDeploymentGateParams",
18921892
},
1893+
"v2.GetDeploymentGateRules" => {
1894+
"gate_id" => "String",
1895+
},
18931896
"v2.CreateDeploymentRule" => {
18941897
"gate_id" => "String",
18951898
"body" => "CreateDeploymentRuleParams",

features/v2/deployment_gates.feature

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,23 @@ Feature: Deployment Gates
207207
When the request is sent
208208
Then the response status is 200 OK
209209

210+
@generated @skip @team:DataDog/ci-app-backend
211+
Scenario: Get rules for a deployment gate returns "Bad request." response
212+
Given operation "GetDeploymentGateRules" enabled
213+
And new "GetDeploymentGateRules" request
214+
And request contains "gate_id" parameter from "REPLACE.ME"
215+
When the request is sent
216+
Then the response status is 400 Bad request.
217+
218+
@team:DataDog/ci-app-backend
219+
Scenario: Get rules for a deployment gate returns "OK" response
220+
Given there is a valid "deployment_gate" in the system
221+
And operation "GetDeploymentGateRules" enabled
222+
And new "GetDeploymentGateRules" request
223+
And request contains "gate_id" parameter from "deployment_gate.data.id"
224+
When the request is sent
225+
Then the response status is 200 OK
226+
210227
@team:DataDog/ci-app-backend
211228
Scenario: Update deployment gate returns "Bad Request" response
212229
Given operation "UpdateDeploymentGate" enabled

features/v2/undo.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,12 @@
13351335
"type": "unsafe"
13361336
}
13371337
},
1338+
"GetDeploymentGateRules": {
1339+
"tag": "Deployment Gates",
1340+
"undo": {
1341+
"type": "safe"
1342+
}
1343+
},
13381344
"CreateDeploymentRule": {
13391345
"tag": "Deployment Gates",
13401346
"undo": {

lib/datadog_api_client/configuration.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ def initialize
244244
"v2.delete_deployment_gate": false,
245245
"v2.delete_deployment_rule": false,
246246
"v2.get_deployment_gate": false,
247+
"v2.get_deployment_gate_rules": false,
247248
"v2.get_deployment_rule": false,
248249
"v2.update_deployment_gate": false,
249250
"v2.update_deployment_rule": false,

lib/datadog_api_client/inflector.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,6 +1931,7 @@ def overrides
19311931
"v2.deployment_gate_response_data_attributes" => "DeploymentGateResponseDataAttributes",
19321932
"v2.deployment_gate_response_data_attributes_created_by" => "DeploymentGateResponseDataAttributesCreatedBy",
19331933
"v2.deployment_gate_response_data_attributes_updated_by" => "DeploymentGateResponseDataAttributesUpdatedBy",
1934+
"v2.deployment_gate_rules_response" => "DeploymentGateRulesResponse",
19341935
"v2.deployment_metadata" => "DeploymentMetadata",
19351936
"v2.deployment_relationship" => "DeploymentRelationship",
19361937
"v2.deployment_relationship_data" => "DeploymentRelationshipData",
@@ -2794,6 +2795,9 @@ def overrides
27942795
"v2.list_connections_response_data_attributes_connections_items" => "ListConnectionsResponseDataAttributesConnectionsItems",
27952796
"v2.list_connections_response_data_attributes_connections_items_join" => "ListConnectionsResponseDataAttributesConnectionsItemsJoin",
27962797
"v2.list_connections_response_data_type" => "ListConnectionsResponseDataType",
2798+
"v2.list_deployment_rule_response_data" => "ListDeploymentRuleResponseData",
2799+
"v2.list_deployment_rules_data_type" => "ListDeploymentRulesDataType",
2800+
"v2.list_deployment_rules_response_data_attributes" => "ListDeploymentRulesResponseDataAttributes",
27972801
"v2.list_devices_response" => "ListDevicesResponse",
27982802
"v2.list_devices_response_metadata" => "ListDevicesResponseMetadata",
27992803
"v2.list_devices_response_metadata_page" => "ListDevicesResponseMetadataPage",

lib/datadog_api_client/v2/api/deployment_gates_api.rb

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,77 @@ def get_deployment_gate_with_http_info(id, opts = {})
392392
return data, status_code, headers
393393
end
394394

395+
# Get rules for a deployment gate.
396+
#
397+
# @see #get_deployment_gate_rules_with_http_info
398+
def get_deployment_gate_rules(gate_id, opts = {})
399+
data, _status_code, _headers = get_deployment_gate_rules_with_http_info(gate_id, opts)
400+
data
401+
end
402+
403+
# Get rules for a deployment gate.
404+
#
405+
# Endpoint to get rules for a deployment gate.
406+
#
407+
# @param gate_id [String] The ID of the deployment gate.
408+
# @param opts [Hash] the optional parameters
409+
# @return [Array<(DeploymentGateRulesResponse, Integer, Hash)>] DeploymentGateRulesResponse data, response status code and response headers
410+
def get_deployment_gate_rules_with_http_info(gate_id, opts = {})
411+
unstable_enabled = @api_client.config.unstable_operations["v2.get_deployment_gate_rules".to_sym]
412+
if unstable_enabled
413+
@api_client.config.logger.warn format("Using unstable operation '%s'", "v2.get_deployment_gate_rules")
414+
else
415+
raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.get_deployment_gate_rules"))
416+
end
417+
418+
if @api_client.config.debugging
419+
@api_client.config.logger.debug 'Calling API: DeploymentGatesAPI.get_deployment_gate_rules ...'
420+
end
421+
# verify the required parameter 'gate_id' is set
422+
if @api_client.config.client_side_validation && gate_id.nil?
423+
fail ArgumentError, "Missing the required parameter 'gate_id' when calling DeploymentGatesAPI.get_deployment_gate_rules"
424+
end
425+
# resource path
426+
local_var_path = '/api/v2/deployment_gates/{gate_id}/rules'.sub('{gate_id}', CGI.escape(gate_id.to_s).gsub('%2F', '/'))
427+
428+
# query parameters
429+
query_params = opts[:query_params] || {}
430+
431+
# header parameters
432+
header_params = opts[:header_params] || {}
433+
# HTTP header 'Accept' (if needed)
434+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
435+
436+
# form parameters
437+
form_params = opts[:form_params] || {}
438+
439+
# http body (model)
440+
post_body = opts[:debug_body]
441+
442+
# return_type
443+
return_type = opts[:debug_return_type] || 'DeploymentGateRulesResponse'
444+
445+
# auth_names
446+
auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]
447+
448+
new_options = opts.merge(
449+
:operation => :get_deployment_gate_rules,
450+
:header_params => header_params,
451+
:query_params => query_params,
452+
:form_params => form_params,
453+
:body => post_body,
454+
:auth_names => auth_names,
455+
:return_type => return_type,
456+
:api_version => "V2"
457+
)
458+
459+
data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options)
460+
if @api_client.config.debugging
461+
@api_client.config.logger.debug "API called: DeploymentGatesAPI#get_deployment_gate_rules\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
462+
end
463+
return data, status_code, headers
464+
end
465+
395466
# Get deployment rule.
396467
#
397468
# @see #get_deployment_rule_with_http_info

0 commit comments

Comments
 (0)