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
7 changes: 7 additions & 0 deletions docs/datadog_api_client.v2.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6605,6 +6605,13 @@ datadog\_api\_client.v2.model.deployment\_gate\_response\_data\_attributes\_upda
:members:
:show-inheritance:

datadog\_api\_client.v2.model.deployment\_gate\_rules\_response module
----------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.deployment_gate_rules_response
:members:
:show-inheritance:

datadog\_api\_client.v2.model.deployment\_metadata module
---------------------------------------------------------

Expand Down
20 changes: 20 additions & 0 deletions examples/v2/deployment-gates/GetDeploymentGateRules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
Get rules for a deployment gate returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.deployment_gates_api import DeploymentGatesApi

# there is a valid "deployment_gate" in the system
DEPLOYMENT_GATE_DATA_ID = environ["DEPLOYMENT_GATE_DATA_ID"]

configuration = Configuration()
configuration.unstable_operations["get_deployment_gate_rules"] = True
with ApiClient(configuration) as api_client:
api_instance = DeploymentGatesApi(api_client)
response = api_instance.get_deployment_gate_rules(
gate_id=DEPLOYMENT_GATE_DATA_ID,
)

print(response)
1 change: 1 addition & 0 deletions src/datadog_api_client/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ def __init__(
"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
41 changes: 41 additions & 0 deletions src/datadog_api_client/v2/api/deployment_gates_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from datadog_api_client.configuration import Configuration
from datadog_api_client.v2.model.deployment_gate_response import DeploymentGateResponse
from datadog_api_client.v2.model.create_deployment_gate_params import CreateDeploymentGateParams
from datadog_api_client.v2.model.deployment_gate_rules_response import DeploymentGateRulesResponse
from datadog_api_client.v2.model.deployment_rule_response import DeploymentRuleResponse
from datadog_api_client.v2.model.create_deployment_rule_params import CreateDeploymentRuleParams
from datadog_api_client.v2.model.update_deployment_rule_params import UpdateDeploymentRuleParams
Expand Down Expand Up @@ -146,6 +147,29 @@ def __init__(self, api_client=None):
api_client=api_client,
)

self._get_deployment_gate_rules_endpoint = _Endpoint(
settings={
"response_type": (DeploymentGateRulesResponse,),
"auth": ["apiKeyAuth", "appKeyAuth"],
"endpoint_path": "/api/v2/deployment_gates/{gate_id}/rules",
"operation_id": "get_deployment_gate_rules",
"http_method": "GET",
"version": "v2",
},
params_map={
"gate_id": {
"required": True,
"openapi_types": (str,),
"attribute": "gate_id",
"location": "path",
},
},
headers_map={
"accept": ["application/json"],
},
api_client=api_client,
)

self._get_deployment_rule_endpoint = _Endpoint(
settings={
"response_type": (DeploymentRuleResponse,),
Expand Down Expand Up @@ -326,6 +350,23 @@ def get_deployment_gate(

return self._get_deployment_gate_endpoint.call_with_http_info(**kwargs)

def get_deployment_gate_rules(
self,
gate_id: str,
) -> DeploymentGateRulesResponse:
"""Get rules for a deployment gate.

Endpoint to get rules for a deployment gate.

:param gate_id: The ID of the deployment gate.
:type gate_id: str
:rtype: DeploymentGateRulesResponse
"""
kwargs: Dict[str, Any] = {}
kwargs["gate_id"] = gate_id

return self._get_deployment_gate_rules_endpoint.call_with_http_info(**kwargs)

def get_deployment_rule(
self,
gate_id: str,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import List, Union, TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
unset,
UnsetType,
)


if TYPE_CHECKING:
from datadog_api_client.v2.model.deployment_rule_response_data import DeploymentRuleResponseData


class DeploymentGateRulesResponse(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.deployment_rule_response_data import DeploymentRuleResponseData

return {
"data": ([DeploymentRuleResponseData],),
}

attribute_map = {
"data": "data",
}

def __init__(self_, data: Union[List[DeploymentRuleResponseData], UnsetType] = unset, **kwargs):
"""
Response for a deployment gate rules.

:param data:
:type data: [DeploymentRuleResponseData], optional
"""
if data is not unset:
kwargs["data"] = data
super().__init__(kwargs)
2 changes: 2 additions & 0 deletions src/datadog_api_client/v2/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,7 @@
from datadog_api_client.v2.model.deployment_gate_response_data_attributes_updated_by import (
DeploymentGateResponseDataAttributesUpdatedBy,
)
from datadog_api_client.v2.model.deployment_gate_rules_response import DeploymentGateRulesResponse
from datadog_api_client.v2.model.deployment_metadata import DeploymentMetadata
from datadog_api_client.v2.model.deployment_relationship import DeploymentRelationship
from datadog_api_client.v2.model.deployment_relationship_data import DeploymentRelationshipData
Expand Down Expand Up @@ -5916,6 +5917,7 @@
"DeploymentGateResponseDataAttributes",
"DeploymentGateResponseDataAttributesCreatedBy",
"DeploymentGateResponseDataAttributesUpdatedBy",
"DeploymentGateRulesResponse",
"DeploymentMetadata",
"DeploymentRelationship",
"DeploymentRelationshipData",
Expand Down
17 changes: 17 additions & 0 deletions tests/v2/features/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 tests/v2/features/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
Loading