UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

116 lines • 4.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Lists = exports.BaseLists = 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 BulkOperationsAPI = tslib_1.__importStar(require("./bulk-operations.js")); const bulk_operations_1 = require("./bulk-operations.js"); const ItemsAPI = tslib_1.__importStar(require("./items.js")); const items_1 = require("./items.js"); const pagination_1 = require("../../../core/pagination.js"); const path_1 = require("../../../internal/utils/path.js"); var BaseLists = /* @__PURE__ */ (() => { class BaseLists extends resource_1.APIResource { /** * Creates a new list of the specified kind. * * @example * ```ts * const list = await client.rules.lists.create({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * kind: 'ip', * name: 'list1', * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post((0, path_1.path) `/accounts/${account_id}/rules/lists`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Updates the description of a list. * * @example * ```ts * const list = await client.rules.lists.update( * '2c0fc9fa937b11eaa1b71c4d701ab86e', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ update(listID, params, options) { const { account_id, ...body } = params; return this._client.put((0, path_1.path) `/accounts/${account_id}/rules/lists/${listID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Fetches all lists in the account. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const listsList of client.rules.lists.list({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * })) { * // ... * } * ``` */ list(params, options) { const { account_id } = params; return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/rules/lists`, (pagination_1.SinglePage), options); } /** * Deletes a specific list and all its items. * * @example * ```ts * const list = await client.rules.lists.delete( * '2c0fc9fa937b11eaa1b71c4d701ab86e', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(listID, params, options) { const { account_id } = params; return this._client.delete((0, path_1.path) `/accounts/${account_id}/rules/lists/${listID}`, options)._thenUnwrap((obj) => obj.result); } /** * Fetches the details of a list. * * @example * ```ts * const list = await client.rules.lists.get( * '2c0fc9fa937b11eaa1b71c4d701ab86e', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(listID, params, options) { const { account_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/rules/lists/${listID}`, options)._thenUnwrap((obj) => obj.result); } } BaseLists._key = Object.freeze(['rules', 'lists']); return BaseLists; })(); exports.BaseLists = BaseLists; var Lists = /* @__PURE__ */ (() => { class Lists extends BaseLists { constructor() { super(...arguments); this.bulkOperations = new BulkOperationsAPI.BulkOperations(this._client); this.items = new ItemsAPI.Items(this._client); } } Lists.BulkOperations = bulk_operations_1.BulkOperations; Lists.BaseBulkOperations = bulk_operations_1.BaseBulkOperations; Lists.Items = items_1.Items; Lists.BaseItems = items_1.BaseItems; return Lists; })(); exports.Lists = Lists; //# sourceMappingURL=lists.js.map