From 8303c05a11d8e5878b1d0b35130c28ecf4b59e32 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Thu, 29 Oct 2026 15:36:52 +0000 Subject: [PATCH] Regenerate client from commit 338eeda of spec repo --- .generator/schemas/v2/openapi.yaml | 51 ++- .../CreateExecutionPolicy_1868371302.rb | 25 ++ .../CreateExecutionPolicy_3240435177.rb | 44 ++ .../ListExecutionPolicies_4120778561.rb | 14 + .../UpdateExecutionPolicy_2851872075.rb | 48 ++ features/v2/execution_policy.feature | 65 ++- generated-test/test-runner-data/manifest.json | 42 ++ ...ution-policy-returns-created-response.json | 40 ++ ...electors-returns-bad-request-response.json | 49 ++ ...ed-scope-returns-bad-request-response.json | 51 +++ ...-and-targets-returns-created-response.json | 59 +++ ...filtered-by-slack-returns-ok-response.json | 42 ++ ...scope-and-targets-returns-ok-response.json | 77 ++++ .../test-server-data/v2/execution-policy.json | 420 ++++++++++++++++++ lib/datadog_api_client/inflector.rb | 2 + .../v2/models/execution_policy_attributes.rb | 6 +- .../v2/models/execution_policy_integration.rb | 1 + .../v2/models/execution_policy_scope.rb | 22 +- .../v2/models/execution_policy_slack_scope.rb | 129 ++++++ .../execution_policy_slack_scope_rule.rb | 134 ++++++ .../v2/models/execution_policy_target.rb | 4 +- .../execution_policy_write_attributes.rb | 6 +- 22 files changed, 1305 insertions(+), 26 deletions(-) create mode 100644 examples/v2/execution-policy/CreateExecutionPolicy_1868371302.rb create mode 100644 examples/v2/execution-policy/CreateExecutionPolicy_3240435177.rb create mode 100644 examples/v2/execution-policy/ListExecutionPolicies_4120778561.rb create mode 100644 examples/v2/execution-policy/UpdateExecutionPolicy_2851872075.rb create mode 100644 generated-test/test-runner-data/v2/execution-policy/create-a-slack-execution-policy-returns-created-response.json create mode 100644 generated-test/test-runner-data/v2/execution-policy/create-a-slack-execution-policy-with-empty-channel-selectors-returns-bad-request-response.json create mode 100644 generated-test/test-runner-data/v2/execution-policy/create-a-slack-execution-policy-with-mismatched-scope-returns-bad-request-response.json create mode 100644 generated-test/test-runner-data/v2/execution-policy/create-a-slack-execution-policy-with-scope-and-targets-returns-created-response.json create mode 100644 generated-test/test-runner-data/v2/execution-policy/list-execution-policies-filtered-by-slack-returns-ok-response.json create mode 100644 generated-test/test-runner-data/v2/execution-policy/update-an-execution-policy-to-slack-with-scope-and-targets-returns-ok-response.json create mode 100644 lib/datadog_api_client/v2/models/execution_policy_slack_scope.rb create mode 100644 lib/datadog_api_client/v2/models/execution_policy_slack_scope_rule.rb diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index f5dd9090d398..dc2fd7efeced 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -42088,12 +42088,14 @@ components: - INTEGRATION_KUBERNETES - INTEGRATION_SCRIPT - INTEGRATION_REMOTE_ACTION + - INTEGRATION_SLACK example: INTEGRATION_SCRIPT type: string x-enum-varnames: - INTEGRATION_KUBERNETES - INTEGRATION_SCRIPT - INTEGRATION_REMOTE_ACTION + - INTEGRATION_SLACK ExecutionPolicyKubernetesScope: description: Restricts the policy to specific Kubernetes namespaces. properties: @@ -42216,9 +42218,9 @@ components: type: object ExecutionPolicyScope: description: |- - Restricts where the policy applies. At most one of `kubernetes`, `scripts`, - or `remote_action_rshell` can be set. An empty object means the policy has - no scope restriction. + Restricts where the policy applies. At most one scope type can be set, + and it must match the action pattern's integration. An empty object means + the policy has no scope restriction. properties: kubernetes: $ref: "#/components/schemas/ExecutionPolicyKubernetesScope" @@ -42226,6 +42228,8 @@ components: $ref: "#/components/schemas/ExecutionPolicyRemoteActionRshellScope" scripts: $ref: "#/components/schemas/ExecutionPolicyScriptScope" + slack: + $ref: "#/components/schemas/ExecutionPolicySlackScope" type: object ExecutionPolicyScriptScope: description: Restricts the policy to specific scripts. @@ -42251,11 +42255,43 @@ components: required: - target_script_names type: object + ExecutionPolicySlackScope: + description: Restricts the policy to specific Slack private channel names. + properties: + rules: + description: The Slack scope rules. + items: + $ref: "#/components/schemas/ExecutionPolicySlackScopeRule" + minItems: 1 + type: array + required: + - rules + type: object + ExecutionPolicySlackScopeRule: + description: A rule restricting a Slack scope to specific private channel names. + properties: + channel_name_selectors: + description: |- + The private channel name selectors this rule applies to. Selectors are lowercase private channel names + without the leading `#`, and can contain `*` wildcards. Use `*` alone to match any private channel name. + example: + - "incident-*" + items: + maxLength: 80 + minLength: 1 + type: string + maxItems: 100 + minItems: 1 + type: array + uniqueItems: true + required: + - channel_name_selectors + type: object ExecutionPolicyTarget: - description: A target this policy is scoped to, expressed as a set of Agent tags. + description: A target this policy is scoped to, expressed as a set of tags. properties: agent_tags: - description: The Agent tags identifying the target. + description: The tags identifying the target. example: - "env:prod" items: @@ -255987,9 +256023,8 @@ tags: name: Events - description: |- Execution policies control which actions Datadog Action Platform is allowed to run - against your infrastructure, and where. Each policy pairs an effect (allow or deny) - with a pattern of actions, and can scope that decision to specific Kubernetes - namespaces, scripts, or remote shell paths. + and where. Each policy pairs an effect (allow or deny) with a pattern of actions, + and can scope that decision to specific resources. name: Execution Policy - description: Create and manage experiments, metrics, subject types, SQL models, and protocols. name: Experiments diff --git a/examples/v2/execution-policy/CreateExecutionPolicy_1868371302.rb b/examples/v2/execution-policy/CreateExecutionPolicy_1868371302.rb new file mode 100644 index 000000000000..cf7f3fb18439 --- /dev/null +++ b/examples/v2/execution-policy/CreateExecutionPolicy_1868371302.rb @@ -0,0 +1,25 @@ +# Create a Slack execution policy returns "Created" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.access_token = ENV["DD_BEARER_TOKEN"] + config.unstable_operations["v2.create_execution_policy".to_sym] = true +end +api_instance = DatadogAPIClient::V2::ExecutionPolicyAPI.new + +body = DatadogAPIClient::V2::ExecutionPolicyCreateRequest.new({ + data: DatadogAPIClient::V2::ExecutionPolicyCreateRequestData.new({ + type: DatadogAPIClient::V2::ExecutionPolicyType::EXECUTION_POLICY, + attributes: DatadogAPIClient::V2::ExecutionPolicyWriteAttributes.new({ + name: "Cassette Execution Policy exampleexecutionpolicy", + effect: DatadogAPIClient::V2::ExecutionPolicyEffect::ALLOW, + action_pattern: DatadogAPIClient::V2::ExecutionPolicyActionPattern.new({ + integration: DatadogAPIClient::V2::ExecutionPolicyIntegration::INTEGRATION_SLACK, + action_fqns: [ + "com.datadoghq.slack.*", + ], + }), + }), + }), +}) +p api_instance.create_execution_policy(body) diff --git a/examples/v2/execution-policy/CreateExecutionPolicy_3240435177.rb b/examples/v2/execution-policy/CreateExecutionPolicy_3240435177.rb new file mode 100644 index 000000000000..84ab7aee48a5 --- /dev/null +++ b/examples/v2/execution-policy/CreateExecutionPolicy_3240435177.rb @@ -0,0 +1,44 @@ +# Create a Slack execution policy with scope and targets returns "Created" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.access_token = ENV["DD_BEARER_TOKEN"] + config.unstable_operations["v2.create_execution_policy".to_sym] = true +end +api_instance = DatadogAPIClient::V2::ExecutionPolicyAPI.new + +body = DatadogAPIClient::V2::ExecutionPolicyCreateRequest.new({ + data: DatadogAPIClient::V2::ExecutionPolicyCreateRequestData.new({ + type: DatadogAPIClient::V2::ExecutionPolicyType::EXECUTION_POLICY, + attributes: DatadogAPIClient::V2::ExecutionPolicyWriteAttributes.new({ + name: "Cassette Execution Policy exampleexecutionpolicy", + effect: DatadogAPIClient::V2::ExecutionPolicyEffect::ALLOW, + action_pattern: DatadogAPIClient::V2::ExecutionPolicyActionPattern.new({ + integration: DatadogAPIClient::V2::ExecutionPolicyIntegration::INTEGRATION_SLACK, + action_fqns: [ + "com.datadoghq.slack.*", + ], + }), + scope: DatadogAPIClient::V2::ExecutionPolicyScope.new({ + slack: DatadogAPIClient::V2::ExecutionPolicySlackScope.new({ + rules: [ + DatadogAPIClient::V2::ExecutionPolicySlackScopeRule.new({ + channel_name_selectors: [ + "incident-*", + ], + }), + ], + }), + }), + targets: [ + DatadogAPIClient::V2::ExecutionPolicyTarget.new({ + name: "Incident workspace", + agent_tags: [ + "slack_workspace_id:T01234567", + ], + }), + ], + }), + }), +}) +p api_instance.create_execution_policy(body) diff --git a/examples/v2/execution-policy/ListExecutionPolicies_4120778561.rb b/examples/v2/execution-policy/ListExecutionPolicies_4120778561.rb new file mode 100644 index 000000000000..d621a2b2927e --- /dev/null +++ b/examples/v2/execution-policy/ListExecutionPolicies_4120778561.rb @@ -0,0 +1,14 @@ +# List execution policies filtered by Slack returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.access_token = ENV["DD_BEARER_TOKEN"] + config.unstable_operations["v2.list_execution_policies".to_sym] = true +end +api_instance = DatadogAPIClient::V2::ExecutionPolicyAPI.new +opts = { + filter_integration: [ + ExecutionPolicyIntegration::INTEGRATION_SLACK, + ], +} +p api_instance.list_execution_policies(opts) diff --git a/examples/v2/execution-policy/UpdateExecutionPolicy_2851872075.rb b/examples/v2/execution-policy/UpdateExecutionPolicy_2851872075.rb new file mode 100644 index 000000000000..bb5e8a411cc2 --- /dev/null +++ b/examples/v2/execution-policy/UpdateExecutionPolicy_2851872075.rb @@ -0,0 +1,48 @@ +# Update an execution policy to Slack with scope and targets returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.access_token = ENV["DD_BEARER_TOKEN"] + config.unstable_operations["v2.update_execution_policy".to_sym] = true +end +api_instance = DatadogAPIClient::V2::ExecutionPolicyAPI.new + +# there is a valid "execution_policy" in the system +EXECUTION_POLICY_DATA_ID = ENV["EXECUTION_POLICY_DATA_ID"] + +body = DatadogAPIClient::V2::ExecutionPolicyUpdateRequest.new({ + data: DatadogAPIClient::V2::ExecutionPolicyUpdateRequestData.new({ + id: EXECUTION_POLICY_DATA_ID, + type: DatadogAPIClient::V2::ExecutionPolicyType::EXECUTION_POLICY, + attributes: DatadogAPIClient::V2::ExecutionPolicyWriteAttributes.new({ + name: "Cassette Execution Policy Updated", + effect: DatadogAPIClient::V2::ExecutionPolicyEffect::DENY, + action_pattern: DatadogAPIClient::V2::ExecutionPolicyActionPattern.new({ + integration: DatadogAPIClient::V2::ExecutionPolicyIntegration::INTEGRATION_SLACK, + action_fqns: [ + "*", + ], + }), + scope: DatadogAPIClient::V2::ExecutionPolicyScope.new({ + slack: DatadogAPIClient::V2::ExecutionPolicySlackScope.new({ + rules: [ + DatadogAPIClient::V2::ExecutionPolicySlackScopeRule.new({ + channel_name_selectors: [ + "incident-denied", + ], + }), + ], + }), + }), + targets: [ + DatadogAPIClient::V2::ExecutionPolicyTarget.new({ + name: "Incident workspace", + agent_tags: [ + "slack_workspace_id:T01234567", + ], + }), + ], + }), + }), +}) +p api_instance.update_execution_policy(EXECUTION_POLICY_DATA_ID, body) diff --git a/features/v2/execution_policy.feature b/features/v2/execution_policy.feature index 9b78c97c4047..11ae23d76340 100644 --- a/features/v2/execution_policy.feature +++ b/features/v2/execution_policy.feature @@ -1,16 +1,51 @@ @endpoint(execution-policy) @endpoint(execution-policy-v2) Feature: Execution Policy Execution policies control which actions Datadog Action Platform is - allowed to run against your infrastructure, and where. Each policy pairs - an effect (allow or deny) with a pattern of actions, and can scope that - decision to specific Kubernetes namespaces, scripts, or remote shell - paths. + allowed to run and where. Each policy pairs an effect (allow or deny) with + a pattern of actions, and can scope that decision to specific resources. Background: Given a valid "apiKeyAuth" key in the system And a valid "appKeyAuth" key in the system And an instance of "ExecutionPolicy" API + @team:ddoghq/action-platform + Scenario: Create a Slack execution policy returns "Created" response + Given operation "CreateExecutionPolicy" enabled + And new "CreateExecutionPolicy" request + And body with value {"data": {"type": "execution_policy", "attributes": {"name": "Cassette Execution Policy {{ unique_lower_alnum }}", "effect": "allow", "action_pattern": {"integration": "INTEGRATION_SLACK", "action_fqns": ["com.datadoghq.slack.*"]}}}} + When the request is sent + Then the response status is 201 Created + And the response "data.attributes.action_pattern.integration" is equal to "INTEGRATION_SLACK" + And the response "data.attributes.targets" is equal to [] + + @skip-python @skip-ruby @team:ddoghq/action-platform + Scenario: Create a Slack execution policy with empty channel selectors returns "Bad Request" response + Given operation "CreateExecutionPolicy" enabled + And new "CreateExecutionPolicy" request + And body with value {"data": {"type": "execution_policy", "attributes": {"name": "Cassette Execution Policy {{ unique_lower_alnum }}", "effect": "allow", "action_pattern": {"integration": "INTEGRATION_SLACK", "action_fqns": ["com.datadoghq.slack.*"]}, "scope": {"slack": {"rules": [{"channel_name_selectors": []}]}}}}} + When the request is sent + Then the response status is 400 Bad Request + + @team:ddoghq/action-platform + Scenario: Create a Slack execution policy with mismatched scope returns "Bad Request" response + Given operation "CreateExecutionPolicy" enabled + And new "CreateExecutionPolicy" request + And body with value {"data": {"type": "execution_policy", "attributes": {"name": "Cassette Execution Policy {{ unique_lower_alnum }}", "effect": "allow", "action_pattern": {"integration": "INTEGRATION_SLACK", "action_fqns": ["com.datadoghq.slack.*"]}, "scope": {"scripts": {"rules": [{"target_script_names": ["restart_service.sh"]}]}}}}} + When the request is sent + Then the response status is 400 Bad Request + + @team:ddoghq/action-platform + Scenario: Create a Slack execution policy with scope and targets returns "Created" response + Given operation "CreateExecutionPolicy" enabled + And new "CreateExecutionPolicy" request + And body with value {"data": {"type": "execution_policy", "attributes": {"name": "Cassette Execution Policy {{ unique_lower_alnum }}", "effect": "allow", "action_pattern": {"integration": "INTEGRATION_SLACK", "action_fqns": ["com.datadoghq.slack.*"]}, "scope": {"slack": {"rules": [{"channel_name_selectors": ["incident-*"]}]}}, "targets": [{"name": "Incident workspace", "agent_tags": ["slack_workspace_id:T01234567"]}]}}} + When the request is sent + Then the response status is 201 Created + And the response "data.attributes.action_pattern.integration" is equal to "INTEGRATION_SLACK" + And the response "data.attributes.scope.slack.rules" is equal to [{"channel_name_selectors": ["incident-*"]}] + And the response "data.attributes.targets" is equal to [{"name": "Incident workspace", "agent_tags": ["slack_workspace_id:T01234567"]}] + @team:ddoghq/action-platform Scenario: Create an execution policy returns "Bad Request" response Given operation "CreateExecutionPolicy" enabled @@ -69,6 +104,14 @@ Feature: Execution Policy When the request is sent Then the response status is 200 OK + @team:ddoghq/action-platform + Scenario: List execution policies filtered by Slack returns "OK" response + Given operation "ListExecutionPolicies" enabled + And new "ListExecutionPolicies" request + And request contains "filter[integration]" parameter with value ["INTEGRATION_SLACK"] + When the request is sent + Then the response status is 200 OK + @team:ddoghq/action-platform Scenario: List execution policies returns "Bad Request" response Given operation "ListExecutionPolicies" enabled @@ -129,3 +172,17 @@ Feature: Execution Policy And body with value {"data": {"id": "{{ execution_policy.data.id }}", "type": "execution_policy", "attributes": {"name": "Cassette Execution Policy Updated", "effect": "allow", "action_pattern": {"integration": "INTEGRATION_SCRIPT", "action_fqns": ["com.datadoghq.script.*"]}}}} When the request is sent Then the response status is 200 OK + + @team:ddoghq/action-platform + Scenario: Update an execution policy to Slack with scope and targets returns "OK" response + Given there is a valid "execution_policy" in the system + And operation "UpdateExecutionPolicy" enabled + And new "UpdateExecutionPolicy" request + And request contains "policy_id" parameter from "execution_policy.data.id" + And body with value {"data": {"id": "{{ execution_policy.data.id }}", "type": "execution_policy", "attributes": {"name": "Cassette Execution Policy Updated", "effect": "deny", "action_pattern": {"integration": "INTEGRATION_SLACK", "action_fqns": ["*"]}, "scope": {"slack": {"rules": [{"channel_name_selectors": ["incident-denied"]}]}}, "targets": [{"name": "Incident workspace", "agent_tags": ["slack_workspace_id:T01234567"]}]}}} + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.effect" is equal to "deny" + And the response "data.attributes.action_pattern.integration" is equal to "INTEGRATION_SLACK" + And the response "data.attributes.scope.slack.rules" is equal to [{"channel_name_selectors": ["incident-denied"]}] + And the response "data.attributes.targets" is equal to [{"name": "Incident workspace", "agent_tags": ["slack_workspace_id:T01234567"]}] diff --git a/generated-test/test-runner-data/manifest.json b/generated-test/test-runner-data/manifest.json index 2c68906d492e..23a28aaa5b4c 100644 --- a/generated-test/test-runner-data/manifest.json +++ b/generated-test/test-runner-data/manifest.json @@ -5502,6 +5502,34 @@ "scenario": "Search events returns \"OK\" response with pagination", "version": "v2" }, + { + "feature": "Execution Policy", + "feature_file": "../../features/v2/execution_policy.feature", + "file": "v2/execution-policy/create-a-slack-execution-policy-returns-created-response.json", + "scenario": "Create a Slack execution policy returns \"Created\" response", + "version": "v2" + }, + { + "feature": "Execution Policy", + "feature_file": "../../features/v2/execution_policy.feature", + "file": "v2/execution-policy/create-a-slack-execution-policy-with-empty-channel-selectors-returns-bad-request-response.json", + "scenario": "Create a Slack execution policy with empty channel selectors returns \"Bad Request\" response", + "version": "v2" + }, + { + "feature": "Execution Policy", + "feature_file": "../../features/v2/execution_policy.feature", + "file": "v2/execution-policy/create-a-slack-execution-policy-with-mismatched-scope-returns-bad-request-response.json", + "scenario": "Create a Slack execution policy with mismatched scope returns \"Bad Request\" response", + "version": "v2" + }, + { + "feature": "Execution Policy", + "feature_file": "../../features/v2/execution_policy.feature", + "file": "v2/execution-policy/create-a-slack-execution-policy-with-scope-and-targets-returns-created-response.json", + "scenario": "Create a Slack execution policy with scope and targets returns \"Created\" response", + "version": "v2" + }, { "feature": "Execution Policy", "feature_file": "../../features/v2/execution_policy.feature", @@ -5551,6 +5579,13 @@ "scenario": "Get an execution policy returns \"OK\" response", "version": "v2" }, + { + "feature": "Execution Policy", + "feature_file": "../../features/v2/execution_policy.feature", + "file": "v2/execution-policy/list-execution-policies-filtered-by-slack-returns-ok-response.json", + "scenario": "List execution policies filtered by Slack returns \"OK\" response", + "version": "v2" + }, { "feature": "Execution Policy", "feature_file": "../../features/v2/execution_policy.feature", @@ -5593,6 +5628,13 @@ "scenario": "Update an execution policy returns \"OK\" response", "version": "v2" }, + { + "feature": "Execution Policy", + "feature_file": "../../features/v2/execution_policy.feature", + "file": "v2/execution-policy/update-an-execution-policy-to-slack-with-scope-and-targets-returns-ok-response.json", + "scenario": "Update an execution policy to Slack with scope and targets returns \"OK\" response", + "version": "v2" + }, { "feature": "Experiments", "feature_file": "../../features/v2/experiments.feature", diff --git a/generated-test/test-runner-data/v2/execution-policy/create-a-slack-execution-policy-returns-created-response.json b/generated-test/test-runner-data/v2/execution-policy/create-a-slack-execution-policy-returns-created-response.json new file mode 100644 index 000000000000..a753f54d843f --- /dev/null +++ b/generated-test/test-runner-data/v2/execution-policy/create-a-slack-execution-policy-returns-created-response.json @@ -0,0 +1,40 @@ +{ + "api": "ExecutionPolicy", + "expected_status": 201, + "feature": "Execution Policy", + "id": "v2/Execution Policy/Create a Slack execution policy returns \"Created\" response", + "operation_id": "CreateExecutionPolicy", + "request": { + "body": { + "schema": { + "format": null, + "ref": "ExecutionPolicyCreateRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "action_pattern": { + "action_fqns": [ + "com.datadoghq.slack.*" + ], + "integration": "INTEGRATION_SLACK" + }, + "effect": "allow", + "name": "Cassette Execution Policy {{ unique_lower_alnum }}" + }, + "type": "execution_policy" + } + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [], + "path": "/api/v2/actions/execution-policies" + }, + "scenario": "Create a Slack execution policy returns \"Created\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/generated-test/test-runner-data/v2/execution-policy/create-a-slack-execution-policy-with-empty-channel-selectors-returns-bad-request-response.json b/generated-test/test-runner-data/v2/execution-policy/create-a-slack-execution-policy-with-empty-channel-selectors-returns-bad-request-response.json new file mode 100644 index 000000000000..dc5b818e8f7a --- /dev/null +++ b/generated-test/test-runner-data/v2/execution-policy/create-a-slack-execution-policy-with-empty-channel-selectors-returns-bad-request-response.json @@ -0,0 +1,49 @@ +{ + "api": "ExecutionPolicy", + "expected_status": 400, + "feature": "Execution Policy", + "id": "v2/Execution Policy/Create a Slack execution policy with empty channel selectors returns \"Bad Request\" response", + "operation_id": "CreateExecutionPolicy", + "request": { + "body": { + "schema": { + "format": null, + "ref": "ExecutionPolicyCreateRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "action_pattern": { + "action_fqns": [ + "com.datadoghq.slack.*" + ], + "integration": "INTEGRATION_SLACK" + }, + "effect": "allow", + "name": "Cassette Execution Policy {{ unique_lower_alnum }}", + "scope": { + "slack": { + "rules": [ + { + "channel_name_selectors": [] + } + ] + } + } + }, + "type": "execution_policy" + } + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [], + "path": "/api/v2/actions/execution-policies" + }, + "scenario": "Create a Slack execution policy with empty channel selectors returns \"Bad Request\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/generated-test/test-runner-data/v2/execution-policy/create-a-slack-execution-policy-with-mismatched-scope-returns-bad-request-response.json b/generated-test/test-runner-data/v2/execution-policy/create-a-slack-execution-policy-with-mismatched-scope-returns-bad-request-response.json new file mode 100644 index 000000000000..8a403d635c36 --- /dev/null +++ b/generated-test/test-runner-data/v2/execution-policy/create-a-slack-execution-policy-with-mismatched-scope-returns-bad-request-response.json @@ -0,0 +1,51 @@ +{ + "api": "ExecutionPolicy", + "expected_status": 400, + "feature": "Execution Policy", + "id": "v2/Execution Policy/Create a Slack execution policy with mismatched scope returns \"Bad Request\" response", + "operation_id": "CreateExecutionPolicy", + "request": { + "body": { + "schema": { + "format": null, + "ref": "ExecutionPolicyCreateRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "action_pattern": { + "action_fqns": [ + "com.datadoghq.slack.*" + ], + "integration": "INTEGRATION_SLACK" + }, + "effect": "allow", + "name": "Cassette Execution Policy {{ unique_lower_alnum }}", + "scope": { + "scripts": { + "rules": [ + { + "target_script_names": [ + "restart_service.sh" + ] + } + ] + } + } + }, + "type": "execution_policy" + } + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [], + "path": "/api/v2/actions/execution-policies" + }, + "scenario": "Create a Slack execution policy with mismatched scope returns \"Bad Request\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/generated-test/test-runner-data/v2/execution-policy/create-a-slack-execution-policy-with-scope-and-targets-returns-created-response.json b/generated-test/test-runner-data/v2/execution-policy/create-a-slack-execution-policy-with-scope-and-targets-returns-created-response.json new file mode 100644 index 000000000000..5c3766cffafe --- /dev/null +++ b/generated-test/test-runner-data/v2/execution-policy/create-a-slack-execution-policy-with-scope-and-targets-returns-created-response.json @@ -0,0 +1,59 @@ +{ + "api": "ExecutionPolicy", + "expected_status": 201, + "feature": "Execution Policy", + "id": "v2/Execution Policy/Create a Slack execution policy with scope and targets returns \"Created\" response", + "operation_id": "CreateExecutionPolicy", + "request": { + "body": { + "schema": { + "format": null, + "ref": "ExecutionPolicyCreateRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "action_pattern": { + "action_fqns": [ + "com.datadoghq.slack.*" + ], + "integration": "INTEGRATION_SLACK" + }, + "effect": "allow", + "name": "Cassette Execution Policy {{ unique_lower_alnum }}", + "scope": { + "slack": { + "rules": [ + { + "channel_name_selectors": [ + "incident-*" + ] + } + ] + } + }, + "targets": [ + { + "agent_tags": [ + "slack_workspace_id:T01234567" + ], + "name": "Incident workspace" + } + ] + }, + "type": "execution_policy" + } + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [], + "path": "/api/v2/actions/execution-policies" + }, + "scenario": "Create a Slack execution policy with scope and targets returns \"Created\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/generated-test/test-runner-data/v2/execution-policy/list-execution-policies-filtered-by-slack-returns-ok-response.json b/generated-test/test-runner-data/v2/execution-policy/list-execution-policies-filtered-by-slack-returns-ok-response.json new file mode 100644 index 000000000000..cd4cd82bb0ba --- /dev/null +++ b/generated-test/test-runner-data/v2/execution-policy/list-execution-policies-filtered-by-slack-returns-ok-response.json @@ -0,0 +1,42 @@ +{ + "api": "ExecutionPolicy", + "expected_status": 200, + "feature": "Execution Policy", + "id": "v2/Execution Policy/List execution policies filtered by Slack returns \"OK\" response", + "operation_id": "ListExecutionPolicies", + "request": { + "body": null, + "content_type": null, + "method": "GET", + "pagination": false, + "parameters": [ + { + "explode": true, + "in": "query", + "name": "filter[integration]", + "required": false, + "schema": { + "format": null, + "items": { + "format": null, + "ref": "ExecutionPolicyIntegration", + "type": "string" + }, + "ref": null, + "type": "array" + }, + "source": { + "type": "literal", + "value": [ + "INTEGRATION_SLACK" + ] + }, + "style": "form" + } + ], + "path": "/api/v2/actions/execution-policies" + }, + "scenario": "List execution policies filtered by Slack returns \"OK\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/generated-test/test-runner-data/v2/execution-policy/update-an-execution-policy-to-slack-with-scope-and-targets-returns-ok-response.json b/generated-test/test-runner-data/v2/execution-policy/update-an-execution-policy-to-slack-with-scope-and-targets-returns-ok-response.json new file mode 100644 index 000000000000..49df041f32ea --- /dev/null +++ b/generated-test/test-runner-data/v2/execution-policy/update-an-execution-policy-to-slack-with-scope-and-targets-returns-ok-response.json @@ -0,0 +1,77 @@ +{ + "api": "ExecutionPolicy", + "expected_status": 200, + "feature": "Execution Policy", + "id": "v2/Execution Policy/Update an execution policy to Slack with scope and targets returns \"OK\" response", + "operation_id": "UpdateExecutionPolicy", + "request": { + "body": { + "schema": { + "format": null, + "ref": "ExecutionPolicyUpdateRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "action_pattern": { + "action_fqns": [ + "*" + ], + "integration": "INTEGRATION_SLACK" + }, + "effect": "deny", + "name": "Cassette Execution Policy Updated", + "scope": { + "slack": { + "rules": [ + { + "channel_name_selectors": [ + "incident-denied" + ] + } + ] + } + }, + "targets": [ + { + "agent_tags": [ + "slack_workspace_id:T01234567" + ], + "name": "Incident workspace" + } + ] + }, + "id": "{{ execution_policy.data.id }}", + "type": "execution_policy" + } + } + }, + "content_type": "application/json", + "method": "PUT", + "pagination": false, + "parameters": [ + { + "explode": null, + "in": "path", + "name": "policy_id", + "required": true, + "schema": { + "format": null, + "ref": null, + "type": "string" + }, + "source": { + "path": "execution_policy.data.id", + "type": "fixture" + }, + "style": null + } + ], + "path": "/api/v2/actions/execution-policies/{policy_id}" + }, + "scenario": "Update an execution policy to Slack with scope and targets returns \"OK\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/generated-test/test-server-data/v2/execution-policy.json b/generated-test/test-server-data/v2/execution-policy.json index 1bd16ddff71d..100f936d0fe4 100644 --- a/generated-test/test-server-data/v2/execution-policy.json +++ b/generated-test/test-server-data/v2/execution-policy.json @@ -1,6 +1,267 @@ { "feature": "Execution Policy", "recordings": [ + { + "feature": "Execution Policy", + "frozen_at": "2026-10-28T14:08:54.779Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "action_pattern": { + "action_fqns": [ + "com.datadoghq.slack.*" + ], + "integration": "INTEGRATION_SLACK" + }, + "effect": "allow", + "name": "Cassette Execution Policy testcreateaslackexecutionpolicyreturnscreatedresponse1793196534" + }, + "type": "execution_policy" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/actions/execution-policies", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"1eca132c-5b3d-482a-a282-07393abdc9d5\",\"type\":\"execution_policy\",\"attributes\":{\"action_pattern\":{\"integration\":\"INTEGRATION_SLACK\",\"action_fqns\":[\"com.datadoghq.slack.*\"]},\"created_at\":\"2026-10-28T14:08:56Z\",\"created_by\":\"028000b7-d90f-4d20-b4a9-6ff4a83b7950\",\"effect\":\"allow\",\"name\":\"Cassette Execution Policy testcreateaslackexecutionpolicyreturnscreatedresponse1793196534\",\"targets\":[],\"updated_at\":\"2026-10-28T14:08:56Z\",\"updated_by\":\"028000b7-d90f-4d20-b4a9-6ff4a83b7950\",\"version\":1}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Created", + "status": 201 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/actions/execution-policies/1eca132c-5b3d-482a-a282-07393abdc9d5", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + } + ], + "scenario": "Create a Slack execution policy returns \"Created\" response", + "version": "v2" + }, + { + "feature": "Execution Policy", + "frozen_at": "2026-10-28T14:08:56.579Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "action_pattern": { + "action_fqns": [ + "com.datadoghq.slack.*" + ], + "integration": "INTEGRATION_SLACK" + }, + "effect": "allow", + "name": "Cassette Execution Policy testcreateaslackexecutionpolicywithemptychannelselectorsreturnsbadrequestresponse1793196536", + "scope": { + "slack": { + "rules": [ + { + "channel_name_selectors": [] + } + ] + } + } + }, + "type": "execution_policy" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/actions/execution-policies", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"error creating execution policy\"}]}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Bad Request", + "status": 400 + } + } + ], + "scenario": "Create a Slack execution policy with empty channel selectors returns \"Bad Request\" response", + "version": "v2" + }, + { + "feature": "Execution Policy", + "frozen_at": "2026-10-28T14:08:56.677Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "action_pattern": { + "action_fqns": [ + "com.datadoghq.slack.*" + ], + "integration": "INTEGRATION_SLACK" + }, + "effect": "allow", + "name": "Cassette Execution Policy testcreateaslackexecutionpolicywithmismatchedscopereturnsbadrequestresponse1793196536", + "scope": { + "scripts": { + "rules": [ + { + "target_script_names": [ + "restart_service.sh" + ] + } + ] + } + } + }, + "type": "execution_policy" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/actions/execution-policies", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"error creating execution policy\"}]}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Bad Request", + "status": 400 + } + } + ], + "scenario": "Create a Slack execution policy with mismatched scope returns \"Bad Request\" response", + "version": "v2" + }, + { + "feature": "Execution Policy", + "frozen_at": "2026-10-28T14:08:56.739Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "action_pattern": { + "action_fqns": [ + "com.datadoghq.slack.*" + ], + "integration": "INTEGRATION_SLACK" + }, + "effect": "allow", + "name": "Cassette Execution Policy testcreateaslackexecutionpolicywithscopeandtargetsreturnscreatedresponse1793196536", + "scope": { + "slack": { + "rules": [ + { + "channel_name_selectors": [ + "incident-*" + ] + } + ] + } + }, + "targets": [ + { + "agent_tags": [ + "slack_workspace_id:T01234567" + ], + "name": "Incident workspace" + } + ] + }, + "type": "execution_policy" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/actions/execution-policies", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"071e5ba3-ba19-4334-adf5-2da5298565f2\",\"type\":\"execution_policy\",\"attributes\":{\"action_pattern\":{\"integration\":\"INTEGRATION_SLACK\",\"action_fqns\":[\"com.datadoghq.slack.*\"]},\"created_at\":\"2026-10-28T14:08:56Z\",\"created_by\":\"028000b7-d90f-4d20-b4a9-6ff4a83b7950\",\"effect\":\"allow\",\"name\":\"Cassette Execution Policy testcreateaslackexecutionpolicywithscopeandtargetsreturnscreatedresponse1793196536\",\"scope\":{\"slack\":{\"rules\":[{\"channel_name_selectors\":[\"incident-*\"]}]}},\"targets\":[{\"agent_tags\":[\"slack_workspace_id:T01234567\"],\"name\":\"Incident workspace\"}],\"updated_at\":\"2026-10-28T14:08:56Z\",\"updated_by\":\"028000b7-d90f-4d20-b4a9-6ff4a83b7950\",\"version\":1}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Created", + "status": 201 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/actions/execution-policies/071e5ba3-ba19-4334-adf5-2da5298565f2", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + } + ], + "scenario": "Create a Slack execution policy with scope and targets returns \"Created\" response", + "version": "v2" + }, { "feature": "Execution Policy", "frozen_at": "2026-08-14T09:13:38.368Z", @@ -437,6 +698,42 @@ "scenario": "Get an execution policy returns \"OK\" response", "version": "v2" }, + { + "feature": "Execution Policy", + "frozen_at": "2026-10-28T14:08:56.947Z", + "interactions": [ + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "GET", + "path": "/api/v2/actions/execution-policies", + "query": [ + [ + "filter[integration]", + "INTEGRATION_SLACK" + ] + ] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":[],\"meta\":{\"page\":{\"total\":0}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "OK", + "status": 200 + } + } + ], + "scenario": "List execution policies filtered by Slack returns \"OK\" response", + "version": "v2" + }, { "feature": "Execution Policy", "frozen_at": "2026-08-14T09:13:43.018Z", @@ -937,6 +1234,129 @@ ], "scenario": "Update an execution policy returns \"OK\" response", "version": "v2" + }, + { + "feature": "Execution Policy", + "frozen_at": "2026-10-28T14:08:57.019Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "action_pattern": { + "action_fqns": [ + "com.datadoghq.script.*" + ], + "integration": "INTEGRATION_SCRIPT" + }, + "effect": "allow", + "name": "Cassette Execution Policy testupdateanexecutionpolicytoslackwithscopeandtargetsreturnsokresponse1793196537" + }, + "type": "execution_policy" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/actions/execution-policies", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"010051ac-04d3-4852-8598-fc620a84ef45\",\"type\":\"execution_policy\",\"attributes\":{\"action_pattern\":{\"integration\":\"INTEGRATION_SCRIPT\",\"action_fqns\":[\"com.datadoghq.script.*\"]},\"created_at\":\"2026-10-28T14:08:57Z\",\"created_by\":\"028000b7-d90f-4d20-b4a9-6ff4a83b7950\",\"effect\":\"allow\",\"name\":\"Cassette Execution Policy testupdateanexecutionpolicytoslackwithscopeandtargetsreturnsokresponse1793196537\",\"targets\":[],\"updated_at\":\"2026-10-28T14:08:57Z\",\"updated_by\":\"028000b7-d90f-4d20-b4a9-6ff4a83b7950\",\"version\":1}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Created", + "status": 201 + } + }, + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "action_pattern": { + "action_fqns": [ + "*" + ], + "integration": "INTEGRATION_SLACK" + }, + "effect": "deny", + "name": "Cassette Execution Policy Updated", + "scope": { + "slack": { + "rules": [ + { + "channel_name_selectors": [ + "incident-denied" + ] + } + ] + } + }, + "targets": [ + { + "agent_tags": [ + "slack_workspace_id:T01234567" + ], + "name": "Incident workspace" + } + ] + }, + "id": "010051ac-04d3-4852-8598-fc620a84ef45", + "type": "execution_policy" + } + } + }, + "content_type": "application/json", + "method": "PUT", + "path": "/api/v2/actions/execution-policies/010051ac-04d3-4852-8598-fc620a84ef45", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"010051ac-04d3-4852-8598-fc620a84ef45\",\"type\":\"execution_policy\",\"attributes\":{\"action_pattern\":{\"integration\":\"INTEGRATION_SLACK\",\"action_fqns\":[\"*\"]},\"created_at\":\"2026-10-28T14:08:57Z\",\"created_by\":\"028000b7-d90f-4d20-b4a9-6ff4a83b7950\",\"effect\":\"deny\",\"name\":\"Cassette Execution Policy Updated\",\"scope\":{\"slack\":{\"rules\":[{\"channel_name_selectors\":[\"incident-denied\"]}]}},\"targets\":[{\"agent_tags\":[\"slack_workspace_id:T01234567\"],\"name\":\"Incident workspace\"}],\"updated_at\":\"2026-10-28T14:08:57Z\",\"updated_by\":\"028000b7-d90f-4d20-b4a9-6ff4a83b7950\",\"version\":2}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "OK", + "status": 200 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/actions/execution-policies/010051ac-04d3-4852-8598-fc620a84ef45", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + } + ], + "scenario": "Update an execution policy to Slack with scope and targets returns \"OK\" response", + "version": "v2" } ], "schema_version": 1, diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 01623f61fc34..c224973f2764 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -3599,6 +3599,8 @@ def overrides "v2.execution_policy_scope" => "ExecutionPolicyScope", "v2.execution_policy_script_scope" => "ExecutionPolicyScriptScope", "v2.execution_policy_script_scope_rule" => "ExecutionPolicyScriptScopeRule", + "v2.execution_policy_slack_scope" => "ExecutionPolicySlackScope", + "v2.execution_policy_slack_scope_rule" => "ExecutionPolicySlackScopeRule", "v2.execution_policy_target" => "ExecutionPolicyTarget", "v2.execution_policy_type" => "ExecutionPolicyType", "v2.execution_policy_update_request" => "ExecutionPolicyUpdateRequest", diff --git a/lib/datadog_api_client/v2/models/execution_policy_attributes.rb b/lib/datadog_api_client/v2/models/execution_policy_attributes.rb index b024b56cca1b..b124e01aab93 100644 --- a/lib/datadog_api_client/v2/models/execution_policy_attributes.rb +++ b/lib/datadog_api_client/v2/models/execution_policy_attributes.rb @@ -36,9 +36,9 @@ class ExecutionPolicyAttributes # The name of the execution policy. attr_reader :name - # Restricts where the policy applies. At most one of `kubernetes`, `scripts`, - # or `remote_action_rshell` can be set. An empty object means the policy has - # no scope restriction. + # Restricts where the policy applies. At most one scope type can be set, + # and it must match the action pattern's integration. An empty object means + # the policy has no scope restriction. attr_accessor :scope # The targets this policy applies to. diff --git a/lib/datadog_api_client/v2/models/execution_policy_integration.rb b/lib/datadog_api_client/v2/models/execution_policy_integration.rb index aa9aa84610e8..aa7302d338e9 100644 --- a/lib/datadog_api_client/v2/models/execution_policy_integration.rb +++ b/lib/datadog_api_client/v2/models/execution_policy_integration.rb @@ -24,5 +24,6 @@ class ExecutionPolicyIntegration INTEGRATION_KUBERNETES = "INTEGRATION_KUBERNETES".freeze INTEGRATION_SCRIPT = "INTEGRATION_SCRIPT".freeze INTEGRATION_REMOTE_ACTION = "INTEGRATION_REMOTE_ACTION".freeze + INTEGRATION_SLACK = "INTEGRATION_SLACK".freeze end end diff --git a/lib/datadog_api_client/v2/models/execution_policy_scope.rb b/lib/datadog_api_client/v2/models/execution_policy_scope.rb index 4e8f37a5c850..c13ca5fbe543 100644 --- a/lib/datadog_api_client/v2/models/execution_policy_scope.rb +++ b/lib/datadog_api_client/v2/models/execution_policy_scope.rb @@ -17,9 +17,9 @@ require 'time' module DatadogAPIClient::V2 - # Restricts where the policy applies. At most one of `kubernetes`, `scripts`, - # or `remote_action_rshell` can be set. An empty object means the policy has - # no scope restriction. + # Restricts where the policy applies. At most one scope type can be set, + # and it must match the action pattern's integration. An empty object means + # the policy has no scope restriction. class ExecutionPolicyScope include BaseGenericModel @@ -32,6 +32,9 @@ class ExecutionPolicyScope # Restricts the policy to specific scripts. attr_accessor :scripts + # Restricts the policy to specific Slack private channel names. + attr_accessor :slack + attr_accessor :additional_properties # Attribute mapping from ruby-style variable name to JSON key. @@ -40,7 +43,8 @@ def self.attribute_map { :'kubernetes' => :'kubernetes', :'remote_action_rshell' => :'remote_action_rshell', - :'scripts' => :'scripts' + :'scripts' => :'scripts', + :'slack' => :'slack' } end @@ -50,7 +54,8 @@ def self.openapi_types { :'kubernetes' => :'ExecutionPolicyKubernetesScope', :'remote_action_rshell' => :'ExecutionPolicyRemoteActionRshellScope', - :'scripts' => :'ExecutionPolicyScriptScope' + :'scripts' => :'ExecutionPolicyScriptScope', + :'slack' => :'ExecutionPolicySlackScope' } end @@ -83,6 +88,10 @@ def initialize(attributes = {}) if attributes.key?(:'scripts') self.scripts = attributes[:'scripts'] end + + if attributes.key?(:'slack') + self.slack = attributes[:'slack'] + end end # Returns the object in the form of hash, with additionalProperties support. @@ -114,6 +123,7 @@ def ==(o) kubernetes == o.kubernetes && remote_action_rshell == o.remote_action_rshell && scripts == o.scripts && + slack == o.slack && additional_properties == o.additional_properties end @@ -121,7 +131,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [kubernetes, remote_action_rshell, scripts, additional_properties].hash + [kubernetes, remote_action_rshell, scripts, slack, additional_properties].hash end end end diff --git a/lib/datadog_api_client/v2/models/execution_policy_slack_scope.rb b/lib/datadog_api_client/v2/models/execution_policy_slack_scope.rb new file mode 100644 index 000000000000..a6189ed79447 --- /dev/null +++ b/lib/datadog_api_client/v2/models/execution_policy_slack_scope.rb @@ -0,0 +1,129 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Restricts the policy to specific Slack private channel names. + class ExecutionPolicySlackScope + include BaseGenericModel + + # The Slack scope rules. + attr_reader :rules + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'rules' => :'rules' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'rules' => :'Array' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ExecutionPolicySlackScope` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'rules') + if (value = attributes[:'rules']).is_a?(Array) + self.rules = value + end + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @rules.nil? + return false if @rules.length < 1 + true + end + + # Custom attribute writer method with validation + # @param rules [Object] Object to be assigned + # @!visibility private + def rules=(rules) + if rules.nil? + fail ArgumentError, 'invalid value for "rules", rules cannot be nil.' + end + if rules.length < 1 + fail ArgumentError, 'invalid value for "rules", number of items must be greater than or equal to 1.' + end + @rules = rules + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + rules == o.rules && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [rules, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/execution_policy_slack_scope_rule.rb b/lib/datadog_api_client/v2/models/execution_policy_slack_scope_rule.rb new file mode 100644 index 000000000000..4e64793724cb --- /dev/null +++ b/lib/datadog_api_client/v2/models/execution_policy_slack_scope_rule.rb @@ -0,0 +1,134 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # A rule restricting a Slack scope to specific private channel names. + class ExecutionPolicySlackScopeRule + include BaseGenericModel + + # The private channel name selectors this rule applies to. Selectors are lowercase private channel names + # without the leading `#`, and can contain `*` wildcards. Use `*` alone to match any private channel name. + attr_reader :channel_name_selectors + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'channel_name_selectors' => :'channel_name_selectors' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'channel_name_selectors' => :'Array' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ExecutionPolicySlackScopeRule` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'channel_name_selectors') + if (value = attributes[:'channel_name_selectors']).is_a?(Array) + self.channel_name_selectors = value + end + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @channel_name_selectors.nil? + return false if @channel_name_selectors.length > 100 + return false if @channel_name_selectors.length < 1 + true + end + + # Custom attribute writer method with validation + # @param channel_name_selectors [Object] Object to be assigned + # @!visibility private + def channel_name_selectors=(channel_name_selectors) + if channel_name_selectors.nil? + fail ArgumentError, 'invalid value for "channel_name_selectors", channel_name_selectors cannot be nil.' + end + if channel_name_selectors.length > 100 + fail ArgumentError, 'invalid value for "channel_name_selectors", number of items must be less than or equal to 100.' + end + if channel_name_selectors.length < 1 + fail ArgumentError, 'invalid value for "channel_name_selectors", number of items must be greater than or equal to 1.' + end + @channel_name_selectors = channel_name_selectors + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + channel_name_selectors == o.channel_name_selectors && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [channel_name_selectors, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/execution_policy_target.rb b/lib/datadog_api_client/v2/models/execution_policy_target.rb index 73744c9cd64e..bff196346711 100644 --- a/lib/datadog_api_client/v2/models/execution_policy_target.rb +++ b/lib/datadog_api_client/v2/models/execution_policy_target.rb @@ -17,11 +17,11 @@ require 'time' module DatadogAPIClient::V2 - # A target this policy is scoped to, expressed as a set of Agent tags. + # A target this policy is scoped to, expressed as a set of tags. class ExecutionPolicyTarget include BaseGenericModel - # The Agent tags identifying the target. + # The tags identifying the target. attr_reader :agent_tags # A human-readable name for the target. diff --git a/lib/datadog_api_client/v2/models/execution_policy_write_attributes.rb b/lib/datadog_api_client/v2/models/execution_policy_write_attributes.rb index 6db57ff4da56..5068f5c8d60a 100644 --- a/lib/datadog_api_client/v2/models/execution_policy_write_attributes.rb +++ b/lib/datadog_api_client/v2/models/execution_policy_write_attributes.rb @@ -30,9 +30,9 @@ class ExecutionPolicyWriteAttributes # The name of the execution policy. attr_reader :name - # Restricts where the policy applies. At most one of `kubernetes`, `scripts`, - # or `remote_action_rshell` can be set. An empty object means the policy has - # no scope restriction. + # Restricts where the policy applies. At most one scope type can be set, + # and it must match the action pattern's integration. An empty object means + # the policy has no scope restriction. attr_accessor :scope # The targets this policy applies to.