cloudflare
Version:
The official TypeScript library for the Cloudflare API
127 lines • 4.71 kB
JavaScript
;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.ItemListResponsesCursorPaginationAfter = exports.Items = void 0;
const resource_1 = require("../../../resource.js");
const pagination_1 = require("../../../pagination.js");
class Items extends resource_1.APIResource {
/**
* Appends new items to the list.
*
* This operation is asynchronous. To get current the 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(`/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 current the 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(`/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(`/accounts/${account_id}/rules/lists/${listId}/items`, ItemListResponsesCursorPaginationAfter, { query, ...options });
}
/**
* Removes one or more items from a list.
*
* This operation is asynchronous. To get current the 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(`/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(
* '2c0fc9fa937b11eaa1b71c4d701ab86e',
* '34b12448945f11eaa1b71c4d701ab86e',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(listId, itemId, params, options) {
const { account_id } = params;
return this._client.get(`/accounts/${account_id}/rules/lists/${listId}/items/${itemId}`, options)._thenUnwrap((obj) => obj.result);
}
}
exports.Items = Items;
class ItemListResponsesCursorPaginationAfter extends pagination_1.CursorPaginationAfter {
}
exports.ItemListResponsesCursorPaginationAfter = ItemListResponsesCursorPaginationAfter;
Items.ItemListResponsesCursorPaginationAfter = ItemListResponsesCursorPaginationAfter;
//# sourceMappingURL=items.js.map