diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index fcf5fd48e2c..c448f255302 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/examples/v2/execution-policy/CreateExecutionPolicy.java b/examples/v2/execution-policy/CreateExecutionPolicy.java new file mode 100644 index 00000000000..c1f55238ad0 --- /dev/null +++ b/examples/v2/execution-policy/CreateExecutionPolicy.java @@ -0,0 +1,48 @@ +// Create an execution policy returns "Created" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.ExecutionPolicyApi; +import com.datadog.api.client.v2.model.ExecutionPolicyActionPattern; +import com.datadog.api.client.v2.model.ExecutionPolicyCreateRequest; +import com.datadog.api.client.v2.model.ExecutionPolicyCreateRequestData; +import com.datadog.api.client.v2.model.ExecutionPolicyEffect; +import com.datadog.api.client.v2.model.ExecutionPolicyIntegration; +import com.datadog.api.client.v2.model.ExecutionPolicyResponse; +import com.datadog.api.client.v2.model.ExecutionPolicyType; +import com.datadog.api.client.v2.model.ExecutionPolicyWriteAttributes; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.createExecutionPolicy", true); + ExecutionPolicyApi apiInstance = new ExecutionPolicyApi(defaultClient); + + ExecutionPolicyCreateRequest body = + new ExecutionPolicyCreateRequest() + .data( + new ExecutionPolicyCreateRequestData() + .type(ExecutionPolicyType.EXECUTION_POLICY) + .attributes( + new ExecutionPolicyWriteAttributes() + .name("Cassette Execution Policy exampleexecutionpolicy") + .effect(ExecutionPolicyEffect.ALLOW) + .actionPattern( + new ExecutionPolicyActionPattern() + .integration(ExecutionPolicyIntegration.INTEGRATION_SCRIPT) + .actionFqns( + Collections.singletonList("com.datadoghq.script.*"))))); + + try { + ExecutionPolicyResponse result = apiInstance.createExecutionPolicy(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ExecutionPolicyApi#createExecutionPolicy"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/execution-policy/CreateExecutionPolicy_1075977289.java b/examples/v2/execution-policy/CreateExecutionPolicy_1075977289.java new file mode 100644 index 00000000000..35de4e9640a --- /dev/null +++ b/examples/v2/execution-policy/CreateExecutionPolicy_1075977289.java @@ -0,0 +1,67 @@ +// Create an execution policy with scope and targets returns "Created" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.ExecutionPolicyApi; +import com.datadog.api.client.v2.model.ExecutionPolicyActionPattern; +import com.datadog.api.client.v2.model.ExecutionPolicyCreateRequest; +import com.datadog.api.client.v2.model.ExecutionPolicyCreateRequestData; +import com.datadog.api.client.v2.model.ExecutionPolicyEffect; +import com.datadog.api.client.v2.model.ExecutionPolicyIntegration; +import com.datadog.api.client.v2.model.ExecutionPolicyResponse; +import com.datadog.api.client.v2.model.ExecutionPolicyScope; +import com.datadog.api.client.v2.model.ExecutionPolicyScriptScope; +import com.datadog.api.client.v2.model.ExecutionPolicyScriptScopeRule; +import com.datadog.api.client.v2.model.ExecutionPolicyTarget; +import com.datadog.api.client.v2.model.ExecutionPolicyType; +import com.datadog.api.client.v2.model.ExecutionPolicyWriteAttributes; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.createExecutionPolicy", true); + ExecutionPolicyApi apiInstance = new ExecutionPolicyApi(defaultClient); + + ExecutionPolicyCreateRequest body = + new ExecutionPolicyCreateRequest() + .data( + new ExecutionPolicyCreateRequestData() + .type(ExecutionPolicyType.EXECUTION_POLICY) + .attributes( + new ExecutionPolicyWriteAttributes() + .name("Cassette Execution Policy exampleexecutionpolicy") + .effect(ExecutionPolicyEffect.ALLOW) + .actionPattern( + new ExecutionPolicyActionPattern() + .integration(ExecutionPolicyIntegration.INTEGRATION_SCRIPT) + .actionFqns( + Collections.singletonList("com.datadoghq.script.*"))) + .scope( + new ExecutionPolicyScope() + .scripts( + new ExecutionPolicyScriptScope() + .rules( + Collections.singletonList( + new ExecutionPolicyScriptScopeRule() + .targetScriptNames( + Collections.singletonList( + "restart_service.sh")))))) + .targets( + Collections.singletonList( + new ExecutionPolicyTarget() + .name("Production hosts") + .agentTags(Collections.singletonList("env:prod")))))); + + try { + ExecutionPolicyResponse result = apiInstance.createExecutionPolicy(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ExecutionPolicyApi#createExecutionPolicy"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/execution-policy/DeleteExecutionPolicy.java b/examples/v2/execution-policy/DeleteExecutionPolicy.java new file mode 100644 index 00000000000..16ffd958bd9 --- /dev/null +++ b/examples/v2/execution-policy/DeleteExecutionPolicy.java @@ -0,0 +1,26 @@ +// Delete an execution policy returns "No Content" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.ExecutionPolicyApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.deleteExecutionPolicy", true); + ExecutionPolicyApi apiInstance = new ExecutionPolicyApi(defaultClient); + + // there is a valid "execution_policy" in the system + String EXECUTION_POLICY_DATA_ID = System.getenv("EXECUTION_POLICY_DATA_ID"); + + try { + apiInstance.deleteExecutionPolicy(EXECUTION_POLICY_DATA_ID); + } catch (ApiException e) { + System.err.println("Exception when calling ExecutionPolicyApi#deleteExecutionPolicy"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/execution-policy/GetExecutionPolicy.java b/examples/v2/execution-policy/GetExecutionPolicy.java new file mode 100644 index 00000000000..79f12e7ee0f --- /dev/null +++ b/examples/v2/execution-policy/GetExecutionPolicy.java @@ -0,0 +1,28 @@ +// Get an execution policy returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.ExecutionPolicyApi; +import com.datadog.api.client.v2.model.ExecutionPolicyResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.getExecutionPolicy", true); + ExecutionPolicyApi apiInstance = new ExecutionPolicyApi(defaultClient); + + // there is a valid "execution_policy" in the system + String EXECUTION_POLICY_DATA_ID = System.getenv("EXECUTION_POLICY_DATA_ID"); + + try { + ExecutionPolicyResponse result = apiInstance.getExecutionPolicy(EXECUTION_POLICY_DATA_ID); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ExecutionPolicyApi#getExecutionPolicy"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/execution-policy/ListExecutionPolicies.java b/examples/v2/execution-policy/ListExecutionPolicies.java new file mode 100644 index 00000000000..67edcd1592d --- /dev/null +++ b/examples/v2/execution-policy/ListExecutionPolicies.java @@ -0,0 +1,25 @@ +// List execution policies returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.ExecutionPolicyApi; +import com.datadog.api.client.v2.model.ExecutionPolicyListResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.listExecutionPolicies", true); + ExecutionPolicyApi apiInstance = new ExecutionPolicyApi(defaultClient); + + try { + ExecutionPolicyListResponse result = apiInstance.listExecutionPolicies(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ExecutionPolicyApi#listExecutionPolicies"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/execution-policy/ListExecutionPolicies_1745885519.java b/examples/v2/execution-policy/ListExecutionPolicies_1745885519.java new file mode 100644 index 00000000000..e243c4abd1d --- /dev/null +++ b/examples/v2/execution-policy/ListExecutionPolicies_1745885519.java @@ -0,0 +1,48 @@ +// List execution policies with query parameters returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.ExecutionPolicyApi; +import com.datadog.api.client.v2.api.ExecutionPolicyApi.ListExecutionPoliciesOptionalParameters; +import com.datadog.api.client.v2.model.ExecutionPolicyEffect; +import com.datadog.api.client.v2.model.ExecutionPolicyIntegration; +import com.datadog.api.client.v2.model.ExecutionPolicyListResponse; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.listExecutionPolicies", true); + ExecutionPolicyApi apiInstance = new ExecutionPolicyApi(defaultClient); + + // there is a valid "execution_policy" in the system + String EXECUTION_POLICY_DATA_ATTRIBUTES_CREATED_BY = + System.getenv("EXECUTION_POLICY_DATA_ATTRIBUTES_CREATED_BY"); + String EXECUTION_POLICY_DATA_ATTRIBUTES_NAME = + System.getenv("EXECUTION_POLICY_DATA_ATTRIBUTES_NAME"); + String EXECUTION_POLICY_DATA_ID = System.getenv("EXECUTION_POLICY_DATA_ID"); + + try { + ExecutionPolicyListResponse result = + apiInstance.listExecutionPolicies( + new ListExecutionPoliciesOptionalParameters() + .pageSize(10) + .pageNumber(0) + .filterName(EXECUTION_POLICY_DATA_ATTRIBUTES_NAME) + .filterIds(Collections.singletonList(EXECUTION_POLICY_DATA_ID)) + .filterIntegration( + Collections.singletonList(ExecutionPolicyIntegration.INTEGRATION_SCRIPT)) + .filterEffects(Collections.singletonList(ExecutionPolicyEffect.ALLOW)) + .filterCreatorIds( + Collections.singletonList(EXECUTION_POLICY_DATA_ATTRIBUTES_CREATED_BY)) + .sort(Collections.singletonList("-created_at"))); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ExecutionPolicyApi#listExecutionPolicies"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/execution-policy/UpdateExecutionPolicy.java b/examples/v2/execution-policy/UpdateExecutionPolicy.java new file mode 100644 index 00000000000..66c72b72b8e --- /dev/null +++ b/examples/v2/execution-policy/UpdateExecutionPolicy.java @@ -0,0 +1,53 @@ +// Update an execution policy returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.ExecutionPolicyApi; +import com.datadog.api.client.v2.model.ExecutionPolicyActionPattern; +import com.datadog.api.client.v2.model.ExecutionPolicyEffect; +import com.datadog.api.client.v2.model.ExecutionPolicyIntegration; +import com.datadog.api.client.v2.model.ExecutionPolicyResponse; +import com.datadog.api.client.v2.model.ExecutionPolicyType; +import com.datadog.api.client.v2.model.ExecutionPolicyUpdateRequest; +import com.datadog.api.client.v2.model.ExecutionPolicyUpdateRequestData; +import com.datadog.api.client.v2.model.ExecutionPolicyWriteAttributes; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.updateExecutionPolicy", true); + ExecutionPolicyApi apiInstance = new ExecutionPolicyApi(defaultClient); + + // there is a valid "execution_policy" in the system + String EXECUTION_POLICY_DATA_ID = System.getenv("EXECUTION_POLICY_DATA_ID"); + + ExecutionPolicyUpdateRequest body = + new ExecutionPolicyUpdateRequest() + .data( + new ExecutionPolicyUpdateRequestData() + .id(EXECUTION_POLICY_DATA_ID) + .type(ExecutionPolicyType.EXECUTION_POLICY) + .attributes( + new ExecutionPolicyWriteAttributes() + .name("Cassette Execution Policy Updated") + .effect(ExecutionPolicyEffect.ALLOW) + .actionPattern( + new ExecutionPolicyActionPattern() + .integration(ExecutionPolicyIntegration.INTEGRATION_SCRIPT) + .actionFqns( + Collections.singletonList("com.datadoghq.script.*"))))); + + try { + ExecutionPolicyResponse result = + apiInstance.updateExecutionPolicy(EXECUTION_POLICY_DATA_ID, body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ExecutionPolicyApi#updateExecutionPolicy"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/ApiClient.java b/src/main/java/com/datadog/api/client/ApiClient.java index 0d8443e0d1a..9ce27e1cc92 100644 --- a/src/main/java/com/datadog/api/client/ApiClient.java +++ b/src/main/java/com/datadog/api/client/ApiClient.java @@ -916,6 +916,11 @@ public class ApiClient { put("v2.uploadLLMObsDatasetRecordsFile", false); put("v2.upsertLLMObsAnnotations", false); put("v2.upsertLLMObsPatternsConfig", false); + put("v2.createExecutionPolicy", false); + put("v2.deleteExecutionPolicy", false); + put("v2.getExecutionPolicy", false); + put("v2.listExecutionPolicies", false); + put("v2.updateExecutionPolicy", false); put("v2.createAnnotation", false); put("v2.deleteAnnotation", false); put("v2.getPageAnnotations", false); diff --git a/src/main/java/com/datadog/api/client/v2/api/ExecutionPolicyApi.java b/src/main/java/com/datadog/api/client/v2/api/ExecutionPolicyApi.java new file mode 100644 index 00000000000..a47327cc021 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/api/ExecutionPolicyApi.java @@ -0,0 +1,991 @@ +package com.datadog.api.client.v2.api; + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.ApiResponse; +import com.datadog.api.client.Pair; +import com.datadog.api.client.v2.model.ExecutionPolicyCreateRequest; +import com.datadog.api.client.v2.model.ExecutionPolicyEffect; +import com.datadog.api.client.v2.model.ExecutionPolicyIntegration; +import com.datadog.api.client.v2.model.ExecutionPolicyListResponse; +import com.datadog.api.client.v2.model.ExecutionPolicyResponse; +import com.datadog.api.client.v2.model.ExecutionPolicyUpdateRequest; +import jakarta.ws.rs.client.Invocation; +import jakarta.ws.rs.core.GenericType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; + +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ExecutionPolicyApi { + private ApiClient apiClient; + + public ExecutionPolicyApi() { + this(ApiClient.getDefaultApiClient()); + } + + public ExecutionPolicyApi(ApiClient apiClient) { + this.apiClient = apiClient; + } + + /** + * Get the API client. + * + * @return API client + */ + public ApiClient getApiClient() { + return apiClient; + } + + /** + * Set the API client. + * + * @param apiClient an instance of API client + */ + public void setApiClient(ApiClient apiClient) { + this.apiClient = apiClient; + } + + /** + * Create an execution policy. + * + *

See {@link #createExecutionPolicyWithHttpInfo}. + * + * @param body The execution policy to create. (required) + * @return ExecutionPolicyResponse + * @throws ApiException if fails to make API call + */ + public ExecutionPolicyResponse createExecutionPolicy(ExecutionPolicyCreateRequest body) + throws ApiException { + return createExecutionPolicyWithHttpInfo(body).getData(); + } + + /** + * Create an execution policy. + * + *

See {@link #createExecutionPolicyWithHttpInfoAsync}. + * + * @param body The execution policy to create. (required) + * @return CompletableFuture<ExecutionPolicyResponse> + */ + public CompletableFuture createExecutionPolicyAsync( + ExecutionPolicyCreateRequest body) { + return createExecutionPolicyWithHttpInfoAsync(body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Create a new execution policy. + * + * @param body The execution policy to create. (required) + * @return ApiResponse<ExecutionPolicyResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
201 Created -
400 Bad Request -
403 Forbidden -
429 Too many requests -
+ */ + public ApiResponse createExecutionPolicyWithHttpInfo( + ExecutionPolicyCreateRequest body) throws ApiException { + // Check if unstable operation is enabled + String operationId = "createExecutionPolicy"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling createExecutionPolicy"); + } + // create path and map variables + String localVarPath = "/api/v2/actions/execution-policies"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.ExecutionPolicyApi.createExecutionPolicy", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Create an execution policy. + * + *

See {@link #createExecutionPolicyWithHttpInfo}. + * + * @param body The execution policy to create. (required) + * @return CompletableFuture<ApiResponse<ExecutionPolicyResponse>> + */ + public CompletableFuture> + createExecutionPolicyWithHttpInfoAsync(ExecutionPolicyCreateRequest body) { + // Check if unstable operation is enabled + String operationId = "createExecutionPolicy"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'body' when calling createExecutionPolicy")); + return result; + } + // create path and map variables + String localVarPath = "/api/v2/actions/execution-policies"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.ExecutionPolicyApi.createExecutionPolicy", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Delete an execution policy. + * + *

See {@link #deleteExecutionPolicyWithHttpInfo}. + * + * @param policyId The ID of the execution policy. (required) + * @throws ApiException if fails to make API call + */ + public void deleteExecutionPolicy(UUID policyId) throws ApiException { + deleteExecutionPolicyWithHttpInfo(policyId); + } + + /** + * Delete an execution policy. + * + *

See {@link #deleteExecutionPolicyWithHttpInfoAsync}. + * + * @param policyId The ID of the execution policy. (required) + * @return CompletableFuture + */ + public CompletableFuture deleteExecutionPolicyAsync(UUID policyId) { + return deleteExecutionPolicyWithHttpInfoAsync(policyId) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Delete a specific execution policy. + * + * @param policyId The ID of the execution policy. (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
204 No Content -
403 Forbidden -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse deleteExecutionPolicyWithHttpInfo(UUID policyId) throws ApiException { + // Check if unstable operation is enabled + String operationId = "deleteExecutionPolicy"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = null; + + // verify the required parameter 'policyId' is set + if (policyId == null) { + throw new ApiException( + 400, "Missing the required parameter 'policyId' when calling deleteExecutionPolicy"); + } + // create path and map variables + String localVarPath = + "/api/v2/actions/execution-policies/{policy_id}" + .replaceAll("\\{" + "policy_id" + "\\}", apiClient.escapeString(policyId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.ExecutionPolicyApi.deleteExecutionPolicy", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "DELETE", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + null); + } + + /** + * Delete an execution policy. + * + *

See {@link #deleteExecutionPolicyWithHttpInfo}. + * + * @param policyId The ID of the execution policy. (required) + * @return CompletableFuture<ApiResponse<Void>> + */ + public CompletableFuture> deleteExecutionPolicyWithHttpInfoAsync( + UUID policyId) { + // Check if unstable operation is enabled + String operationId = "deleteExecutionPolicy"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = null; + + // verify the required parameter 'policyId' is set + if (policyId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'policyId' when calling deleteExecutionPolicy")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/actions/execution-policies/{policy_id}" + .replaceAll("\\{" + "policy_id" + "\\}", apiClient.escapeString(policyId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.ExecutionPolicyApi.deleteExecutionPolicy", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "DELETE", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + null); + } + + /** + * Get an execution policy. + * + *

See {@link #getExecutionPolicyWithHttpInfo}. + * + * @param policyId The ID of the execution policy. (required) + * @return ExecutionPolicyResponse + * @throws ApiException if fails to make API call + */ + public ExecutionPolicyResponse getExecutionPolicy(UUID policyId) throws ApiException { + return getExecutionPolicyWithHttpInfo(policyId).getData(); + } + + /** + * Get an execution policy. + * + *

See {@link #getExecutionPolicyWithHttpInfoAsync}. + * + * @param policyId The ID of the execution policy. (required) + * @return CompletableFuture<ExecutionPolicyResponse> + */ + public CompletableFuture getExecutionPolicyAsync(UUID policyId) { + return getExecutionPolicyWithHttpInfoAsync(policyId) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Retrieve an existing execution policy by ID. + * + * @param policyId The ID of the execution policy. (required) + * @return ApiResponse<ExecutionPolicyResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse getExecutionPolicyWithHttpInfo(UUID policyId) + throws ApiException { + // Check if unstable operation is enabled + String operationId = "getExecutionPolicy"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = null; + + // verify the required parameter 'policyId' is set + if (policyId == null) { + throw new ApiException( + 400, "Missing the required parameter 'policyId' when calling getExecutionPolicy"); + } + // create path and map variables + String localVarPath = + "/api/v2/actions/execution-policies/{policy_id}" + .replaceAll("\\{" + "policy_id" + "\\}", apiClient.escapeString(policyId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.ExecutionPolicyApi.getExecutionPolicy", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Get an execution policy. + * + *

See {@link #getExecutionPolicyWithHttpInfo}. + * + * @param policyId The ID of the execution policy. (required) + * @return CompletableFuture<ApiResponse<ExecutionPolicyResponse>> + */ + public CompletableFuture> + getExecutionPolicyWithHttpInfoAsync(UUID policyId) { + // Check if unstable operation is enabled + String operationId = "getExecutionPolicy"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = null; + + // verify the required parameter 'policyId' is set + if (policyId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'policyId' when calling getExecutionPolicy")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/actions/execution-policies/{policy_id}" + .replaceAll("\\{" + "policy_id" + "\\}", apiClient.escapeString(policyId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.ExecutionPolicyApi.getExecutionPolicy", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** Manage optional parameters to listExecutionPolicies. */ + public static class ListExecutionPoliciesOptionalParameters { + private Integer pageSize; + private Integer pageNumber; + private String filterName; + private List filterIds; + private List filterIntegration; + private List filterEffects; + private List filterCreatorIds; + private List sort; + + /** + * Set pageSize. + * + * @param pageSize The number of execution policies to return per page. (optional, default to + * 100) + * @return ListExecutionPoliciesOptionalParameters + */ + public ListExecutionPoliciesOptionalParameters pageSize(Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + /** + * Set pageNumber. + * + * @param pageNumber The page number to return. (optional, default to 0) + * @return ListExecutionPoliciesOptionalParameters + */ + public ListExecutionPoliciesOptionalParameters pageNumber(Integer pageNumber) { + this.pageNumber = pageNumber; + return this; + } + + /** + * Set filterName. + * + * @param filterName Filter execution policies by name. (optional) + * @return ListExecutionPoliciesOptionalParameters + */ + public ListExecutionPoliciesOptionalParameters filterName(String filterName) { + this.filterName = filterName; + return this; + } + + /** + * Set filterIds. + * + * @param filterIds Filter execution policies by a list of IDs. (optional) + * @return ListExecutionPoliciesOptionalParameters + */ + public ListExecutionPoliciesOptionalParameters filterIds(List filterIds) { + this.filterIds = filterIds; + return this; + } + + /** + * Set filterIntegration. + * + * @param filterIntegration Filter execution policies by a list of integrations. (optional) + * @return ListExecutionPoliciesOptionalParameters + */ + public ListExecutionPoliciesOptionalParameters filterIntegration( + List filterIntegration) { + this.filterIntegration = filterIntegration; + return this; + } + + /** + * Set filterEffects. + * + * @param filterEffects Filter execution policies by a list of effects. (optional) + * @return ListExecutionPoliciesOptionalParameters + */ + public ListExecutionPoliciesOptionalParameters filterEffects( + List filterEffects) { + this.filterEffects = filterEffects; + return this; + } + + /** + * Set filterCreatorIds. + * + * @param filterCreatorIds Filter execution policies by a list of creator IDs. (optional) + * @return ListExecutionPoliciesOptionalParameters + */ + public ListExecutionPoliciesOptionalParameters filterCreatorIds(List filterCreatorIds) { + this.filterCreatorIds = filterCreatorIds; + return this; + } + + /** + * Set sort. + * + * @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. (optional) + * @return ListExecutionPoliciesOptionalParameters + */ + public ListExecutionPoliciesOptionalParameters sort(List sort) { + this.sort = sort; + return this; + } + } + + /** + * List execution policies. + * + *

See {@link #listExecutionPoliciesWithHttpInfo}. + * + * @return ExecutionPolicyListResponse + * @throws ApiException if fails to make API call + */ + public ExecutionPolicyListResponse listExecutionPolicies() throws ApiException { + return listExecutionPoliciesWithHttpInfo(new ListExecutionPoliciesOptionalParameters()) + .getData(); + } + + /** + * List execution policies. + * + *

See {@link #listExecutionPoliciesWithHttpInfoAsync}. + * + * @return CompletableFuture<ExecutionPolicyListResponse> + */ + public CompletableFuture listExecutionPoliciesAsync() { + return listExecutionPoliciesWithHttpInfoAsync(new ListExecutionPoliciesOptionalParameters()) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * List execution policies. + * + *

See {@link #listExecutionPoliciesWithHttpInfo}. + * + * @param parameters Optional parameters for the request. + * @return ExecutionPolicyListResponse + * @throws ApiException if fails to make API call + */ + public ExecutionPolicyListResponse listExecutionPolicies( + ListExecutionPoliciesOptionalParameters parameters) throws ApiException { + return listExecutionPoliciesWithHttpInfo(parameters).getData(); + } + + /** + * List execution policies. + * + *

See {@link #listExecutionPoliciesWithHttpInfoAsync}. + * + * @param parameters Optional parameters for the request. + * @return CompletableFuture<ExecutionPolicyListResponse> + */ + public CompletableFuture listExecutionPoliciesAsync( + ListExecutionPoliciesOptionalParameters parameters) { + return listExecutionPoliciesWithHttpInfoAsync(parameters) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Retrieve a list of execution policies for the current organization. + * + * @param parameters Optional parameters for the request. + * @return ApiResponse<ExecutionPolicyListResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
429 Too many requests -
+ */ + public ApiResponse listExecutionPoliciesWithHttpInfo( + ListExecutionPoliciesOptionalParameters parameters) throws ApiException { + // Check if unstable operation is enabled + String operationId = "listExecutionPolicies"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = null; + Integer pageSize = parameters.pageSize; + Integer pageNumber = parameters.pageNumber; + String filterName = parameters.filterName; + List filterIds = parameters.filterIds; + List filterIntegration = parameters.filterIntegration; + List filterEffects = parameters.filterEffects; + List filterCreatorIds = parameters.filterCreatorIds; + List sort = parameters.sort; + // create path and map variables + String localVarPath = "/api/v2/actions/execution-policies"; + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[size]", pageSize)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[number]", pageNumber)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter[name]", filterName)); + localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "filter[ids]", filterIds)); + localVarQueryParams.addAll( + apiClient.parameterToPairs("multi", "filter[integration]", filterIntegration)); + localVarQueryParams.addAll( + apiClient.parameterToPairs("multi", "filter[effects]", filterEffects)); + localVarQueryParams.addAll( + apiClient.parameterToPairs("multi", "filter[creator_ids]", filterCreatorIds)); + localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "sort", sort)); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.ExecutionPolicyApi.listExecutionPolicies", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * List execution policies. + * + *

See {@link #listExecutionPoliciesWithHttpInfo}. + * + * @param parameters Optional parameters for the request. + * @return CompletableFuture<ApiResponse<ExecutionPolicyListResponse>> + */ + public CompletableFuture> + listExecutionPoliciesWithHttpInfoAsync(ListExecutionPoliciesOptionalParameters parameters) { + // Check if unstable operation is enabled + String operationId = "listExecutionPolicies"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = null; + Integer pageSize = parameters.pageSize; + Integer pageNumber = parameters.pageNumber; + String filterName = parameters.filterName; + List filterIds = parameters.filterIds; + List filterIntegration = parameters.filterIntegration; + List filterEffects = parameters.filterEffects; + List filterCreatorIds = parameters.filterCreatorIds; + List sort = parameters.sort; + // create path and map variables + String localVarPath = "/api/v2/actions/execution-policies"; + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[size]", pageSize)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[number]", pageNumber)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter[name]", filterName)); + localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "filter[ids]", filterIds)); + localVarQueryParams.addAll( + apiClient.parameterToPairs("multi", "filter[integration]", filterIntegration)); + localVarQueryParams.addAll( + apiClient.parameterToPairs("multi", "filter[effects]", filterEffects)); + localVarQueryParams.addAll( + apiClient.parameterToPairs("multi", "filter[creator_ids]", filterCreatorIds)); + localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "sort", sort)); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.ExecutionPolicyApi.listExecutionPolicies", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Update an execution policy. + * + *

See {@link #updateExecutionPolicyWithHttpInfo}. + * + * @param policyId The ID of the execution policy. (required) + * @param body The new execution policy. (required) + * @return ExecutionPolicyResponse + * @throws ApiException if fails to make API call + */ + public ExecutionPolicyResponse updateExecutionPolicy( + UUID policyId, ExecutionPolicyUpdateRequest body) throws ApiException { + return updateExecutionPolicyWithHttpInfo(policyId, body).getData(); + } + + /** + * Update an execution policy. + * + *

See {@link #updateExecutionPolicyWithHttpInfoAsync}. + * + * @param policyId The ID of the execution policy. (required) + * @param body The new execution policy. (required) + * @return CompletableFuture<ExecutionPolicyResponse> + */ + public CompletableFuture updateExecutionPolicyAsync( + UUID policyId, ExecutionPolicyUpdateRequest body) { + return updateExecutionPolicyWithHttpInfoAsync(policyId, body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Update an existing execution policy. Returns the execution policy object when the request is + * successful. + * + * @param policyId The ID of the execution policy. (required) + * @param body The new execution policy. (required) + * @return ApiResponse<ExecutionPolicyResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse updateExecutionPolicyWithHttpInfo( + UUID policyId, ExecutionPolicyUpdateRequest body) throws ApiException { + // Check if unstable operation is enabled + String operationId = "updateExecutionPolicy"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = body; + + // verify the required parameter 'policyId' is set + if (policyId == null) { + throw new ApiException( + 400, "Missing the required parameter 'policyId' when calling updateExecutionPolicy"); + } + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling updateExecutionPolicy"); + } + // create path and map variables + String localVarPath = + "/api/v2/actions/execution-policies/{policy_id}" + .replaceAll("\\{" + "policy_id" + "\\}", apiClient.escapeString(policyId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.ExecutionPolicyApi.updateExecutionPolicy", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "PUT", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Update an execution policy. + * + *

See {@link #updateExecutionPolicyWithHttpInfo}. + * + * @param policyId The ID of the execution policy. (required) + * @param body The new execution policy. (required) + * @return CompletableFuture<ApiResponse<ExecutionPolicyResponse>> + */ + public CompletableFuture> + updateExecutionPolicyWithHttpInfoAsync(UUID policyId, ExecutionPolicyUpdateRequest body) { + // Check if unstable operation is enabled + String operationId = "updateExecutionPolicy"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = body; + + // verify the required parameter 'policyId' is set + if (policyId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'policyId' when calling updateExecutionPolicy")); + return result; + } + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'body' when calling updateExecutionPolicy")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/actions/execution-policies/{policy_id}" + .replaceAll("\\{" + "policy_id" + "\\}", apiClient.escapeString(policyId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.ExecutionPolicyApi.updateExecutionPolicy", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "PUT", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyActionPattern.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyActionPattern.java new file mode 100644 index 00000000000..bd97c0dd99d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyActionPattern.java @@ -0,0 +1,189 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** The set of actions this policy applies to. */ +@JsonPropertyOrder({ + ExecutionPolicyActionPattern.JSON_PROPERTY_ACTION_FQNS, + ExecutionPolicyActionPattern.JSON_PROPERTY_INTEGRATION +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ExecutionPolicyActionPattern { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ACTION_FQNS = "action_fqns"; + private List actionFqns = new ArrayList<>(); + + public static final String JSON_PROPERTY_INTEGRATION = "integration"; + private ExecutionPolicyIntegration integration; + + public ExecutionPolicyActionPattern() {} + + @JsonCreator + public ExecutionPolicyActionPattern( + @JsonProperty(required = true, value = JSON_PROPERTY_ACTION_FQNS) List actionFqns, + @JsonProperty(required = true, value = JSON_PROPERTY_INTEGRATION) + ExecutionPolicyIntegration integration) { + this.actionFqns = actionFqns; + this.integration = integration; + this.unparsed |= !integration.isValid(); + } + + public ExecutionPolicyActionPattern actionFqns(List actionFqns) { + this.actionFqns = actionFqns; + return this; + } + + public ExecutionPolicyActionPattern addActionFqnsItem(String actionFqnsItem) { + this.actionFqns.add(actionFqnsItem); + return this; + } + + /** + * 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). + * + * @return actionFqns + */ + @JsonProperty(JSON_PROPERTY_ACTION_FQNS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getActionFqns() { + return actionFqns; + } + + public void setActionFqns(List actionFqns) { + this.actionFqns = actionFqns; + } + + public ExecutionPolicyActionPattern integration(ExecutionPolicyIntegration integration) { + this.integration = integration; + this.unparsed |= !integration.isValid(); + return this; + } + + /** + * The integration the action pattern applies to. + * + * @return integration + */ + @JsonProperty(JSON_PROPERTY_INTEGRATION) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ExecutionPolicyIntegration getIntegration() { + return integration; + } + + public void setIntegration(ExecutionPolicyIntegration integration) { + if (!integration.isValid()) { + this.unparsed = true; + } + this.integration = integration; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ExecutionPolicyActionPattern + */ + @JsonAnySetter + public ExecutionPolicyActionPattern putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ExecutionPolicyActionPattern object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionPolicyActionPattern executionPolicyActionPattern = (ExecutionPolicyActionPattern) o; + return Objects.equals(this.actionFqns, executionPolicyActionPattern.actionFqns) + && Objects.equals(this.integration, executionPolicyActionPattern.integration) + && Objects.equals( + this.additionalProperties, executionPolicyActionPattern.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(actionFqns, integration, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionPolicyActionPattern {\n"); + sb.append(" actionFqns: ").append(toIndentedString(actionFqns)).append("\n"); + sb.append(" integration: ").append(toIndentedString(integration)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyAttributes.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyAttributes.java new file mode 100644 index 00000000000..66bb40612fb --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyAttributes.java @@ -0,0 +1,445 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** An execution policy. */ +@JsonPropertyOrder({ + ExecutionPolicyAttributes.JSON_PROPERTY_ACTION_PATTERN, + ExecutionPolicyAttributes.JSON_PROPERTY_CREATED_AT, + ExecutionPolicyAttributes.JSON_PROPERTY_CREATED_BY, + ExecutionPolicyAttributes.JSON_PROPERTY_EFFECT, + ExecutionPolicyAttributes.JSON_PROPERTY_NAME, + ExecutionPolicyAttributes.JSON_PROPERTY_SCOPE, + ExecutionPolicyAttributes.JSON_PROPERTY_TARGETS, + ExecutionPolicyAttributes.JSON_PROPERTY_UPDATED_AT, + ExecutionPolicyAttributes.JSON_PROPERTY_UPDATED_BY, + ExecutionPolicyAttributes.JSON_PROPERTY_VERSION +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ExecutionPolicyAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ACTION_PATTERN = "action_pattern"; + private ExecutionPolicyActionPattern actionPattern; + + public static final String JSON_PROPERTY_CREATED_AT = "created_at"; + private OffsetDateTime createdAt; + + public static final String JSON_PROPERTY_CREATED_BY = "created_by"; + private String createdBy; + + public static final String JSON_PROPERTY_EFFECT = "effect"; + private ExecutionPolicyEffect effect; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_SCOPE = "scope"; + private ExecutionPolicyScope scope; + + public static final String JSON_PROPERTY_TARGETS = "targets"; + private List targets = new ArrayList<>(); + + public static final String JSON_PROPERTY_UPDATED_AT = "updated_at"; + private OffsetDateTime updatedAt; + + public static final String JSON_PROPERTY_UPDATED_BY = "updated_by"; + private String updatedBy; + + public static final String JSON_PROPERTY_VERSION = "version"; + private Integer version; + + public ExecutionPolicyAttributes() {} + + @JsonCreator + public ExecutionPolicyAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_ACTION_PATTERN) + ExecutionPolicyActionPattern actionPattern, + @JsonProperty(required = true, value = JSON_PROPERTY_CREATED_AT) OffsetDateTime createdAt, + @JsonProperty(required = true, value = JSON_PROPERTY_CREATED_BY) String createdBy, + @JsonProperty(required = true, value = JSON_PROPERTY_EFFECT) ExecutionPolicyEffect effect, + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_TARGETS) + List targets, + @JsonProperty(required = true, value = JSON_PROPERTY_UPDATED_AT) OffsetDateTime updatedAt, + @JsonProperty(required = true, value = JSON_PROPERTY_UPDATED_BY) String updatedBy, + @JsonProperty(required = true, value = JSON_PROPERTY_VERSION) Integer version) { + this.actionPattern = actionPattern; + this.unparsed |= actionPattern.unparsed; + this.createdAt = createdAt; + this.createdBy = createdBy; + this.effect = effect; + this.unparsed |= !effect.isValid(); + this.name = name; + this.targets = targets; + for (ExecutionPolicyTarget item : targets) { + this.unparsed |= item.unparsed; + } + this.updatedAt = updatedAt; + this.updatedBy = updatedBy; + this.version = version; + } + + public ExecutionPolicyAttributes actionPattern(ExecutionPolicyActionPattern actionPattern) { + this.actionPattern = actionPattern; + this.unparsed |= actionPattern.unparsed; + return this; + } + + /** + * The set of actions this policy applies to. + * + * @return actionPattern + */ + @JsonProperty(JSON_PROPERTY_ACTION_PATTERN) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ExecutionPolicyActionPattern getActionPattern() { + return actionPattern; + } + + public void setActionPattern(ExecutionPolicyActionPattern actionPattern) { + this.actionPattern = actionPattern; + if (actionPattern != null) { + this.unparsed |= actionPattern.unparsed; + } + } + + public ExecutionPolicyAttributes createdAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * The date and time the execution policy was created. + * + * @return createdAt + */ + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + public ExecutionPolicyAttributes createdBy(String createdBy) { + this.createdBy = createdBy; + return this; + } + + /** + * The ID of the user who created the execution policy. + * + * @return createdBy + */ + @JsonProperty(JSON_PROPERTY_CREATED_BY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public ExecutionPolicyAttributes effect(ExecutionPolicyEffect effect) { + this.effect = effect; + this.unparsed |= !effect.isValid(); + return this; + } + + /** + * Whether the policy allows or denies matching actions. + * + * @return effect + */ + @JsonProperty(JSON_PROPERTY_EFFECT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ExecutionPolicyEffect getEffect() { + return effect; + } + + public void setEffect(ExecutionPolicyEffect effect) { + if (!effect.isValid()) { + this.unparsed = true; + } + this.effect = effect; + } + + public ExecutionPolicyAttributes name(String name) { + this.name = name; + return this; + } + + /** + * The name of the execution policy. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ExecutionPolicyAttributes scope(ExecutionPolicyScope scope) { + this.scope = scope; + this.unparsed |= scope.unparsed; + return this; + } + + /** + * Restricts where the policy applies. Exactly one of kubernetes, scripts + * , or remote_action_rshell can be set. + * + * @return scope + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SCOPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ExecutionPolicyScope getScope() { + return scope; + } + + public void setScope(ExecutionPolicyScope scope) { + this.scope = scope; + if (scope != null) { + this.unparsed |= scope.unparsed; + } + } + + public ExecutionPolicyAttributes targets(List targets) { + this.targets = targets; + for (ExecutionPolicyTarget item : targets) { + this.unparsed |= item.unparsed; + } + return this; + } + + public ExecutionPolicyAttributes addTargetsItem(ExecutionPolicyTarget targetsItem) { + this.targets.add(targetsItem); + this.unparsed |= targetsItem.unparsed; + return this; + } + + /** + * The targets this policy applies to. + * + * @return targets + */ + @JsonProperty(JSON_PROPERTY_TARGETS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getTargets() { + return targets; + } + + public void setTargets(List targets) { + this.targets = targets; + if (targets != null) { + for (ExecutionPolicyTarget item : targets) { + this.unparsed |= item.unparsed; + } + } + } + + public ExecutionPolicyAttributes updatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + /** + * The date and time the execution policy was last updated. + * + * @return updatedAt + */ + @JsonProperty(JSON_PROPERTY_UPDATED_AT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + } + + public ExecutionPolicyAttributes updatedBy(String updatedBy) { + this.updatedBy = updatedBy; + return this; + } + + /** + * The ID of the user who last updated the execution policy. + * + * @return updatedBy + */ + @JsonProperty(JSON_PROPERTY_UPDATED_BY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getUpdatedBy() { + return updatedBy; + } + + public void setUpdatedBy(String updatedBy) { + this.updatedBy = updatedBy; + } + + public ExecutionPolicyAttributes version(Integer version) { + this.version = version; + return this; + } + + /** + * The version of the execution policy. Incremented on every update. maximum: 2147483647 + * + * @return version + */ + @JsonProperty(JSON_PROPERTY_VERSION) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Integer getVersion() { + return version; + } + + public void setVersion(Integer version) { + this.version = version; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ExecutionPolicyAttributes + */ + @JsonAnySetter + public ExecutionPolicyAttributes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ExecutionPolicyAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionPolicyAttributes executionPolicyAttributes = (ExecutionPolicyAttributes) o; + return Objects.equals(this.actionPattern, executionPolicyAttributes.actionPattern) + && Objects.equals(this.createdAt, executionPolicyAttributes.createdAt) + && Objects.equals(this.createdBy, executionPolicyAttributes.createdBy) + && Objects.equals(this.effect, executionPolicyAttributes.effect) + && Objects.equals(this.name, executionPolicyAttributes.name) + && Objects.equals(this.scope, executionPolicyAttributes.scope) + && Objects.equals(this.targets, executionPolicyAttributes.targets) + && Objects.equals(this.updatedAt, executionPolicyAttributes.updatedAt) + && Objects.equals(this.updatedBy, executionPolicyAttributes.updatedBy) + && Objects.equals(this.version, executionPolicyAttributes.version) + && Objects.equals( + this.additionalProperties, executionPolicyAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + actionPattern, + createdAt, + createdBy, + effect, + name, + scope, + targets, + updatedAt, + updatedBy, + version, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionPolicyAttributes {\n"); + sb.append(" actionPattern: ").append(toIndentedString(actionPattern)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" createdBy: ").append(toIndentedString(createdBy)).append("\n"); + sb.append(" effect: ").append(toIndentedString(effect)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" scope: ").append(toIndentedString(scope)).append("\n"); + sb.append(" targets: ").append(toIndentedString(targets)).append("\n"); + sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); + sb.append(" updatedBy: ").append(toIndentedString(updatedBy)).append("\n"); + sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyCreateRequest.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyCreateRequest.java new file mode 100644 index 00000000000..11ae2419022 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyCreateRequest.java @@ -0,0 +1,150 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Request object that includes the execution policy to create. */ +@JsonPropertyOrder({ExecutionPolicyCreateRequest.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ExecutionPolicyCreateRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private ExecutionPolicyCreateRequestData data; + + public ExecutionPolicyCreateRequest() {} + + @JsonCreator + public ExecutionPolicyCreateRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) + ExecutionPolicyCreateRequestData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public ExecutionPolicyCreateRequest data(ExecutionPolicyCreateRequestData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Object for a single execution policy. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ExecutionPolicyCreateRequestData getData() { + return data; + } + + public void setData(ExecutionPolicyCreateRequestData data) { + this.data = data; + if (data != null) { + this.unparsed |= data.unparsed; + } + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ExecutionPolicyCreateRequest + */ + @JsonAnySetter + public ExecutionPolicyCreateRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ExecutionPolicyCreateRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionPolicyCreateRequest executionPolicyCreateRequest = (ExecutionPolicyCreateRequest) o; + return Objects.equals(this.data, executionPolicyCreateRequest.data) + && Objects.equals( + this.additionalProperties, executionPolicyCreateRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionPolicyCreateRequest {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyCreateRequestData.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyCreateRequestData.java new file mode 100644 index 00000000000..ba0890df31f --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyCreateRequestData.java @@ -0,0 +1,186 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Object for a single execution policy. */ +@JsonPropertyOrder({ + ExecutionPolicyCreateRequestData.JSON_PROPERTY_ATTRIBUTES, + ExecutionPolicyCreateRequestData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ExecutionPolicyCreateRequestData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private ExecutionPolicyWriteAttributes attributes; + + public static final String JSON_PROPERTY_TYPE = "type"; + private ExecutionPolicyType type = ExecutionPolicyType.EXECUTION_POLICY; + + public ExecutionPolicyCreateRequestData() {} + + @JsonCreator + public ExecutionPolicyCreateRequestData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + ExecutionPolicyWriteAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) ExecutionPolicyType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public ExecutionPolicyCreateRequestData attributes(ExecutionPolicyWriteAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes used to create or update an execution policy. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ExecutionPolicyWriteAttributes getAttributes() { + return attributes; + } + + public void setAttributes(ExecutionPolicyWriteAttributes attributes) { + this.attributes = attributes; + if (attributes != null) { + this.unparsed |= attributes.unparsed; + } + } + + public ExecutionPolicyCreateRequestData type(ExecutionPolicyType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The type of the resource. The value should always be execution_policy. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ExecutionPolicyType getType() { + return type; + } + + public void setType(ExecutionPolicyType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ExecutionPolicyCreateRequestData + */ + @JsonAnySetter + public ExecutionPolicyCreateRequestData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ExecutionPolicyCreateRequestData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionPolicyCreateRequestData executionPolicyCreateRequestData = + (ExecutionPolicyCreateRequestData) o; + return Objects.equals(this.attributes, executionPolicyCreateRequestData.attributes) + && Objects.equals(this.type, executionPolicyCreateRequestData.type) + && Objects.equals( + this.additionalProperties, executionPolicyCreateRequestData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionPolicyCreateRequestData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyEffect.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyEffect.java new file mode 100644 index 00000000000..7eb22aa2eb8 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyEffect.java @@ -0,0 +1,56 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** Whether the policy allows or denies matching actions. */ +@JsonSerialize(using = ExecutionPolicyEffect.ExecutionPolicyEffectSerializer.class) +public class ExecutionPolicyEffect extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("allow", "deny")); + + public static final ExecutionPolicyEffect ALLOW = new ExecutionPolicyEffect("allow"); + public static final ExecutionPolicyEffect DENY = new ExecutionPolicyEffect("deny"); + + ExecutionPolicyEffect(String value) { + super(value, allowedValues); + } + + public static class ExecutionPolicyEffectSerializer extends StdSerializer { + public ExecutionPolicyEffectSerializer(Class t) { + super(t); + } + + public ExecutionPolicyEffectSerializer() { + this(null); + } + + @Override + public void serialize( + ExecutionPolicyEffect value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static ExecutionPolicyEffect fromValue(String value) { + return new ExecutionPolicyEffect(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyIntegration.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyIntegration.java new file mode 100644 index 00000000000..a0c0084e964 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyIntegration.java @@ -0,0 +1,63 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** The integration the action pattern applies to. */ +@JsonSerialize(using = ExecutionPolicyIntegration.ExecutionPolicyIntegrationSerializer.class) +public class ExecutionPolicyIntegration extends ModelEnum { + + private static final Set allowedValues = + new HashSet( + Arrays.asList( + "INTEGRATION_KUBERNETES", "INTEGRATION_SCRIPT", "INTEGRATION_REMOTE_ACTION")); + + public static final ExecutionPolicyIntegration INTEGRATION_KUBERNETES = + new ExecutionPolicyIntegration("INTEGRATION_KUBERNETES"); + public static final ExecutionPolicyIntegration INTEGRATION_SCRIPT = + new ExecutionPolicyIntegration("INTEGRATION_SCRIPT"); + public static final ExecutionPolicyIntegration INTEGRATION_REMOTE_ACTION = + new ExecutionPolicyIntegration("INTEGRATION_REMOTE_ACTION"); + + ExecutionPolicyIntegration(String value) { + super(value, allowedValues); + } + + public static class ExecutionPolicyIntegrationSerializer + extends StdSerializer { + public ExecutionPolicyIntegrationSerializer(Class t) { + super(t); + } + + public ExecutionPolicyIntegrationSerializer() { + this(null); + } + + @Override + public void serialize( + ExecutionPolicyIntegration value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static ExecutionPolicyIntegration fromValue(String value) { + return new ExecutionPolicyIntegration(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyKubernetesScope.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyKubernetesScope.java new file mode 100644 index 00000000000..057b9c54da9 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyKubernetesScope.java @@ -0,0 +1,165 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Restricts the policy to specific Kubernetes namespaces. */ +@JsonPropertyOrder({ExecutionPolicyKubernetesScope.JSON_PROPERTY_RULES}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ExecutionPolicyKubernetesScope { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_RULES = "rules"; + private List rules = new ArrayList<>(); + + public ExecutionPolicyKubernetesScope() {} + + @JsonCreator + public ExecutionPolicyKubernetesScope( + @JsonProperty(required = true, value = JSON_PROPERTY_RULES) + List rules) { + this.rules = rules; + for (ExecutionPolicyKubernetesScopeRule item : rules) { + this.unparsed |= item.unparsed; + } + } + + public ExecutionPolicyKubernetesScope rules(List rules) { + this.rules = rules; + for (ExecutionPolicyKubernetesScopeRule item : rules) { + this.unparsed |= item.unparsed; + } + return this; + } + + public ExecutionPolicyKubernetesScope addRulesItem(ExecutionPolicyKubernetesScopeRule rulesItem) { + this.rules.add(rulesItem); + this.unparsed |= rulesItem.unparsed; + return this; + } + + /** + * The Kubernetes scope rules. + * + * @return rules + */ + @JsonProperty(JSON_PROPERTY_RULES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getRules() { + return rules; + } + + public void setRules(List rules) { + this.rules = rules; + if (rules != null) { + for (ExecutionPolicyKubernetesScopeRule item : rules) { + this.unparsed |= item.unparsed; + } + } + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ExecutionPolicyKubernetesScope + */ + @JsonAnySetter + public ExecutionPolicyKubernetesScope putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ExecutionPolicyKubernetesScope object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionPolicyKubernetesScope executionPolicyKubernetesScope = + (ExecutionPolicyKubernetesScope) o; + return Objects.equals(this.rules, executionPolicyKubernetesScope.rules) + && Objects.equals( + this.additionalProperties, executionPolicyKubernetesScope.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(rules, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionPolicyKubernetesScope {\n"); + sb.append(" rules: ").append(toIndentedString(rules)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyKubernetesScopeRule.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyKubernetesScopeRule.java new file mode 100644 index 00000000000..ee279d262ca --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyKubernetesScopeRule.java @@ -0,0 +1,154 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** A rule restricting a Kubernetes scope to specific namespaces. */ +@JsonPropertyOrder({ExecutionPolicyKubernetesScopeRule.JSON_PROPERTY_TARGET_NAMESPACES}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ExecutionPolicyKubernetesScopeRule { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_TARGET_NAMESPACES = "target_namespaces"; + private List targetNamespaces = new ArrayList<>(); + + public ExecutionPolicyKubernetesScopeRule() {} + + @JsonCreator + public ExecutionPolicyKubernetesScopeRule( + @JsonProperty(required = true, value = JSON_PROPERTY_TARGET_NAMESPACES) + List targetNamespaces) { + this.targetNamespaces = targetNamespaces; + } + + public ExecutionPolicyKubernetesScopeRule targetNamespaces(List targetNamespaces) { + this.targetNamespaces = targetNamespaces; + return this; + } + + public ExecutionPolicyKubernetesScopeRule addTargetNamespacesItem(String targetNamespacesItem) { + this.targetNamespaces.add(targetNamespacesItem); + return this; + } + + /** + * The Kubernetes namespaces this rule applies to. + * + * @return targetNamespaces + */ + @JsonProperty(JSON_PROPERTY_TARGET_NAMESPACES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getTargetNamespaces() { + return targetNamespaces; + } + + public void setTargetNamespaces(List targetNamespaces) { + this.targetNamespaces = targetNamespaces; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ExecutionPolicyKubernetesScopeRule + */ + @JsonAnySetter + public ExecutionPolicyKubernetesScopeRule putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ExecutionPolicyKubernetesScopeRule object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionPolicyKubernetesScopeRule executionPolicyKubernetesScopeRule = + (ExecutionPolicyKubernetesScopeRule) o; + return Objects.equals( + this.targetNamespaces, executionPolicyKubernetesScopeRule.targetNamespaces) + && Objects.equals( + this.additionalProperties, executionPolicyKubernetesScopeRule.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(targetNamespaces, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionPolicyKubernetesScopeRule {\n"); + sb.append(" targetNamespaces: ").append(toIndentedString(targetNamespaces)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyListResponse.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyListResponse.java new file mode 100644 index 00000000000..5adcb6a787f --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyListResponse.java @@ -0,0 +1,200 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Response object that includes a list of execution policies. */ +@JsonPropertyOrder({ + ExecutionPolicyListResponse.JSON_PROPERTY_DATA, + ExecutionPolicyListResponse.JSON_PROPERTY_META +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ExecutionPolicyListResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private List data = new ArrayList<>(); + + public static final String JSON_PROPERTY_META = "meta"; + private ExecutionPolicyListResponseMeta meta; + + public ExecutionPolicyListResponse() {} + + @JsonCreator + public ExecutionPolicyListResponse( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) + List data, + @JsonProperty(required = true, value = JSON_PROPERTY_META) + ExecutionPolicyListResponseMeta meta) { + this.data = data; + for (ExecutionPolicyResponseData item : data) { + this.unparsed |= item.unparsed; + } + this.meta = meta; + this.unparsed |= meta.unparsed; + } + + public ExecutionPolicyListResponse data(List data) { + this.data = data; + for (ExecutionPolicyResponseData item : data) { + this.unparsed |= item.unparsed; + } + return this; + } + + public ExecutionPolicyListResponse addDataItem(ExecutionPolicyResponseData dataItem) { + this.data.add(dataItem); + this.unparsed |= dataItem.unparsed; + return this; + } + + /** + * The execution policies. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + if (data != null) { + for (ExecutionPolicyResponseData item : data) { + this.unparsed |= item.unparsed; + } + } + } + + public ExecutionPolicyListResponse meta(ExecutionPolicyListResponseMeta meta) { + this.meta = meta; + this.unparsed |= meta.unparsed; + return this; + } + + /** + * Pagination metadata for the list of execution policies. + * + * @return meta + */ + @JsonProperty(JSON_PROPERTY_META) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ExecutionPolicyListResponseMeta getMeta() { + return meta; + } + + public void setMeta(ExecutionPolicyListResponseMeta meta) { + this.meta = meta; + if (meta != null) { + this.unparsed |= meta.unparsed; + } + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ExecutionPolicyListResponse + */ + @JsonAnySetter + public ExecutionPolicyListResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ExecutionPolicyListResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionPolicyListResponse executionPolicyListResponse = (ExecutionPolicyListResponse) o; + return Objects.equals(this.data, executionPolicyListResponse.data) + && Objects.equals(this.meta, executionPolicyListResponse.meta) + && Objects.equals( + this.additionalProperties, executionPolicyListResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, meta, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionPolicyListResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyListResponseMeta.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyListResponseMeta.java new file mode 100644 index 00000000000..40af0dcfab3 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyListResponseMeta.java @@ -0,0 +1,151 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Pagination metadata for the list of execution policies. */ +@JsonPropertyOrder({ExecutionPolicyListResponseMeta.JSON_PROPERTY_PAGE}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ExecutionPolicyListResponseMeta { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_PAGE = "page"; + private ExecutionPolicyListResponsePage page; + + public ExecutionPolicyListResponseMeta() {} + + @JsonCreator + public ExecutionPolicyListResponseMeta( + @JsonProperty(required = true, value = JSON_PROPERTY_PAGE) + ExecutionPolicyListResponsePage page) { + this.page = page; + this.unparsed |= page.unparsed; + } + + public ExecutionPolicyListResponseMeta page(ExecutionPolicyListResponsePage page) { + this.page = page; + this.unparsed |= page.unparsed; + return this; + } + + /** + * Pagination details. + * + * @return page + */ + @JsonProperty(JSON_PROPERTY_PAGE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ExecutionPolicyListResponsePage getPage() { + return page; + } + + public void setPage(ExecutionPolicyListResponsePage page) { + this.page = page; + if (page != null) { + this.unparsed |= page.unparsed; + } + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ExecutionPolicyListResponseMeta + */ + @JsonAnySetter + public ExecutionPolicyListResponseMeta putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ExecutionPolicyListResponseMeta object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionPolicyListResponseMeta executionPolicyListResponseMeta = + (ExecutionPolicyListResponseMeta) o; + return Objects.equals(this.page, executionPolicyListResponseMeta.page) + && Objects.equals( + this.additionalProperties, executionPolicyListResponseMeta.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(page, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionPolicyListResponseMeta {\n"); + sb.append(" page: ").append(toIndentedString(page)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyListResponsePage.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyListResponsePage.java new file mode 100644 index 00000000000..7b581b2f760 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyListResponsePage.java @@ -0,0 +1,145 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Pagination details. */ +@JsonPropertyOrder({ExecutionPolicyListResponsePage.JSON_PROPERTY_TOTAL}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ExecutionPolicyListResponsePage { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_TOTAL = "total"; + private Integer total; + + public ExecutionPolicyListResponsePage() {} + + @JsonCreator + public ExecutionPolicyListResponsePage( + @JsonProperty(required = true, value = JSON_PROPERTY_TOTAL) Integer total) { + this.total = total; + } + + public ExecutionPolicyListResponsePage total(Integer total) { + this.total = total; + return this; + } + + /** + * The total number of execution policies matching the query. maximum: 2147483647 + * + * @return total + */ + @JsonProperty(JSON_PROPERTY_TOTAL) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Integer getTotal() { + return total; + } + + public void setTotal(Integer total) { + this.total = total; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ExecutionPolicyListResponsePage + */ + @JsonAnySetter + public ExecutionPolicyListResponsePage putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ExecutionPolicyListResponsePage object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionPolicyListResponsePage executionPolicyListResponsePage = + (ExecutionPolicyListResponsePage) o; + return Objects.equals(this.total, executionPolicyListResponsePage.total) + && Objects.equals( + this.additionalProperties, executionPolicyListResponsePage.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(total, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionPolicyListResponsePage {\n"); + sb.append(" total: ").append(toIndentedString(total)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyRemoteActionRshellAccess.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyRemoteActionRshellAccess.java new file mode 100644 index 00000000000..6fb4055795c --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyRemoteActionRshellAccess.java @@ -0,0 +1,65 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** The level of remote shell access granted for the target paths. */ +@JsonSerialize( + using = + ExecutionPolicyRemoteActionRshellAccess.ExecutionPolicyRemoteActionRshellAccessSerializer + .class) +public class ExecutionPolicyRemoteActionRshellAccess extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("read_only", "read_write")); + + public static final ExecutionPolicyRemoteActionRshellAccess READ_ONLY = + new ExecutionPolicyRemoteActionRshellAccess("read_only"); + public static final ExecutionPolicyRemoteActionRshellAccess READ_WRITE = + new ExecutionPolicyRemoteActionRshellAccess("read_write"); + + ExecutionPolicyRemoteActionRshellAccess(String value) { + super(value, allowedValues); + } + + public static class ExecutionPolicyRemoteActionRshellAccessSerializer + extends StdSerializer { + public ExecutionPolicyRemoteActionRshellAccessSerializer( + Class t) { + super(t); + } + + public ExecutionPolicyRemoteActionRshellAccessSerializer() { + this(null); + } + + @Override + public void serialize( + ExecutionPolicyRemoteActionRshellAccess value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static ExecutionPolicyRemoteActionRshellAccess fromValue(String value) { + return new ExecutionPolicyRemoteActionRshellAccess(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyRemoteActionRshellScope.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyRemoteActionRshellScope.java new file mode 100644 index 00000000000..e387ba5e868 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyRemoteActionRshellScope.java @@ -0,0 +1,167 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Restricts the policy to specific remote shell paths. */ +@JsonPropertyOrder({ExecutionPolicyRemoteActionRshellScope.JSON_PROPERTY_RULES}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ExecutionPolicyRemoteActionRshellScope { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_RULES = "rules"; + private List rules = new ArrayList<>(); + + public ExecutionPolicyRemoteActionRshellScope() {} + + @JsonCreator + public ExecutionPolicyRemoteActionRshellScope( + @JsonProperty(required = true, value = JSON_PROPERTY_RULES) + List rules) { + this.rules = rules; + for (ExecutionPolicyRemoteActionRshellScopeRule item : rules) { + this.unparsed |= item.unparsed; + } + } + + public ExecutionPolicyRemoteActionRshellScope rules( + List rules) { + this.rules = rules; + for (ExecutionPolicyRemoteActionRshellScopeRule item : rules) { + this.unparsed |= item.unparsed; + } + return this; + } + + public ExecutionPolicyRemoteActionRshellScope addRulesItem( + ExecutionPolicyRemoteActionRshellScopeRule rulesItem) { + this.rules.add(rulesItem); + this.unparsed |= rulesItem.unparsed; + return this; + } + + /** + * The remote shell scope rules. + * + * @return rules + */ + @JsonProperty(JSON_PROPERTY_RULES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getRules() { + return rules; + } + + public void setRules(List rules) { + this.rules = rules; + if (rules != null) { + for (ExecutionPolicyRemoteActionRshellScopeRule item : rules) { + this.unparsed |= item.unparsed; + } + } + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ExecutionPolicyRemoteActionRshellScope + */ + @JsonAnySetter + public ExecutionPolicyRemoteActionRshellScope putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ExecutionPolicyRemoteActionRshellScope object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionPolicyRemoteActionRshellScope executionPolicyRemoteActionRshellScope = + (ExecutionPolicyRemoteActionRshellScope) o; + return Objects.equals(this.rules, executionPolicyRemoteActionRshellScope.rules) + && Objects.equals( + this.additionalProperties, executionPolicyRemoteActionRshellScope.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(rules, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionPolicyRemoteActionRshellScope {\n"); + sb.append(" rules: ").append(toIndentedString(rules)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyRemoteActionRshellScopeRule.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyRemoteActionRshellScopeRule.java new file mode 100644 index 00000000000..54098154d0c --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyRemoteActionRshellScopeRule.java @@ -0,0 +1,191 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** A rule restricting remote shell access to specific paths. */ +@JsonPropertyOrder({ + ExecutionPolicyRemoteActionRshellScopeRule.JSON_PROPERTY_ACCESS, + ExecutionPolicyRemoteActionRshellScopeRule.JSON_PROPERTY_TARGET_PATHS +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ExecutionPolicyRemoteActionRshellScopeRule { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ACCESS = "access"; + private ExecutionPolicyRemoteActionRshellAccess access; + + public static final String JSON_PROPERTY_TARGET_PATHS = "target_paths"; + private List targetPaths = new ArrayList<>(); + + public ExecutionPolicyRemoteActionRshellScopeRule() {} + + @JsonCreator + public ExecutionPolicyRemoteActionRshellScopeRule( + @JsonProperty(required = true, value = JSON_PROPERTY_ACCESS) + ExecutionPolicyRemoteActionRshellAccess access, + @JsonProperty(required = true, value = JSON_PROPERTY_TARGET_PATHS) List targetPaths) { + this.access = access; + this.unparsed |= !access.isValid(); + this.targetPaths = targetPaths; + } + + public ExecutionPolicyRemoteActionRshellScopeRule access( + ExecutionPolicyRemoteActionRshellAccess access) { + this.access = access; + this.unparsed |= !access.isValid(); + return this; + } + + /** + * The level of remote shell access granted for the target paths. + * + * @return access + */ + @JsonProperty(JSON_PROPERTY_ACCESS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ExecutionPolicyRemoteActionRshellAccess getAccess() { + return access; + } + + public void setAccess(ExecutionPolicyRemoteActionRshellAccess access) { + if (!access.isValid()) { + this.unparsed = true; + } + this.access = access; + } + + public ExecutionPolicyRemoteActionRshellScopeRule targetPaths(List targetPaths) { + this.targetPaths = targetPaths; + return this; + } + + public ExecutionPolicyRemoteActionRshellScopeRule addTargetPathsItem(String targetPathsItem) { + this.targetPaths.add(targetPathsItem); + return this; + } + + /** + * The file system paths this rule applies to. + * + * @return targetPaths + */ + @JsonProperty(JSON_PROPERTY_TARGET_PATHS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getTargetPaths() { + return targetPaths; + } + + public void setTargetPaths(List targetPaths) { + this.targetPaths = targetPaths; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ExecutionPolicyRemoteActionRshellScopeRule + */ + @JsonAnySetter + public ExecutionPolicyRemoteActionRshellScopeRule putAdditionalProperty( + String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ExecutionPolicyRemoteActionRshellScopeRule object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionPolicyRemoteActionRshellScopeRule executionPolicyRemoteActionRshellScopeRule = + (ExecutionPolicyRemoteActionRshellScopeRule) o; + return Objects.equals(this.access, executionPolicyRemoteActionRshellScopeRule.access) + && Objects.equals(this.targetPaths, executionPolicyRemoteActionRshellScopeRule.targetPaths) + && Objects.equals( + this.additionalProperties, + executionPolicyRemoteActionRshellScopeRule.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(access, targetPaths, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionPolicyRemoteActionRshellScopeRule {\n"); + sb.append(" access: ").append(toIndentedString(access)).append("\n"); + sb.append(" targetPaths: ").append(toIndentedString(targetPaths)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyResponse.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyResponse.java new file mode 100644 index 00000000000..0e788cb6eff --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyResponse.java @@ -0,0 +1,148 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Response object that includes a single execution policy. */ +@JsonPropertyOrder({ExecutionPolicyResponse.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ExecutionPolicyResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private ExecutionPolicyResponseData data; + + public ExecutionPolicyResponse() {} + + @JsonCreator + public ExecutionPolicyResponse( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) ExecutionPolicyResponseData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public ExecutionPolicyResponse data(ExecutionPolicyResponseData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Object for a single execution policy. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ExecutionPolicyResponseData getData() { + return data; + } + + public void setData(ExecutionPolicyResponseData data) { + this.data = data; + if (data != null) { + this.unparsed |= data.unparsed; + } + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ExecutionPolicyResponse + */ + @JsonAnySetter + public ExecutionPolicyResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ExecutionPolicyResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionPolicyResponse executionPolicyResponse = (ExecutionPolicyResponse) o; + return Objects.equals(this.data, executionPolicyResponse.data) + && Objects.equals(this.additionalProperties, executionPolicyResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionPolicyResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyResponseData.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyResponseData.java new file mode 100644 index 00000000000..4aef8bb3c02 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyResponseData.java @@ -0,0 +1,204 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Object for a single execution policy. */ +@JsonPropertyOrder({ + ExecutionPolicyResponseData.JSON_PROPERTY_ATTRIBUTES, + ExecutionPolicyResponseData.JSON_PROPERTY_ID, + ExecutionPolicyResponseData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ExecutionPolicyResponseData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private ExecutionPolicyAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private ExecutionPolicyType type = ExecutionPolicyType.EXECUTION_POLICY; + + public ExecutionPolicyResponseData() {} + + @JsonCreator + public ExecutionPolicyResponseData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + ExecutionPolicyAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) ExecutionPolicyType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public ExecutionPolicyResponseData attributes(ExecutionPolicyAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * An execution policy. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ExecutionPolicyAttributes getAttributes() { + return attributes; + } + + public void setAttributes(ExecutionPolicyAttributes attributes) { + this.attributes = attributes; + if (attributes != null) { + this.unparsed |= attributes.unparsed; + } + } + + /** + * The ID of the execution policy. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getId() { + return id; + } + + public ExecutionPolicyResponseData type(ExecutionPolicyType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The type of the resource. The value should always be execution_policy. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ExecutionPolicyType getType() { + return type; + } + + public void setType(ExecutionPolicyType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ExecutionPolicyResponseData + */ + @JsonAnySetter + public ExecutionPolicyResponseData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ExecutionPolicyResponseData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionPolicyResponseData executionPolicyResponseData = (ExecutionPolicyResponseData) o; + return Objects.equals(this.attributes, executionPolicyResponseData.attributes) + && Objects.equals(this.id, executionPolicyResponseData.id) + && Objects.equals(this.type, executionPolicyResponseData.type) + && Objects.equals( + this.additionalProperties, executionPolicyResponseData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionPolicyResponseData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyScope.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyScope.java new file mode 100644 index 00000000000..621d0ef3071 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyScope.java @@ -0,0 +1,207 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Restricts where the policy applies. Exactly one of kubernetes, scripts, + * or remote_action_rshell can be set. + */ +@JsonPropertyOrder({ + ExecutionPolicyScope.JSON_PROPERTY_KUBERNETES, + ExecutionPolicyScope.JSON_PROPERTY_REMOTE_ACTION_RSHELL, + ExecutionPolicyScope.JSON_PROPERTY_SCRIPTS +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ExecutionPolicyScope { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_KUBERNETES = "kubernetes"; + private ExecutionPolicyKubernetesScope kubernetes; + + public static final String JSON_PROPERTY_REMOTE_ACTION_RSHELL = "remote_action_rshell"; + private ExecutionPolicyRemoteActionRshellScope remoteActionRshell; + + public static final String JSON_PROPERTY_SCRIPTS = "scripts"; + private ExecutionPolicyScriptScope scripts; + + public ExecutionPolicyScope kubernetes(ExecutionPolicyKubernetesScope kubernetes) { + this.kubernetes = kubernetes; + this.unparsed |= kubernetes.unparsed; + return this; + } + + /** + * Restricts the policy to specific Kubernetes namespaces. + * + * @return kubernetes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_KUBERNETES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ExecutionPolicyKubernetesScope getKubernetes() { + return kubernetes; + } + + public void setKubernetes(ExecutionPolicyKubernetesScope kubernetes) { + this.kubernetes = kubernetes; + if (kubernetes != null) { + this.unparsed |= kubernetes.unparsed; + } + } + + public ExecutionPolicyScope remoteActionRshell( + ExecutionPolicyRemoteActionRshellScope remoteActionRshell) { + this.remoteActionRshell = remoteActionRshell; + this.unparsed |= remoteActionRshell.unparsed; + return this; + } + + /** + * Restricts the policy to specific remote shell paths. + * + * @return remoteActionRshell + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_REMOTE_ACTION_RSHELL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ExecutionPolicyRemoteActionRshellScope getRemoteActionRshell() { + return remoteActionRshell; + } + + public void setRemoteActionRshell(ExecutionPolicyRemoteActionRshellScope remoteActionRshell) { + this.remoteActionRshell = remoteActionRshell; + if (remoteActionRshell != null) { + this.unparsed |= remoteActionRshell.unparsed; + } + } + + public ExecutionPolicyScope scripts(ExecutionPolicyScriptScope scripts) { + this.scripts = scripts; + this.unparsed |= scripts.unparsed; + return this; + } + + /** + * Restricts the policy to specific scripts. + * + * @return scripts + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SCRIPTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ExecutionPolicyScriptScope getScripts() { + return scripts; + } + + public void setScripts(ExecutionPolicyScriptScope scripts) { + this.scripts = scripts; + if (scripts != null) { + this.unparsed |= scripts.unparsed; + } + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ExecutionPolicyScope + */ + @JsonAnySetter + public ExecutionPolicyScope putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ExecutionPolicyScope object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionPolicyScope executionPolicyScope = (ExecutionPolicyScope) o; + return Objects.equals(this.kubernetes, executionPolicyScope.kubernetes) + && Objects.equals(this.remoteActionRshell, executionPolicyScope.remoteActionRshell) + && Objects.equals(this.scripts, executionPolicyScope.scripts) + && Objects.equals(this.additionalProperties, executionPolicyScope.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(kubernetes, remoteActionRshell, scripts, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionPolicyScope {\n"); + sb.append(" kubernetes: ").append(toIndentedString(kubernetes)).append("\n"); + sb.append(" remoteActionRshell: ").append(toIndentedString(remoteActionRshell)).append("\n"); + sb.append(" scripts: ").append(toIndentedString(scripts)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyScriptScope.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyScriptScope.java new file mode 100644 index 00000000000..42724a3658d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyScriptScope.java @@ -0,0 +1,164 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Restricts the policy to specific scripts. */ +@JsonPropertyOrder({ExecutionPolicyScriptScope.JSON_PROPERTY_RULES}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ExecutionPolicyScriptScope { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_RULES = "rules"; + private List rules = new ArrayList<>(); + + public ExecutionPolicyScriptScope() {} + + @JsonCreator + public ExecutionPolicyScriptScope( + @JsonProperty(required = true, value = JSON_PROPERTY_RULES) + List rules) { + this.rules = rules; + for (ExecutionPolicyScriptScopeRule item : rules) { + this.unparsed |= item.unparsed; + } + } + + public ExecutionPolicyScriptScope rules(List rules) { + this.rules = rules; + for (ExecutionPolicyScriptScopeRule item : rules) { + this.unparsed |= item.unparsed; + } + return this; + } + + public ExecutionPolicyScriptScope addRulesItem(ExecutionPolicyScriptScopeRule rulesItem) { + this.rules.add(rulesItem); + this.unparsed |= rulesItem.unparsed; + return this; + } + + /** + * The script scope rules. + * + * @return rules + */ + @JsonProperty(JSON_PROPERTY_RULES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getRules() { + return rules; + } + + public void setRules(List rules) { + this.rules = rules; + if (rules != null) { + for (ExecutionPolicyScriptScopeRule item : rules) { + this.unparsed |= item.unparsed; + } + } + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ExecutionPolicyScriptScope + */ + @JsonAnySetter + public ExecutionPolicyScriptScope putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ExecutionPolicyScriptScope object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionPolicyScriptScope executionPolicyScriptScope = (ExecutionPolicyScriptScope) o; + return Objects.equals(this.rules, executionPolicyScriptScope.rules) + && Objects.equals( + this.additionalProperties, executionPolicyScriptScope.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(rules, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionPolicyScriptScope {\n"); + sb.append(" rules: ").append(toIndentedString(rules)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyScriptScopeRule.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyScriptScopeRule.java new file mode 100644 index 00000000000..bae2efa1268 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyScriptScopeRule.java @@ -0,0 +1,153 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** A rule restricting a script scope to specific script names. */ +@JsonPropertyOrder({ExecutionPolicyScriptScopeRule.JSON_PROPERTY_TARGET_SCRIPT_NAMES}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ExecutionPolicyScriptScopeRule { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_TARGET_SCRIPT_NAMES = "target_script_names"; + private List targetScriptNames = new ArrayList<>(); + + public ExecutionPolicyScriptScopeRule() {} + + @JsonCreator + public ExecutionPolicyScriptScopeRule( + @JsonProperty(required = true, value = JSON_PROPERTY_TARGET_SCRIPT_NAMES) + List targetScriptNames) { + this.targetScriptNames = targetScriptNames; + } + + public ExecutionPolicyScriptScopeRule targetScriptNames(List targetScriptNames) { + this.targetScriptNames = targetScriptNames; + return this; + } + + public ExecutionPolicyScriptScopeRule addTargetScriptNamesItem(String targetScriptNamesItem) { + this.targetScriptNames.add(targetScriptNamesItem); + return this; + } + + /** + * The script names this rule applies to. + * + * @return targetScriptNames + */ + @JsonProperty(JSON_PROPERTY_TARGET_SCRIPT_NAMES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getTargetScriptNames() { + return targetScriptNames; + } + + public void setTargetScriptNames(List targetScriptNames) { + this.targetScriptNames = targetScriptNames; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ExecutionPolicyScriptScopeRule + */ + @JsonAnySetter + public ExecutionPolicyScriptScopeRule putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ExecutionPolicyScriptScopeRule object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionPolicyScriptScopeRule executionPolicyScriptScopeRule = + (ExecutionPolicyScriptScopeRule) o; + return Objects.equals(this.targetScriptNames, executionPolicyScriptScopeRule.targetScriptNames) + && Objects.equals( + this.additionalProperties, executionPolicyScriptScopeRule.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(targetScriptNames, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionPolicyScriptScopeRule {\n"); + sb.append(" targetScriptNames: ").append(toIndentedString(targetScriptNames)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyTarget.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyTarget.java new file mode 100644 index 00000000000..ee0d5de4bd6 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyTarget.java @@ -0,0 +1,190 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** A target this policy is scoped to, expressed as a set of Agent tags. */ +@JsonPropertyOrder({ + ExecutionPolicyTarget.JSON_PROPERTY_AGENT_TAGS, + ExecutionPolicyTarget.JSON_PROPERTY_NAME +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ExecutionPolicyTarget { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_AGENT_TAGS = "agent_tags"; + private List agentTags = new ArrayList<>(); + + public static final String JSON_PROPERTY_NAME = "name"; + private JsonNullable name = JsonNullable.undefined(); + + public ExecutionPolicyTarget() {} + + @JsonCreator + public ExecutionPolicyTarget( + @JsonProperty(required = true, value = JSON_PROPERTY_AGENT_TAGS) List agentTags) { + this.agentTags = agentTags; + } + + public ExecutionPolicyTarget agentTags(List agentTags) { + this.agentTags = agentTags; + return this; + } + + public ExecutionPolicyTarget addAgentTagsItem(String agentTagsItem) { + this.agentTags.add(agentTagsItem); + return this; + } + + /** + * The Agent tags identifying the target. + * + * @return agentTags + */ + @JsonProperty(JSON_PROPERTY_AGENT_TAGS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getAgentTags() { + return agentTags; + } + + public void setAgentTags(List agentTags) { + this.agentTags = agentTags; + } + + public ExecutionPolicyTarget name(String name) { + this.name = JsonNullable.of(name); + return this; + } + + /** + * A human-readable name for the target. + * + * @return name + */ + @jakarta.annotation.Nullable + @JsonIgnore + public String getName() { + return name.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getName_JsonNullable() { + return name; + } + + @JsonProperty(JSON_PROPERTY_NAME) + public void setName_JsonNullable(JsonNullable name) { + this.name = name; + } + + public void setName(String name) { + this.name = JsonNullable.of(name); + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ExecutionPolicyTarget + */ + @JsonAnySetter + public ExecutionPolicyTarget putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ExecutionPolicyTarget object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionPolicyTarget executionPolicyTarget = (ExecutionPolicyTarget) o; + return Objects.equals(this.agentTags, executionPolicyTarget.agentTags) + && Objects.equals(this.name, executionPolicyTarget.name) + && Objects.equals(this.additionalProperties, executionPolicyTarget.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(agentTags, name, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionPolicyTarget {\n"); + sb.append(" agentTags: ").append(toIndentedString(agentTags)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyType.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyType.java new file mode 100644 index 00000000000..2f4f255dfe1 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyType.java @@ -0,0 +1,56 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** The type of the resource. The value should always be execution_policy. */ +@JsonSerialize(using = ExecutionPolicyType.ExecutionPolicyTypeSerializer.class) +public class ExecutionPolicyType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("execution_policy")); + + public static final ExecutionPolicyType EXECUTION_POLICY = + new ExecutionPolicyType("execution_policy"); + + ExecutionPolicyType(String value) { + super(value, allowedValues); + } + + public static class ExecutionPolicyTypeSerializer extends StdSerializer { + public ExecutionPolicyTypeSerializer(Class t) { + super(t); + } + + public ExecutionPolicyTypeSerializer() { + this(null); + } + + @Override + public void serialize( + ExecutionPolicyType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static ExecutionPolicyType fromValue(String value) { + return new ExecutionPolicyType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyUpdateRequest.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyUpdateRequest.java new file mode 100644 index 00000000000..f8226c283f2 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyUpdateRequest.java @@ -0,0 +1,150 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Request object that includes the execution policy to update. */ +@JsonPropertyOrder({ExecutionPolicyUpdateRequest.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ExecutionPolicyUpdateRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private ExecutionPolicyUpdateRequestData data; + + public ExecutionPolicyUpdateRequest() {} + + @JsonCreator + public ExecutionPolicyUpdateRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) + ExecutionPolicyUpdateRequestData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public ExecutionPolicyUpdateRequest data(ExecutionPolicyUpdateRequestData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Object for a single execution policy. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ExecutionPolicyUpdateRequestData getData() { + return data; + } + + public void setData(ExecutionPolicyUpdateRequestData data) { + this.data = data; + if (data != null) { + this.unparsed |= data.unparsed; + } + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ExecutionPolicyUpdateRequest + */ + @JsonAnySetter + public ExecutionPolicyUpdateRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ExecutionPolicyUpdateRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionPolicyUpdateRequest executionPolicyUpdateRequest = (ExecutionPolicyUpdateRequest) o; + return Objects.equals(this.data, executionPolicyUpdateRequest.data) + && Objects.equals( + this.additionalProperties, executionPolicyUpdateRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionPolicyUpdateRequest {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyUpdateRequestData.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyUpdateRequestData.java new file mode 100644 index 00000000000..847af45f36d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyUpdateRequestData.java @@ -0,0 +1,214 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Object for a single execution policy. */ +@JsonPropertyOrder({ + ExecutionPolicyUpdateRequestData.JSON_PROPERTY_ATTRIBUTES, + ExecutionPolicyUpdateRequestData.JSON_PROPERTY_ID, + ExecutionPolicyUpdateRequestData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ExecutionPolicyUpdateRequestData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private ExecutionPolicyWriteAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private ExecutionPolicyType type = ExecutionPolicyType.EXECUTION_POLICY; + + public ExecutionPolicyUpdateRequestData() {} + + @JsonCreator + public ExecutionPolicyUpdateRequestData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + ExecutionPolicyWriteAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) ExecutionPolicyType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public ExecutionPolicyUpdateRequestData attributes(ExecutionPolicyWriteAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes used to create or update an execution policy. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ExecutionPolicyWriteAttributes getAttributes() { + return attributes; + } + + public void setAttributes(ExecutionPolicyWriteAttributes attributes) { + this.attributes = attributes; + if (attributes != null) { + this.unparsed |= attributes.unparsed; + } + } + + public ExecutionPolicyUpdateRequestData id(String id) { + this.id = id; + return this; + } + + /** + * The ID of the execution policy. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public ExecutionPolicyUpdateRequestData type(ExecutionPolicyType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The type of the resource. The value should always be execution_policy. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ExecutionPolicyType getType() { + return type; + } + + public void setType(ExecutionPolicyType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ExecutionPolicyUpdateRequestData + */ + @JsonAnySetter + public ExecutionPolicyUpdateRequestData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ExecutionPolicyUpdateRequestData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionPolicyUpdateRequestData executionPolicyUpdateRequestData = + (ExecutionPolicyUpdateRequestData) o; + return Objects.equals(this.attributes, executionPolicyUpdateRequestData.attributes) + && Objects.equals(this.id, executionPolicyUpdateRequestData.id) + && Objects.equals(this.type, executionPolicyUpdateRequestData.type) + && Objects.equals( + this.additionalProperties, executionPolicyUpdateRequestData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionPolicyUpdateRequestData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyWriteAttributes.java b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyWriteAttributes.java new file mode 100644 index 00000000000..4b748bc7c54 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ExecutionPolicyWriteAttributes.java @@ -0,0 +1,294 @@ +/* + * 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. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Attributes used to create or update an execution policy. */ +@JsonPropertyOrder({ + ExecutionPolicyWriteAttributes.JSON_PROPERTY_ACTION_PATTERN, + ExecutionPolicyWriteAttributes.JSON_PROPERTY_EFFECT, + ExecutionPolicyWriteAttributes.JSON_PROPERTY_NAME, + ExecutionPolicyWriteAttributes.JSON_PROPERTY_SCOPE, + ExecutionPolicyWriteAttributes.JSON_PROPERTY_TARGETS +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ExecutionPolicyWriteAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ACTION_PATTERN = "action_pattern"; + private ExecutionPolicyActionPattern actionPattern; + + public static final String JSON_PROPERTY_EFFECT = "effect"; + private ExecutionPolicyEffect effect; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_SCOPE = "scope"; + private ExecutionPolicyScope scope; + + public static final String JSON_PROPERTY_TARGETS = "targets"; + private List targets = null; + + public ExecutionPolicyWriteAttributes() {} + + @JsonCreator + public ExecutionPolicyWriteAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_ACTION_PATTERN) + ExecutionPolicyActionPattern actionPattern, + @JsonProperty(required = true, value = JSON_PROPERTY_EFFECT) ExecutionPolicyEffect effect, + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name) { + this.actionPattern = actionPattern; + this.unparsed |= actionPattern.unparsed; + this.effect = effect; + this.unparsed |= !effect.isValid(); + this.name = name; + } + + public ExecutionPolicyWriteAttributes actionPattern(ExecutionPolicyActionPattern actionPattern) { + this.actionPattern = actionPattern; + this.unparsed |= actionPattern.unparsed; + return this; + } + + /** + * The set of actions this policy applies to. + * + * @return actionPattern + */ + @JsonProperty(JSON_PROPERTY_ACTION_PATTERN) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ExecutionPolicyActionPattern getActionPattern() { + return actionPattern; + } + + public void setActionPattern(ExecutionPolicyActionPattern actionPattern) { + this.actionPattern = actionPattern; + if (actionPattern != null) { + this.unparsed |= actionPattern.unparsed; + } + } + + public ExecutionPolicyWriteAttributes effect(ExecutionPolicyEffect effect) { + this.effect = effect; + this.unparsed |= !effect.isValid(); + return this; + } + + /** + * Whether the policy allows or denies matching actions. + * + * @return effect + */ + @JsonProperty(JSON_PROPERTY_EFFECT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ExecutionPolicyEffect getEffect() { + return effect; + } + + public void setEffect(ExecutionPolicyEffect effect) { + if (!effect.isValid()) { + this.unparsed = true; + } + this.effect = effect; + } + + public ExecutionPolicyWriteAttributes name(String name) { + this.name = name; + return this; + } + + /** + * The name of the execution policy. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ExecutionPolicyWriteAttributes scope(ExecutionPolicyScope scope) { + this.scope = scope; + this.unparsed |= scope.unparsed; + return this; + } + + /** + * Restricts where the policy applies. Exactly one of kubernetes, scripts + * , or remote_action_rshell can be set. + * + * @return scope + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SCOPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ExecutionPolicyScope getScope() { + return scope; + } + + public void setScope(ExecutionPolicyScope scope) { + this.scope = scope; + if (scope != null) { + this.unparsed |= scope.unparsed; + } + } + + public ExecutionPolicyWriteAttributes targets(List targets) { + this.targets = targets; + if (targets != null) { + for (ExecutionPolicyTarget item : targets) { + this.unparsed |= item.unparsed; + } + } + return this; + } + + public ExecutionPolicyWriteAttributes addTargetsItem(ExecutionPolicyTarget targetsItem) { + if (this.targets == null) { + this.targets = new ArrayList<>(); + } + this.targets.add(targetsItem); + this.unparsed |= targetsItem.unparsed; + return this; + } + + /** + * The targets this policy applies to. + * + * @return targets + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TARGETS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getTargets() { + return targets; + } + + public void setTargets(List targets) { + this.targets = targets; + if (targets != null) { + for (ExecutionPolicyTarget item : targets) { + this.unparsed |= item.unparsed; + } + } + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ExecutionPolicyWriteAttributes + */ + @JsonAnySetter + public ExecutionPolicyWriteAttributes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ExecutionPolicyWriteAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ExecutionPolicyWriteAttributes executionPolicyWriteAttributes = + (ExecutionPolicyWriteAttributes) o; + return Objects.equals(this.actionPattern, executionPolicyWriteAttributes.actionPattern) + && Objects.equals(this.effect, executionPolicyWriteAttributes.effect) + && Objects.equals(this.name, executionPolicyWriteAttributes.name) + && Objects.equals(this.scope, executionPolicyWriteAttributes.scope) + && Objects.equals(this.targets, executionPolicyWriteAttributes.targets) + && Objects.equals( + this.additionalProperties, executionPolicyWriteAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(actionPattern, effect, name, scope, targets, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ExecutionPolicyWriteAttributes {\n"); + sb.append(" actionPattern: ").append(toIndentedString(actionPattern)).append("\n"); + sb.append(" effect: ").append(toIndentedString(effect)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" scope: ").append(toIndentedString(scope)).append("\n"); + sb.append(" targets: ").append(toIndentedString(targets)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/test/resources/cassettes/features/v2/Create_an_execution_policy_returns_Bad_Request_response.freeze b/src/test/resources/cassettes/features/v2/Create_an_execution_policy_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..424a723c117 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Create_an_execution_policy_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2026-08-14T09:13:38.368Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Create_an_execution_policy_returns_Bad_Request_response.json b/src/test/resources/cassettes/features/v2/Create_an_execution_policy_returns_Bad_Request_response.json new file mode 100644 index 00000000000..83b029907cd --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Create_an_execution_policy_returns_Bad_Request_response.json @@ -0,0 +1,32 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"action_pattern\":{\"action_fqns\":[\"com.datadoghq.script.*\"],\"integration\":\"INTEGRATION_SCRIPT\"},\"effect\":\"invalid_effect\",\"name\":\"Cassette Execution Policy\"},\"type\":\"execution_policy\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/actions/execution-policies", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"error creating execution policy\"}]}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 400, + "reasonPhrase": "Bad Request" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "083210f6-836e-5086-89d9-ea02d768b1c9" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Create_an_execution_policy_returns_Created_response.freeze b/src/test/resources/cassettes/features/v2/Create_an_execution_policy_returns_Created_response.freeze new file mode 100644 index 00000000000..5ed5e8ab879 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Create_an_execution_policy_returns_Created_response.freeze @@ -0,0 +1 @@ +2026-08-14T09:13:38.801Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Create_an_execution_policy_returns_Created_response.json b/src/test/resources/cassettes/features/v2/Create_an_execution_policy_returns_Created_response.json new file mode 100644 index 00000000000..ad87525665c --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Create_an_execution_policy_returns_Created_response.json @@ -0,0 +1,53 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"action_pattern\":{\"action_fqns\":[\"com.datadoghq.script.*\"],\"integration\":\"INTEGRATION_SCRIPT\"},\"effect\":\"allow\",\"name\":\"Cassette Execution Policy testcreateanexecutionpolicyreturnscreatedresponse1786698818\"},\"type\":\"execution_policy\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/actions/execution-policies", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "6b5f94b8-4a34-0045-4232-60b220a2dfc3" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/actions/execution-policies/78061915-3922-4868-93c5-12a631d74ed1", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "5541efd6-1efa-002e-aec9-e01469a1f000" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Create_an_execution_policy_with_scope_and_targets_returns_Created_response.freeze b/src/test/resources/cassettes/features/v2/Create_an_execution_policy_with_scope_and_targets_returns_Created_response.freeze new file mode 100644 index 00000000000..f51bfa15b31 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Create_an_execution_policy_with_scope_and_targets_returns_Created_response.freeze @@ -0,0 +1 @@ +2026-08-14T09:13:39.401Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Create_an_execution_policy_with_scope_and_targets_returns_Created_response.json b/src/test/resources/cassettes/features/v2/Create_an_execution_policy_with_scope_and_targets_returns_Created_response.json new file mode 100644 index 00000000000..291eddef1f5 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Create_an_execution_policy_with_scope_and_targets_returns_Created_response.json @@ -0,0 +1,53 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"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": {}, + "method": "POST", + "path": "/api/v2/actions/execution-policies", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "0f6c0b9e-d487-6d7d-14fb-6fec69810d60" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/actions/execution-policies/90a83e60-76b3-4064-a240-f65b602bbddd", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "a80a9572-7991-7b14-b0e1-cf120c22e51d" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Delete_an_execution_policy_returns_No_Content_response.freeze b/src/test/resources/cassettes/features/v2/Delete_an_execution_policy_returns_No_Content_response.freeze new file mode 100644 index 00000000000..499fef5f169 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Delete_an_execution_policy_returns_No_Content_response.freeze @@ -0,0 +1 @@ +2026-08-14T09:13:40.195Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Delete_an_execution_policy_returns_No_Content_response.json b/src/test/resources/cassettes/features/v2/Delete_an_execution_policy_returns_No_Content_response.json new file mode 100644 index 00000000000..ae2c7ebcc81 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Delete_an_execution_policy_returns_No_Content_response.json @@ -0,0 +1,79 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"action_pattern\":{\"action_fqns\":[\"com.datadoghq.script.*\"],\"integration\":\"INTEGRATION_SCRIPT\"},\"effect\":\"allow\",\"name\":\"Cassette Execution Policy testdeleteanexecutionpolicyreturnsnocontentresponse1786698820\"},\"type\":\"execution_policy\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/actions/execution-policies", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "983e1c9d-b587-e2a4-252d-e8647052a679" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/actions/execution-policies/a8e55d88-0769-4cb9-b7d9-10f55fc6ecc2", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "b6257a55-c371-b02e-69ab-e241e232c3a0" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/actions/execution-policies/a8e55d88-0769-4cb9-b7d9-10f55fc6ecc2", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"error deleting execution policy\"}]}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 404, + "reasonPhrase": "Not Found" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "b6257a55-c371-b02e-69ab-e241e232c3a1" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Delete_an_execution_policy_returns_Not_Found_response.freeze b/src/test/resources/cassettes/features/v2/Delete_an_execution_policy_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..3c448d019f3 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Delete_an_execution_policy_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2026-08-14T09:13:41.276Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Delete_an_execution_policy_returns_Not_Found_response.json b/src/test/resources/cassettes/features/v2/Delete_an_execution_policy_returns_Not_Found_response.json new file mode 100644 index 00000000000..c3260dddfa6 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Delete_an_execution_policy_returns_Not_Found_response.json @@ -0,0 +1,28 @@ +[ + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/actions/execution-policies/aaa11111-aa11-aa11-aaaa-aaaaaa111111", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"error deleting execution policy\"}]}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 404, + "reasonPhrase": "Not Found" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "e0843177-541c-24c1-8450-7391d7fa0b5e" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_an_execution_policy_returns_Not_Found_response.freeze b/src/test/resources/cassettes/features/v2/Get_an_execution_policy_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..85555326ef8 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_an_execution_policy_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2026-08-14T09:13:41.623Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_an_execution_policy_returns_Not_Found_response.json b/src/test/resources/cassettes/features/v2/Get_an_execution_policy_returns_Not_Found_response.json new file mode 100644 index 00000000000..f9c5cf7eb29 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_an_execution_policy_returns_Not_Found_response.json @@ -0,0 +1,28 @@ +[ + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/actions/execution-policies/aaa11111-aa11-aa11-aaaa-aaaaaa111111", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"error getting execution policy\"}]}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 404, + "reasonPhrase": "Not Found" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "65db3da5-7e49-128c-df6d-d07c447497cc" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_an_execution_policy_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Get_an_execution_policy_returns_OK_response.freeze new file mode 100644 index 00000000000..c4173bfec7a --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_an_execution_policy_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-08-14T09:13:41.923Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_an_execution_policy_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Get_an_execution_policy_returns_OK_response.json new file mode 100644 index 00000000000..357bb174e40 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_an_execution_policy_returns_OK_response.json @@ -0,0 +1,79 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"action_pattern\":{\"action_fqns\":[\"com.datadoghq.script.*\"],\"integration\":\"INTEGRATION_SCRIPT\"},\"effect\":\"allow\",\"name\":\"Cassette Execution Policy testgetanexecutionpolicyreturnsokresponse1786698821\"},\"type\":\"execution_policy\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/actions/execution-policies", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "6009ff28-8ccf-389c-1f82-6f6f6b23295f" + }, + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/actions/execution-policies/8856f100-43c1-4462-a96e-5ab404e695dc", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "5f4391dd-6b6a-c9ac-2dc9-2b317f28d0f8" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/actions/execution-policies/8856f100-43c1-4462-a96e-5ab404e695dc", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "86f78b69-710e-1bc7-d819-e4323e2b0190" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/List_execution_policies_returns_Bad_Request_response.freeze b/src/test/resources/cassettes/features/v2/List_execution_policies_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..5161e8eccbe --- /dev/null +++ b/src/test/resources/cassettes/features/v2/List_execution_policies_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2026-08-14T09:13:43.018Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/List_execution_policies_returns_Bad_Request_response.json b/src/test/resources/cassettes/features/v2/List_execution_policies_returns_Bad_Request_response.json new file mode 100644 index 00000000000..7214820f462 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/List_execution_policies_returns_Bad_Request_response.json @@ -0,0 +1,33 @@ +[ + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/actions/execution-policies", + "queryStringParameters": { + "page[size]": [ + "0" + ] + }, + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"error listing execution policies\"}]}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 400, + "reasonPhrase": "Bad Request" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "d6d8f3b2-ced2-1dd7-29b5-1b74fc4acf6b" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/List_execution_policies_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/List_execution_policies_returns_OK_response.freeze new file mode 100644 index 00000000000..653eb373285 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/List_execution_policies_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-08-14T09:13:43.364Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/List_execution_policies_returns_OK_response.json b/src/test/resources/cassettes/features/v2/List_execution_policies_returns_OK_response.json new file mode 100644 index 00000000000..34814696348 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/List_execution_policies_returns_OK_response.json @@ -0,0 +1,79 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"action_pattern\":{\"action_fqns\":[\"com.datadoghq.script.*\"],\"integration\":\"INTEGRATION_SCRIPT\"},\"effect\":\"allow\",\"name\":\"Cassette Execution Policy testlistexecutionpoliciesreturnsokresponse1786698823\"},\"type\":\"execution_policy\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/actions/execution-policies", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "e543a273-d088-5f43-b93e-d5c65f6d9e78" + }, + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/actions/execution-policies", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "7ed60fd7-b05a-643d-eb64-510ac5474de6" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/actions/execution-policies/8bb1ecd0-aed6-42cd-8a07-f9f781856f39", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "fea8b81d-48cd-00f6-6e5c-d8569af99b3b" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/List_execution_policies_with_query_parameters_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/List_execution_policies_with_query_parameters_returns_OK_response.freeze new file mode 100644 index 00000000000..0cba39e9f65 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/List_execution_policies_with_query_parameters_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-08-14T09:13:44.371Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/List_execution_policies_with_query_parameters_returns_OK_response.json b/src/test/resources/cassettes/features/v2/List_execution_policies_with_query_parameters_returns_OK_response.json new file mode 100644 index 00000000000..1b9f5a5ed5f --- /dev/null +++ b/src/test/resources/cassettes/features/v2/List_execution_policies_with_query_parameters_returns_OK_response.json @@ -0,0 +1,105 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"action_pattern\":{\"action_fqns\":[\"com.datadoghq.script.*\"],\"integration\":\"INTEGRATION_SCRIPT\"},\"effect\":\"allow\",\"name\":\"Cassette Execution Policy testlistexecutionpolicieswithqueryparametersreturnsokresponse1786698824\"},\"type\":\"execution_policy\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/actions/execution-policies", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "ffc7f720-d345-ee96-c354-9d477e6b9929" + }, + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/actions/execution-policies", + "queryStringParameters": { + "page[size]": [ + "10" + ], + "page[number]": [ + "0" + ], + "filter[name]": [ + "Cassette Execution Policy testlistexecutionpolicieswithqueryparametersreturnsokresponse1786698824" + ], + "filter[ids]": [ + "6f0fbc08-9666-44fd-93da-cf1bfcff5e8f" + ], + "filter[integration]": [ + "INTEGRATION_SCRIPT" + ], + "filter[effects]": [ + "allow" + ], + "filter[creator_ids]": [ + "262c2ca8-d93e-45bc-8d47-5c9ab7af8e6b" + ], + "sort": [ + "-created_at" + ] + }, + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "fd8fb522-929d-52c6-4203-5a0704825f76" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/actions/execution-policies/6f0fbc08-9666-44fd-93da-cf1bfcff5e8f", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "52fba4f0-339e-0986-370a-a13757985c11" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Update_an_execution_policy_returns_Bad_Request_response.freeze b/src/test/resources/cassettes/features/v2/Update_an_execution_policy_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..e5ae18eb081 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Update_an_execution_policy_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2026-08-14T09:13:45.415Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Update_an_execution_policy_returns_Bad_Request_response.json b/src/test/resources/cassettes/features/v2/Update_an_execution_policy_returns_Bad_Request_response.json new file mode 100644 index 00000000000..5eb4105c363 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Update_an_execution_policy_returns_Bad_Request_response.json @@ -0,0 +1,83 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"action_pattern\":{\"action_fqns\":[\"com.datadoghq.script.*\"],\"integration\":\"INTEGRATION_SCRIPT\"},\"effect\":\"allow\",\"name\":\"Cassette Execution Policy testupdateanexecutionpolicyreturnsbadrequestresponse1786698825\"},\"type\":\"execution_policy\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/actions/execution-policies", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "22a9332c-23e3-a978-015f-6af3982f2d03" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"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": {}, + "method": "PUT", + "path": "/api/v2/actions/execution-policies/0ce84810-fb1b-48ad-9012-ac49a505491a", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"error updating execution policy\"}]}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 400, + "reasonPhrase": "Bad Request" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "5acbd721-1d78-c368-9986-ce4a47ff6757" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/actions/execution-policies/0ce84810-fb1b-48ad-9012-ac49a505491a", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "e7ab022c-01b3-7c12-2c8f-be55a7fc6796" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Update_an_execution_policy_returns_Not_Found_response.freeze b/src/test/resources/cassettes/features/v2/Update_an_execution_policy_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..0b6eb323a2e --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Update_an_execution_policy_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2026-08-14T09:13:46.457Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Update_an_execution_policy_returns_Not_Found_response.json b/src/test/resources/cassettes/features/v2/Update_an_execution_policy_returns_Not_Found_response.json new file mode 100644 index 00000000000..1804f9e0255 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Update_an_execution_policy_returns_Not_Found_response.json @@ -0,0 +1,32 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"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": {}, + "method": "PUT", + "path": "/api/v2/actions/execution-policies/aaa11111-aa11-aa11-aaaa-aaaaaa111111", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"error updating execution policy\"}]}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 404, + "reasonPhrase": "Not Found" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "3a7f6834-af9a-ef50-7c84-aca7512a1244" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Update_an_execution_policy_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Update_an_execution_policy_returns_OK_response.freeze new file mode 100644 index 00000000000..db6d2e00d32 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Update_an_execution_policy_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-08-14T09:13:46.840Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Update_an_execution_policy_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Update_an_execution_policy_returns_OK_response.json new file mode 100644 index 00000000000..cef2f5e8dd3 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Update_an_execution_policy_returns_OK_response.json @@ -0,0 +1,83 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"action_pattern\":{\"action_fqns\":[\"com.datadoghq.script.*\"],\"integration\":\"INTEGRATION_SCRIPT\"},\"effect\":\"allow\",\"name\":\"Cassette Execution Policy testupdateanexecutionpolicyreturnsokresponse1786698826\"},\"type\":\"execution_policy\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/actions/execution-policies", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "355507d9-2042-ebe3-acd2-ba9487b83f47" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"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": {}, + "method": "PUT", + "path": "/api/v2/actions/execution-policies/0405b41b-8865-4918-91ce-6d935b6af245", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"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" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "4ebb571f-72ea-6633-2888-a0f92bdb2e66" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/actions/execution-policies/0405b41b-8865-4918-91ce-6d935b6af245", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "6c36dd01-cf36-26b6-abb7-659562c41702" + } +] \ No newline at end of file diff --git a/src/test/resources/com/datadog/api/client/v2/api/execution_policy.feature b/src/test/resources/com/datadog/api/client/v2/api/execution_policy.feature new file mode 100644 index 00000000000..3c356ac2036 --- /dev/null +++ b/src/test/resources/com/datadog/api/client/v2/api/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/src/test/resources/com/datadog/api/client/v2/api/given.json b/src/test/resources/com/datadog/api/client/v2/api/given.json index 6e48ed1fc53..62f981bc5e5 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/given.json +++ b/src/test/resources/com/datadog/api/client/v2/api/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/src/test/resources/com/datadog/api/client/v2/api/undo.json b/src/test/resources/com/datadog/api/client/v2/api/undo.json index df961ee10c8..27ff001f90a 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/undo.json +++ b/src/test/resources/com/datadog/api/client/v2/api/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": {