UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

132 lines • 5.06 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../core/resource.mjs"; import { CursorPaginationAfter, } from "../../../core/pagination.mjs"; import { path } from "../../../internal/utils/path.mjs"; export var BaseItems = /* @__PURE__ */ (() => { class BaseItems extends APIResource { /** * Appends new items to the list. * * This operation is asynchronous. To get the current operation status, invoke the * `Get bulk operation status` endpoint with the returned `operation_id`. * * There is a limit of 1 pending bulk operation per account. If an outstanding bulk * operation is in progress, the request will be rejected. * * @example * ```ts * const item = await client.rules.lists.items.create( * '2c0fc9fa937b11eaa1b71c4d701ab86e', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * body: [{ ip: '10.0.0.1' }], * }, * ); * ``` */ create(listID, params, options) { const { account_id, body } = params; return this._client.post(path `/accounts/${account_id}/rules/lists/${listID}/items`, { body: body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Removes all existing items from the list and adds the provided items to the * list. * * This operation is asynchronous. To get the current operation status, invoke the * `Get bulk operation status` endpoint with the returned `operation_id`. * * There is a limit of 1 pending bulk operation per account. If an outstanding bulk * operation is in progress, the request will be rejected. * * @example * ```ts * const item = await client.rules.lists.items.update( * '2c0fc9fa937b11eaa1b71c4d701ab86e', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * body: [{ ip: '10.0.0.1' }], * }, * ); * ``` */ update(listID, params, options) { const { account_id, body } = params; return this._client.put(path `/accounts/${account_id}/rules/lists/${listID}/items`, { body: body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Fetches all the items in the list. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const itemListResponse of client.rules.lists.items.list( * '2c0fc9fa937b11eaa1b71c4d701ab86e', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(listID, params, options) { const { account_id, ...query } = params; return this._client.getAPIList(path `/accounts/${account_id}/rules/lists/${listID}/items`, (CursorPaginationAfter), { query, ...options }); } /** * Removes one or more items from a list. * * This operation is asynchronous. To get the current operation status, invoke the * `Get bulk operation status` endpoint with the returned `operation_id`. * * There is a limit of 1 pending bulk operation per account. If an outstanding bulk * operation is in progress, the request will be rejected. * * @example * ```ts * const item = await client.rules.lists.items.delete( * '2c0fc9fa937b11eaa1b71c4d701ab86e', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(listID, params, options) { const { account_id, ...body } = params; return this._client.delete(path `/accounts/${account_id}/rules/lists/${listID}/items`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Fetches a list item in the list. * * @example * ```ts * const item = await client.rules.lists.items.get( * '34b12448945f11eaa1b71c4d701ab86e', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * list_id: '2c0fc9fa937b11eaa1b71c4d701ab86e', * }, * ); * ``` */ get(itemID, params, options) { const { account_id, list_id } = params; return this._client.get(path `/accounts/${account_id}/rules/lists/${list_id}/items/${itemID}`, options)._thenUnwrap((obj) => obj.result); } } BaseItems._key = Object.freeze([ 'rules', 'lists', 'items', ]); return BaseItems; })(); export class Items extends BaseItems { } //# sourceMappingURL=items.mjs.map