cloudflare
Version:
The official TypeScript library for the Cloudflare API
107 lines • 4.36 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../core/resource.mjs";
import { SinglePage } from "../../core/pagination.mjs";
import { path } from "../../internal/utils/path.mjs";
export var BasePayloads = /* @__PURE__ */ (() => {
class BasePayloads extends APIResource {
/**
* Create one or more Content Scanning custom expressions, appending them to the
* existing list of the zone, and return the updated list. Each expression reaches
* content objects the scanner cannot find automatically, for example
* `lookup_json_string(http.request.body.raw, "file")`.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const payloadCreateResponse of client.contentScanning.payloads.create(
* {
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* body: [
* {
* payload:
* 'lookup_json_string(http.request.body.raw, "file")',
* },
* ],
* },
* )) {
* // ...
* }
* ```
*/
create(params, options) {
const { zone_id, body } = params;
return this._client.getAPIList(path `/zones/${zone_id}/content-upload-scan/payloads`, (SinglePage), { body: body, method: 'post', ...options });
}
/**
* Update the Content Scanning custom expression with the given identifier and
* return the updated list of expressions.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const payloadUpdateResponse of client.contentScanning.payloads.update(
* 'a350a054caa840c9becd89c3b4f0195b',
* {
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* payload:
* 'lookup_json_string(http.request.body.raw, "file")',
* },
* )) {
* // ...
* }
* ```
*/
update(expressionID, params, options) {
const { zone_id, ...body } = params;
return this._client.getAPIList(path `/zones/${zone_id}/content-upload-scan/payloads/${expressionID}`, (SinglePage), { body, method: 'patch', ...options });
}
/**
* List the Content Scanning custom expressions configured for the zone, each with
* its own identifier. A custom expression tells the scanner how to reach content
* objects in a request it cannot parse on its own, such as files Base64-encoded
* inside a JSON body.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const payloadListResponse of client.contentScanning.payloads.list(
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { zone_id } = params;
return this._client.getAPIList(path `/zones/${zone_id}/content-upload-scan/payloads`, (SinglePage), options);
}
/**
* Delete the Content Scanning custom expression with the given identifier and
* return the expressions that remain. Content objects reached only by the deleted
* expression are no longer scanned.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const payloadDeleteResponse of client.contentScanning.payloads.delete(
* 'a350a054caa840c9becd89c3b4f0195b',
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
delete(expressionID, params, options) {
const { zone_id } = params;
return this._client.getAPIList(path `/zones/${zone_id}/content-upload-scan/payloads/${expressionID}`, (SinglePage), { method: 'delete', ...options });
}
}
BasePayloads._key = Object.freeze([
'contentScanning',
'payloads',
]);
return BasePayloads;
})();
export class Payloads extends BasePayloads {
}
//# sourceMappingURL=payloads.mjs.map