cloudflare
Version:
The official TypeScript library for the Cloudflare API
125 lines • 5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Policies = exports.BasePolicies = void 0;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../../core/resource.js");
const pagination_1 = require("../../../../core/pagination.js");
const path_1 = require("../../../../internal/utils/path.js");
var BasePolicies = /* @__PURE__ */ (() => {
class BasePolicies extends resource_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/data-security/posture/policies`, (pagination_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/data-security/posture/policies/${policyID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BasePolicies._key = Object.freeze([
'zeroTrust',
'casb',
'posture',
'policies',
]);
return BasePolicies;
})();
exports.BasePolicies = BasePolicies;
class Policies extends BasePolicies {
}
exports.Policies = Policies;
//# sourceMappingURL=policies.js.map