UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

112 lines • 4.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Payloads = exports.BasePayloads = 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 BasePayloads = /* @__PURE__ */ (() => { class BasePayloads extends resource_1.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((0, path_1.path) `/zones/${zone_id}/content-upload-scan/payloads`, (pagination_1.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((0, path_1.path) `/zones/${zone_id}/content-upload-scan/payloads/${expressionID}`, (pagination_1.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((0, path_1.path) `/zones/${zone_id}/content-upload-scan/payloads`, (pagination_1.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((0, path_1.path) `/zones/${zone_id}/content-upload-scan/payloads/${expressionID}`, (pagination_1.SinglePage), { method: 'delete', ...options }); } } BasePayloads._key = Object.freeze([ 'contentScanning', 'payloads', ]); return BasePayloads; })(); exports.BasePayloads = BasePayloads; class Payloads extends BasePayloads { } exports.Payloads = Payloads; //# sourceMappingURL=payloads.js.map