UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

171 lines • 6.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Pools = exports.BasePools = 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 HealthAPI = tslib_1.__importStar(require("./health.js")); const health_1 = require("./health.js"); const ReferencesAPI = tslib_1.__importStar(require("./references.js")); const references_1 = require("./references.js"); const pagination_1 = require("../../../core/pagination.js"); const path_1 = require("../../../internal/utils/path.js"); var BasePools = /* @__PURE__ */ (() => { class BasePools extends resource_1.APIResource { /** * Create a new pool. * * @example * ```ts * const pool = await client.loadBalancers.pools.create({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * name: 'primary-dc-1', * origins: [{}], * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post((0, path_1.path) `/accounts/${account_id}/load_balancers/pools`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Modify a configured pool. * * @example * ```ts * const pool = await client.loadBalancers.pools.update( * '17b5962d775c646f3f9725cbc7a53df4', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * name: 'primary-dc-1', * origins: [{}], * }, * ); * ``` */ update(poolID, params, options) { const { account_id, ...body } = params; return this._client.put((0, path_1.path) `/accounts/${account_id}/load_balancers/pools/${poolID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * List configured pools. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const pool of client.loadBalancers.pools.list({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * })) { * // ... * } * ``` */ list(params, options) { const { account_id, ...query } = params; return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/load_balancers/pools`, (pagination_1.SinglePage), { query, ...options, }); } /** * Delete a configured pool. * * @example * ```ts * const pool = await client.loadBalancers.pools.delete( * '17b5962d775c646f3f9725cbc7a53df4', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(poolID, params, options) { const { account_id } = params; return this._client.delete((0, path_1.path) `/accounts/${account_id}/load_balancers/pools/${poolID}`, options)._thenUnwrap((obj) => obj.result); } /** * Apply changes to a number of existing pools, overwriting the supplied * properties. Pools are ordered by ascending `name`. Returns the list of affected * pools. Supports the standard pagination query parameters, either * `limit`/`offset` or `per_page`/`page`. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const pool of client.loadBalancers.pools.bulkEdit( * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ bulkEdit(params, options) { const { account_id, ...body } = params; return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/load_balancers/pools`, (pagination_1.SinglePage), { body, method: 'patch', ...options, }); } /** * Apply changes to an existing pool, overwriting the supplied properties. * * @example * ```ts * const pool = await client.loadBalancers.pools.edit( * '17b5962d775c646f3f9725cbc7a53df4', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ edit(poolID, params, options) { const { account_id, ...body } = params; return this._client.patch((0, path_1.path) `/accounts/${account_id}/load_balancers/pools/${poolID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Fetch a single configured pool. * * @example * ```ts * const pool = await client.loadBalancers.pools.get( * '17b5962d775c646f3f9725cbc7a53df4', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(poolID, params, options) { const { account_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/load_balancers/pools/${poolID}`, options)._thenUnwrap((obj) => obj.result); } } BasePools._key = Object.freeze([ 'loadBalancers', 'pools', ]); return BasePools; })(); exports.BasePools = BasePools; var Pools = /* @__PURE__ */ (() => { class Pools extends BasePools { constructor() { super(...arguments); this.health = new HealthAPI.Health(this._client); this.references = new ReferencesAPI.References(this._client); } } Pools.Health = health_1.Health; Pools.BaseHealth = health_1.BaseHealth; Pools.References = references_1.References; Pools.BaseReferences = references_1.BaseReferences; return Pools; })(); exports.Pools = Pools; //# sourceMappingURL=pools.js.map