From f38dae7c512bcde790be1aa8e48e7404d618d042 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Mon, 8 Jun 2026 13:17:42 +0000 Subject: [PATCH] Regenerate client from commit 4f95357 of spec repo --- .generator/schemas/v2/openapi.yaml | 153 +++++++++++++++++- docs/datadog_api_client.v2.model.rst | 56 +++++++ .../TriggerDeploymentGatesEvaluation.py | 18 +++ .../v2/api/deployment_gates_api.py | 4 + ...ployment_gates_evaluation_configuration.py | 64 ++++++++ ...ent_gates_evaluation_request_attributes.py | 24 ++- ...eployment_gates_evaluation_request_data.py | 2 + .../model/deployment_gates_evaluation_rule.py | 49 ++++++ .../v2/model/deployment_gates_fdd_rule.py | 71 ++++++++ .../deployment_gates_fdd_rule_options.py | 54 +++++++ .../model/deployment_gates_fdd_rule_type.py | 35 ++++ .../v2/model/deployment_gates_monitor_rule.py | 71 ++++++++ .../deployment_gates_monitor_rule_options.py | 49 ++++++ .../deployment_gates_monitor_rule_type.py | 35 ++++ src/datadog_api_client/v2/models/__init__.py | 16 ++ tests/v2/features/deployment_gates.feature | 6 +- 16 files changed, 702 insertions(+), 5 deletions(-) create mode 100644 src/datadog_api_client/v2/model/deployment_gates_evaluation_configuration.py create mode 100644 src/datadog_api_client/v2/model/deployment_gates_evaluation_rule.py create mode 100644 src/datadog_api_client/v2/model/deployment_gates_fdd_rule.py create mode 100644 src/datadog_api_client/v2/model/deployment_gates_fdd_rule_options.py create mode 100644 src/datadog_api_client/v2/model/deployment_gates_fdd_rule_type.py create mode 100644 src/datadog_api_client/v2/model/deployment_gates_monitor_rule.py create mode 100644 src/datadog_api_client/v2/model/deployment_gates_monitor_rule_options.py create mode 100644 src/datadog_api_client/v2/model/deployment_gates_monitor_rule_type.py diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 122c27ff50..cc2d8329b0 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/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index 185c7dc72a..7527141ece 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -11421,6 +11421,13 @@ datadog\_api\_client.v2.model.deployment\_gate\_rules\_response module :members: :show-inheritance: +datadog\_api\_client.v2.model.deployment\_gates\_evaluation\_configuration module +--------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.deployment_gates_evaluation_configuration + :members: + :show-inheritance: + datadog\_api\_client.v2.model.deployment\_gates\_evaluation\_request module --------------------------------------------------------------------------- @@ -11512,6 +11519,34 @@ datadog\_api\_client.v2.model.deployment\_gates\_evaluation\_result\_response\_d :members: :show-inheritance: +datadog\_api\_client.v2.model.deployment\_gates\_evaluation\_rule module +------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.deployment_gates_evaluation_rule + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.deployment\_gates\_fdd\_rule module +----------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.deployment_gates_fdd_rule + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.deployment\_gates\_fdd\_rule\_options module +-------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.deployment_gates_fdd_rule_options + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.deployment\_gates\_fdd\_rule\_type module +----------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.deployment_gates_fdd_rule_type + :members: + :show-inheritance: + datadog\_api\_client.v2.model.deployment\_gates\_list\_response module ---------------------------------------------------------------------- @@ -11533,6 +11568,27 @@ datadog\_api\_client.v2.model.deployment\_gates\_list\_response\_meta\_page modu :members: :show-inheritance: +datadog\_api\_client.v2.model.deployment\_gates\_monitor\_rule module +--------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.deployment_gates_monitor_rule + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.deployment\_gates\_monitor\_rule\_options module +------------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.deployment_gates_monitor_rule_options + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.deployment\_gates\_monitor\_rule\_type module +--------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.deployment_gates_monitor_rule_type + :members: + :show-inheritance: + datadog\_api\_client.v2.model.deployment\_gates\_rule\_response module ---------------------------------------------------------------------- diff --git a/examples/v2/deployment-gates/TriggerDeploymentGatesEvaluation.py b/examples/v2/deployment-gates/TriggerDeploymentGatesEvaluation.py index a287064929..6f715c436c 100644 --- a/examples/v2/deployment-gates/TriggerDeploymentGatesEvaluation.py +++ b/examples/v2/deployment-gates/TriggerDeploymentGatesEvaluation.py @@ -4,6 +4,7 @@ from datadog_api_client import ApiClient, Configuration from datadog_api_client.v2.api.deployment_gates_api import DeploymentGatesApi +from datadog_api_client.v2.model.deployment_gates_evaluation_configuration import DeploymentGatesEvaluationConfiguration from datadog_api_client.v2.model.deployment_gates_evaluation_request import DeploymentGatesEvaluationRequest from datadog_api_client.v2.model.deployment_gates_evaluation_request_attributes import ( DeploymentGatesEvaluationRequestAttributes, @@ -12,10 +13,27 @@ from datadog_api_client.v2.model.deployment_gates_evaluation_request_data_type import ( DeploymentGatesEvaluationRequestDataType, ) +from datadog_api_client.v2.model.deployment_gates_monitor_rule import DeploymentGatesMonitorRule +from datadog_api_client.v2.model.deployment_gates_monitor_rule_options import DeploymentGatesMonitorRuleOptions +from datadog_api_client.v2.model.deployment_gates_monitor_rule_type import DeploymentGatesMonitorRuleType body = DeploymentGatesEvaluationRequest( data=DeploymentGatesEvaluationRequestData( attributes=DeploymentGatesEvaluationRequestAttributes( + configuration=DeploymentGatesEvaluationConfiguration( + dry_run=False, + rules=[ + DeploymentGatesMonitorRule( + dry_run=False, + name="error rate monitors", + options=DeploymentGatesMonitorRuleOptions( + duration=300, + query="service:transaction-backend env:production", + ), + type=DeploymentGatesMonitorRuleType.MONITOR, + ), + ], + ), env="staging", identifier="pre-deploy", primary_tag="region:us-east-1", 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 9b0efbc06d..4dd8a2ac59 100644 --- a/src/datadog_api_client/v2/api/deployment_gates_api.py +++ b/src/datadog_api_client/v2/api/deployment_gates_api.py @@ -531,6 +531,10 @@ def trigger_deployment_gates_evaluation( 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. + :type body: DeploymentGatesEvaluationRequest :rtype: DeploymentGatesEvaluationResponse """ diff --git a/src/datadog_api_client/v2/model/deployment_gates_evaluation_configuration.py b/src/datadog_api_client/v2/model/deployment_gates_evaluation_configuration.py new file mode 100644 index 0000000000..1ea5be3f90 --- /dev/null +++ b/src/datadog_api_client/v2/model/deployment_gates_evaluation_configuration.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 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_gates_evaluation_rule import DeploymentGatesEvaluationRule + from datadog_api_client.v2.model.deployment_gates_monitor_rule import DeploymentGatesMonitorRule + from datadog_api_client.v2.model.deployment_gates_fdd_rule import DeploymentGatesFDDRule + + +class DeploymentGatesEvaluationConfiguration(ModelNormal): + validations = { + "rules": { + "min_items": 1, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.deployment_gates_evaluation_rule import DeploymentGatesEvaluationRule + + return { + "dry_run": (bool,), + "rules": ([DeploymentGatesEvaluationRule],), + } + + attribute_map = { + "dry_run": "dry_run", + "rules": "rules", + } + + def __init__( + self_, + rules: List[Union[DeploymentGatesEvaluationRule, DeploymentGatesMonitorRule, DeploymentGatesFDDRule]], + dry_run: Union[bool, UnsetType] = unset, + **kwargs, + ): + """ + 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. + + :param dry_run: 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. + :type dry_run: bool, optional + + :param rules: The list of rules to evaluate. At least one rule is required. + :type rules: [DeploymentGatesEvaluationRule] + """ + if dry_run is not unset: + kwargs["dry_run"] = dry_run + super().__init__(kwargs) + + self_.rules = rules diff --git a/src/datadog_api_client/v2/model/deployment_gates_evaluation_request_attributes.py b/src/datadog_api_client/v2/model/deployment_gates_evaluation_request_attributes.py index 784a60c64a..5f2ce8ab8f 100644 --- a/src/datadog_api_client/v2/model/deployment_gates_evaluation_request_attributes.py +++ b/src/datadog_api_client/v2/model/deployment_gates_evaluation_request_attributes.py @@ -3,7 +3,7 @@ # Copyright 2019-Present Datadog, Inc. from __future__ import annotations -from typing import Union +from typing import Union, TYPE_CHECKING from datadog_api_client.model_utils import ( ModelNormal, @@ -13,10 +13,21 @@ ) +if TYPE_CHECKING: + from datadog_api_client.v2.model.deployment_gates_evaluation_configuration import ( + DeploymentGatesEvaluationConfiguration, + ) + + class DeploymentGatesEvaluationRequestAttributes(ModelNormal): @cached_property def openapi_types(_): + from datadog_api_client.v2.model.deployment_gates_evaluation_configuration import ( + DeploymentGatesEvaluationConfiguration, + ) + return { + "configuration": (DeploymentGatesEvaluationConfiguration,), "env": (str,), "identifier": (str,), "primary_tag": (str,), @@ -25,6 +36,7 @@ def openapi_types(_): } attribute_map = { + "configuration": "configuration", "env": "env", "identifier": "identifier", "primary_tag": "primary_tag", @@ -36,6 +48,7 @@ def __init__( self_, env: str, service: str, + configuration: Union[DeploymentGatesEvaluationConfiguration, UnsetType] = unset, identifier: Union[str, UnsetType] = unset, primary_tag: Union[str, UnsetType] = unset, version: Union[str, UnsetType] = unset, @@ -43,6 +56,13 @@ def __init__( ): """ 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. + + :param configuration: 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. + :type configuration: DeploymentGatesEvaluationConfiguration, optional :param env: The environment of the deployment. :type env: str @@ -59,6 +79,8 @@ def __init__( :param version: The version of the deployment. Required for APM Faulty Deployment Detection rules. :type version: str, optional """ + if configuration is not unset: + kwargs["configuration"] = configuration if identifier is not unset: kwargs["identifier"] = identifier if primary_tag is not unset: diff --git a/src/datadog_api_client/v2/model/deployment_gates_evaluation_request_data.py b/src/datadog_api_client/v2/model/deployment_gates_evaluation_request_data.py index 9b141844b0..239364b02e 100644 --- a/src/datadog_api_client/v2/model/deployment_gates_evaluation_request_data.py +++ b/src/datadog_api_client/v2/model/deployment_gates_evaluation_request_data.py @@ -50,6 +50,8 @@ def __init__( Data for a deployment gate evaluation request. :param attributes: 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. :type attributes: DeploymentGatesEvaluationRequestAttributes :param type: JSON:API type for a deployment gate evaluation request. diff --git a/src/datadog_api_client/v2/model/deployment_gates_evaluation_rule.py b/src/datadog_api_client/v2/model/deployment_gates_evaluation_rule.py new file mode 100644 index 0000000000..b397b1cc29 --- /dev/null +++ b/src/datadog_api_client/v2/model/deployment_gates_evaluation_rule.py @@ -0,0 +1,49 @@ +# 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 ( + ModelComposed, + cached_property, +) + + +class DeploymentGatesEvaluationRule(ModelComposed): + def __init__(self, **kwargs): + """ + A rule to evaluate as part of a deployment gate evaluation. + + :param dry_run: 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. + :type dry_run: bool, optional + + :param name: Human-readable name for this rule. + :type name: str + + :param options: Options for a `monitor` rule. + :type options: DeploymentGatesMonitorRuleOptions, optional + + :param type: The type identifier for a monitor rule. + :type type: DeploymentGatesMonitorRuleType + """ + super().__init__(kwargs) + + @cached_property + def _composed_schemas(_): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error because the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + from datadog_api_client.v2.model.deployment_gates_monitor_rule import DeploymentGatesMonitorRule + from datadog_api_client.v2.model.deployment_gates_fdd_rule import DeploymentGatesFDDRule + + return { + "oneOf": [ + DeploymentGatesMonitorRule, + DeploymentGatesFDDRule, + ], + } diff --git a/src/datadog_api_client/v2/model/deployment_gates_fdd_rule.py b/src/datadog_api_client/v2/model/deployment_gates_fdd_rule.py new file mode 100644 index 0000000000..3da5c20455 --- /dev/null +++ b/src/datadog_api_client/v2/model/deployment_gates_fdd_rule.py @@ -0,0 +1,71 @@ +# 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.deployment_gates_fdd_rule_options import DeploymentGatesFDDRuleOptions + from datadog_api_client.v2.model.deployment_gates_fdd_rule_type import DeploymentGatesFDDRuleType + + +class DeploymentGatesFDDRule(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.deployment_gates_fdd_rule_options import DeploymentGatesFDDRuleOptions + from datadog_api_client.v2.model.deployment_gates_fdd_rule_type import DeploymentGatesFDDRuleType + + return { + "dry_run": (bool,), + "name": (str,), + "options": (DeploymentGatesFDDRuleOptions,), + "type": (DeploymentGatesFDDRuleType,), + } + + attribute_map = { + "dry_run": "dry_run", + "name": "name", + "options": "options", + "type": "type", + } + + def __init__( + self_, + name: str, + type: DeploymentGatesFDDRuleType, + dry_run: Union[bool, UnsetType] = unset, + options: Union[DeploymentGatesFDDRuleOptions, UnsetType] = unset, + **kwargs, + ): + """ + A faulty deployment detection rule to evaluate as part of a deployment gate evaluation. + + :param dry_run: 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. + :type dry_run: bool, optional + + :param name: Human-readable name for this rule. + :type name: str + + :param options: Options for a ``faulty_deployment_detection`` rule. + :type options: DeploymentGatesFDDRuleOptions, optional + + :param type: The type identifier for a faulty deployment detection rule. + :type type: DeploymentGatesFDDRuleType + """ + if dry_run is not unset: + kwargs["dry_run"] = dry_run + if options is not unset: + kwargs["options"] = options + super().__init__(kwargs) + + self_.name = name + self_.type = type diff --git a/src/datadog_api_client/v2/model/deployment_gates_fdd_rule_options.py b/src/datadog_api_client/v2/model/deployment_gates_fdd_rule_options.py new file mode 100644 index 0000000000..4f56f48ba3 --- /dev/null +++ b/src/datadog_api_client/v2/model/deployment_gates_fdd_rule_options.py @@ -0,0 +1,54 @@ +# 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 + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +class DeploymentGatesFDDRuleOptions(ModelNormal): + validations = { + "duration": { + "inclusive_maximum": 7200, + }, + } + + @cached_property + def openapi_types(_): + return { + "duration": (int,), + "excluded_resources": ([str],), + } + + attribute_map = { + "duration": "duration", + "excluded_resources": "excluded_resources", + } + + def __init__( + self_, + duration: Union[int, UnsetType] = unset, + excluded_resources: Union[List[str], UnsetType] = unset, + **kwargs, + ): + """ + Options for a ``faulty_deployment_detection`` rule. + + :param duration: Evaluation window in seconds. Maximum 7200 (2 hours). + :type duration: int, optional + + :param excluded_resources: APM resource names to exclude from analysis. + :type excluded_resources: [str], optional + """ + if duration is not unset: + kwargs["duration"] = duration + if excluded_resources is not unset: + kwargs["excluded_resources"] = excluded_resources + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/deployment_gates_fdd_rule_type.py b/src/datadog_api_client/v2/model/deployment_gates_fdd_rule_type.py new file mode 100644 index 0000000000..b634e7a9ba --- /dev/null +++ b/src/datadog_api_client/v2/model/deployment_gates_fdd_rule_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 DeploymentGatesFDDRuleType(ModelSimple): + """ + The type identifier for a faulty deployment detection rule. + + :param value: If omitted defaults to "faulty_deployment_detection". Must be one of ["faulty_deployment_detection"]. + :type value: str + """ + + allowed_values = { + "faulty_deployment_detection", + } + FAULTY_DEPLOYMENT_DETECTION: ClassVar["DeploymentGatesFDDRuleType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +DeploymentGatesFDDRuleType.FAULTY_DEPLOYMENT_DETECTION = DeploymentGatesFDDRuleType("faulty_deployment_detection") diff --git a/src/datadog_api_client/v2/model/deployment_gates_monitor_rule.py b/src/datadog_api_client/v2/model/deployment_gates_monitor_rule.py new file mode 100644 index 0000000000..a232bf5295 --- /dev/null +++ b/src/datadog_api_client/v2/model/deployment_gates_monitor_rule.py @@ -0,0 +1,71 @@ +# 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.deployment_gates_monitor_rule_options import DeploymentGatesMonitorRuleOptions + from datadog_api_client.v2.model.deployment_gates_monitor_rule_type import DeploymentGatesMonitorRuleType + + +class DeploymentGatesMonitorRule(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.deployment_gates_monitor_rule_options import DeploymentGatesMonitorRuleOptions + from datadog_api_client.v2.model.deployment_gates_monitor_rule_type import DeploymentGatesMonitorRuleType + + return { + "dry_run": (bool,), + "name": (str,), + "options": (DeploymentGatesMonitorRuleOptions,), + "type": (DeploymentGatesMonitorRuleType,), + } + + attribute_map = { + "dry_run": "dry_run", + "name": "name", + "options": "options", + "type": "type", + } + + def __init__( + self_, + name: str, + type: DeploymentGatesMonitorRuleType, + dry_run: Union[bool, UnsetType] = unset, + options: Union[DeploymentGatesMonitorRuleOptions, UnsetType] = unset, + **kwargs, + ): + """ + A monitor rule to evaluate as part of a deployment gate evaluation. + + :param dry_run: 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. + :type dry_run: bool, optional + + :param name: Human-readable name for this rule. + :type name: str + + :param options: Options for a ``monitor`` rule. + :type options: DeploymentGatesMonitorRuleOptions, optional + + :param type: The type identifier for a monitor rule. + :type type: DeploymentGatesMonitorRuleType + """ + if dry_run is not unset: + kwargs["dry_run"] = dry_run + if options is not unset: + kwargs["options"] = options + super().__init__(kwargs) + + self_.name = name + self_.type = type diff --git a/src/datadog_api_client/v2/model/deployment_gates_monitor_rule_options.py b/src/datadog_api_client/v2/model/deployment_gates_monitor_rule_options.py new file mode 100644 index 0000000000..1b2c95851a --- /dev/null +++ b/src/datadog_api_client/v2/model/deployment_gates_monitor_rule_options.py @@ -0,0 +1,49 @@ +# 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 + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +class DeploymentGatesMonitorRuleOptions(ModelNormal): + validations = { + "duration": { + "inclusive_maximum": 7200, + }, + } + + @cached_property + def openapi_types(_): + return { + "duration": (int,), + "query": (str,), + } + + attribute_map = { + "duration": "duration", + "query": "query", + } + + def __init__(self_, query: str, duration: Union[int, UnsetType] = unset, **kwargs): + """ + Options for a ``monitor`` rule. + + :param duration: Evaluation window in seconds. Maximum 7200 (2 hours). + :type duration: int, optional + + :param query: Monitor search query. + :type query: str + """ + if duration is not unset: + kwargs["duration"] = duration + super().__init__(kwargs) + + self_.query = query diff --git a/src/datadog_api_client/v2/model/deployment_gates_monitor_rule_type.py b/src/datadog_api_client/v2/model/deployment_gates_monitor_rule_type.py new file mode 100644 index 0000000000..496fc5701f --- /dev/null +++ b/src/datadog_api_client/v2/model/deployment_gates_monitor_rule_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 DeploymentGatesMonitorRuleType(ModelSimple): + """ + The type identifier for a monitor rule. + + :param value: If omitted defaults to "monitor". Must be one of ["monitor"]. + :type value: str + """ + + allowed_values = { + "monitor", + } + MONITOR: ClassVar["DeploymentGatesMonitorRuleType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +DeploymentGatesMonitorRuleType.MONITOR = DeploymentGatesMonitorRuleType("monitor") diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 5670b17fa1..66ed61cea5 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -2207,6 +2207,7 @@ DeploymentGateResponseDataAttributesUpdatedBy, ) from datadog_api_client.v2.model.deployment_gate_rules_response import DeploymentGateRulesResponse +from datadog_api_client.v2.model.deployment_gates_evaluation_configuration import DeploymentGatesEvaluationConfiguration from datadog_api_client.v2.model.deployment_gates_evaluation_request import DeploymentGatesEvaluationRequest from datadog_api_client.v2.model.deployment_gates_evaluation_request_attributes import ( DeploymentGatesEvaluationRequestAttributes, @@ -2238,9 +2239,16 @@ from datadog_api_client.v2.model.deployment_gates_evaluation_result_response_data_type import ( DeploymentGatesEvaluationResultResponseDataType, ) +from datadog_api_client.v2.model.deployment_gates_evaluation_rule import DeploymentGatesEvaluationRule +from datadog_api_client.v2.model.deployment_gates_fdd_rule import DeploymentGatesFDDRule +from datadog_api_client.v2.model.deployment_gates_fdd_rule_options import DeploymentGatesFDDRuleOptions +from datadog_api_client.v2.model.deployment_gates_fdd_rule_type import DeploymentGatesFDDRuleType from datadog_api_client.v2.model.deployment_gates_list_response import DeploymentGatesListResponse from datadog_api_client.v2.model.deployment_gates_list_response_meta import DeploymentGatesListResponseMeta from datadog_api_client.v2.model.deployment_gates_list_response_meta_page import DeploymentGatesListResponseMetaPage +from datadog_api_client.v2.model.deployment_gates_monitor_rule import DeploymentGatesMonitorRule +from datadog_api_client.v2.model.deployment_gates_monitor_rule_options import DeploymentGatesMonitorRuleOptions +from datadog_api_client.v2.model.deployment_gates_monitor_rule_type import DeploymentGatesMonitorRuleType from datadog_api_client.v2.model.deployment_gates_rule_response import DeploymentGatesRuleResponse from datadog_api_client.v2.model.deployment_metadata import DeploymentMetadata from datadog_api_client.v2.model.deployment_relationship import DeploymentRelationship @@ -10587,6 +10595,7 @@ "DeploymentGateResponseDataAttributesCreatedBy", "DeploymentGateResponseDataAttributesUpdatedBy", "DeploymentGateRulesResponse", + "DeploymentGatesEvaluationConfiguration", "DeploymentGatesEvaluationRequest", "DeploymentGatesEvaluationRequestAttributes", "DeploymentGatesEvaluationRequestData", @@ -10600,9 +10609,16 @@ "DeploymentGatesEvaluationResultResponseAttributesGateStatus", "DeploymentGatesEvaluationResultResponseData", "DeploymentGatesEvaluationResultResponseDataType", + "DeploymentGatesEvaluationRule", + "DeploymentGatesFDDRule", + "DeploymentGatesFDDRuleOptions", + "DeploymentGatesFDDRuleType", "DeploymentGatesListResponse", "DeploymentGatesListResponseMeta", "DeploymentGatesListResponseMetaPage", + "DeploymentGatesMonitorRule", + "DeploymentGatesMonitorRuleOptions", + "DeploymentGatesMonitorRuleType", "DeploymentGatesRuleResponse", "DeploymentMetadata", "DeploymentRelationship", diff --git a/tests/v2/features/deployment_gates.feature b/tests/v2/features/deployment_gates.feature index df9494d2ae..de5ceaeaa3 100644 --- a/tests/v2/features/deployment_gates.feature +++ b/tests/v2/features/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.