cloudflare
Version:
The official TypeScript library for the Cloudflare API
128 lines • 4.9 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Datasets = exports.BaseDatasets = void 0;
const tslib_1 = require("../../../../internal/tslib.js");
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../../core/resource.js");
const UploadAPI = tslib_1.__importStar(require("./upload.js"));
const upload_1 = require("./upload.js");
const VersionsAPI = tslib_1.__importStar(require("./versions/versions.js"));
const versions_1 = require("./versions/versions.js");
const pagination_1 = require("../../../../core/pagination.js");
const headers_1 = require("../../../../internal/headers.js");
const path_1 = require("../../../../internal/utils/path.js");
var BaseDatasets = /* @__PURE__ */ (() => {
class BaseDatasets extends resource_1.APIResource {
/**
* Creates a new DLP (Data Loss Prevention) dataset for storing custom detection
* patterns. Datasets can contain exact match data, word lists, or EDM (Exact Data
* Match) configurations.
*
* @example
* ```ts
* const datasetCreation =
* await client.zeroTrust.dlp.datasets.create({
* account_id: 'account_id',
* name: 'name',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/dlp/datasets`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Updates the configuration of an existing DLP dataset, such as its name,
* description, or detection settings.
*
* @example
* ```ts
* const dataset = await client.zeroTrust.dlp.datasets.update(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { account_id: 'account_id' },
* );
* ```
*/
update(datasetID, params, options) {
const { account_id, ...body } = params;
return this._client.put((0, path_1.path) `/accounts/${account_id}/dlp/datasets/${datasetID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Lists all DLP datasets configured for the account, including custom word lists
* and EDM datasets.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const dataset of client.zeroTrust.dlp.datasets.list(
* { account_id: 'account_id' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id } = params;
return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/dlp/datasets`, (pagination_1.SinglePage), options);
}
/**
* This deletes all versions of the dataset.
*
* @example
* ```ts
* await client.zeroTrust.dlp.datasets.delete(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { account_id: 'account_id' },
* );
* ```
*/
delete(datasetID, params, options) {
const { account_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/dlp/datasets/${datasetID}`, {
...options,
headers: (0, headers_1.buildHeaders)([{ Accept: '*/*' }, options?.headers]),
});
}
/**
* Gets a dataset and its latest upload status.
*
* @example
* ```ts
* const dataset = await client.zeroTrust.dlp.datasets.get(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { account_id: 'account_id' },
* );
* ```
*/
get(datasetID, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/dlp/datasets/${datasetID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseDatasets._key = Object.freeze([
'zeroTrust',
'dlp',
'datasets',
]);
return BaseDatasets;
})();
exports.BaseDatasets = BaseDatasets;
var Datasets = /* @__PURE__ */ (() => {
class Datasets extends BaseDatasets {
constructor() {
super(...arguments);
this.upload = new UploadAPI.Upload(this._client);
this.versions = new VersionsAPI.Versions(this._client);
}
}
Datasets.Upload = upload_1.Upload;
Datasets.BaseUpload = upload_1.BaseUpload;
Datasets.Versions = versions_1.Versions;
Datasets.BaseVersions = versions_1.BaseVersions;
return Datasets;
})();
exports.Datasets = Datasets;
//# sourceMappingURL=datasets.js.map