cloudflare
Version:
The official TypeScript library for the Cloudflare API
67 lines • 2.71 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Upload = exports.BaseUpload = void 0;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../../core/resource.js");
const headers_1 = require("../../../../internal/headers.js");
const path_1 = require("../../../../internal/utils/path.js");
var BaseUpload = /* @__PURE__ */ (() => {
class BaseUpload extends resource_1.APIResource {
/**
* Creates a new version of a DLP dataset, allowing you to stage changes before
* activation. Used for single-column EDM and custom word lists.
*
* @example
* ```ts
* const newVersion =
* await client.zeroTrust.dlp.datasets.upload.create(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { account_id: 'account_id' },
* );
* ```
*/
create(datasetID, params, options) {
const { account_id } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/dlp/datasets/${datasetID}/upload`, options)._thenUnwrap((obj) => obj.result);
}
/**
* This is used for single-column EDMv1 and Custom Word Lists. The EDM format can
* only be created in the Cloudflare dashboard. For other clients, this operation
* can only be used for non-secret Custom Word Lists. The body must be a UTF-8
* encoded, newline (NL or CRNL) separated list of words to be matched.
*
* @example
* ```ts
* const dataset =
* await client.zeroTrust.dlp.datasets.upload.edit(
* 0,
* fs.createReadStream('path/to/file'),
* {
* account_id: 'account_id',
* dataset_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* },
* );
* ```
*/
edit(version, dataset, params, options) {
const { account_id, dataset_id } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/dlp/datasets/${dataset_id}/upload/${version}`, {
body: dataset,
...options,
headers: (0, headers_1.buildHeaders)([{ 'Content-Type': 'application/octet-stream' }, options?.headers]),
})._thenUnwrap((obj) => obj.result);
}
}
BaseUpload._key = Object.freeze([
'zeroTrust',
'dlp',
'datasets',
'upload',
]);
return BaseUpload;
})();
exports.BaseUpload = BaseUpload;
class Upload extends BaseUpload {
}
exports.Upload = Upload;
//# sourceMappingURL=upload.js.map