diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index dad178ca22..70cb1fd3b9 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/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index 86d07a5663..19370f1cf4 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -6850,6 +6850,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 --------------------------------------------------------- @@ -12933,6 +12940,27 @@ datadog\_api\_client.v2.model.list\_connections\_response\_data\_type module :members: :show-inheritance: +datadog\_api\_client.v2.model.list\_deployment\_rule\_response\_data module +--------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.list_deployment_rule_response_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.list\_deployment\_rules\_data\_type module +------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.list_deployment_rules_data_type + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.list\_deployment\_rules\_response\_data\_attributes module +---------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.list_deployment_rules_response_data_attributes + :members: + :show-inheritance: + datadog\_api\_client.v2.model.list\_devices\_response module ------------------------------------------------------------ diff --git a/examples/v2/deployment-gates/GetDeploymentGateRules.py b/examples/v2/deployment-gates/GetDeploymentGateRules.py new file mode 100644 index 0000000000..5965500134 --- /dev/null +++ b/examples/v2/deployment-gates/GetDeploymentGateRules.py @@ -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) diff --git a/src/datadog_api_client/configuration.py b/src/datadog_api_client/configuration.py index 758e7fcd6f..ed6d39324a 100644 --- a/src/datadog_api_client/configuration.py +++ b/src/datadog_api_client/configuration.py @@ -300,6 +300,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, diff --git a/src/datadog_api_client/v2/api/deployment_gates_api.py b/src/datadog_api_client/v2/api/deployment_gates_api.py index 84e3ea50b3..cec0823a93 100644 --- a/src/datadog_api_client/v2/api/deployment_gates_api.py +++ b/src/datadog_api_client/v2/api/deployment_gates_api.py @@ -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 @@ -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,), @@ -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, diff --git a/src/datadog_api_client/v2/model/deployment_gate_rules_response.py b/src/datadog_api_client/v2/model/deployment_gate_rules_response.py new file mode 100644 index 0000000000..de1c6da276 --- /dev/null +++ b/src/datadog_api_client/v2/model/deployment_gate_rules_response.py @@ -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 Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.list_deployment_rule_response_data import ListDeploymentRuleResponseData + + +class DeploymentGateRulesResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.list_deployment_rule_response_data import ListDeploymentRuleResponseData + + return { + "data": (ListDeploymentRuleResponseData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: Union[ListDeploymentRuleResponseData, UnsetType] = unset, **kwargs): + """ + Response for a deployment gate rules. + + :param data: Data for a list of deployment rules. + :type data: ListDeploymentRuleResponseData, optional + """ + if data is not unset: + kwargs["data"] = data + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/list_deployment_rule_response_data.py b/src/datadog_api_client/v2/model/list_deployment_rule_response_data.py new file mode 100644 index 0000000000..5e377cfc5c --- /dev/null +++ b/src/datadog_api_client/v2/model/list_deployment_rule_response_data.py @@ -0,0 +1,64 @@ +# 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 TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.list_deployment_rules_response_data_attributes import ( + ListDeploymentRulesResponseDataAttributes, + ) + from datadog_api_client.v2.model.list_deployment_rules_data_type import ListDeploymentRulesDataType + + +class ListDeploymentRuleResponseData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.list_deployment_rules_response_data_attributes import ( + ListDeploymentRulesResponseDataAttributes, + ) + from datadog_api_client.v2.model.list_deployment_rules_data_type import ListDeploymentRulesDataType + + return { + "attributes": (ListDeploymentRulesResponseDataAttributes,), + "id": (str,), + "type": (ListDeploymentRulesDataType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__( + self_, + attributes: ListDeploymentRulesResponseDataAttributes, + id: str, + type: ListDeploymentRulesDataType, + **kwargs, + ): + """ + Data for a list of deployment rules. + + :param attributes: + :type attributes: ListDeploymentRulesResponseDataAttributes + + :param id: Unique identifier of the deployment rule. + :type id: str + + :param type: List deployment rule resource type. + :type type: ListDeploymentRulesDataType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/list_deployment_rules_data_type.py b/src/datadog_api_client/v2/model/list_deployment_rules_data_type.py new file mode 100644 index 0000000000..d3626e3eb6 --- /dev/null +++ b/src/datadog_api_client/v2/model/list_deployment_rules_data_type.py @@ -0,0 +1,35 @@ +# 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 datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class ListDeploymentRulesDataType(ModelSimple): + """ + List deployment rule resource type. + + :param value: If omitted defaults to "list_deployment_rules". Must be one of ["list_deployment_rules"]. + :type value: str + """ + + allowed_values = { + "list_deployment_rules", + } + LIST_DEPLOYMENT_RULES: ClassVar["ListDeploymentRulesDataType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +ListDeploymentRulesDataType.LIST_DEPLOYMENT_RULES = ListDeploymentRulesDataType("list_deployment_rules") diff --git a/src/datadog_api_client/v2/model/list_deployment_rules_response_data_attributes.py b/src/datadog_api_client/v2/model/list_deployment_rules_response_data_attributes.py new file mode 100644 index 0000000000..53ad9dde9f --- /dev/null +++ b/src/datadog_api_client/v2/model/list_deployment_rules_response_data_attributes.py @@ -0,0 +1,46 @@ +# 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_attributes import ( + DeploymentRuleResponseDataAttributes, + ) + + +class ListDeploymentRulesResponseDataAttributes(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.deployment_rule_response_data_attributes import ( + DeploymentRuleResponseDataAttributes, + ) + + return { + "rules": ([DeploymentRuleResponseDataAttributes],), + } + + attribute_map = { + "rules": "rules", + } + + def __init__(self_, rules: Union[List[DeploymentRuleResponseDataAttributes], UnsetType] = unset, **kwargs): + """ + + + :param rules: + :type rules: [DeploymentRuleResponseDataAttributes], optional + """ + if rules is not unset: + kwargs["rules"] = rules + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 615d7d3efe..801962e810 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -1381,6 +1381,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 @@ -2434,6 +2435,11 @@ ListConnectionsResponseDataAttributesConnectionsItemsJoin, ) from datadog_api_client.v2.model.list_connections_response_data_type import ListConnectionsResponseDataType +from datadog_api_client.v2.model.list_deployment_rule_response_data import ListDeploymentRuleResponseData +from datadog_api_client.v2.model.list_deployment_rules_data_type import ListDeploymentRulesDataType +from datadog_api_client.v2.model.list_deployment_rules_response_data_attributes import ( + ListDeploymentRulesResponseDataAttributes, +) from datadog_api_client.v2.model.list_devices_response import ListDevicesResponse from datadog_api_client.v2.model.list_devices_response_metadata import ListDevicesResponseMetadata from datadog_api_client.v2.model.list_devices_response_metadata_page import ListDevicesResponseMetadataPage @@ -6074,6 +6080,7 @@ "DeploymentGateResponseDataAttributes", "DeploymentGateResponseDataAttributesCreatedBy", "DeploymentGateResponseDataAttributesUpdatedBy", + "DeploymentGateRulesResponse", "DeploymentMetadata", "DeploymentRelationship", "DeploymentRelationshipData", @@ -6921,6 +6928,9 @@ "ListConnectionsResponseDataAttributesConnectionsItems", "ListConnectionsResponseDataAttributesConnectionsItemsJoin", "ListConnectionsResponseDataType", + "ListDeploymentRuleResponseData", + "ListDeploymentRulesDataType", + "ListDeploymentRulesResponseDataAttributes", "ListDevicesResponse", "ListDevicesResponseMetadata", "ListDevicesResponseMetadataPage", diff --git a/tests/v2/cassettes/test_scenarios/test_get_rules_for_a_deployment_gate_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_get_rules_for_a_deployment_gate_returns_ok_response.frozen new file mode 100644 index 0000000000..fef8528de8 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_get_rules_for_a_deployment_gate_returns_ok_response.frozen @@ -0,0 +1 @@ +2025-12-09T13:34:21.892Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_get_rules_for_a_deployment_gate_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_get_rules_for_a_deployment_gate_returns_ok_response.yaml new file mode 100644 index 0000000000..81068c4813 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_get_rules_for_a_deployment_gate_returns_ok_response.yaml @@ -0,0 +1,52 @@ +interactions: +- request: + body: '{"data":{"attributes":{"dry_run":false,"env":"production","identifier":"my-gate","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: + string: '{"data":{"id":"4e020f52-06d2-4584-9bc8-4955ce5de1b8","type":"deployment_gate","attributes":{"created_at":"2025-12-09T13:34:22.624907Z","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","service":"my-service","updated_at":"2025-12-09T13:34:22.624907Z","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 +- request: + body: null + headers: + accept: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/deployment_gates/4e020f52-06d2-4584-9bc8-4955ce5de1b8/rules + response: + body: + string: '{"data":{"id":"4e020f52-06d2-4584-9bc8-4955ce5de1b8","type":"list_deployment_rules","attributes":{"rules":[]}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 200 + message: OK +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/deployment_gates/4e020f52-06d2-4584-9bc8-4955ce5de1b8 + response: + body: + string: '' + headers: {} + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/features/deployment_gates.feature b/tests/v2/features/deployment_gates.feature index e4023c5650..cb0c5a1262 100644 --- a/tests/v2/features/deployment_gates.feature +++ b/tests/v2/features/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/tests/v2/features/undo.json b/tests/v2/features/undo.json index 71dba8f3e3..396d523836 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -1335,6 +1335,12 @@ "type": "unsafe" } }, + "GetDeploymentGateRules": { + "tag": "Deployment Gates", + "undo": { + "type": "safe" + } + }, "CreateDeploymentRule": { "tag": "Deployment Gates", "undo": {