cloudflare
Version:
The official TypeScript library for the Cloudflare API
120 lines • 4.75 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../../core/resource.mjs";
import { CursorPaginationAfter, } from "../../../../core/pagination.mjs";
import { path } from "../../../../internal/utils/path.mjs";
export var BasePolicies = /* @__PURE__ */ (() => {
class BasePolicies extends APIResource {
/**
* Creates a new policy configuration that defines automated actions to be executed
* when security findings are detected. A policy can include multiple remediation
* and/or webhook actions that will be triggered automatically.
*
* @example
* ```ts
* const policy =
* await client.zeroTrust.casb.posture.policies.create({
* account_id: '46148281d8a93d002ef242d8b0d5f9f6',
* actions: {},
* applies_to_all_integrations: false,
* display_name: 'Auto-remediate public files',
* enabled: true,
* finding_type_id: '5a7d9e2f-1b3c-4d5e-8f6a-7b8c9d0e1f2a',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post(path `/accounts/${account_id}/data-security/posture/policies`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Updates an existing policy configuration and replaces its actions.
*
* @example
* ```ts
* const policy =
* await client.zeroTrust.casb.posture.policies.update(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* {
* account_id: '46148281d8a93d002ef242d8b0d5f9f6',
* actions: {},
* applies_to_all_integrations: false,
* display_name: 'Auto-remediate public files',
* enabled: true,
* },
* );
* ```
*/
update(policyID, params, options) {
const { account_id, ...body } = params;
return this._client.put(path `/accounts/${account_id}/data-security/posture/policies/${policyID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Returns a list of integration-scoped policy configurations for the given
* account. This endpoint supports cursor based pagination. By default, results are
* returned in sorted order based on created_at.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const policyListResponse of client.zeroTrust.casb.posture.policies.list(
* { account_id: '46148281d8a93d002ef242d8b0d5f9f6' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList(path `/accounts/${account_id}/data-security/posture/policies`, (CursorPaginationAfter), { query, ...options });
}
/**
* Deletes a policy configuration.
*
* @example
* ```ts
* const policy =
* await client.zeroTrust.casb.posture.policies.delete(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { account_id: '46148281d8a93d002ef242d8b0d5f9f6' },
* );
* ```
*/
delete(policyID, params, options) {
const { account_id } = params;
return this._client.delete(path `/accounts/${account_id}/data-security/posture/policies/${policyID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Retrieves the details of a specific policy configuration, including its
* associated remediation and webhook actions.
*
* @example
* ```ts
* const policy =
* await client.zeroTrust.casb.posture.policies.get(
* '497f6eca-6276-4993-bfeb-53cbbbba6f08',
* { account_id: '46148281d8a93d002ef242d8b0d5f9f6' },
* );
* ```
*/
get(policyID, params, options) {
const { account_id } = params;
return this._client.get(path `/accounts/${account_id}/data-security/posture/policies/${policyID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BasePolicies._key = Object.freeze([
'zeroTrust',
'casb',
'posture',
'policies',
]);
return BasePolicies;
})();
export class Policies extends BasePolicies {
}
//# sourceMappingURL=policies.mjs.map