From 47cffa04d005d89e6b4512e87d6bddc98478d953 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Mon, 14 Sep 2026 08:02:26 +0000 Subject: [PATCH] Regenerate client from commit 9bc79cc of spec repo --- .generator/schemas/v2/openapi.yaml | 65 ++- .../CreateDeploymentRule_2423265690.py | 48 ++ .../CreateDeploymentRule_4286388136.py | 39 ++ ..._deployment_rule_params_data_attributes.py | 6 +- .../model/deployment_rule_options_monitor.py | 4 +- .../deployment_rule_options_monitor_id.py | 48 ++ .../deployment_rule_options_monitor_ids.py | 91 ++++ ...eployment_rule_response_data_attributes.py | 6 +- .../v2/model/deployment_rules_options.py | 7 +- ..._deployment_rule_params_data_attributes.py | 6 +- src/datadog_api_client/v2/models/__init__.py | 4 + .../test-runner-data/manifest.json | 21 + ...-with-monitor-ids-returns-ok-response.json | 60 +++ ...itor-ids-returns-bad-request-response.json | 61 +++ ...t-rule-with-query-returns-ok-response.json | 55 +++ .../test-server-data/v2/deployment-gates.json | 420 ++++++++++++++++++ tests/v2/features/deployment_gates.feature | 31 ++ 17 files changed, 964 insertions(+), 8 deletions(-) create mode 100644 examples/v2/deployment-gates/CreateDeploymentRule_2423265690.py create mode 100644 examples/v2/deployment-gates/CreateDeploymentRule_4286388136.py create mode 100644 src/datadog_api_client/v2/model/deployment_rule_options_monitor_id.py create mode 100644 src/datadog_api_client/v2/model/deployment_rule_options_monitor_ids.py create mode 100644 tests/generated-test/test-runner-data/v2/deployment-gates/create-monitor-deployment-rule-with-monitor-ids-returns-ok-response.json create mode 100644 tests/generated-test/test-runner-data/v2/deployment-gates/create-monitor-deployment-rule-with-query-and-monitor-ids-returns-bad-request-response.json create mode 100644 tests/generated-test/test-runner-data/v2/deployment-gates/create-monitor-deployment-rule-with-query-returns-ok-response.json diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index a681b29aea..f150f98ea1 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -35206,7 +35206,7 @@ components: type: object DeploymentRuleOptionsMonitor: additionalProperties: false - description: Monitor options for deployment rules. + description: Monitor query options for deployment rules. properties: duration: description: Seconds the monitor needs to stay in OK status for the rule to pass. @@ -35224,7 +35224,7 @@ components: example: false type: boolean query: - description: Monitors that match this query are evaluated. + description: A query that selects the monitors to evaluate. example: "service:my-service env:prod" type: string warmup: @@ -35237,6 +35237,66 @@ components: required: - query type: object + DeploymentRuleOptionsMonitorId: + additionalProperties: false + description: A specific monitor and the groups to evaluate for it. + properties: + groups: + description: The exact monitor group names to evaluate. An empty array evaluates all groups. + example: [] + items: + description: An exact monitor group name. + minLength: 1 + type: string + type: array + uniqueItems: true + id: + description: The monitor's decimal ID. + example: "123456" + pattern: "^[1-9][0-9]*$" + type: string + required: + - id + - groups + type: object + DeploymentRuleOptionsMonitorIds: + additionalProperties: false + description: Specific monitor options for deployment rules. + properties: + duration: + description: Seconds the monitors need to stay in OK status for the rule to pass. + example: 3600 + format: int64 + type: integer + fail_on_no_data: + default: true + description: Whether the rule should fail if a selected monitor group is in a NO DATA state. + example: false + type: boolean + fail_on_no_groups_found: + default: false + description: Whether the rule should fail if no monitor groups are found for the selected monitors. + example: false + type: boolean + monitor_ids: + description: A non-empty list of specific monitors to evaluate. + example: + - groups: [] + id: "123456" + items: + $ref: "#/components/schemas/DeploymentRuleOptionsMonitorId" + minItems: 1 + type: array + warmup: + default: 0 + description: Seconds to wait after a deployment starts before evaluating the monitors' statuses. + example: 0 + format: int64 + minimum: 0 + type: integer + required: + - monitor_ids + type: object DeploymentRuleResponse: description: Response for a deployment rule. properties: @@ -35351,6 +35411,7 @@ components: oneOf: - $ref: "#/components/schemas/DeploymentRuleOptionsFaultyDeploymentDetection" - $ref: "#/components/schemas/DeploymentRuleOptionsMonitor" + - $ref: "#/components/schemas/DeploymentRuleOptionsMonitorIds" DetachCaseRequest: description: Request for detaching security findings from their case. properties: diff --git a/examples/v2/deployment-gates/CreateDeploymentRule_2423265690.py b/examples/v2/deployment-gates/CreateDeploymentRule_2423265690.py new file mode 100644 index 0000000000..673d8480b3 --- /dev/null +++ b/examples/v2/deployment-gates/CreateDeploymentRule_2423265690.py @@ -0,0 +1,48 @@ +""" +Create monitor deployment rule with monitor IDs 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 +from datadog_api_client.v2.model.create_deployment_rule_params import CreateDeploymentRuleParams +from datadog_api_client.v2.model.create_deployment_rule_params_data import CreateDeploymentRuleParamsData +from datadog_api_client.v2.model.create_deployment_rule_params_data_attributes import ( + CreateDeploymentRuleParamsDataAttributes, +) +from datadog_api_client.v2.model.deployment_rule_data_type import DeploymentRuleDataType +from datadog_api_client.v2.model.deployment_rule_options_monitor_id import DeploymentRuleOptionsMonitorId +from datadog_api_client.v2.model.deployment_rule_options_monitor_ids import DeploymentRuleOptionsMonitorIds + +# there is a valid "deployment_gate" in the system +DEPLOYMENT_GATE_DATA_ID = environ["DEPLOYMENT_GATE_DATA_ID"] + +# there is a valid "monitor" in the system +MONITOR_ID = environ["MONITOR_ID"] + +body = CreateDeploymentRuleParams( + data=CreateDeploymentRuleParamsData( + attributes=CreateDeploymentRuleParamsDataAttributes( + dry_run=False, + name="Specific monitor deployment rule", + options=DeploymentRuleOptionsMonitorIds( + monitor_ids=[ + DeploymentRuleOptionsMonitorId( + id="7", + groups=[], + ), + ], + ), + type="monitor", + ), + type=DeploymentRuleDataType.DEPLOYMENT_RULE, + ), +) + +configuration = Configuration() +configuration.unstable_operations["create_deployment_rule"] = True +with ApiClient(configuration) as api_client: + api_instance = DeploymentGatesApi(api_client) + response = api_instance.create_deployment_rule(gate_id=DEPLOYMENT_GATE_DATA_ID, body=body) + + print(response) diff --git a/examples/v2/deployment-gates/CreateDeploymentRule_4286388136.py b/examples/v2/deployment-gates/CreateDeploymentRule_4286388136.py new file mode 100644 index 0000000000..b5ae8d9cbf --- /dev/null +++ b/examples/v2/deployment-gates/CreateDeploymentRule_4286388136.py @@ -0,0 +1,39 @@ +""" +Create monitor deployment rule with query 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 +from datadog_api_client.v2.model.create_deployment_rule_params import CreateDeploymentRuleParams +from datadog_api_client.v2.model.create_deployment_rule_params_data import CreateDeploymentRuleParamsData +from datadog_api_client.v2.model.create_deployment_rule_params_data_attributes import ( + CreateDeploymentRuleParamsDataAttributes, +) +from datadog_api_client.v2.model.deployment_rule_data_type import DeploymentRuleDataType +from datadog_api_client.v2.model.deployment_rule_options_monitor import DeploymentRuleOptionsMonitor + +# there is a valid "deployment_gate" in the system +DEPLOYMENT_GATE_DATA_ID = environ["DEPLOYMENT_GATE_DATA_ID"] + +body = CreateDeploymentRuleParams( + data=CreateDeploymentRuleParamsData( + attributes=CreateDeploymentRuleParamsDataAttributes( + dry_run=False, + name="Query monitor deployment rule", + options=DeploymentRuleOptionsMonitor( + query="service:transaction-backend env:production", + ), + type="monitor", + ), + type=DeploymentRuleDataType.DEPLOYMENT_RULE, + ), +) + +configuration = Configuration() +configuration.unstable_operations["create_deployment_rule"] = True +with ApiClient(configuration) as api_client: + api_instance = DeploymentGatesApi(api_client) + response = api_instance.create_deployment_rule(gate_id=DEPLOYMENT_GATE_DATA_ID, body=body) + + print(response) diff --git a/src/datadog_api_client/v2/model/create_deployment_rule_params_data_attributes.py b/src/datadog_api_client/v2/model/create_deployment_rule_params_data_attributes.py index 504e7e7c96..7c9356c145 100644 --- a/src/datadog_api_client/v2/model/create_deployment_rule_params_data_attributes.py +++ b/src/datadog_api_client/v2/model/create_deployment_rule_params_data_attributes.py @@ -19,6 +19,7 @@ DeploymentRuleOptionsFaultyDeploymentDetection, ) from datadog_api_client.v2.model.deployment_rule_options_monitor import DeploymentRuleOptionsMonitor + from datadog_api_client.v2.model.deployment_rule_options_monitor_ids import DeploymentRuleOptionsMonitorIds class CreateDeploymentRuleParamsDataAttributes(ModelNormal): @@ -44,7 +45,10 @@ def __init__( self_, name: str, options: Union[ - DeploymentRulesOptions, DeploymentRuleOptionsFaultyDeploymentDetection, DeploymentRuleOptionsMonitor + DeploymentRulesOptions, + DeploymentRuleOptionsFaultyDeploymentDetection, + DeploymentRuleOptionsMonitor, + DeploymentRuleOptionsMonitorIds, ], type: str, dry_run: Union[bool, UnsetType] = unset, diff --git a/src/datadog_api_client/v2/model/deployment_rule_options_monitor.py b/src/datadog_api_client/v2/model/deployment_rule_options_monitor.py index 9147de5203..c14ab006e3 100644 --- a/src/datadog_api_client/v2/model/deployment_rule_options_monitor.py +++ b/src/datadog_api_client/v2/model/deployment_rule_options_monitor.py @@ -52,7 +52,7 @@ def __init__( **kwargs, ): """ - Monitor options for deployment rules. + Monitor query options for deployment rules. :param duration: Seconds the monitor needs to stay in OK status for the rule to pass. :type duration: int, optional @@ -63,7 +63,7 @@ def __init__( :param fail_on_no_groups_found: Whether the rule should fail if no monitor groups are found for the query. :type fail_on_no_groups_found: bool, optional - :param query: Monitors that match this query are evaluated. + :param query: A query that selects the monitors to evaluate. :type query: str :param warmup: Seconds to wait after a deployment starts before evaluating the monitor's status. diff --git a/src/datadog_api_client/v2/model/deployment_rule_options_monitor_id.py b/src/datadog_api_client/v2/model/deployment_rule_options_monitor_id.py new file mode 100644 index 0000000000..763cb53a79 --- /dev/null +++ b/src/datadog_api_client/v2/model/deployment_rule_options_monitor_id.py @@ -0,0 +1,48 @@ +# 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 + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +class DeploymentRuleOptionsMonitorId(ModelNormal): + validations = { + "id": {}, + } + + @cached_property + def additional_properties_type(_): + return None + + @cached_property + def openapi_types(_): + return { + "groups": ([str],), + "id": (str,), + } + + attribute_map = { + "groups": "groups", + "id": "id", + } + + def __init__(self_, groups: List[str], id: str, **kwargs): + """ + A specific monitor and the groups to evaluate for it. + + :param groups: The exact monitor group names to evaluate. An empty array evaluates all groups. + :type groups: [str] + + :param id: The monitor's decimal ID. + :type id: str + """ + super().__init__(kwargs) + + self_.groups = groups + self_.id = id diff --git a/src/datadog_api_client/v2/model/deployment_rule_options_monitor_ids.py b/src/datadog_api_client/v2/model/deployment_rule_options_monitor_ids.py new file mode 100644 index 0000000000..071643586a --- /dev/null +++ b/src/datadog_api_client/v2/model/deployment_rule_options_monitor_ids.py @@ -0,0 +1,91 @@ +# 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_options_monitor_id import DeploymentRuleOptionsMonitorId + + +class DeploymentRuleOptionsMonitorIds(ModelNormal): + validations = { + "monitor_ids": { + "min_items": 1, + }, + "warmup": { + "inclusive_minimum": 0, + }, + } + + @cached_property + def additional_properties_type(_): + return None + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.deployment_rule_options_monitor_id import DeploymentRuleOptionsMonitorId + + return { + "duration": (int,), + "fail_on_no_data": (bool,), + "fail_on_no_groups_found": (bool,), + "monitor_ids": ([DeploymentRuleOptionsMonitorId],), + "warmup": (int,), + } + + attribute_map = { + "duration": "duration", + "fail_on_no_data": "fail_on_no_data", + "fail_on_no_groups_found": "fail_on_no_groups_found", + "monitor_ids": "monitor_ids", + "warmup": "warmup", + } + + def __init__( + self_, + monitor_ids: List[DeploymentRuleOptionsMonitorId], + duration: Union[int, UnsetType] = unset, + fail_on_no_data: Union[bool, UnsetType] = unset, + fail_on_no_groups_found: Union[bool, UnsetType] = unset, + warmup: Union[int, UnsetType] = unset, + **kwargs, + ): + """ + Specific monitor options for deployment rules. + + :param duration: Seconds the monitors need to stay in OK status for the rule to pass. + :type duration: int, optional + + :param fail_on_no_data: Whether the rule should fail if a selected monitor group is in a NO DATA state. + :type fail_on_no_data: bool, optional + + :param fail_on_no_groups_found: Whether the rule should fail if no monitor groups are found for the selected monitors. + :type fail_on_no_groups_found: bool, optional + + :param monitor_ids: A non-empty list of specific monitors to evaluate. + :type monitor_ids: [DeploymentRuleOptionsMonitorId] + + :param warmup: Seconds to wait after a deployment starts before evaluating the monitors' statuses. + :type warmup: int, optional + """ + if duration is not unset: + kwargs["duration"] = duration + if fail_on_no_data is not unset: + kwargs["fail_on_no_data"] = fail_on_no_data + if fail_on_no_groups_found is not unset: + kwargs["fail_on_no_groups_found"] = fail_on_no_groups_found + if warmup is not unset: + kwargs["warmup"] = warmup + super().__init__(kwargs) + + self_.monitor_ids = monitor_ids diff --git a/src/datadog_api_client/v2/model/deployment_rule_response_data_attributes.py b/src/datadog_api_client/v2/model/deployment_rule_response_data_attributes.py index 874e36f6bf..c3996169ab 100644 --- a/src/datadog_api_client/v2/model/deployment_rule_response_data_attributes.py +++ b/src/datadog_api_client/v2/model/deployment_rule_response_data_attributes.py @@ -29,6 +29,7 @@ DeploymentRuleOptionsFaultyDeploymentDetection, ) from datadog_api_client.v2.model.deployment_rule_options_monitor import DeploymentRuleOptionsMonitor + from datadog_api_client.v2.model.deployment_rule_options_monitor_ids import DeploymentRuleOptionsMonitorIds class DeploymentRuleResponseDataAttributes(ModelNormal): @@ -77,7 +78,10 @@ def __init__( gate_id: str, name: str, options: Union[ - DeploymentRulesOptions, DeploymentRuleOptionsFaultyDeploymentDetection, DeploymentRuleOptionsMonitor + DeploymentRulesOptions, + DeploymentRuleOptionsFaultyDeploymentDetection, + DeploymentRuleOptionsMonitor, + DeploymentRuleOptionsMonitorIds, ], type: DeploymentRuleResponseDataAttributesType, updated_at: Union[datetime, UnsetType] = unset, diff --git a/src/datadog_api_client/v2/model/deployment_rules_options.py b/src/datadog_api_client/v2/model/deployment_rules_options.py index 64f838b587..72c4cad60c 100644 --- a/src/datadog_api_client/v2/model/deployment_rules_options.py +++ b/src/datadog_api_client/v2/model/deployment_rules_options.py @@ -30,11 +30,14 @@ def __init__(self, **kwargs): :param fail_on_no_groups_found: Whether the rule should fail if no monitor groups are found for the query. :type fail_on_no_groups_found: bool, optional - :param query: Monitors that match this query are evaluated. + :param query: A query that selects the monitors to evaluate. :type query: str :param warmup: Seconds to wait after a deployment starts before evaluating the monitor's status. :type warmup: int, optional + + :param monitor_ids: A non-empty list of specific monitors to evaluate. + :type monitor_ids: [DeploymentRuleOptionsMonitorId] """ super().__init__(kwargs) @@ -51,10 +54,12 @@ def _composed_schemas(_): DeploymentRuleOptionsFaultyDeploymentDetection, ) from datadog_api_client.v2.model.deployment_rule_options_monitor import DeploymentRuleOptionsMonitor + from datadog_api_client.v2.model.deployment_rule_options_monitor_ids import DeploymentRuleOptionsMonitorIds return { "oneOf": [ DeploymentRuleOptionsFaultyDeploymentDetection, DeploymentRuleOptionsMonitor, + DeploymentRuleOptionsMonitorIds, ], } diff --git a/src/datadog_api_client/v2/model/update_deployment_rule_params_data_attributes.py b/src/datadog_api_client/v2/model/update_deployment_rule_params_data_attributes.py index cc51b544a3..e218e18666 100644 --- a/src/datadog_api_client/v2/model/update_deployment_rule_params_data_attributes.py +++ b/src/datadog_api_client/v2/model/update_deployment_rule_params_data_attributes.py @@ -17,6 +17,7 @@ DeploymentRuleOptionsFaultyDeploymentDetection, ) from datadog_api_client.v2.model.deployment_rule_options_monitor import DeploymentRuleOptionsMonitor + from datadog_api_client.v2.model.deployment_rule_options_monitor_ids import DeploymentRuleOptionsMonitorIds class UpdateDeploymentRuleParamsDataAttributes(ModelNormal): @@ -41,7 +42,10 @@ def __init__( dry_run: bool, name: str, options: Union[ - DeploymentRulesOptions, DeploymentRuleOptionsFaultyDeploymentDetection, DeploymentRuleOptionsMonitor + DeploymentRulesOptions, + DeploymentRuleOptionsFaultyDeploymentDetection, + DeploymentRuleOptionsMonitor, + DeploymentRuleOptionsMonitorIds, ], **kwargs, ): diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 5998801952..2fc69440f5 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -2633,6 +2633,8 @@ DeploymentRuleOptionsFaultyDeploymentDetection, ) from datadog_api_client.v2.model.deployment_rule_options_monitor import DeploymentRuleOptionsMonitor +from datadog_api_client.v2.model.deployment_rule_options_monitor_id import DeploymentRuleOptionsMonitorId +from datadog_api_client.v2.model.deployment_rule_options_monitor_ids import DeploymentRuleOptionsMonitorIds from datadog_api_client.v2.model.deployment_rule_response import DeploymentRuleResponse from datadog_api_client.v2.model.deployment_rule_response_data import DeploymentRuleResponseData from datadog_api_client.v2.model.deployment_rule_response_data_attributes import DeploymentRuleResponseDataAttributes @@ -13481,6 +13483,8 @@ "DeploymentRuleDataType", "DeploymentRuleOptionsFaultyDeploymentDetection", "DeploymentRuleOptionsMonitor", + "DeploymentRuleOptionsMonitorId", + "DeploymentRuleOptionsMonitorIds", "DeploymentRuleResponse", "DeploymentRuleResponseData", "DeploymentRuleResponseDataAttributes", diff --git a/tests/generated-test/test-runner-data/manifest.json b/tests/generated-test/test-runner-data/manifest.json index dcb754c9e6..a939968d4e 100644 --- a/tests/generated-test/test-runner-data/manifest.json +++ b/tests/generated-test/test-runner-data/manifest.json @@ -4893,6 +4893,27 @@ "scenario": "Create deployment rule returns \"OK\" response", "version": "v2" }, + { + "feature": "Deployment Gates", + "feature_file": "../../v2/features/deployment_gates.feature", + "file": "v2/deployment-gates/create-monitor-deployment-rule-with-monitor-ids-returns-ok-response.json", + "scenario": "Create monitor deployment rule with monitor IDs returns \"OK\" response", + "version": "v2" + }, + { + "feature": "Deployment Gates", + "feature_file": "../../v2/features/deployment_gates.feature", + "file": "v2/deployment-gates/create-monitor-deployment-rule-with-query-and-monitor-ids-returns-bad-request-response.json", + "scenario": "Create monitor deployment rule with query and monitor IDs returns \"Bad Request\" response", + "version": "v2" + }, + { + "feature": "Deployment Gates", + "feature_file": "../../v2/features/deployment_gates.feature", + "file": "v2/deployment-gates/create-monitor-deployment-rule-with-query-returns-ok-response.json", + "scenario": "Create monitor deployment rule with query returns \"OK\" response", + "version": "v2" + }, { "feature": "Deployment Gates", "feature_file": "../../v2/features/deployment_gates.feature", diff --git a/tests/generated-test/test-runner-data/v2/deployment-gates/create-monitor-deployment-rule-with-monitor-ids-returns-ok-response.json b/tests/generated-test/test-runner-data/v2/deployment-gates/create-monitor-deployment-rule-with-monitor-ids-returns-ok-response.json new file mode 100644 index 0000000000..0abb0bfbd0 --- /dev/null +++ b/tests/generated-test/test-runner-data/v2/deployment-gates/create-monitor-deployment-rule-with-monitor-ids-returns-ok-response.json @@ -0,0 +1,60 @@ +{ + "api": "DeploymentGates", + "expected_status": 200, + "feature": "Deployment Gates", + "id": "v2/Deployment Gates/Create monitor deployment rule with monitor IDs returns \"OK\" response", + "operation_id": "CreateDeploymentRule", + "request": { + "body": { + "schema": { + "format": null, + "ref": "CreateDeploymentRuleParams", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "dry_run": false, + "name": "Specific monitor deployment rule", + "options": { + "monitor_ids": [ + { + "groups": [], + "id": "{{ monitor.id }}" + } + ] + }, + "type": "monitor" + }, + "type": "deployment_rule" + } + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [ + { + "explode": null, + "in": "path", + "name": "gate_id", + "required": true, + "schema": { + "format": null, + "ref": null, + "type": "string" + }, + "source": { + "path": "deployment_gate.data.id", + "type": "fixture" + }, + "style": null + } + ], + "path": "/api/v2/deployment_gates/{gate_id}/rules" + }, + "scenario": "Create monitor deployment rule with monitor IDs returns \"OK\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/tests/generated-test/test-runner-data/v2/deployment-gates/create-monitor-deployment-rule-with-query-and-monitor-ids-returns-bad-request-response.json b/tests/generated-test/test-runner-data/v2/deployment-gates/create-monitor-deployment-rule-with-query-and-monitor-ids-returns-bad-request-response.json new file mode 100644 index 0000000000..eba55de59c --- /dev/null +++ b/tests/generated-test/test-runner-data/v2/deployment-gates/create-monitor-deployment-rule-with-query-and-monitor-ids-returns-bad-request-response.json @@ -0,0 +1,61 @@ +{ + "api": "DeploymentGates", + "expected_status": 400, + "feature": "Deployment Gates", + "id": "v2/Deployment Gates/Create monitor deployment rule with query and monitor IDs returns \"Bad Request\" response", + "operation_id": "CreateDeploymentRule", + "request": { + "body": { + "schema": { + "format": null, + "ref": "CreateDeploymentRuleParams", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "dry_run": false, + "name": "Ambiguous monitor deployment rule", + "options": { + "monitor_ids": [ + { + "groups": [], + "id": "123456" + } + ], + "query": "service:transaction-backend env:production" + }, + "type": "monitor" + }, + "type": "deployment_rule" + } + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [ + { + "explode": null, + "in": "path", + "name": "gate_id", + "required": true, + "schema": { + "format": null, + "ref": null, + "type": "string" + }, + "source": { + "path": "deployment_gate.data.id", + "type": "fixture" + }, + "style": null + } + ], + "path": "/api/v2/deployment_gates/{gate_id}/rules" + }, + "scenario": "Create monitor deployment rule with query and monitor IDs returns \"Bad Request\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/tests/generated-test/test-runner-data/v2/deployment-gates/create-monitor-deployment-rule-with-query-returns-ok-response.json b/tests/generated-test/test-runner-data/v2/deployment-gates/create-monitor-deployment-rule-with-query-returns-ok-response.json new file mode 100644 index 0000000000..862fdccd07 --- /dev/null +++ b/tests/generated-test/test-runner-data/v2/deployment-gates/create-monitor-deployment-rule-with-query-returns-ok-response.json @@ -0,0 +1,55 @@ +{ + "api": "DeploymentGates", + "expected_status": 200, + "feature": "Deployment Gates", + "id": "v2/Deployment Gates/Create monitor deployment rule with query returns \"OK\" response", + "operation_id": "CreateDeploymentRule", + "request": { + "body": { + "schema": { + "format": null, + "ref": "CreateDeploymentRuleParams", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "dry_run": false, + "name": "Query monitor deployment rule", + "options": { + "query": "service:transaction-backend env:production" + }, + "type": "monitor" + }, + "type": "deployment_rule" + } + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [ + { + "explode": null, + "in": "path", + "name": "gate_id", + "required": true, + "schema": { + "format": null, + "ref": null, + "type": "string" + }, + "source": { + "path": "deployment_gate.data.id", + "type": "fixture" + }, + "style": null + } + ], + "path": "/api/v2/deployment_gates/{gate_id}/rules" + }, + "scenario": "Create monitor deployment rule with query returns \"OK\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/tests/generated-test/test-server-data/v2/deployment-gates.json b/tests/generated-test/test-server-data/v2/deployment-gates.json index 877ef4c029..3d2525996a 100644 --- a/tests/generated-test/test-server-data/v2/deployment-gates.json +++ b/tests/generated-test/test-server-data/v2/deployment-gates.json @@ -460,6 +460,426 @@ "scenario": "Create deployment rule returns \"OK\" response", "version": "v2" }, + { + "feature": "Deployment Gates", + "frozen_at": "2026-09-09T08:52:04.617Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "dry_run": false, + "env": "production", + "identifier": "my-gate-testcreatemonitordeploymentrulewithmonitoridsreturnsokresponse1788943924", + "service": "my-service" + }, + "type": "deployment_gate" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/deployment_gates", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"f0a2f7a7-3edb-4c32-8b6f-2b294e050070\",\"type\":\"deployment_gate\",\"attributes\":{\"created_at\":\"2026-09-09T08:52:05.675749Z\",\"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-testcreatemonitordeploymentrulewithmonitoridsreturnsokresponse1788943924\",\"service\":\"my-service\",\"updated_at\":\"2026-09-09T08:52:05.675749Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "OK", + "status": 200 + } + }, + { + "request": { + "body": { + "type": "json", + "value": { + "message": "some message Notify: @hipchat-channel", + "name": "Test-Create_monitor_deployment_rule_with_monitor_IDs_returns_OK_response-1788943924", + "options": { + "enable_logs_sample": true, + "escalation_message": "the situation has escalated", + "evaluation_delay": 700, + "include_tags": true, + "locked": false, + "new_host_delay": 600, + "no_data_timeframe": null, + "notification_preset_name": "hide_handles", + "notify_audit": false, + "notify_no_data": false, + "on_missing_data": "show_and_notify_no_data", + "renotify_interval": 60, + "require_full_window": true, + "thresholds": { + "critical": 2, + "warning": 1 + }, + "timeout_h": 24 + }, + "priority": 3, + "query": "logs(\"service:foo AND type:error\").index(\"main\").rollup(\"count\").by(\"source\").last(\"5m\") > 2", + "tags": [ + "test:testcreatemonitordeploymentrulewithmonitoridsreturnsokresponse1788943924", + "env:ci" + ], + "type": "log alert" + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v1/monitor", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"id\":320387601,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Create_monitor_deployment_rule_with_monitor_IDs_returns_OK_response-1788943924\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testcreatemonitordeploymentrulewithmonitoridsreturnsokresponse1788943924\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"groupby_simple_monitor\":false,\"silenced\":{}},\"multi\":true,\"created_at\":1788943926000,\"created\":\"2026-09-09T08:52:06.017418+00:00\",\"modified\":\"2026-09-09T08:52:06.017418+00:00\",\"deleted\":null,\"priority\":3,\"restricted_roles\":null,\"restriction_policy\":null,\"draft_status\":\"published\",\"assets\":[],\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"id\":2320499}}\n" + }, + "headers": { + "content-type": "application/json" + }, + "reason": "OK", + "status": 200 + } + }, + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "dry_run": false, + "name": "Specific monitor deployment rule", + "options": { + "monitor_ids": [ + { + "groups": [], + "id": "320387601" + } + ] + }, + "type": "monitor" + }, + "type": "deployment_rule" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/deployment_gates/f0a2f7a7-3edb-4c32-8b6f-2b294e050070/rules", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"a7022950-2803-4275-a3a4-d2b611a38901\",\"type\":\"deployment_rule\",\"attributes\":{\"created_at\":\"2026-09-09T08:52:06.381853Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"gate_id\":\"f0a2f7a7-3edb-4c32-8b6f-2b294e050070\",\"name\":\"Specific monitor deployment rule\",\"options\":{\"monitor_ids\":[{\"id\":\"320387601\",\"groups\":[]}]},\"type\":\"monitor\",\"updated_at\":\"2026-09-09T08:52:06.381853Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "OK", + "status": 200 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/deployment_gates/f0a2f7a7-3edb-4c32-8b6f-2b294e050070/rules/a7022950-2803-4275-a3a4-d2b611a38901", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v1/monitor/320387601", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"deleted_monitor_id\":320387601}\n" + }, + "headers": { + "content-type": "application/json" + }, + "reason": "OK", + "status": 200 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/deployment_gates/f0a2f7a7-3edb-4c32-8b6f-2b294e050070", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + } + ], + "scenario": "Create monitor deployment rule with monitor IDs returns \"OK\" response", + "version": "v2" + }, + { + "feature": "Deployment Gates", + "frozen_at": "2026-09-09T08:52:07.322Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "dry_run": false, + "env": "production", + "identifier": "my-gate-testcreatemonitordeploymentrulewithqueryandmonitoridsreturnsbadrequestresponse1788943927", + "service": "my-service" + }, + "type": "deployment_gate" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/deployment_gates", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"a5f38bf8-bd06-4dac-82a8-8b80bdafb001\",\"type\":\"deployment_gate\",\"attributes\":{\"created_at\":\"2026-09-09T08:52:07.633476Z\",\"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-testcreatemonitordeploymentrulewithqueryandmonitoridsreturnsbadrequestresponse1788943927\",\"service\":\"my-service\",\"updated_at\":\"2026-09-09T08:52:07.633476Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "OK", + "status": 200 + } + }, + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "dry_run": false, + "name": "Ambiguous monitor deployment rule", + "options": { + "monitor_ids": [ + { + "groups": [], + "id": "123456" + } + ], + "query": "service:transaction-backend env:production" + }, + "type": "monitor" + }, + "type": "deployment_rule" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/deployment_gates/a5f38bf8-bd06-4dac-82a8-8b80bdafb001/rules", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"errors\":[{\"status\":\"400\",\"title\":\"Bad Request\",\"detail\":\"options.query and options.monitor_ids are mutually exclusive\"}]}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Bad Request", + "status": 400 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/deployment_gates/a5f38bf8-bd06-4dac-82a8-8b80bdafb001", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + } + ], + "scenario": "Create monitor deployment rule with query and monitor IDs returns \"Bad Request\" response", + "version": "v2" + }, + { + "feature": "Deployment Gates", + "frozen_at": "2026-09-09T08:52:08.166Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "dry_run": false, + "env": "production", + "identifier": "my-gate-testcreatemonitordeploymentrulewithqueryreturnsokresponse1788943928", + "service": "my-service" + }, + "type": "deployment_gate" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/deployment_gates", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"a4d3587f-f61d-42bd-869a-2318a4f377e7\",\"type\":\"deployment_gate\",\"attributes\":{\"created_at\":\"2026-09-09T08:52:08.338192Z\",\"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-testcreatemonitordeploymentrulewithqueryreturnsokresponse1788943928\",\"service\":\"my-service\",\"updated_at\":\"2026-09-09T08:52:08.338192Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "OK", + "status": 200 + } + }, + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "dry_run": false, + "name": "Query monitor deployment rule", + "options": { + "query": "service:transaction-backend env:production" + }, + "type": "monitor" + }, + "type": "deployment_rule" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/deployment_gates/a4d3587f-f61d-42bd-869a-2318a4f377e7/rules", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"5db11563-3823-41bf-883b-791028de5b7d\",\"type\":\"deployment_rule\",\"attributes\":{\"created_at\":\"2026-09-09T08:52:08.601315Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"gate_id\":\"a4d3587f-f61d-42bd-869a-2318a4f377e7\",\"name\":\"Query monitor deployment rule\",\"options\":{\"query\":\"service:transaction-backend env:production\"},\"type\":\"monitor\",\"updated_at\":\"2026-09-09T08:52:08.601315Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "OK", + "status": 200 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/deployment_gates/a4d3587f-f61d-42bd-869a-2318a4f377e7/rules/5db11563-3823-41bf-883b-791028de5b7d", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/deployment_gates/a4d3587f-f61d-42bd-869a-2318a4f377e7", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + } + ], + "scenario": "Create monitor deployment rule with query returns \"OK\" response", + "version": "v2" + }, { "feature": "Deployment Gates", "frozen_at": "2025-10-28T14:03:29.170Z", diff --git a/tests/v2/features/deployment_gates.feature b/tests/v2/features/deployment_gates.feature index 1825f8af3a..b4ccba22c5 100644 --- a/tests/v2/features/deployment_gates.feature +++ b/tests/v2/features/deployment_gates.feature @@ -63,6 +63,37 @@ Feature: Deployment Gates When the request is sent Then the response status is 200 OK + @team:DataDog/ci-app-backend + Scenario: Create monitor deployment rule with monitor IDs returns "OK" response + Given there is a valid "deployment_gate" in the system + And there is a valid "monitor" in the system + And operation "CreateDeploymentRule" enabled + And new "CreateDeploymentRule" request + And request contains "gate_id" parameter from "deployment_gate.data.id" + And body with value {"data": {"attributes": {"dry_run": false, "name": "Specific monitor deployment rule", "options": {"monitor_ids": [{"id": "{{ monitor.id }}", "groups": []}]}, "type": "monitor"}, "type": "deployment_rule"}} + When the request is sent + Then the response status is 200 OK + + @team:DataDog/ci-app-backend + Scenario: Create monitor deployment rule with query and monitor IDs returns "Bad Request" response + Given there is a valid "deployment_gate" in the system + And operation "CreateDeploymentRule" enabled + And new "CreateDeploymentRule" request + And request contains "gate_id" parameter from "deployment_gate.data.id" + And body with value {"data": {"attributes": {"dry_run": false, "name": "Ambiguous monitor deployment rule", "options": {"query": "service:transaction-backend env:production", "monitor_ids": [{"id": "123456", "groups": []}]}, "type": "monitor"}, "type": "deployment_rule"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/ci-app-backend + Scenario: Create monitor deployment rule with query returns "OK" response + Given there is a valid "deployment_gate" in the system + And operation "CreateDeploymentRule" enabled + And new "CreateDeploymentRule" request + And request contains "gate_id" parameter from "deployment_gate.data.id" + And body with value {"data": {"attributes": {"dry_run": false, "name": "Query monitor deployment rule", "options": {"query": "service:transaction-backend env:production"}, "type": "monitor"}, "type": "deployment_rule"}} + When the request is sent + Then the response status is 200 OK + @team:DataDog/ci-app-backend Scenario: Delete deployment gate returns "Bad Request" response Given operation "DeleteDeploymentGate" enabled