From 40b62e0dcffb52aef64ce006a586cccfbd965261 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Wed, 9 Sep 2026 09:24:36 +0000 Subject: [PATCH] Regenerate client from commit 900182b of spec repo --- .generator/schemas/v2/openapi.yaml | 65 ++- .../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 ++++++++++++++++++ features/v2/deployment_gates.feature | 31 ++ services/deployment_gates/src/v2/index.ts | 2 + .../v2/models/DeploymentRuleOptionsMonitor.ts | 4 +- .../models/DeploymentRuleOptionsMonitorId.ts | 44 ++ .../models/DeploymentRuleOptionsMonitorIds.ts | 71 +++ .../src/v2/models/DeploymentRulesOptions.ts | 2 + .../src/v2/models/TypingInfo.ts | 5 + 13 files changed, 837 insertions(+), 4 deletions(-) create mode 100644 features/generated-test/test-runner-data/v2/deployment-gates/create-monitor-deployment-rule-with-monitor-ids-returns-ok-response.json create mode 100644 features/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 features/generated-test/test-runner-data/v2/deployment-gates/create-monitor-deployment-rule-with-query-returns-ok-response.json create mode 100644 services/deployment_gates/src/v2/models/DeploymentRuleOptionsMonitorId.ts create mode 100644 services/deployment_gates/src/v2/models/DeploymentRuleOptionsMonitorIds.ts diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 3fa7f36527d2..51c8bab2abe1 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -34605,7 +34605,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. @@ -34623,7 +34623,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: @@ -34636,6 +34636,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: @@ -34750,6 +34810,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/features/generated-test/test-runner-data/manifest.json b/features/generated-test/test-runner-data/manifest.json index 8de5b5161fa9..67d330911bcf 100644 --- a/features/generated-test/test-runner-data/manifest.json +++ b/features/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/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/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/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/deployment_gates.feature", diff --git a/features/generated-test/test-runner-data/v2/deployment-gates/create-monitor-deployment-rule-with-monitor-ids-returns-ok-response.json b/features/generated-test/test-runner-data/v2/deployment-gates/create-monitor-deployment-rule-with-monitor-ids-returns-ok-response.json new file mode 100644 index 000000000000..0abb0bfbd0b1 --- /dev/null +++ b/features/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/features/generated-test/test-runner-data/v2/deployment-gates/create-monitor-deployment-rule-with-query-and-monitor-ids-returns-bad-request-response.json b/features/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 000000000000..eba55de59cb6 --- /dev/null +++ b/features/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/features/generated-test/test-runner-data/v2/deployment-gates/create-monitor-deployment-rule-with-query-returns-ok-response.json b/features/generated-test/test-runner-data/v2/deployment-gates/create-monitor-deployment-rule-with-query-returns-ok-response.json new file mode 100644 index 000000000000..862fdccd070c --- /dev/null +++ b/features/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/features/generated-test/test-server-data/v2/deployment-gates.json b/features/generated-test/test-server-data/v2/deployment-gates.json index 877ef4c02938..3d2525996a4a 100644 --- a/features/generated-test/test-server-data/v2/deployment-gates.json +++ b/features/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/features/v2/deployment_gates.feature b/features/v2/deployment_gates.feature index 1825f8af3a92..b4ccba22c50d 100644 --- a/features/v2/deployment_gates.feature +++ b/features/v2/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 diff --git a/services/deployment_gates/src/v2/index.ts b/services/deployment_gates/src/v2/index.ts index 965b39eb6f9d..b049452c6976 100644 --- a/services/deployment_gates/src/v2/index.ts +++ b/services/deployment_gates/src/v2/index.ts @@ -56,6 +56,8 @@ export { DeploymentGatesRuleResponse } from "./models/DeploymentGatesRuleRespons export { DeploymentRuleDataType } from "./models/DeploymentRuleDataType"; export { DeploymentRuleOptionsFaultyDeploymentDetection } from "./models/DeploymentRuleOptionsFaultyDeploymentDetection"; export { DeploymentRuleOptionsMonitor } from "./models/DeploymentRuleOptionsMonitor"; +export { DeploymentRuleOptionsMonitorId } from "./models/DeploymentRuleOptionsMonitorId"; +export { DeploymentRuleOptionsMonitorIds } from "./models/DeploymentRuleOptionsMonitorIds"; export { DeploymentRuleResponse } from "./models/DeploymentRuleResponse"; export { DeploymentRuleResponseData } from "./models/DeploymentRuleResponseData"; export { DeploymentRuleResponseDataAttributes } from "./models/DeploymentRuleResponseDataAttributes"; diff --git a/services/deployment_gates/src/v2/models/DeploymentRuleOptionsMonitor.ts b/services/deployment_gates/src/v2/models/DeploymentRuleOptionsMonitor.ts index 6ff3b011a8b2..603942897e4e 100644 --- a/services/deployment_gates/src/v2/models/DeploymentRuleOptionsMonitor.ts +++ b/services/deployment_gates/src/v2/models/DeploymentRuleOptionsMonitor.ts @@ -1,7 +1,7 @@ import { AttributeTypeMap } from "@datadog/datadog-api-client"; /** - * Monitor options for deployment rules. + * Monitor query options for deployment rules. */ export class DeploymentRuleOptionsMonitor { /** @@ -17,7 +17,7 @@ export class DeploymentRuleOptionsMonitor { */ "failOnNoGroupsFound"?: boolean; /** - * Monitors that match this query are evaluated. + * A query that selects the monitors to evaluate. */ "query": string; /** diff --git a/services/deployment_gates/src/v2/models/DeploymentRuleOptionsMonitorId.ts b/services/deployment_gates/src/v2/models/DeploymentRuleOptionsMonitorId.ts new file mode 100644 index 000000000000..6b4055078c39 --- /dev/null +++ b/services/deployment_gates/src/v2/models/DeploymentRuleOptionsMonitorId.ts @@ -0,0 +1,44 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +/** + * A specific monitor and the groups to evaluate for it. + */ +export class DeploymentRuleOptionsMonitorId { + /** + * The exact monitor group names to evaluate. An empty array evaluates all groups. + */ + "groups": Array; + /** + * The monitor's decimal ID. + */ + "id": string; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + groups: { + baseName: "groups", + type: "Array", + required: true, + }, + id: { + baseName: "id", + type: "string", + required: true, + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return DeploymentRuleOptionsMonitorId.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/deployment_gates/src/v2/models/DeploymentRuleOptionsMonitorIds.ts b/services/deployment_gates/src/v2/models/DeploymentRuleOptionsMonitorIds.ts new file mode 100644 index 000000000000..afa42e8d7330 --- /dev/null +++ b/services/deployment_gates/src/v2/models/DeploymentRuleOptionsMonitorIds.ts @@ -0,0 +1,71 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { DeploymentRuleOptionsMonitorId } from "./DeploymentRuleOptionsMonitorId"; + +/** + * Specific monitor options for deployment rules. + */ +export class DeploymentRuleOptionsMonitorIds { + /** + * Seconds the monitors need to stay in OK status for the rule to pass. + */ + "duration"?: number; + /** + * Whether the rule should fail if a selected monitor group is in a NO DATA state. + */ + "failOnNoData"?: boolean; + /** + * Whether the rule should fail if no monitor groups are found for the selected monitors. + */ + "failOnNoGroupsFound"?: boolean; + /** + * A non-empty list of specific monitors to evaluate. + */ + "monitorIds": Array; + /** + * Seconds to wait after a deployment starts before evaluating the monitors' statuses. + */ + "warmup"?: number; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + duration: { + baseName: "duration", + type: "number", + format: "int64", + }, + failOnNoData: { + baseName: "fail_on_no_data", + type: "boolean", + }, + failOnNoGroupsFound: { + baseName: "fail_on_no_groups_found", + type: "boolean", + }, + monitorIds: { + baseName: "monitor_ids", + type: "Array", + required: true, + }, + warmup: { + baseName: "warmup", + type: "number", + format: "int64", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return DeploymentRuleOptionsMonitorIds.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/deployment_gates/src/v2/models/DeploymentRulesOptions.ts b/services/deployment_gates/src/v2/models/DeploymentRulesOptions.ts index 2b0f1af12eb2..386b1736554f 100644 --- a/services/deployment_gates/src/v2/models/DeploymentRulesOptions.ts +++ b/services/deployment_gates/src/v2/models/DeploymentRulesOptions.ts @@ -2,6 +2,7 @@ import { UnparsedObject } from "@datadog/datadog-api-client"; import { DeploymentRuleOptionsFaultyDeploymentDetection } from "./DeploymentRuleOptionsFaultyDeploymentDetection"; import { DeploymentRuleOptionsMonitor } from "./DeploymentRuleOptionsMonitor"; +import { DeploymentRuleOptionsMonitorIds } from "./DeploymentRuleOptionsMonitorIds"; /** * Options for deployment rule response representing either faulty deployment detection or monitor options. @@ -9,4 +10,5 @@ import { DeploymentRuleOptionsMonitor } from "./DeploymentRuleOptionsMonitor"; export type DeploymentRulesOptions = | DeploymentRuleOptionsFaultyDeploymentDetection | DeploymentRuleOptionsMonitor + | DeploymentRuleOptionsMonitorIds | UnparsedObject; diff --git a/services/deployment_gates/src/v2/models/TypingInfo.ts b/services/deployment_gates/src/v2/models/TypingInfo.ts index 0b91d7e3f832..446efe56bf6f 100644 --- a/services/deployment_gates/src/v2/models/TypingInfo.ts +++ b/services/deployment_gates/src/v2/models/TypingInfo.ts @@ -33,6 +33,8 @@ import { DeploymentGatesMonitorRuleOptions } from "./DeploymentGatesMonitorRuleO import { DeploymentGatesRuleResponse } from "./DeploymentGatesRuleResponse"; import { DeploymentRuleOptionsFaultyDeploymentDetection } from "./DeploymentRuleOptionsFaultyDeploymentDetection"; import { DeploymentRuleOptionsMonitor } from "./DeploymentRuleOptionsMonitor"; +import { DeploymentRuleOptionsMonitorId } from "./DeploymentRuleOptionsMonitorId"; +import { DeploymentRuleOptionsMonitorIds } from "./DeploymentRuleOptionsMonitorIds"; import { DeploymentRuleResponse } from "./DeploymentRuleResponse"; import { DeploymentRuleResponseData } from "./DeploymentRuleResponseData"; import { DeploymentRuleResponseDataAttributes } from "./DeploymentRuleResponseDataAttributes"; @@ -86,6 +88,7 @@ export const TypingInfo: ModelTypingInfo = { DeploymentRulesOptions: [ "DeploymentRuleOptionsFaultyDeploymentDetection", "DeploymentRuleOptionsMonitor", + "DeploymentRuleOptionsMonitorIds", ], }, typeMap: { @@ -134,6 +137,8 @@ export const TypingInfo: ModelTypingInfo = { DeploymentRuleOptionsFaultyDeploymentDetection: DeploymentRuleOptionsFaultyDeploymentDetection, DeploymentRuleOptionsMonitor: DeploymentRuleOptionsMonitor, + DeploymentRuleOptionsMonitorId: DeploymentRuleOptionsMonitorId, + DeploymentRuleOptionsMonitorIds: DeploymentRuleOptionsMonitorIds, DeploymentRuleResponse: DeploymentRuleResponse, DeploymentRuleResponseData: DeploymentRuleResponseData, DeploymentRuleResponseDataAttributes: DeploymentRuleResponseDataAttributes,