cloudflare
Version:
The official TypeScript library for the Cloudflare API
122 lines • 4.54 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../../core/resource.mjs";
import * as UploadAPI from "./upload.mjs";
import { BaseUpload, Upload as UploadAPIUpload, } from "./upload.mjs";
import * as VersionsAPI from "./versions/versions.mjs";
import { BaseVersions, Versions, } from "./versions/versions.mjs";
import { SinglePage } from "../../../../core/pagination.mjs";
import { buildHeaders } from "../../../../internal/headers.mjs";
import { path } from "../../../../internal/utils/path.mjs";
export var BaseDatasets = /* @__PURE__ */ (() => {
class BaseDatasets extends 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(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(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(path `/accounts/${account_id}/dlp/datasets`, (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(path `/accounts/${account_id}/dlp/datasets/${datasetID}`, {
...options,
headers: 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(path `/accounts/${account_id}/dlp/datasets/${datasetID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseDatasets._key = Object.freeze([
'zeroTrust',
'dlp',
'datasets',
]);
return BaseDatasets;
})();
export 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 = UploadAPIUpload;
Datasets.BaseUpload = BaseUpload;
Datasets.Versions = Versions;
Datasets.BaseVersions = BaseVersions;
return Datasets;
})();
//# sourceMappingURL=datasets.mjs.map