diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index fcf5fd48e2..c448f25530 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -521,6 +521,15 @@ components: schema: example: github type: string + ExecutionPolicyId: + description: The ID of the execution policy. + example: "3fa85f64-5717-4562-b3fc-2c963f66afa6" + in: path + name: policy_id + required: true + schema: + format: uuid + type: string FastlyAccountID: description: Fastly Account id. in: path @@ -37665,6 +37674,349 @@ components: example: "One or several indexes are missing or invalid. Results hold data from the other indexes." type: string type: object + ExecutionPolicyActionPattern: + description: The set of actions this policy applies to. + properties: + action_fqns: + description: |- + The fully qualified action names this policy matches. Use `*` to match all actions + of the integration, or a fully qualified name prefixed with the integration's action + namespace (for example `com.datadoghq.script.*` for the Script integration). + example: + - "com.datadoghq.script.*" + items: + type: string + type: array + integration: + $ref: "#/components/schemas/ExecutionPolicyIntegration" + required: + - integration + - action_fqns + type: object + ExecutionPolicyAttributes: + description: An execution policy. + properties: + action_pattern: + $ref: "#/components/schemas/ExecutionPolicyActionPattern" + created_at: + description: The date and time the execution policy was created. + example: "2026-01-15T10:00:00.000Z" + format: date-time + type: string + created_by: + description: The ID of the user who created the execution policy. + example: "3fa85f64-5717-4562-b3fc-2c963f66afa6" + type: string + effect: + $ref: "#/components/schemas/ExecutionPolicyEffect" + name: + description: The name of the execution policy. + example: "Block prod restarts" + type: string + scope: + $ref: "#/components/schemas/ExecutionPolicyScope" + targets: + description: The targets this policy applies to. + items: + $ref: "#/components/schemas/ExecutionPolicyTarget" + type: array + updated_at: + description: The date and time the execution policy was last updated. + example: "2026-01-15T10:00:00.000Z" + format: date-time + type: string + updated_by: + description: The ID of the user who last updated the execution policy. + example: "3fa85f64-5717-4562-b3fc-2c963f66afa6" + type: string + version: + description: The version of the execution policy. Incremented on every update. + example: 1 + format: int32 + maximum: 2147483647 + type: integer + required: + - name + - effect + - action_pattern + - targets + - version + - created_at + - updated_at + - created_by + - updated_by + type: object + ExecutionPolicyCreateRequest: + description: Request object that includes the execution policy to create. + properties: + data: + $ref: "#/components/schemas/ExecutionPolicyCreateRequestData" + required: + - data + type: object + ExecutionPolicyCreateRequestData: + description: Object for a single execution policy. + properties: + attributes: + $ref: "#/components/schemas/ExecutionPolicyWriteAttributes" + type: + $ref: "#/components/schemas/ExecutionPolicyType" + required: + - type + - attributes + type: object + ExecutionPolicyEffect: + description: Whether the policy allows or denies matching actions. + enum: + - allow + - deny + example: allow + type: string + x-enum-varnames: + - ALLOW + - DENY + ExecutionPolicyIntegration: + description: The integration the action pattern applies to. + enum: + - INTEGRATION_KUBERNETES + - INTEGRATION_SCRIPT + - INTEGRATION_REMOTE_ACTION + example: INTEGRATION_SCRIPT + type: string + x-enum-varnames: + - INTEGRATION_KUBERNETES + - INTEGRATION_SCRIPT + - INTEGRATION_REMOTE_ACTION + ExecutionPolicyKubernetesScope: + description: Restricts the policy to specific Kubernetes namespaces. + properties: + rules: + description: The Kubernetes scope rules. + items: + $ref: "#/components/schemas/ExecutionPolicyKubernetesScopeRule" + type: array + required: + - rules + type: object + ExecutionPolicyKubernetesScopeRule: + description: A rule restricting a Kubernetes scope to specific namespaces. + properties: + target_namespaces: + description: The Kubernetes namespaces this rule applies to. + example: + - "default" + items: + type: string + type: array + required: + - target_namespaces + type: object + ExecutionPolicyListResponse: + description: Response object that includes a list of execution policies. + properties: + data: + description: The execution policies. + items: + $ref: "#/components/schemas/ExecutionPolicyResponseData" + type: array + meta: + $ref: "#/components/schemas/ExecutionPolicyListResponseMeta" + required: + - data + - meta + type: object + ExecutionPolicyListResponseMeta: + description: Pagination metadata for the list of execution policies. + properties: + page: + $ref: "#/components/schemas/ExecutionPolicyListResponsePage" + required: + - page + type: object + ExecutionPolicyListResponsePage: + description: Pagination details. + properties: + total: + description: The total number of execution policies matching the query. + example: 1 + format: int32 + maximum: 2147483647 + type: integer + required: + - total + type: object + ExecutionPolicyRemoteActionRshellAccess: + description: The level of remote shell access granted for the target paths. + enum: + - read_only + - read_write + example: read_only + type: string + x-enum-varnames: + - READ_ONLY + - READ_WRITE + ExecutionPolicyRemoteActionRshellScope: + description: Restricts the policy to specific remote shell paths. + properties: + rules: + description: The remote shell scope rules. + items: + $ref: "#/components/schemas/ExecutionPolicyRemoteActionRshellScopeRule" + type: array + required: + - rules + type: object + ExecutionPolicyRemoteActionRshellScopeRule: + description: A rule restricting remote shell access to specific paths. + properties: + access: + $ref: "#/components/schemas/ExecutionPolicyRemoteActionRshellAccess" + target_paths: + description: The file system paths this rule applies to. + example: + - "/var/log" + items: + type: string + type: array + required: + - target_paths + - access + type: object + ExecutionPolicyResponse: + description: Response object that includes a single execution policy. + properties: + data: + $ref: "#/components/schemas/ExecutionPolicyResponseData" + required: + - data + type: object + ExecutionPolicyResponseData: + description: Object for a single execution policy. + properties: + attributes: + $ref: "#/components/schemas/ExecutionPolicyAttributes" + id: + description: The ID of the execution policy. + example: "3fa85f64-5717-4562-b3fc-2c963f66afa6" + readOnly: true + type: string + type: + $ref: "#/components/schemas/ExecutionPolicyType" + required: + - id + - type + - attributes + type: object + ExecutionPolicyScope: + description: |- + Restricts where the policy applies. Exactly one of `kubernetes`, `scripts`, + or `remote_action_rshell` can be set. + properties: + kubernetes: + $ref: "#/components/schemas/ExecutionPolicyKubernetesScope" + remote_action_rshell: + $ref: "#/components/schemas/ExecutionPolicyRemoteActionRshellScope" + scripts: + $ref: "#/components/schemas/ExecutionPolicyScriptScope" + type: object + ExecutionPolicyScriptScope: + description: Restricts the policy to specific scripts. + properties: + rules: + description: The script scope rules. + items: + $ref: "#/components/schemas/ExecutionPolicyScriptScopeRule" + type: array + required: + - rules + type: object + ExecutionPolicyScriptScopeRule: + description: A rule restricting a script scope to specific script names. + properties: + target_script_names: + description: The script names this rule applies to. + example: + - "restart_service.sh" + items: + type: string + type: array + required: + - target_script_names + type: object + ExecutionPolicyTarget: + description: A target this policy is scoped to, expressed as a set of Agent tags. + properties: + agent_tags: + description: The Agent tags identifying the target. + example: + - "env:prod" + items: + type: string + type: array + name: + description: A human-readable name for the target. + example: "Production hosts" + nullable: true + type: string + required: + - agent_tags + type: object + ExecutionPolicyType: + default: execution_policy + description: The type of the resource. The value should always be `execution_policy`. + enum: + - execution_policy + example: execution_policy + type: string + x-enum-varnames: + - EXECUTION_POLICY + ExecutionPolicyUpdateRequest: + description: Request object that includes the execution policy to update. + properties: + data: + $ref: "#/components/schemas/ExecutionPolicyUpdateRequestData" + required: + - data + type: object + ExecutionPolicyUpdateRequestData: + description: Object for a single execution policy. + properties: + attributes: + $ref: "#/components/schemas/ExecutionPolicyWriteAttributes" + id: + description: The ID of the execution policy. + example: "3fa85f64-5717-4562-b3fc-2c963f66afa6" + type: string + type: + $ref: "#/components/schemas/ExecutionPolicyType" + required: + - id + - type + - attributes + type: object + ExecutionPolicyWriteAttributes: + description: Attributes used to create or update an execution policy. + properties: + action_pattern: + $ref: "#/components/schemas/ExecutionPolicyActionPattern" + effect: + $ref: "#/components/schemas/ExecutionPolicyEffect" + name: + description: The name of the execution policy. + example: "Block prod restarts" + type: string + scope: + $ref: "#/components/schemas/ExecutionPolicyScope" + targets: + description: The targets this policy applies to. + items: + $ref: "#/components/schemas/ExecutionPolicyTarget" + type: array + required: + - name + - effect + - action_pattern + type: object ExposureRolloutStepRequest: description: Rollout step request payload. properties: @@ -121661,6 +122013,401 @@ paths: summary: Update an existing Action Connection tags: - Action Connection + /api/v2/actions/execution-policies: + get: + description: Retrieve a list of execution policies for the current organization. + operationId: ListExecutionPolicies + parameters: + - description: The number of execution policies to return per page. + example: 100 + in: query + name: page[size] + required: false + schema: + default: 100 + format: int32 + maximum: 100 + minimum: 1 + type: integer + - description: The page number to return. + example: 0 + in: query + name: page[number] + required: false + schema: + default: 0 + format: int32 + maximum: 1000 + minimum: 0 + type: integer + - description: Filter execution policies by name. + example: "Block prod restarts" + in: query + name: filter[name] + required: false + schema: + type: string + - description: Filter execution policies by a list of IDs. + example: + - "3fa85f64-5717-4562-b3fc-2c963f66afa6" + explode: true + in: query + name: filter[ids] + required: false + schema: + items: + type: string + type: array + style: form + - description: Filter execution policies by a list of integrations. + example: + - INTEGRATION_SCRIPT + explode: true + in: query + name: filter[integration] + required: false + schema: + items: + $ref: "#/components/schemas/ExecutionPolicyIntegration" + type: array + style: form + - description: Filter execution policies by a list of effects. + example: + - allow + explode: true + in: query + name: filter[effects] + required: false + schema: + items: + $ref: "#/components/schemas/ExecutionPolicyEffect" + type: array + style: form + - description: Filter execution policies by a list of creator IDs. + example: + - "3fa85f64-5717-4562-b3fc-2c963f66afa6" + explode: true + in: query + name: filter[creator_ids] + required: false + schema: + items: + type: string + type: array + style: form + - description: |- + The sort order for the results. Prefix a field with `-` to sort in + descending order. Valid fields are `name`, `effect`, `integration`, + `created_at`, and `updated_at`. + example: + - "-created_at" + explode: true + in: query + name: sort + required: false + schema: + items: + type: string + type: array + style: form + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + action_pattern: + action_fqns: + - "com.datadoghq.script.*" + integration: INTEGRATION_SCRIPT + created_at: "2026-01-15T10:00:00.000Z" + created_by: "3fa85f64-5717-4562-b3fc-2c963f66afa6" + effect: allow + name: "Block prod restarts" + targets: [] + updated_at: "2026-01-15T10:00:00.000Z" + updated_by: "3fa85f64-5717-4562-b3fc-2c963f66afa6" + version: 1 + id: "3fa85f64-5717-4562-b3fc-2c963f66afa6" + type: execution_policy + meta: + page: + total: 1 + schema: + $ref: "#/components/schemas/ExecutionPolicyListResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: List execution policies + tags: + - Execution Policy + x-permission: + operator: OR + permissions: + - execution_groups_read + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + post: + description: Create a new execution policy. + operationId: CreateExecutionPolicy + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + action_pattern: + action_fqns: + - "com.datadoghq.script.*" + integration: INTEGRATION_SCRIPT + effect: allow + name: "Block prod restarts" + type: execution_policy + schema: + $ref: "#/components/schemas/ExecutionPolicyCreateRequest" + description: The execution policy to create. + required: true + responses: + "201": + content: + application/json: + examples: + default: + value: + data: + attributes: + action_pattern: + action_fqns: + - "com.datadoghq.script.*" + integration: INTEGRATION_SCRIPT + created_at: "2026-01-15T10:00:00.000Z" + created_by: "3fa85f64-5717-4562-b3fc-2c963f66afa6" + effect: allow + name: "Block prod restarts" + targets: [] + updated_at: "2026-01-15T10:00:00.000Z" + updated_by: "3fa85f64-5717-4562-b3fc-2c963f66afa6" + version: 1 + id: "3fa85f64-5717-4562-b3fc-2c963f66afa6" + type: execution_policy + schema: + $ref: "#/components/schemas/ExecutionPolicyResponse" + description: Created + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Create an execution policy + tags: + - Execution Policy + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - execution_groups_write + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/actions/execution-policies/{policy_id}: + delete: + description: Delete a specific execution policy. + operationId: DeleteExecutionPolicy + parameters: + - $ref: "#/components/parameters/ExecutionPolicyId" + responses: + "204": + description: No Content + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Delete an execution policy + tags: + - Execution Policy + x-permission: + operator: OR + permissions: + - execution_groups_write + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + get: + description: Retrieve an existing execution policy by ID. + operationId: GetExecutionPolicy + parameters: + - $ref: "#/components/parameters/ExecutionPolicyId" + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + action_pattern: + action_fqns: + - "com.datadoghq.script.*" + integration: INTEGRATION_SCRIPT + created_at: "2026-01-15T10:00:00.000Z" + created_by: "3fa85f64-5717-4562-b3fc-2c963f66afa6" + effect: allow + name: "Block prod restarts" + targets: [] + updated_at: "2026-01-15T10:00:00.000Z" + updated_by: "3fa85f64-5717-4562-b3fc-2c963f66afa6" + version: 1 + id: "3fa85f64-5717-4562-b3fc-2c963f66afa6" + type: execution_policy + schema: + $ref: "#/components/schemas/ExecutionPolicyResponse" + description: OK + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Get an execution policy + tags: + - Execution Policy + x-permission: + operator: OR + permissions: + - execution_groups_read + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + put: + description: |- + Update an existing execution policy. + Returns the execution policy object when the request is successful. + operationId: UpdateExecutionPolicy + parameters: + - $ref: "#/components/parameters/ExecutionPolicyId" + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + action_pattern: + action_fqns: + - "com.datadoghq.script.*" + integration: INTEGRATION_SCRIPT + effect: allow + name: "Block prod restarts" + id: "3fa85f64-5717-4562-b3fc-2c963f66afa6" + type: execution_policy + schema: + $ref: "#/components/schemas/ExecutionPolicyUpdateRequest" + description: The new execution policy. + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + action_pattern: + action_fqns: + - "com.datadoghq.script.*" + integration: INTEGRATION_SCRIPT + created_at: "2026-01-15T10:00:00.000Z" + created_by: "3fa85f64-5717-4562-b3fc-2c963f66afa6" + effect: allow + name: "Block prod restarts" + targets: [] + updated_at: "2026-01-15T10:00:00.000Z" + updated_by: "3fa85f64-5717-4562-b3fc-2c963f66afa6" + version: 2 + id: "3fa85f64-5717-4562-b3fc-2c963f66afa6" + type: execution_policy + schema: + $ref: "#/components/schemas/ExecutionPolicyResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Update an execution policy + tags: + - Execution Policy + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - execution_groups_write + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/agentless_scanning/accounts/aws: get: description: Fetches the scan options configured for AWS accounts. @@ -213615,6 +214362,12 @@ tags: **Update to Datadog monitor events `aggregation_key` starting March 1, 2025:** The Datadog monitor events `aggregation_key` is unique to each Monitor ID. Starting March 1st, this key will also include Monitor Group, making it unique per *Monitor ID and Monitor Group*. If you're using monitor events `aggregation_key` in dashboard queries or the Event API, you must migrate to use `@monitor.id`. Reach out to [support](https://www.datadoghq.com/support/) if you have any question. 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. + name: Execution Policy - description: |- Manage your Datadog Fastly integration accounts and services directly through the Datadog API. See the [Fastly integration page](https://docs.datadoghq.com/integrations/fastly/) for more information. name: Fastly Integration diff --git a/docs/datadog_api_client.v2.api.rst b/docs/datadog_api_client.v2.api.rst index c4aa3dd164..be0d328f51 100644 --- a/docs/datadog_api_client.v2.api.rst +++ b/docs/datadog_api_client.v2.api.rst @@ -375,6 +375,13 @@ datadog\_api\_client.v2.api.events\_api module :members: :show-inheritance: +datadog\_api\_client.v2.api.execution\_policy\_api module +--------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.api.execution_policy_api + :members: + :show-inheritance: + datadog\_api\_client.v2.api.fastly\_integration\_api module ----------------------------------------------------------- diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index c2a5e5aa47..9da47d3c20 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -15194,6 +15194,174 @@ datadog\_api\_client.v2.model.events\_warning module :members: :show-inheritance: +datadog\_api\_client.v2.model.execution\_policy\_action\_pattern module +----------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.execution_policy_action_pattern + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_attributes module +------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.execution_policy_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_create\_request module +----------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.execution_policy_create_request + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_create\_request\_data module +----------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.execution_policy_create_request_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_effect module +-------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.execution_policy_effect + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_integration module +------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.execution_policy_integration + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_kubernetes\_scope module +------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.execution_policy_kubernetes_scope + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_kubernetes\_scope\_rule module +------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.execution_policy_kubernetes_scope_rule + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_list\_response module +---------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.execution_policy_list_response + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_list\_response\_meta module +---------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.execution_policy_list_response_meta + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_list\_response\_page module +---------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.execution_policy_list_response_page + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_remote\_action\_rshell\_access module +-------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.execution_policy_remote_action_rshell_access + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_remote\_action\_rshell\_scope module +------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.execution_policy_remote_action_rshell_scope + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_remote\_action\_rshell\_scope\_rule module +------------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.execution_policy_remote_action_rshell_scope_rule + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_response module +---------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.execution_policy_response + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_response\_data module +---------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.execution_policy_response_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_scope module +------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.execution_policy_scope + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_script\_scope module +--------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.execution_policy_script_scope + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_script\_scope\_rule module +--------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.execution_policy_script_scope_rule + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_target module +-------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.execution_policy_target + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_type module +------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.execution_policy_type + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_update\_request module +----------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.execution_policy_update_request + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_update\_request\_data module +----------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.execution_policy_update_request_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.execution\_policy\_write\_attributes module +------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.execution_policy_write_attributes + :members: + :show-inheritance: + datadog\_api\_client.v2.model.exposure\_rollout\_step\_request module --------------------------------------------------------------------- diff --git a/examples/v2/execution-policy/CreateExecutionPolicy.py b/examples/v2/execution-policy/CreateExecutionPolicy.py new file mode 100644 index 0000000000..5d0edbcbb1 --- /dev/null +++ b/examples/v2/execution-policy/CreateExecutionPolicy.py @@ -0,0 +1,37 @@ +""" +Create an execution policy returns "Created" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.execution_policy_api import ExecutionPolicyApi +from datadog_api_client.v2.model.execution_policy_action_pattern import ExecutionPolicyActionPattern +from datadog_api_client.v2.model.execution_policy_create_request import ExecutionPolicyCreateRequest +from datadog_api_client.v2.model.execution_policy_create_request_data import ExecutionPolicyCreateRequestData +from datadog_api_client.v2.model.execution_policy_effect import ExecutionPolicyEffect +from datadog_api_client.v2.model.execution_policy_integration import ExecutionPolicyIntegration +from datadog_api_client.v2.model.execution_policy_type import ExecutionPolicyType +from datadog_api_client.v2.model.execution_policy_write_attributes import ExecutionPolicyWriteAttributes + +body = ExecutionPolicyCreateRequest( + data=ExecutionPolicyCreateRequestData( + type=ExecutionPolicyType.EXECUTION_POLICY, + attributes=ExecutionPolicyWriteAttributes( + name="Cassette Execution Policy exampleexecutionpolicy", + effect=ExecutionPolicyEffect.ALLOW, + action_pattern=ExecutionPolicyActionPattern( + integration=ExecutionPolicyIntegration.INTEGRATION_SCRIPT, + action_fqns=[ + "com.datadoghq.script.*", + ], + ), + ), + ), +) + +configuration = Configuration() +configuration.unstable_operations["create_execution_policy"] = True +with ApiClient(configuration) as api_client: + api_instance = ExecutionPolicyApi(api_client) + response = api_instance.create_execution_policy(body=body) + + print(response) diff --git a/examples/v2/execution-policy/CreateExecutionPolicy_1075977289.py b/examples/v2/execution-policy/CreateExecutionPolicy_1075977289.py new file mode 100644 index 0000000000..048e11086b --- /dev/null +++ b/examples/v2/execution-policy/CreateExecutionPolicy_1075977289.py @@ -0,0 +1,60 @@ +""" +Create an execution policy with scope and targets returns "Created" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.execution_policy_api import ExecutionPolicyApi +from datadog_api_client.v2.model.execution_policy_action_pattern import ExecutionPolicyActionPattern +from datadog_api_client.v2.model.execution_policy_create_request import ExecutionPolicyCreateRequest +from datadog_api_client.v2.model.execution_policy_create_request_data import ExecutionPolicyCreateRequestData +from datadog_api_client.v2.model.execution_policy_effect import ExecutionPolicyEffect +from datadog_api_client.v2.model.execution_policy_integration import ExecutionPolicyIntegration +from datadog_api_client.v2.model.execution_policy_scope import ExecutionPolicyScope +from datadog_api_client.v2.model.execution_policy_script_scope import ExecutionPolicyScriptScope +from datadog_api_client.v2.model.execution_policy_script_scope_rule import ExecutionPolicyScriptScopeRule +from datadog_api_client.v2.model.execution_policy_target import ExecutionPolicyTarget +from datadog_api_client.v2.model.execution_policy_type import ExecutionPolicyType +from datadog_api_client.v2.model.execution_policy_write_attributes import ExecutionPolicyWriteAttributes + +body = ExecutionPolicyCreateRequest( + data=ExecutionPolicyCreateRequestData( + type=ExecutionPolicyType.EXECUTION_POLICY, + attributes=ExecutionPolicyWriteAttributes( + name="Cassette Execution Policy exampleexecutionpolicy", + effect=ExecutionPolicyEffect.ALLOW, + action_pattern=ExecutionPolicyActionPattern( + integration=ExecutionPolicyIntegration.INTEGRATION_SCRIPT, + action_fqns=[ + "com.datadoghq.script.*", + ], + ), + scope=ExecutionPolicyScope( + scripts=ExecutionPolicyScriptScope( + rules=[ + ExecutionPolicyScriptScopeRule( + target_script_names=[ + "restart_service.sh", + ], + ), + ], + ), + ), + targets=[ + ExecutionPolicyTarget( + name="Production hosts", + agent_tags=[ + "env:prod", + ], + ), + ], + ), + ), +) + +configuration = Configuration() +configuration.unstable_operations["create_execution_policy"] = True +with ApiClient(configuration) as api_client: + api_instance = ExecutionPolicyApi(api_client) + response = api_instance.create_execution_policy(body=body) + + print(response) diff --git a/examples/v2/execution-policy/DeleteExecutionPolicy.py b/examples/v2/execution-policy/DeleteExecutionPolicy.py new file mode 100644 index 0000000000..603fe6458d --- /dev/null +++ b/examples/v2/execution-policy/DeleteExecutionPolicy.py @@ -0,0 +1,18 @@ +""" +Delete an execution policy returns "No Content" response +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.execution_policy_api import ExecutionPolicyApi + +# there is a valid "execution_policy" in the system +EXECUTION_POLICY_DATA_ID = environ["EXECUTION_POLICY_DATA_ID"] + +configuration = Configuration() +configuration.unstable_operations["delete_execution_policy"] = True +with ApiClient(configuration) as api_client: + api_instance = ExecutionPolicyApi(api_client) + api_instance.delete_execution_policy( + policy_id=EXECUTION_POLICY_DATA_ID, + ) diff --git a/examples/v2/execution-policy/GetExecutionPolicy.py b/examples/v2/execution-policy/GetExecutionPolicy.py new file mode 100644 index 0000000000..17301661a7 --- /dev/null +++ b/examples/v2/execution-policy/GetExecutionPolicy.py @@ -0,0 +1,20 @@ +""" +Get an execution policy returns "OK" response +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.execution_policy_api import ExecutionPolicyApi + +# there is a valid "execution_policy" in the system +EXECUTION_POLICY_DATA_ID = environ["EXECUTION_POLICY_DATA_ID"] + +configuration = Configuration() +configuration.unstable_operations["get_execution_policy"] = True +with ApiClient(configuration) as api_client: + api_instance = ExecutionPolicyApi(api_client) + response = api_instance.get_execution_policy( + policy_id=EXECUTION_POLICY_DATA_ID, + ) + + print(response) diff --git a/examples/v2/execution-policy/ListExecutionPolicies.py b/examples/v2/execution-policy/ListExecutionPolicies.py new file mode 100644 index 0000000000..1ec940c907 --- /dev/null +++ b/examples/v2/execution-policy/ListExecutionPolicies.py @@ -0,0 +1,14 @@ +""" +List execution policies returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.execution_policy_api import ExecutionPolicyApi + +configuration = Configuration() +configuration.unstable_operations["list_execution_policies"] = True +with ApiClient(configuration) as api_client: + api_instance = ExecutionPolicyApi(api_client) + response = api_instance.list_execution_policies() + + print(response) diff --git a/examples/v2/execution-policy/ListExecutionPolicies_1745885519.py b/examples/v2/execution-policy/ListExecutionPolicies_1745885519.py new file mode 100644 index 0000000000..4b4c162678 --- /dev/null +++ b/examples/v2/execution-policy/ListExecutionPolicies_1745885519.py @@ -0,0 +1,41 @@ +""" +List execution policies with query parameters returns "OK" response +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.execution_policy_api import ExecutionPolicyApi +from datadog_api_client.v2.model.execution_policy_effect import ExecutionPolicyEffect +from datadog_api_client.v2.model.execution_policy_integration import ExecutionPolicyIntegration + +# there is a valid "execution_policy" in the system +EXECUTION_POLICY_DATA_ATTRIBUTES_CREATED_BY = environ["EXECUTION_POLICY_DATA_ATTRIBUTES_CREATED_BY"] +EXECUTION_POLICY_DATA_ATTRIBUTES_NAME = environ["EXECUTION_POLICY_DATA_ATTRIBUTES_NAME"] +EXECUTION_POLICY_DATA_ID = environ["EXECUTION_POLICY_DATA_ID"] + +configuration = Configuration() +configuration.unstable_operations["list_execution_policies"] = True +with ApiClient(configuration) as api_client: + api_instance = ExecutionPolicyApi(api_client) + response = api_instance.list_execution_policies( + page_size=10, + page_number=0, + filter_name=EXECUTION_POLICY_DATA_ATTRIBUTES_NAME, + filter_ids=[ + EXECUTION_POLICY_DATA_ID, + ], + filter_integration=[ + ExecutionPolicyIntegration.INTEGRATION_SCRIPT, + ], + filter_effects=[ + ExecutionPolicyEffect.ALLOW, + ], + filter_creator_ids=[ + EXECUTION_POLICY_DATA_ATTRIBUTES_CREATED_BY, + ], + sort=[ + "-created_at", + ], + ) + + print(response) diff --git a/examples/v2/execution-policy/UpdateExecutionPolicy.py b/examples/v2/execution-policy/UpdateExecutionPolicy.py new file mode 100644 index 0000000000..dcc80a44c5 --- /dev/null +++ b/examples/v2/execution-policy/UpdateExecutionPolicy.py @@ -0,0 +1,42 @@ +""" +Update an execution policy returns "OK" response +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.execution_policy_api import ExecutionPolicyApi +from datadog_api_client.v2.model.execution_policy_action_pattern import ExecutionPolicyActionPattern +from datadog_api_client.v2.model.execution_policy_effect import ExecutionPolicyEffect +from datadog_api_client.v2.model.execution_policy_integration import ExecutionPolicyIntegration +from datadog_api_client.v2.model.execution_policy_type import ExecutionPolicyType +from datadog_api_client.v2.model.execution_policy_update_request import ExecutionPolicyUpdateRequest +from datadog_api_client.v2.model.execution_policy_update_request_data import ExecutionPolicyUpdateRequestData +from datadog_api_client.v2.model.execution_policy_write_attributes import ExecutionPolicyWriteAttributes + +# there is a valid "execution_policy" in the system +EXECUTION_POLICY_DATA_ID = environ["EXECUTION_POLICY_DATA_ID"] + +body = ExecutionPolicyUpdateRequest( + data=ExecutionPolicyUpdateRequestData( + id=EXECUTION_POLICY_DATA_ID, + type=ExecutionPolicyType.EXECUTION_POLICY, + attributes=ExecutionPolicyWriteAttributes( + name="Cassette Execution Policy Updated", + effect=ExecutionPolicyEffect.ALLOW, + action_pattern=ExecutionPolicyActionPattern( + integration=ExecutionPolicyIntegration.INTEGRATION_SCRIPT, + action_fqns=[ + "com.datadoghq.script.*", + ], + ), + ), + ), +) + +configuration = Configuration() +configuration.unstable_operations["update_execution_policy"] = True +with ApiClient(configuration) as api_client: + api_instance = ExecutionPolicyApi(api_client) + response = api_instance.update_execution_policy(policy_id=EXECUTION_POLICY_DATA_ID, body=body) + + print(response) diff --git a/src/datadog_api_client/configuration.py b/src/datadog_api_client/configuration.py index 9c01331488..8ac524a0d0 100644 --- a/src/datadog_api_client/configuration.py +++ b/src/datadog_api_client/configuration.py @@ -326,6 +326,11 @@ def __init__( "v2.upload_llm_obs_dataset_records_file": False, "v2.upsert_llm_obs_annotations": False, "v2.upsert_llm_obs_patterns_config": False, + "v2.create_execution_policy": False, + "v2.delete_execution_policy": False, + "v2.get_execution_policy": False, + "v2.list_execution_policies": False, + "v2.update_execution_policy": False, "v2.create_annotation": False, "v2.delete_annotation": False, "v2.get_page_annotations": False, diff --git a/src/datadog_api_client/v2/api/execution_policy_api.py b/src/datadog_api_client/v2/api/execution_policy_api.py new file mode 100644 index 0000000000..5b61dff57a --- /dev/null +++ b/src/datadog_api_client/v2/api/execution_policy_api.py @@ -0,0 +1,333 @@ +# 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 Any, Dict, List, Union + +from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint +from datadog_api_client.configuration import Configuration +from datadog_api_client.model_utils import ( + UnsetType, + unset, + UUID, +) +from datadog_api_client.v2.model.execution_policy_list_response import ExecutionPolicyListResponse +from datadog_api_client.v2.model.execution_policy_integration import ExecutionPolicyIntegration +from datadog_api_client.v2.model.execution_policy_effect import ExecutionPolicyEffect +from datadog_api_client.v2.model.execution_policy_response import ExecutionPolicyResponse +from datadog_api_client.v2.model.execution_policy_create_request import ExecutionPolicyCreateRequest +from datadog_api_client.v2.model.execution_policy_update_request import ExecutionPolicyUpdateRequest + + +class ExecutionPolicyApi: + """ + 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. + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient(Configuration()) + self.api_client = api_client + + self._create_execution_policy_endpoint = _Endpoint( + settings={ + "response_type": (ExecutionPolicyResponse,), + "auth": ["apiKeyAuth", "appKeyAuth"], + "endpoint_path": "/api/v2/actions/execution-policies", + "operation_id": "create_execution_policy", + "http_method": "POST", + "version": "v2", + }, + params_map={ + "body": { + "required": True, + "openapi_types": (ExecutionPolicyCreateRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + + self._delete_execution_policy_endpoint = _Endpoint( + settings={ + "response_type": None, + "auth": ["apiKeyAuth", "appKeyAuth"], + "endpoint_path": "/api/v2/actions/execution-policies/{policy_id}", + "operation_id": "delete_execution_policy", + "http_method": "DELETE", + "version": "v2", + }, + params_map={ + "policy_id": { + "required": True, + "openapi_types": (UUID,), + "attribute": "policy_id", + "location": "path", + }, + }, + headers_map={ + "accept": ["*/*"], + }, + api_client=api_client, + ) + + self._get_execution_policy_endpoint = _Endpoint( + settings={ + "response_type": (ExecutionPolicyResponse,), + "auth": ["apiKeyAuth", "appKeyAuth"], + "endpoint_path": "/api/v2/actions/execution-policies/{policy_id}", + "operation_id": "get_execution_policy", + "http_method": "GET", + "version": "v2", + }, + params_map={ + "policy_id": { + "required": True, + "openapi_types": (UUID,), + "attribute": "policy_id", + "location": "path", + }, + }, + headers_map={ + "accept": ["application/json"], + }, + api_client=api_client, + ) + + self._list_execution_policies_endpoint = _Endpoint( + settings={ + "response_type": (ExecutionPolicyListResponse,), + "auth": ["apiKeyAuth", "appKeyAuth"], + "endpoint_path": "/api/v2/actions/execution-policies", + "operation_id": "list_execution_policies", + "http_method": "GET", + "version": "v2", + }, + params_map={ + "page_size": { + "validation": { + "inclusive_maximum": 100, + "inclusive_minimum": 1, + }, + "openapi_types": (int,), + "attribute": "page[size]", + "location": "query", + }, + "page_number": { + "validation": { + "inclusive_maximum": 1000, + "inclusive_minimum": 0, + }, + "openapi_types": (int,), + "attribute": "page[number]", + "location": "query", + }, + "filter_name": { + "openapi_types": (str,), + "attribute": "filter[name]", + "location": "query", + }, + "filter_ids": { + "openapi_types": ([str],), + "attribute": "filter[ids]", + "location": "query", + "collection_format": "multi", + }, + "filter_integration": { + "openapi_types": ([ExecutionPolicyIntegration],), + "attribute": "filter[integration]", + "location": "query", + "collection_format": "multi", + }, + "filter_effects": { + "openapi_types": ([ExecutionPolicyEffect],), + "attribute": "filter[effects]", + "location": "query", + "collection_format": "multi", + }, + "filter_creator_ids": { + "openapi_types": ([str],), + "attribute": "filter[creator_ids]", + "location": "query", + "collection_format": "multi", + }, + "sort": { + "openapi_types": ([str],), + "attribute": "sort", + "location": "query", + "collection_format": "multi", + }, + }, + headers_map={ + "accept": ["application/json"], + }, + api_client=api_client, + ) + + self._update_execution_policy_endpoint = _Endpoint( + settings={ + "response_type": (ExecutionPolicyResponse,), + "auth": ["apiKeyAuth", "appKeyAuth"], + "endpoint_path": "/api/v2/actions/execution-policies/{policy_id}", + "operation_id": "update_execution_policy", + "http_method": "PUT", + "version": "v2", + }, + params_map={ + "policy_id": { + "required": True, + "openapi_types": (UUID,), + "attribute": "policy_id", + "location": "path", + }, + "body": { + "required": True, + "openapi_types": (ExecutionPolicyUpdateRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + + def create_execution_policy( + self, + body: ExecutionPolicyCreateRequest, + ) -> ExecutionPolicyResponse: + """Create an execution policy. + + Create a new execution policy. + + :param body: The execution policy to create. + :type body: ExecutionPolicyCreateRequest + :rtype: ExecutionPolicyResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["body"] = body + + return self._create_execution_policy_endpoint.call_with_http_info(**kwargs) + + def delete_execution_policy( + self, + policy_id: UUID, + ) -> None: + """Delete an execution policy. + + Delete a specific execution policy. + + :param policy_id: The ID of the execution policy. + :type policy_id: UUID + :rtype: None + """ + kwargs: Dict[str, Any] = {} + kwargs["policy_id"] = policy_id + + return self._delete_execution_policy_endpoint.call_with_http_info(**kwargs) + + def get_execution_policy( + self, + policy_id: UUID, + ) -> ExecutionPolicyResponse: + """Get an execution policy. + + Retrieve an existing execution policy by ID. + + :param policy_id: The ID of the execution policy. + :type policy_id: UUID + :rtype: ExecutionPolicyResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["policy_id"] = policy_id + + return self._get_execution_policy_endpoint.call_with_http_info(**kwargs) + + def list_execution_policies( + self, + *, + page_size: Union[int, UnsetType] = unset, + page_number: Union[int, UnsetType] = unset, + filter_name: Union[str, UnsetType] = unset, + filter_ids: Union[List[str], UnsetType] = unset, + filter_integration: Union[List[ExecutionPolicyIntegration], UnsetType] = unset, + filter_effects: Union[List[ExecutionPolicyEffect], UnsetType] = unset, + filter_creator_ids: Union[List[str], UnsetType] = unset, + sort: Union[List[str], UnsetType] = unset, + ) -> ExecutionPolicyListResponse: + """List execution policies. + + Retrieve a list of execution policies for the current organization. + + :param page_size: The number of execution policies to return per page. + :type page_size: int, optional + :param page_number: The page number to return. + :type page_number: int, optional + :param filter_name: Filter execution policies by name. + :type filter_name: str, optional + :param filter_ids: Filter execution policies by a list of IDs. + :type filter_ids: [str], optional + :param filter_integration: Filter execution policies by a list of integrations. + :type filter_integration: [ExecutionPolicyIntegration], optional + :param filter_effects: Filter execution policies by a list of effects. + :type filter_effects: [ExecutionPolicyEffect], optional + :param filter_creator_ids: Filter execution policies by a list of creator IDs. + :type filter_creator_ids: [str], optional + :param sort: The sort order for the results. Prefix a field with ``-`` to sort in + descending order. Valid fields are ``name`` , ``effect`` , ``integration`` , + ``created_at`` , and ``updated_at``. + :type sort: [str], optional + :rtype: ExecutionPolicyListResponse + """ + kwargs: Dict[str, Any] = {} + if page_size is not unset: + kwargs["page_size"] = page_size + + if page_number is not unset: + kwargs["page_number"] = page_number + + if filter_name is not unset: + kwargs["filter_name"] = filter_name + + if filter_ids is not unset: + kwargs["filter_ids"] = filter_ids + + if filter_integration is not unset: + kwargs["filter_integration"] = filter_integration + + if filter_effects is not unset: + kwargs["filter_effects"] = filter_effects + + if filter_creator_ids is not unset: + kwargs["filter_creator_ids"] = filter_creator_ids + + if sort is not unset: + kwargs["sort"] = sort + + return self._list_execution_policies_endpoint.call_with_http_info(**kwargs) + + def update_execution_policy( + self, + policy_id: UUID, + body: ExecutionPolicyUpdateRequest, + ) -> ExecutionPolicyResponse: + """Update an execution policy. + + Update an existing execution policy. + Returns the execution policy object when the request is successful. + + :param policy_id: The ID of the execution policy. + :type policy_id: UUID + :param body: The new execution policy. + :type body: ExecutionPolicyUpdateRequest + :rtype: ExecutionPolicyResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["policy_id"] = policy_id + + kwargs["body"] = body + + return self._update_execution_policy_endpoint.call_with_http_info(**kwargs) diff --git a/src/datadog_api_client/v2/apis/__init__.py b/src/datadog_api_client/v2/apis/__init__.py index 4b206c9efa..ca86ad5591 100644 --- a/src/datadog_api_client/v2/apis/__init__.py +++ b/src/datadog_api_client/v2/apis/__init__.py @@ -51,6 +51,7 @@ from datadog_api_client.v2.api.entity_risk_scores_api import EntityRiskScoresApi from datadog_api_client.v2.api.error_tracking_api import ErrorTrackingApi from datadog_api_client.v2.api.events_api import EventsApi +from datadog_api_client.v2.api.execution_policy_api import ExecutionPolicyApi from datadog_api_client.v2.api.fastly_integration_api import FastlyIntegrationApi from datadog_api_client.v2.api.feature_flags_api import FeatureFlagsApi from datadog_api_client.v2.api.fleet_automation_api import FleetAutomationApi @@ -194,6 +195,7 @@ "EntityRiskScoresApi", "ErrorTrackingApi", "EventsApi", + "ExecutionPolicyApi", "FastlyIntegrationApi", "FeatureFlagsApi", "FleetAutomationApi", diff --git a/src/datadog_api_client/v2/model/execution_policy_action_pattern.py b/src/datadog_api_client/v2/model/execution_policy_action_pattern.py new file mode 100644 index 0000000000..fa16396aa9 --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_action_pattern.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, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.execution_policy_integration import ExecutionPolicyIntegration + + +class ExecutionPolicyActionPattern(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.execution_policy_integration import ExecutionPolicyIntegration + + return { + "action_fqns": ([str],), + "integration": (ExecutionPolicyIntegration,), + } + + attribute_map = { + "action_fqns": "action_fqns", + "integration": "integration", + } + + def __init__(self_, action_fqns: List[str], integration: ExecutionPolicyIntegration, **kwargs): + """ + The set of actions this policy applies to. + + :param action_fqns: The fully qualified action names this policy matches. Use ``*`` to match all actions + of the integration, or a fully qualified name prefixed with the integration's action + namespace (for example ``com.datadoghq.script.*`` for the Script integration). + :type action_fqns: [str] + + :param integration: The integration the action pattern applies to. + :type integration: ExecutionPolicyIntegration + """ + super().__init__(kwargs) + + self_.action_fqns = action_fqns + self_.integration = integration diff --git a/src/datadog_api_client/v2/model/execution_policy_attributes.py b/src/datadog_api_client/v2/model/execution_policy_attributes.py new file mode 100644 index 0000000000..2b518b0e23 --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_attributes.py @@ -0,0 +1,124 @@ +# 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, + datetime, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.execution_policy_action_pattern import ExecutionPolicyActionPattern + from datadog_api_client.v2.model.execution_policy_effect import ExecutionPolicyEffect + from datadog_api_client.v2.model.execution_policy_scope import ExecutionPolicyScope + from datadog_api_client.v2.model.execution_policy_target import ExecutionPolicyTarget + + +class ExecutionPolicyAttributes(ModelNormal): + validations = { + "version": { + "inclusive_maximum": 2147483647, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.execution_policy_action_pattern import ExecutionPolicyActionPattern + from datadog_api_client.v2.model.execution_policy_effect import ExecutionPolicyEffect + from datadog_api_client.v2.model.execution_policy_scope import ExecutionPolicyScope + from datadog_api_client.v2.model.execution_policy_target import ExecutionPolicyTarget + + return { + "action_pattern": (ExecutionPolicyActionPattern,), + "created_at": (datetime,), + "created_by": (str,), + "effect": (ExecutionPolicyEffect,), + "name": (str,), + "scope": (ExecutionPolicyScope,), + "targets": ([ExecutionPolicyTarget],), + "updated_at": (datetime,), + "updated_by": (str,), + "version": (int,), + } + + attribute_map = { + "action_pattern": "action_pattern", + "created_at": "created_at", + "created_by": "created_by", + "effect": "effect", + "name": "name", + "scope": "scope", + "targets": "targets", + "updated_at": "updated_at", + "updated_by": "updated_by", + "version": "version", + } + + def __init__( + self_, + action_pattern: ExecutionPolicyActionPattern, + created_at: datetime, + created_by: str, + effect: ExecutionPolicyEffect, + name: str, + targets: List[ExecutionPolicyTarget], + updated_at: datetime, + updated_by: str, + version: int, + scope: Union[ExecutionPolicyScope, UnsetType] = unset, + **kwargs, + ): + """ + An execution policy. + + :param action_pattern: The set of actions this policy applies to. + :type action_pattern: ExecutionPolicyActionPattern + + :param created_at: The date and time the execution policy was created. + :type created_at: datetime + + :param created_by: The ID of the user who created the execution policy. + :type created_by: str + + :param effect: Whether the policy allows or denies matching actions. + :type effect: ExecutionPolicyEffect + + :param name: The name of the execution policy. + :type name: str + + :param scope: Restricts where the policy applies. Exactly one of ``kubernetes`` , ``scripts`` , + or ``remote_action_rshell`` can be set. + :type scope: ExecutionPolicyScope, optional + + :param targets: The targets this policy applies to. + :type targets: [ExecutionPolicyTarget] + + :param updated_at: The date and time the execution policy was last updated. + :type updated_at: datetime + + :param updated_by: The ID of the user who last updated the execution policy. + :type updated_by: str + + :param version: The version of the execution policy. Incremented on every update. + :type version: int + """ + if scope is not unset: + kwargs["scope"] = scope + super().__init__(kwargs) + + self_.action_pattern = action_pattern + self_.created_at = created_at + self_.created_by = created_by + self_.effect = effect + self_.name = name + self_.targets = targets + self_.updated_at = updated_at + self_.updated_by = updated_by + self_.version = version diff --git a/src/datadog_api_client/v2/model/execution_policy_create_request.py b/src/datadog_api_client/v2/model/execution_policy_create_request.py new file mode 100644 index 0000000000..1a3b7fc53a --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_create_request.py @@ -0,0 +1,40 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.execution_policy_create_request_data import ExecutionPolicyCreateRequestData + + +class ExecutionPolicyCreateRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.execution_policy_create_request_data import ExecutionPolicyCreateRequestData + + return { + "data": (ExecutionPolicyCreateRequestData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: ExecutionPolicyCreateRequestData, **kwargs): + """ + Request object that includes the execution policy to create. + + :param data: Object for a single execution policy. + :type data: ExecutionPolicyCreateRequestData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/execution_policy_create_request_data.py b/src/datadog_api_client/v2/model/execution_policy_create_request_data.py new file mode 100644 index 0000000000..df4e7a7f36 --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_create_request_data.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 TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.execution_policy_write_attributes import ExecutionPolicyWriteAttributes + from datadog_api_client.v2.model.execution_policy_type import ExecutionPolicyType + + +class ExecutionPolicyCreateRequestData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.execution_policy_write_attributes import ExecutionPolicyWriteAttributes + from datadog_api_client.v2.model.execution_policy_type import ExecutionPolicyType + + return { + "attributes": (ExecutionPolicyWriteAttributes,), + "type": (ExecutionPolicyType,), + } + + attribute_map = { + "attributes": "attributes", + "type": "type", + } + + def __init__(self_, attributes: ExecutionPolicyWriteAttributes, type: ExecutionPolicyType, **kwargs): + """ + Object for a single execution policy. + + :param attributes: Attributes used to create or update an execution policy. + :type attributes: ExecutionPolicyWriteAttributes + + :param type: The type of the resource. The value should always be ``execution_policy``. + :type type: ExecutionPolicyType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.type = type diff --git a/src/datadog_api_client/v2/model/execution_policy_effect.py b/src/datadog_api_client/v2/model/execution_policy_effect.py new file mode 100644 index 0000000000..e7f6135b8f --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_effect.py @@ -0,0 +1,38 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class ExecutionPolicyEffect(ModelSimple): + """ + Whether the policy allows or denies matching actions. + + :param value: Must be one of ["allow", "deny"]. + :type value: str + """ + + allowed_values = { + "allow", + "deny", + } + ALLOW: ClassVar["ExecutionPolicyEffect"] + DENY: ClassVar["ExecutionPolicyEffect"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +ExecutionPolicyEffect.ALLOW = ExecutionPolicyEffect("allow") +ExecutionPolicyEffect.DENY = ExecutionPolicyEffect("deny") diff --git a/src/datadog_api_client/v2/model/execution_policy_integration.py b/src/datadog_api_client/v2/model/execution_policy_integration.py new file mode 100644 index 0000000000..b6182fcfcd --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_integration.py @@ -0,0 +1,41 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class ExecutionPolicyIntegration(ModelSimple): + """ + The integration the action pattern applies to. + + :param value: Must be one of ["INTEGRATION_KUBERNETES", "INTEGRATION_SCRIPT", "INTEGRATION_REMOTE_ACTION"]. + :type value: str + """ + + allowed_values = { + "INTEGRATION_KUBERNETES", + "INTEGRATION_SCRIPT", + "INTEGRATION_REMOTE_ACTION", + } + INTEGRATION_KUBERNETES: ClassVar["ExecutionPolicyIntegration"] + INTEGRATION_SCRIPT: ClassVar["ExecutionPolicyIntegration"] + INTEGRATION_REMOTE_ACTION: ClassVar["ExecutionPolicyIntegration"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +ExecutionPolicyIntegration.INTEGRATION_KUBERNETES = ExecutionPolicyIntegration("INTEGRATION_KUBERNETES") +ExecutionPolicyIntegration.INTEGRATION_SCRIPT = ExecutionPolicyIntegration("INTEGRATION_SCRIPT") +ExecutionPolicyIntegration.INTEGRATION_REMOTE_ACTION = ExecutionPolicyIntegration("INTEGRATION_REMOTE_ACTION") diff --git a/src/datadog_api_client/v2/model/execution_policy_kubernetes_scope.py b/src/datadog_api_client/v2/model/execution_policy_kubernetes_scope.py new file mode 100644 index 0000000000..59250ac19e --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_kubernetes_scope.py @@ -0,0 +1,42 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.execution_policy_kubernetes_scope_rule import ExecutionPolicyKubernetesScopeRule + + +class ExecutionPolicyKubernetesScope(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.execution_policy_kubernetes_scope_rule import ( + ExecutionPolicyKubernetesScopeRule, + ) + + return { + "rules": ([ExecutionPolicyKubernetesScopeRule],), + } + + attribute_map = { + "rules": "rules", + } + + def __init__(self_, rules: List[ExecutionPolicyKubernetesScopeRule], **kwargs): + """ + Restricts the policy to specific Kubernetes namespaces. + + :param rules: The Kubernetes scope rules. + :type rules: [ExecutionPolicyKubernetesScopeRule] + """ + super().__init__(kwargs) + + self_.rules = rules diff --git a/src/datadog_api_client/v2/model/execution_policy_kubernetes_scope_rule.py b/src/datadog_api_client/v2/model/execution_policy_kubernetes_scope_rule.py new file mode 100644 index 0000000000..f6d6958265 --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_kubernetes_scope_rule.py @@ -0,0 +1,34 @@ +# 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 ExecutionPolicyKubernetesScopeRule(ModelNormal): + @cached_property + def openapi_types(_): + return { + "target_namespaces": ([str],), + } + + attribute_map = { + "target_namespaces": "target_namespaces", + } + + def __init__(self_, target_namespaces: List[str], **kwargs): + """ + A rule restricting a Kubernetes scope to specific namespaces. + + :param target_namespaces: The Kubernetes namespaces this rule applies to. + :type target_namespaces: [str] + """ + super().__init__(kwargs) + + self_.target_namespaces = target_namespaces diff --git a/src/datadog_api_client/v2/model/execution_policy_list_response.py b/src/datadog_api_client/v2/model/execution_policy_list_response.py new file mode 100644 index 0000000000..1217e5b195 --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_list_response.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, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.execution_policy_response_data import ExecutionPolicyResponseData + from datadog_api_client.v2.model.execution_policy_list_response_meta import ExecutionPolicyListResponseMeta + + +class ExecutionPolicyListResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.execution_policy_response_data import ExecutionPolicyResponseData + from datadog_api_client.v2.model.execution_policy_list_response_meta import ExecutionPolicyListResponseMeta + + return { + "data": ([ExecutionPolicyResponseData],), + "meta": (ExecutionPolicyListResponseMeta,), + } + + attribute_map = { + "data": "data", + "meta": "meta", + } + + def __init__(self_, data: List[ExecutionPolicyResponseData], meta: ExecutionPolicyListResponseMeta, **kwargs): + """ + Response object that includes a list of execution policies. + + :param data: The execution policies. + :type data: [ExecutionPolicyResponseData] + + :param meta: Pagination metadata for the list of execution policies. + :type meta: ExecutionPolicyListResponseMeta + """ + super().__init__(kwargs) + + self_.data = data + self_.meta = meta diff --git a/src/datadog_api_client/v2/model/execution_policy_list_response_meta.py b/src/datadog_api_client/v2/model/execution_policy_list_response_meta.py new file mode 100644 index 0000000000..075f4ba8ef --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_list_response_meta.py @@ -0,0 +1,40 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.execution_policy_list_response_page import ExecutionPolicyListResponsePage + + +class ExecutionPolicyListResponseMeta(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.execution_policy_list_response_page import ExecutionPolicyListResponsePage + + return { + "page": (ExecutionPolicyListResponsePage,), + } + + attribute_map = { + "page": "page", + } + + def __init__(self_, page: ExecutionPolicyListResponsePage, **kwargs): + """ + Pagination metadata for the list of execution policies. + + :param page: Pagination details. + :type page: ExecutionPolicyListResponsePage + """ + super().__init__(kwargs) + + self_.page = page diff --git a/src/datadog_api_client/v2/model/execution_policy_list_response_page.py b/src/datadog_api_client/v2/model/execution_policy_list_response_page.py new file mode 100644 index 0000000000..7875212df1 --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_list_response_page.py @@ -0,0 +1,39 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +class ExecutionPolicyListResponsePage(ModelNormal): + validations = { + "total": { + "inclusive_maximum": 2147483647, + }, + } + + @cached_property + def openapi_types(_): + return { + "total": (int,), + } + + attribute_map = { + "total": "total", + } + + def __init__(self_, total: int, **kwargs): + """ + Pagination details. + + :param total: The total number of execution policies matching the query. + :type total: int + """ + super().__init__(kwargs) + + self_.total = total diff --git a/src/datadog_api_client/v2/model/execution_policy_remote_action_rshell_access.py b/src/datadog_api_client/v2/model/execution_policy_remote_action_rshell_access.py new file mode 100644 index 0000000000..407a890a76 --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_remote_action_rshell_access.py @@ -0,0 +1,38 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class ExecutionPolicyRemoteActionRshellAccess(ModelSimple): + """ + The level of remote shell access granted for the target paths. + + :param value: Must be one of ["read_only", "read_write"]. + :type value: str + """ + + allowed_values = { + "read_only", + "read_write", + } + READ_ONLY: ClassVar["ExecutionPolicyRemoteActionRshellAccess"] + READ_WRITE: ClassVar["ExecutionPolicyRemoteActionRshellAccess"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +ExecutionPolicyRemoteActionRshellAccess.READ_ONLY = ExecutionPolicyRemoteActionRshellAccess("read_only") +ExecutionPolicyRemoteActionRshellAccess.READ_WRITE = ExecutionPolicyRemoteActionRshellAccess("read_write") diff --git a/src/datadog_api_client/v2/model/execution_policy_remote_action_rshell_scope.py b/src/datadog_api_client/v2/model/execution_policy_remote_action_rshell_scope.py new file mode 100644 index 0000000000..e3d41a810b --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_remote_action_rshell_scope.py @@ -0,0 +1,44 @@ +# 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, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.execution_policy_remote_action_rshell_scope_rule import ( + ExecutionPolicyRemoteActionRshellScopeRule, + ) + + +class ExecutionPolicyRemoteActionRshellScope(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.execution_policy_remote_action_rshell_scope_rule import ( + ExecutionPolicyRemoteActionRshellScopeRule, + ) + + return { + "rules": ([ExecutionPolicyRemoteActionRshellScopeRule],), + } + + attribute_map = { + "rules": "rules", + } + + def __init__(self_, rules: List[ExecutionPolicyRemoteActionRshellScopeRule], **kwargs): + """ + Restricts the policy to specific remote shell paths. + + :param rules: The remote shell scope rules. + :type rules: [ExecutionPolicyRemoteActionRshellScopeRule] + """ + super().__init__(kwargs) + + self_.rules = rules diff --git a/src/datadog_api_client/v2/model/execution_policy_remote_action_rshell_scope_rule.py b/src/datadog_api_client/v2/model/execution_policy_remote_action_rshell_scope_rule.py new file mode 100644 index 0000000000..0cc7e8b2fd --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_remote_action_rshell_scope_rule.py @@ -0,0 +1,50 @@ +# 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, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.execution_policy_remote_action_rshell_access import ( + ExecutionPolicyRemoteActionRshellAccess, + ) + + +class ExecutionPolicyRemoteActionRshellScopeRule(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.execution_policy_remote_action_rshell_access import ( + ExecutionPolicyRemoteActionRshellAccess, + ) + + return { + "access": (ExecutionPolicyRemoteActionRshellAccess,), + "target_paths": ([str],), + } + + attribute_map = { + "access": "access", + "target_paths": "target_paths", + } + + def __init__(self_, access: ExecutionPolicyRemoteActionRshellAccess, target_paths: List[str], **kwargs): + """ + A rule restricting remote shell access to specific paths. + + :param access: The level of remote shell access granted for the target paths. + :type access: ExecutionPolicyRemoteActionRshellAccess + + :param target_paths: The file system paths this rule applies to. + :type target_paths: [str] + """ + super().__init__(kwargs) + + self_.access = access + self_.target_paths = target_paths diff --git a/src/datadog_api_client/v2/model/execution_policy_response.py b/src/datadog_api_client/v2/model/execution_policy_response.py new file mode 100644 index 0000000000..7764e8cd12 --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_response.py @@ -0,0 +1,40 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.execution_policy_response_data import ExecutionPolicyResponseData + + +class ExecutionPolicyResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.execution_policy_response_data import ExecutionPolicyResponseData + + return { + "data": (ExecutionPolicyResponseData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: ExecutionPolicyResponseData, **kwargs): + """ + Response object that includes a single execution policy. + + :param data: Object for a single execution policy. + :type data: ExecutionPolicyResponseData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/execution_policy_response_data.py b/src/datadog_api_client/v2/model/execution_policy_response_data.py new file mode 100644 index 0000000000..84607f9ac3 --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_response_data.py @@ -0,0 +1,57 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.execution_policy_attributes import ExecutionPolicyAttributes + from datadog_api_client.v2.model.execution_policy_type import ExecutionPolicyType + + +class ExecutionPolicyResponseData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.execution_policy_attributes import ExecutionPolicyAttributes + from datadog_api_client.v2.model.execution_policy_type import ExecutionPolicyType + + return { + "attributes": (ExecutionPolicyAttributes,), + "id": (str,), + "type": (ExecutionPolicyType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + read_only_vars = { + "id", + } + + def __init__(self_, attributes: ExecutionPolicyAttributes, id: str, type: ExecutionPolicyType, **kwargs): + """ + Object for a single execution policy. + + :param attributes: An execution policy. + :type attributes: ExecutionPolicyAttributes + + :param id: The ID of the execution policy. + :type id: str + + :param type: The type of the resource. The value should always be ``execution_policy``. + :type type: ExecutionPolicyType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/execution_policy_scope.py b/src/datadog_api_client/v2/model/execution_policy_scope.py new file mode 100644 index 0000000000..39113b4f8c --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_scope.py @@ -0,0 +1,71 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.execution_policy_kubernetes_scope import ExecutionPolicyKubernetesScope + from datadog_api_client.v2.model.execution_policy_remote_action_rshell_scope import ( + ExecutionPolicyRemoteActionRshellScope, + ) + from datadog_api_client.v2.model.execution_policy_script_scope import ExecutionPolicyScriptScope + + +class ExecutionPolicyScope(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.execution_policy_kubernetes_scope import ExecutionPolicyKubernetesScope + from datadog_api_client.v2.model.execution_policy_remote_action_rshell_scope import ( + ExecutionPolicyRemoteActionRshellScope, + ) + from datadog_api_client.v2.model.execution_policy_script_scope import ExecutionPolicyScriptScope + + return { + "kubernetes": (ExecutionPolicyKubernetesScope,), + "remote_action_rshell": (ExecutionPolicyRemoteActionRshellScope,), + "scripts": (ExecutionPolicyScriptScope,), + } + + attribute_map = { + "kubernetes": "kubernetes", + "remote_action_rshell": "remote_action_rshell", + "scripts": "scripts", + } + + def __init__( + self_, + kubernetes: Union[ExecutionPolicyKubernetesScope, UnsetType] = unset, + remote_action_rshell: Union[ExecutionPolicyRemoteActionRshellScope, UnsetType] = unset, + scripts: Union[ExecutionPolicyScriptScope, UnsetType] = unset, + **kwargs, + ): + """ + Restricts where the policy applies. Exactly one of ``kubernetes`` , ``scripts`` , + or ``remote_action_rshell`` can be set. + + :param kubernetes: Restricts the policy to specific Kubernetes namespaces. + :type kubernetes: ExecutionPolicyKubernetesScope, optional + + :param remote_action_rshell: Restricts the policy to specific remote shell paths. + :type remote_action_rshell: ExecutionPolicyRemoteActionRshellScope, optional + + :param scripts: Restricts the policy to specific scripts. + :type scripts: ExecutionPolicyScriptScope, optional + """ + if kubernetes is not unset: + kwargs["kubernetes"] = kubernetes + if remote_action_rshell is not unset: + kwargs["remote_action_rshell"] = remote_action_rshell + if scripts is not unset: + kwargs["scripts"] = scripts + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/execution_policy_script_scope.py b/src/datadog_api_client/v2/model/execution_policy_script_scope.py new file mode 100644 index 0000000000..094aa0d9c2 --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_script_scope.py @@ -0,0 +1,40 @@ +# 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, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.execution_policy_script_scope_rule import ExecutionPolicyScriptScopeRule + + +class ExecutionPolicyScriptScope(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.execution_policy_script_scope_rule import ExecutionPolicyScriptScopeRule + + return { + "rules": ([ExecutionPolicyScriptScopeRule],), + } + + attribute_map = { + "rules": "rules", + } + + def __init__(self_, rules: List[ExecutionPolicyScriptScopeRule], **kwargs): + """ + Restricts the policy to specific scripts. + + :param rules: The script scope rules. + :type rules: [ExecutionPolicyScriptScopeRule] + """ + super().__init__(kwargs) + + self_.rules = rules diff --git a/src/datadog_api_client/v2/model/execution_policy_script_scope_rule.py b/src/datadog_api_client/v2/model/execution_policy_script_scope_rule.py new file mode 100644 index 0000000000..de5c565cf2 --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_script_scope_rule.py @@ -0,0 +1,34 @@ +# 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 ExecutionPolicyScriptScopeRule(ModelNormal): + @cached_property + def openapi_types(_): + return { + "target_script_names": ([str],), + } + + attribute_map = { + "target_script_names": "target_script_names", + } + + def __init__(self_, target_script_names: List[str], **kwargs): + """ + A rule restricting a script scope to specific script names. + + :param target_script_names: The script names this rule applies to. + :type target_script_names: [str] + """ + super().__init__(kwargs) + + self_.target_script_names = target_script_names diff --git a/src/datadog_api_client/v2/model/execution_policy_target.py b/src/datadog_api_client/v2/model/execution_policy_target.py new file mode 100644 index 0000000000..c9b652c679 --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_target.py @@ -0,0 +1,44 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + none_type, + unset, + UnsetType, +) + + +class ExecutionPolicyTarget(ModelNormal): + @cached_property + def openapi_types(_): + return { + "agent_tags": ([str],), + "name": (str, none_type), + } + + attribute_map = { + "agent_tags": "agent_tags", + "name": "name", + } + + def __init__(self_, agent_tags: List[str], name: Union[str, none_type, UnsetType] = unset, **kwargs): + """ + A target this policy is scoped to, expressed as a set of Agent tags. + + :param agent_tags: The Agent tags identifying the target. + :type agent_tags: [str] + + :param name: A human-readable name for the target. + :type name: str, none_type, optional + """ + if name is not unset: + kwargs["name"] = name + super().__init__(kwargs) + + self_.agent_tags = agent_tags diff --git a/src/datadog_api_client/v2/model/execution_policy_type.py b/src/datadog_api_client/v2/model/execution_policy_type.py new file mode 100644 index 0000000000..83387f8040 --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_type.py @@ -0,0 +1,35 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class ExecutionPolicyType(ModelSimple): + """ + The type of the resource. The value should always be `execution_policy`. + + :param value: If omitted defaults to "execution_policy". Must be one of ["execution_policy"]. + :type value: str + """ + + allowed_values = { + "execution_policy", + } + EXECUTION_POLICY: ClassVar["ExecutionPolicyType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +ExecutionPolicyType.EXECUTION_POLICY = ExecutionPolicyType("execution_policy") diff --git a/src/datadog_api_client/v2/model/execution_policy_update_request.py b/src/datadog_api_client/v2/model/execution_policy_update_request.py new file mode 100644 index 0000000000..371ca9ae36 --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_update_request.py @@ -0,0 +1,40 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.execution_policy_update_request_data import ExecutionPolicyUpdateRequestData + + +class ExecutionPolicyUpdateRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.execution_policy_update_request_data import ExecutionPolicyUpdateRequestData + + return { + "data": (ExecutionPolicyUpdateRequestData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: ExecutionPolicyUpdateRequestData, **kwargs): + """ + Request object that includes the execution policy to update. + + :param data: Object for a single execution policy. + :type data: ExecutionPolicyUpdateRequestData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/execution_policy_update_request_data.py b/src/datadog_api_client/v2/model/execution_policy_update_request_data.py new file mode 100644 index 0000000000..cc468c27eb --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_update_request_data.py @@ -0,0 +1,54 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.execution_policy_write_attributes import ExecutionPolicyWriteAttributes + from datadog_api_client.v2.model.execution_policy_type import ExecutionPolicyType + + +class ExecutionPolicyUpdateRequestData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.execution_policy_write_attributes import ExecutionPolicyWriteAttributes + from datadog_api_client.v2.model.execution_policy_type import ExecutionPolicyType + + return { + "attributes": (ExecutionPolicyWriteAttributes,), + "id": (str,), + "type": (ExecutionPolicyType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__(self_, attributes: ExecutionPolicyWriteAttributes, id: str, type: ExecutionPolicyType, **kwargs): + """ + Object for a single execution policy. + + :param attributes: Attributes used to create or update an execution policy. + :type attributes: ExecutionPolicyWriteAttributes + + :param id: The ID of the execution policy. + :type id: str + + :param type: The type of the resource. The value should always be ``execution_policy``. + :type type: ExecutionPolicyType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/execution_policy_write_attributes.py b/src/datadog_api_client/v2/model/execution_policy_write_attributes.py new file mode 100644 index 0000000000..43c1221e00 --- /dev/null +++ b/src/datadog_api_client/v2/model/execution_policy_write_attributes.py @@ -0,0 +1,83 @@ +# 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.execution_policy_action_pattern import ExecutionPolicyActionPattern + from datadog_api_client.v2.model.execution_policy_effect import ExecutionPolicyEffect + from datadog_api_client.v2.model.execution_policy_scope import ExecutionPolicyScope + from datadog_api_client.v2.model.execution_policy_target import ExecutionPolicyTarget + + +class ExecutionPolicyWriteAttributes(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.execution_policy_action_pattern import ExecutionPolicyActionPattern + from datadog_api_client.v2.model.execution_policy_effect import ExecutionPolicyEffect + from datadog_api_client.v2.model.execution_policy_scope import ExecutionPolicyScope + from datadog_api_client.v2.model.execution_policy_target import ExecutionPolicyTarget + + return { + "action_pattern": (ExecutionPolicyActionPattern,), + "effect": (ExecutionPolicyEffect,), + "name": (str,), + "scope": (ExecutionPolicyScope,), + "targets": ([ExecutionPolicyTarget],), + } + + attribute_map = { + "action_pattern": "action_pattern", + "effect": "effect", + "name": "name", + "scope": "scope", + "targets": "targets", + } + + def __init__( + self_, + action_pattern: ExecutionPolicyActionPattern, + effect: ExecutionPolicyEffect, + name: str, + scope: Union[ExecutionPolicyScope, UnsetType] = unset, + targets: Union[List[ExecutionPolicyTarget], UnsetType] = unset, + **kwargs, + ): + """ + Attributes used to create or update an execution policy. + + :param action_pattern: The set of actions this policy applies to. + :type action_pattern: ExecutionPolicyActionPattern + + :param effect: Whether the policy allows or denies matching actions. + :type effect: ExecutionPolicyEffect + + :param name: The name of the execution policy. + :type name: str + + :param scope: Restricts where the policy applies. Exactly one of ``kubernetes`` , ``scripts`` , + or ``remote_action_rshell`` can be set. + :type scope: ExecutionPolicyScope, optional + + :param targets: The targets this policy applies to. + :type targets: [ExecutionPolicyTarget], optional + """ + if scope is not unset: + kwargs["scope"] = scope + if targets is not unset: + kwargs["targets"] = targets + super().__init__(kwargs) + + self_.action_pattern = action_pattern + self_.effect = effect + self_.name = name diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 7200f76674..a5c154584b 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -2936,6 +2936,36 @@ from datadog_api_client.v2.model.events_sort_type import EventsSortType from datadog_api_client.v2.model.events_timeseries_query import EventsTimeseriesQuery from datadog_api_client.v2.model.events_warning import EventsWarning +from datadog_api_client.v2.model.execution_policy_action_pattern import ExecutionPolicyActionPattern +from datadog_api_client.v2.model.execution_policy_attributes import ExecutionPolicyAttributes +from datadog_api_client.v2.model.execution_policy_create_request import ExecutionPolicyCreateRequest +from datadog_api_client.v2.model.execution_policy_create_request_data import ExecutionPolicyCreateRequestData +from datadog_api_client.v2.model.execution_policy_effect import ExecutionPolicyEffect +from datadog_api_client.v2.model.execution_policy_integration import ExecutionPolicyIntegration +from datadog_api_client.v2.model.execution_policy_kubernetes_scope import ExecutionPolicyKubernetesScope +from datadog_api_client.v2.model.execution_policy_kubernetes_scope_rule import ExecutionPolicyKubernetesScopeRule +from datadog_api_client.v2.model.execution_policy_list_response import ExecutionPolicyListResponse +from datadog_api_client.v2.model.execution_policy_list_response_meta import ExecutionPolicyListResponseMeta +from datadog_api_client.v2.model.execution_policy_list_response_page import ExecutionPolicyListResponsePage +from datadog_api_client.v2.model.execution_policy_remote_action_rshell_access import ( + ExecutionPolicyRemoteActionRshellAccess, +) +from datadog_api_client.v2.model.execution_policy_remote_action_rshell_scope import ( + ExecutionPolicyRemoteActionRshellScope, +) +from datadog_api_client.v2.model.execution_policy_remote_action_rshell_scope_rule import ( + ExecutionPolicyRemoteActionRshellScopeRule, +) +from datadog_api_client.v2.model.execution_policy_response import ExecutionPolicyResponse +from datadog_api_client.v2.model.execution_policy_response_data import ExecutionPolicyResponseData +from datadog_api_client.v2.model.execution_policy_scope import ExecutionPolicyScope +from datadog_api_client.v2.model.execution_policy_script_scope import ExecutionPolicyScriptScope +from datadog_api_client.v2.model.execution_policy_script_scope_rule import ExecutionPolicyScriptScopeRule +from datadog_api_client.v2.model.execution_policy_target import ExecutionPolicyTarget +from datadog_api_client.v2.model.execution_policy_type import ExecutionPolicyType +from datadog_api_client.v2.model.execution_policy_update_request import ExecutionPolicyUpdateRequest +from datadog_api_client.v2.model.execution_policy_update_request_data import ExecutionPolicyUpdateRequestData +from datadog_api_client.v2.model.execution_policy_write_attributes import ExecutionPolicyWriteAttributes from datadog_api_client.v2.model.exposure_rollout_step_request import ExposureRolloutStepRequest from datadog_api_client.v2.model.exposure_schedule_request import ExposureScheduleRequest from datadog_api_client.v2.model.facet_info_request import FacetInfoRequest @@ -12766,6 +12796,30 @@ "EventsSortType", "EventsTimeseriesQuery", "EventsWarning", + "ExecutionPolicyActionPattern", + "ExecutionPolicyAttributes", + "ExecutionPolicyCreateRequest", + "ExecutionPolicyCreateRequestData", + "ExecutionPolicyEffect", + "ExecutionPolicyIntegration", + "ExecutionPolicyKubernetesScope", + "ExecutionPolicyKubernetesScopeRule", + "ExecutionPolicyListResponse", + "ExecutionPolicyListResponseMeta", + "ExecutionPolicyListResponsePage", + "ExecutionPolicyRemoteActionRshellAccess", + "ExecutionPolicyRemoteActionRshellScope", + "ExecutionPolicyRemoteActionRshellScopeRule", + "ExecutionPolicyResponse", + "ExecutionPolicyResponseData", + "ExecutionPolicyScope", + "ExecutionPolicyScriptScope", + "ExecutionPolicyScriptScopeRule", + "ExecutionPolicyTarget", + "ExecutionPolicyType", + "ExecutionPolicyUpdateRequest", + "ExecutionPolicyUpdateRequestData", + "ExecutionPolicyWriteAttributes", "ExposureRolloutStepRequest", "ExposureScheduleRequest", "FacetInfoRequest", diff --git a/tests/v2/cassettes/test_scenarios/test_create_an_execution_policy_returns_bad_request_response.frozen b/tests/v2/cassettes/test_scenarios/test_create_an_execution_policy_returns_bad_request_response.frozen new file mode 100644 index 0000000000..424a723c11 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_an_execution_policy_returns_bad_request_response.frozen @@ -0,0 +1 @@ +2026-08-14T09:13:38.368Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_create_an_execution_policy_returns_bad_request_response.yaml b/tests/v2/cassettes/test_scenarios/test_create_an_execution_policy_returns_bad_request_response.yaml new file mode 100644 index 0000000000..ffe72f7b53 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_an_execution_policy_returns_bad_request_response.yaml @@ -0,0 +1,22 @@ +interactions: +- request: + body: '{"data":{"attributes":{"action_pattern":{"action_fqns":["com.datadoghq.script.*"],"integration":"INTEGRATION_SCRIPT"},"effect":"invalid_effect","name":"Cassette + Execution Policy"},"type":"execution_policy"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/actions/execution-policies + response: + body: + string: '{"errors":[{"title":"Generic Error","detail":"error creating execution + policy"}]}' + headers: + content-type: + - application/vnd.api+json + status: + code: 400 + message: Bad Request +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_create_an_execution_policy_returns_created_response.frozen b/tests/v2/cassettes/test_scenarios/test_create_an_execution_policy_returns_created_response.frozen new file mode 100644 index 0000000000..5ed5e8ab87 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_an_execution_policy_returns_created_response.frozen @@ -0,0 +1 @@ +2026-08-14T09:13:38.801Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_create_an_execution_policy_returns_created_response.yaml b/tests/v2/cassettes/test_scenarios/test_create_an_execution_policy_returns_created_response.yaml new file mode 100644 index 0000000000..f04cb209a3 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_an_execution_policy_returns_created_response.yaml @@ -0,0 +1,36 @@ +interactions: +- request: + body: '{"data":{"attributes":{"action_pattern":{"action_fqns":["com.datadoghq.script.*"],"integration":"INTEGRATION_SCRIPT"},"effect":"allow","name":"Cassette + Execution Policy testcreateanexecutionpolicyreturnscreatedresponse1786698818"},"type":"execution_policy"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/actions/execution-policies + response: + body: + string: '{"data":{"id":"78061915-3922-4868-93c5-12a631d74ed1","type":"execution_policy","attributes":{"action_pattern":{"integration":"INTEGRATION_SCRIPT","action_fqns":["com.datadoghq.script.*"]},"created_at":"2026-08-14T09:13:39Z","created_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","effect":"allow","name":"Cassette + Execution Policy testcreateanexecutionpolicyreturnscreatedresponse1786698818","targets":[],"updated_at":"2026-08-14T09:13:39Z","updated_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","version":1}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 201 + message: Created +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/actions/execution-policies/78061915-3922-4868-93c5-12a631d74ed1 + response: + body: + string: '' + headers: {} + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_create_an_execution_policy_with_scope_and_targets_returns_created_response.frozen b/tests/v2/cassettes/test_scenarios/test_create_an_execution_policy_with_scope_and_targets_returns_created_response.frozen new file mode 100644 index 0000000000..f51bfa15b3 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_an_execution_policy_with_scope_and_targets_returns_created_response.frozen @@ -0,0 +1 @@ +2026-08-14T09:13:39.401Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_create_an_execution_policy_with_scope_and_targets_returns_created_response.yaml b/tests/v2/cassettes/test_scenarios/test_create_an_execution_policy_with_scope_and_targets_returns_created_response.yaml new file mode 100644 index 0000000000..72493fce35 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_an_execution_policy_with_scope_and_targets_returns_created_response.yaml @@ -0,0 +1,38 @@ +interactions: +- request: + body: '{"data":{"attributes":{"action_pattern":{"action_fqns":["com.datadoghq.script.*"],"integration":"INTEGRATION_SCRIPT"},"effect":"allow","name":"Cassette + Execution Policy testcreateanexecutionpolicywithscopeandtargetsreturnscreatedresponse1786698819","scope":{"scripts":{"rules":[{"target_script_names":["restart_service.sh"]}]}},"targets":[{"agent_tags":["env:prod"],"name":"Production + hosts"}]},"type":"execution_policy"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/actions/execution-policies + response: + body: + string: '{"data":{"id":"90a83e60-76b3-4064-a240-f65b602bbddd","type":"execution_policy","attributes":{"action_pattern":{"integration":"INTEGRATION_SCRIPT","action_fqns":["com.datadoghq.script.*"]},"created_at":"2026-08-14T09:13:40Z","created_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","effect":"allow","name":"Cassette + Execution Policy testcreateanexecutionpolicywithscopeandtargetsreturnscreatedresponse1786698819","scope":{"scripts":{"rules":[{"target_script_names":["restart_service.sh"]}]}},"targets":[{"agent_tags":["env:prod"],"name":"Production + hosts"}],"updated_at":"2026-08-14T09:13:40Z","updated_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","version":1}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 201 + message: Created +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/actions/execution-policies/90a83e60-76b3-4064-a240-f65b602bbddd + response: + body: + string: '' + headers: {} + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_delete_an_execution_policy_returns_no_content_response.frozen b/tests/v2/cassettes/test_scenarios/test_delete_an_execution_policy_returns_no_content_response.frozen new file mode 100644 index 0000000000..499fef5f16 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_delete_an_execution_policy_returns_no_content_response.frozen @@ -0,0 +1 @@ +2026-08-14T09:13:40.195Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_delete_an_execution_policy_returns_no_content_response.yaml b/tests/v2/cassettes/test_scenarios/test_delete_an_execution_policy_returns_no_content_response.yaml new file mode 100644 index 0000000000..30f377e1a5 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_delete_an_execution_policy_returns_no_content_response.yaml @@ -0,0 +1,53 @@ +interactions: +- request: + body: '{"data":{"attributes":{"action_pattern":{"action_fqns":["com.datadoghq.script.*"],"integration":"INTEGRATION_SCRIPT"},"effect":"allow","name":"Cassette + Execution Policy testdeleteanexecutionpolicyreturnsnocontentresponse1786698820"},"type":"execution_policy"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/actions/execution-policies + response: + body: + string: '{"data":{"id":"a8e55d88-0769-4cb9-b7d9-10f55fc6ecc2","type":"execution_policy","attributes":{"action_pattern":{"integration":"INTEGRATION_SCRIPT","action_fqns":["com.datadoghq.script.*"]},"created_at":"2026-08-14T09:13:41Z","created_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","effect":"allow","name":"Cassette + Execution Policy testdeleteanexecutionpolicyreturnsnocontentresponse1786698820","targets":[],"updated_at":"2026-08-14T09:13:41Z","updated_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","version":1}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 201 + message: Created +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/actions/execution-policies/a8e55d88-0769-4cb9-b7d9-10f55fc6ecc2 + response: + body: + string: '' + headers: {} + status: + code: 204 + message: No Content +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/actions/execution-policies/a8e55d88-0769-4cb9-b7d9-10f55fc6ecc2 + response: + body: + string: '{"errors":[{"title":"Generic Error","detail":"error deleting execution + policy"}]}' + headers: + content-type: + - application/vnd.api+json + status: + code: 404 + message: Not Found +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_delete_an_execution_policy_returns_not_found_response.frozen b/tests/v2/cassettes/test_scenarios/test_delete_an_execution_policy_returns_not_found_response.frozen new file mode 100644 index 0000000000..3c448d019f --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_delete_an_execution_policy_returns_not_found_response.frozen @@ -0,0 +1 @@ +2026-08-14T09:13:41.276Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_delete_an_execution_policy_returns_not_found_response.yaml b/tests/v2/cassettes/test_scenarios/test_delete_an_execution_policy_returns_not_found_response.yaml new file mode 100644 index 0000000000..24b20773fc --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_delete_an_execution_policy_returns_not_found_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/actions/execution-policies/aaa11111-aa11-aa11-aaaa-aaaaaa111111 + response: + body: + string: '{"errors":[{"title":"Generic Error","detail":"error deleting execution + policy"}]}' + headers: + content-type: + - application/vnd.api+json + status: + code: 404 + message: Not Found +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_get_an_execution_policy_returns_not_found_response.frozen b/tests/v2/cassettes/test_scenarios/test_get_an_execution_policy_returns_not_found_response.frozen new file mode 100644 index 0000000000..85555326ef --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_get_an_execution_policy_returns_not_found_response.frozen @@ -0,0 +1 @@ +2026-08-14T09:13:41.623Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_get_an_execution_policy_returns_not_found_response.yaml b/tests/v2/cassettes/test_scenarios/test_get_an_execution_policy_returns_not_found_response.yaml new file mode 100644 index 0000000000..b76f42a0a8 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_get_an_execution_policy_returns_not_found_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: null + headers: + accept: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/actions/execution-policies/aaa11111-aa11-aa11-aaaa-aaaaaa111111 + response: + body: + string: '{"errors":[{"title":"Generic Error","detail":"error getting execution + policy"}]}' + headers: + content-type: + - application/vnd.api+json + status: + code: 404 + message: Not Found +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_get_an_execution_policy_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_get_an_execution_policy_returns_ok_response.frozen new file mode 100644 index 0000000000..c4173bfec7 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_get_an_execution_policy_returns_ok_response.frozen @@ -0,0 +1 @@ +2026-08-14T09:13:41.923Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_get_an_execution_policy_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_get_an_execution_policy_returns_ok_response.yaml new file mode 100644 index 0000000000..649f0e7e56 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_get_an_execution_policy_returns_ok_response.yaml @@ -0,0 +1,53 @@ +interactions: +- request: + body: '{"data":{"attributes":{"action_pattern":{"action_fqns":["com.datadoghq.script.*"],"integration":"INTEGRATION_SCRIPT"},"effect":"allow","name":"Cassette + Execution Policy testgetanexecutionpolicyreturnsokresponse1786698821"},"type":"execution_policy"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/actions/execution-policies + response: + body: + string: '{"data":{"id":"8856f100-43c1-4462-a96e-5ab404e695dc","type":"execution_policy","attributes":{"action_pattern":{"integration":"INTEGRATION_SCRIPT","action_fqns":["com.datadoghq.script.*"]},"created_at":"2026-08-14T09:13:42Z","created_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","effect":"allow","name":"Cassette + Execution Policy testgetanexecutionpolicyreturnsokresponse1786698821","targets":[],"updated_at":"2026-08-14T09:13:42Z","updated_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","version":1}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 201 + message: Created +- request: + body: null + headers: + accept: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/actions/execution-policies/8856f100-43c1-4462-a96e-5ab404e695dc + response: + body: + string: '{"data":{"id":"8856f100-43c1-4462-a96e-5ab404e695dc","type":"execution_policy","attributes":{"action_pattern":{"integration":"INTEGRATION_SCRIPT","action_fqns":["com.datadoghq.script.*"]},"created_at":"2026-08-14T09:13:42Z","created_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","effect":"allow","name":"Cassette + Execution Policy testgetanexecutionpolicyreturnsokresponse1786698821","scope":{},"targets":[],"updated_at":"2026-08-14T09:13:42Z","updated_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","version":1}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 200 + message: OK +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/actions/execution-policies/8856f100-43c1-4462-a96e-5ab404e695dc + response: + body: + string: '' + headers: {} + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_list_execution_policies_returns_bad_request_response.frozen b/tests/v2/cassettes/test_scenarios/test_list_execution_policies_returns_bad_request_response.frozen new file mode 100644 index 0000000000..5161e8eccb --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_list_execution_policies_returns_bad_request_response.frozen @@ -0,0 +1 @@ +2026-08-14T09:13:43.018Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_list_execution_policies_returns_bad_request_response.yaml b/tests/v2/cassettes/test_scenarios/test_list_execution_policies_returns_bad_request_response.yaml new file mode 100644 index 0000000000..af693dcee9 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_list_execution_policies_returns_bad_request_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: null + headers: + accept: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/actions/execution-policies?page%5Bsize%5D=0 + response: + body: + string: '{"errors":[{"title":"Generic Error","detail":"error listing execution + policies"}]}' + headers: + content-type: + - application/vnd.api+json + status: + code: 400 + message: Bad Request +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_list_execution_policies_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_list_execution_policies_returns_ok_response.frozen new file mode 100644 index 0000000000..653eb37328 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_list_execution_policies_returns_ok_response.frozen @@ -0,0 +1 @@ +2026-08-14T09:13:43.364Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_list_execution_policies_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_list_execution_policies_returns_ok_response.yaml new file mode 100644 index 0000000000..751613c794 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_list_execution_policies_returns_ok_response.yaml @@ -0,0 +1,53 @@ +interactions: +- request: + body: '{"data":{"attributes":{"action_pattern":{"action_fqns":["com.datadoghq.script.*"],"integration":"INTEGRATION_SCRIPT"},"effect":"allow","name":"Cassette + Execution Policy testlistexecutionpoliciesreturnsokresponse1786698823"},"type":"execution_policy"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/actions/execution-policies + response: + body: + string: '{"data":{"id":"8bb1ecd0-aed6-42cd-8a07-f9f781856f39","type":"execution_policy","attributes":{"action_pattern":{"integration":"INTEGRATION_SCRIPT","action_fqns":["com.datadoghq.script.*"]},"created_at":"2026-08-14T09:13:44Z","created_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","effect":"allow","name":"Cassette + Execution Policy testlistexecutionpoliciesreturnsokresponse1786698823","targets":[],"updated_at":"2026-08-14T09:13:44Z","updated_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","version":1}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 201 + message: Created +- request: + body: null + headers: + accept: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/actions/execution-policies + response: + body: + string: '{"data":[{"id":"8bb1ecd0-aed6-42cd-8a07-f9f781856f39","type":"execution_policy","attributes":{"action_pattern":{"integration":"INTEGRATION_SCRIPT","action_fqns":["com.datadoghq.script.*"]},"created_at":"2026-08-14T09:13:44Z","created_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","effect":"allow","name":"Cassette + Execution Policy testlistexecutionpoliciesreturnsokresponse1786698823","scope":{},"targets":[],"updated_at":"2026-08-14T09:13:44Z","updated_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","version":1}}],"meta":{"page":{"total":1}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 200 + message: OK +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/actions/execution-policies/8bb1ecd0-aed6-42cd-8a07-f9f781856f39 + response: + body: + string: '' + headers: {} + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_list_execution_policies_with_query_parameters_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_list_execution_policies_with_query_parameters_returns_ok_response.frozen new file mode 100644 index 0000000000..0cba39e9f6 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_list_execution_policies_with_query_parameters_returns_ok_response.frozen @@ -0,0 +1 @@ +2026-08-14T09:13:44.371Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_list_execution_policies_with_query_parameters_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_list_execution_policies_with_query_parameters_returns_ok_response.yaml new file mode 100644 index 0000000000..e04bdf209a --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_list_execution_policies_with_query_parameters_returns_ok_response.yaml @@ -0,0 +1,53 @@ +interactions: +- request: + body: '{"data":{"attributes":{"action_pattern":{"action_fqns":["com.datadoghq.script.*"],"integration":"INTEGRATION_SCRIPT"},"effect":"allow","name":"Cassette + Execution Policy testlistexecutionpolicieswithqueryparametersreturnsokresponse1786698824"},"type":"execution_policy"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/actions/execution-policies + response: + body: + string: '{"data":{"id":"6f0fbc08-9666-44fd-93da-cf1bfcff5e8f","type":"execution_policy","attributes":{"action_pattern":{"integration":"INTEGRATION_SCRIPT","action_fqns":["com.datadoghq.script.*"]},"created_at":"2026-08-14T09:13:45Z","created_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","effect":"allow","name":"Cassette + Execution Policy testlistexecutionpolicieswithqueryparametersreturnsokresponse1786698824","targets":[],"updated_at":"2026-08-14T09:13:45Z","updated_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","version":1}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 201 + message: Created +- request: + body: null + headers: + accept: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/actions/execution-policies?page%5Bsize%5D=10&page%5Bnumber%5D=0&filter%5Bname%5D=Cassette%20Execution%20Policy%20testlistexecutionpolicieswithqueryparametersreturnsokresponse1786698824&filter%5Bids%5D=6f0fbc08-9666-44fd-93da-cf1bfcff5e8f&filter%5Bintegration%5D=INTEGRATION_SCRIPT&filter%5Beffects%5D=allow&filter%5Bcreator_ids%5D=262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b&sort=-created_at + response: + body: + string: '{"data":[{"id":"6f0fbc08-9666-44fd-93da-cf1bfcff5e8f","type":"execution_policy","attributes":{"action_pattern":{"integration":"INTEGRATION_SCRIPT","action_fqns":["com.datadoghq.script.*"]},"created_at":"2026-08-14T09:13:45Z","created_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","effect":"allow","name":"Cassette + Execution Policy testlistexecutionpolicieswithqueryparametersreturnsokresponse1786698824","scope":{},"targets":[],"updated_at":"2026-08-14T09:13:45Z","updated_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","version":1}}],"meta":{"page":{"total":1}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 200 + message: OK +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/actions/execution-policies/6f0fbc08-9666-44fd-93da-cf1bfcff5e8f + response: + body: + string: '' + headers: {} + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_update_an_execution_policy_returns_bad_request_response.frozen b/tests/v2/cassettes/test_scenarios/test_update_an_execution_policy_returns_bad_request_response.frozen new file mode 100644 index 0000000000..e5ae18eb08 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_update_an_execution_policy_returns_bad_request_response.frozen @@ -0,0 +1 @@ +2026-08-14T09:13:45.415Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_update_an_execution_policy_returns_bad_request_response.yaml b/tests/v2/cassettes/test_scenarios/test_update_an_execution_policy_returns_bad_request_response.yaml new file mode 100644 index 0000000000..d14122a9e8 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_update_an_execution_policy_returns_bad_request_response.yaml @@ -0,0 +1,56 @@ +interactions: +- request: + body: '{"data":{"attributes":{"action_pattern":{"action_fqns":["com.datadoghq.script.*"],"integration":"INTEGRATION_SCRIPT"},"effect":"allow","name":"Cassette + Execution Policy testupdateanexecutionpolicyreturnsbadrequestresponse1786698825"},"type":"execution_policy"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/actions/execution-policies + response: + body: + string: '{"data":{"id":"0ce84810-fb1b-48ad-9012-ac49a505491a","type":"execution_policy","attributes":{"action_pattern":{"integration":"INTEGRATION_SCRIPT","action_fqns":["com.datadoghq.script.*"]},"created_at":"2026-08-14T09:13:46Z","created_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","effect":"allow","name":"Cassette + Execution Policy testupdateanexecutionpolicyreturnsbadrequestresponse1786698825","targets":[],"updated_at":"2026-08-14T09:13:46Z","updated_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","version":1}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 201 + message: Created +- request: + body: '{"data":{"attributes":{"action_pattern":{"action_fqns":["com.datadoghq.script.*"],"integration":"INTEGRATION_SCRIPT"},"effect":"invalid_effect","name":"Cassette + Execution Policy Updated"},"id":"0ce84810-fb1b-48ad-9012-ac49a505491a","type":"execution_policy"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: PUT + uri: https://api.datadoghq.com/api/v2/actions/execution-policies/0ce84810-fb1b-48ad-9012-ac49a505491a + response: + body: + string: '{"errors":[{"title":"Generic Error","detail":"error updating execution + policy"}]}' + headers: + content-type: + - application/vnd.api+json + status: + code: 400 + message: Bad Request +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/actions/execution-policies/0ce84810-fb1b-48ad-9012-ac49a505491a + response: + body: + string: '' + headers: {} + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_update_an_execution_policy_returns_not_found_response.frozen b/tests/v2/cassettes/test_scenarios/test_update_an_execution_policy_returns_not_found_response.frozen new file mode 100644 index 0000000000..0b6eb323a2 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_update_an_execution_policy_returns_not_found_response.frozen @@ -0,0 +1 @@ +2026-08-14T09:13:46.457Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_update_an_execution_policy_returns_not_found_response.yaml b/tests/v2/cassettes/test_scenarios/test_update_an_execution_policy_returns_not_found_response.yaml new file mode 100644 index 0000000000..2cb3cde22e --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_update_an_execution_policy_returns_not_found_response.yaml @@ -0,0 +1,22 @@ +interactions: +- request: + body: '{"data":{"attributes":{"action_pattern":{"action_fqns":["com.datadoghq.script.*"],"integration":"INTEGRATION_SCRIPT"},"effect":"allow","name":"Cassette + Execution Policy Updated"},"id":"aaa11111-aa11-aa11-aaaa-aaaaaa111111","type":"execution_policy"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: PUT + uri: https://api.datadoghq.com/api/v2/actions/execution-policies/aaa11111-aa11-aa11-aaaa-aaaaaa111111 + response: + body: + string: '{"errors":[{"title":"Generic Error","detail":"error updating execution + policy"}]}' + headers: + content-type: + - application/vnd.api+json + status: + code: 404 + message: Not Found +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_update_an_execution_policy_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_update_an_execution_policy_returns_ok_response.frozen new file mode 100644 index 0000000000..db6d2e00d3 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_update_an_execution_policy_returns_ok_response.frozen @@ -0,0 +1 @@ +2026-08-14T09:13:46.840Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_update_an_execution_policy_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_update_an_execution_policy_returns_ok_response.yaml new file mode 100644 index 0000000000..baa6439112 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_update_an_execution_policy_returns_ok_response.yaml @@ -0,0 +1,56 @@ +interactions: +- request: + body: '{"data":{"attributes":{"action_pattern":{"action_fqns":["com.datadoghq.script.*"],"integration":"INTEGRATION_SCRIPT"},"effect":"allow","name":"Cassette + Execution Policy testupdateanexecutionpolicyreturnsokresponse1786698826"},"type":"execution_policy"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/actions/execution-policies + response: + body: + string: '{"data":{"id":"0405b41b-8865-4918-91ce-6d935b6af245","type":"execution_policy","attributes":{"action_pattern":{"integration":"INTEGRATION_SCRIPT","action_fqns":["com.datadoghq.script.*"]},"created_at":"2026-08-14T09:13:47Z","created_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","effect":"allow","name":"Cassette + Execution Policy testupdateanexecutionpolicyreturnsokresponse1786698826","targets":[],"updated_at":"2026-08-14T09:13:47Z","updated_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","version":1}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 201 + message: Created +- request: + body: '{"data":{"attributes":{"action_pattern":{"action_fqns":["com.datadoghq.script.*"],"integration":"INTEGRATION_SCRIPT"},"effect":"allow","name":"Cassette + Execution Policy Updated"},"id":"0405b41b-8865-4918-91ce-6d935b6af245","type":"execution_policy"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: PUT + uri: https://api.datadoghq.com/api/v2/actions/execution-policies/0405b41b-8865-4918-91ce-6d935b6af245 + response: + body: + string: '{"data":{"id":"0405b41b-8865-4918-91ce-6d935b6af245","type":"execution_policy","attributes":{"action_pattern":{"integration":"INTEGRATION_SCRIPT","action_fqns":["com.datadoghq.script.*"]},"created_at":"2026-08-14T09:13:47Z","created_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","effect":"allow","name":"Cassette + Execution Policy Updated","scope":{},"targets":[],"updated_at":"2026-08-14T09:13:48Z","updated_by":"262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b","version":2}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 200 + message: OK +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/actions/execution-policies/0405b41b-8865-4918-91ce-6d935b6af245 + response: + body: + string: '' + headers: {} + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/features/execution_policy.feature b/tests/v2/features/execution_policy.feature new file mode 100644 index 0000000000..3c356ac203 --- /dev/null +++ b/tests/v2/features/execution_policy.feature @@ -0,0 +1,131 @@ +@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. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "ExecutionPolicy" API + + @team:DataDog/action-platform + Scenario: Create an execution policy 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", "effect": "invalid_effect", "action_pattern": {"integration": "INTEGRATION_SCRIPT", "action_fqns": ["com.datadoghq.script.*"]}}}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/action-platform + Scenario: Create an 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_SCRIPT", "action_fqns": ["com.datadoghq.script.*"]}}}} + When the request is sent + Then the response status is 201 Created + + @team:DataDog/action-platform + Scenario: Create an 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_SCRIPT", "action_fqns": ["com.datadoghq.script.*"]}, "scope": {"scripts": {"rules": [{"target_script_names": ["restart_service.sh"]}]}}, "targets": [{"name": "Production hosts", "agent_tags": ["env:prod"]}]}}} + When the request is sent + Then the response status is 201 Created + + @team:DataDog/action-platform + Scenario: Delete an execution policy returns "No Content" response + Given there is a valid "execution_policy" in the system + And operation "DeleteExecutionPolicy" enabled + And new "DeleteExecutionPolicy" request + And request contains "policy_id" parameter from "execution_policy.data.id" + When the request is sent + Then the response status is 204 No Content + + @team:DataDog/action-platform + Scenario: Delete an execution policy returns "Not Found" response + Given operation "DeleteExecutionPolicy" enabled + And new "DeleteExecutionPolicy" request + And request contains "policy_id" parameter with value "aaa11111-aa11-aa11-aaaa-aaaaaa111111" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/action-platform + Scenario: Get an execution policy returns "Not Found" response + Given operation "GetExecutionPolicy" enabled + And new "GetExecutionPolicy" request + And request contains "policy_id" parameter with value "aaa11111-aa11-aa11-aaaa-aaaaaa111111" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/action-platform + Scenario: Get an execution policy returns "OK" response + Given there is a valid "execution_policy" in the system + And operation "GetExecutionPolicy" enabled + And new "GetExecutionPolicy" request + And request contains "policy_id" parameter from "execution_policy.data.id" + When the request is sent + Then the response status is 200 OK + + @team:DataDog/action-platform + Scenario: List execution policies returns "Bad Request" response + Given operation "ListExecutionPolicies" enabled + And new "ListExecutionPolicies" request + And request contains "page[size]" parameter with value 0 + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/action-platform + Scenario: List execution policies returns "OK" response + Given there is a valid "execution_policy" in the system + And operation "ListExecutionPolicies" enabled + And new "ListExecutionPolicies" request + When the request is sent + Then the response status is 200 OK + + @team:DataDog/action-platform + Scenario: List execution policies with query parameters returns "OK" response + Given there is a valid "execution_policy" in the system + And operation "ListExecutionPolicies" enabled + And new "ListExecutionPolicies" request + And request contains "page[size]" parameter with value 10 + And request contains "page[number]" parameter with value 0 + And request contains "filter[name]" parameter from "execution_policy.data.attributes.name" + And request contains "filter[ids]" parameter with value ["{{ execution_policy.data.id }}"] + And request contains "filter[integration]" parameter with value ["INTEGRATION_SCRIPT"] + And request contains "filter[effects]" parameter with value ["allow"] + And request contains "filter[creator_ids]" parameter with value ["{{ execution_policy.data.attributes.created_by }}"] + And request contains "sort" parameter with value ["-created_at"] + When the request is sent + Then the response status is 200 OK + + @team:DataDog/action-platform + Scenario: Update an execution policy returns "Bad Request" 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": "invalid_effect", "action_pattern": {"integration": "INTEGRATION_SCRIPT", "action_fqns": ["com.datadoghq.script.*"]}}}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/action-platform + Scenario: Update an execution policy returns "Not Found" response + Given operation "UpdateExecutionPolicy" enabled + And new "UpdateExecutionPolicy" request + And request contains "policy_id" parameter with value "aaa11111-aa11-aa11-aaaa-aaaaaa111111" + And body with value {"data": {"id": "aaa11111-aa11-aa11-aaaa-aaaaaa111111", "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 404 Not Found + + @team:DataDog/action-platform + Scenario: Update an execution policy 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": "allow", "action_pattern": {"integration": "INTEGRATION_SCRIPT", "action_fqns": ["com.datadoghq.script.*"]}}}} + When the request is sent + Then the response status is 200 OK diff --git a/tests/v2/features/given.json b/tests/v2/features/given.json index 6e48ed1fc5..62f981bc5e 100644 --- a/tests/v2/features/given.json +++ b/tests/v2/features/given.json @@ -52,6 +52,18 @@ "tag": "Action Connection", "operationId": "CreateActionConnection" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"execution_policy\",\n \"attributes\": {\n \"name\": \"Cassette Execution Policy {{ unique_lower_alnum }}\",\n \"effect\": \"allow\",\n \"action_pattern\": {\n \"integration\": \"INTEGRATION_SCRIPT\",\n \"action_fqns\": [\"com.datadoghq.script.*\"]\n }\n }\n }\n}" + } + ], + "step": "there is a valid \"execution_policy\" in the system", + "key": "execution_policy", + "tag": "Execution Policy", + "operationId": "CreateExecutionPolicy" + }, { "source": "data[0]", "step": "there is a valid \"aws_scan_options\" in the system", diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index df961ee10c..27ff001f90 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -202,6 +202,43 @@ "type": "idempotent" } }, + "ListExecutionPolicies": { + "tag": "Execution Policy", + "undo": { + "type": "safe" + } + }, + "CreateExecutionPolicy": { + "tag": "Execution Policy", + "undo": { + "operationId": "DeleteExecutionPolicy", + "parameters": [ + { + "name": "policy_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteExecutionPolicy": { + "tag": "Execution Policy", + "undo": { + "type": "idempotent" + } + }, + "GetExecutionPolicy": { + "tag": "Execution Policy", + "undo": { + "type": "safe" + } + }, + "UpdateExecutionPolicy": { + "tag": "Execution Policy", + "undo": { + "type": "idempotent" + } + }, "ListAwsScanOptions": { "tag": "Agentless Scanning", "undo": {