cloudflare
Version:
The official TypeScript library for the Cloudflare API
137 lines • 5.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Items = exports.BaseItems = 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 BaseItems = /* @__PURE__ */ (() => {
class BaseItems extends resource_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/rules/lists/${listID}/items`, (pagination_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/rules/lists/${list_id}/items/${itemID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseItems._key = Object.freeze([
'rules',
'lists',
'items',
]);
return BaseItems;
})();
exports.BaseItems = BaseItems;
class Items extends BaseItems {
}
exports.Items = Items;
//# sourceMappingURL=items.js.map