cloudflare
Version:
The official TypeScript library for the Cloudflare API
110 lines • 4.01 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import * as BulkOperationsAPI from "./bulk-operations.mjs";
import { BaseBulkOperations, BulkOperations, } from "./bulk-operations.mjs";
import * as ItemsAPI from "./items.mjs";
import { BaseItems, Items, } from "./items.mjs";
import { SinglePage } from "../../../core/pagination.mjs";
import { path } from "../../../internal/utils/path.mjs";
export var BaseLists = /* @__PURE__ */ (() => {
class BaseLists extends 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(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(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(path `/accounts/${account_id}/rules/lists`, (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(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(path `/accounts/${account_id}/rules/lists/${listID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseLists._key = Object.freeze(['rules', 'lists']);
return BaseLists;
})();
export 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 = BulkOperations;
Lists.BaseBulkOperations = BaseBulkOperations;
Lists.Items = Items;
Lists.BaseItems = BaseItems;
return Lists;
})();
//# sourceMappingURL=lists.mjs.map