UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

165 lines • 5.84 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../core/resource.mjs"; import * as HealthAPI from "./health.mjs"; import { BaseHealth, Health, } from "./health.mjs"; import * as ReferencesAPI from "./references.mjs"; import { BaseReferences, References, } from "./references.mjs"; import { SinglePage } from "../../../core/pagination.mjs"; import { path } from "../../../internal/utils/path.mjs"; export var BasePools = /* @__PURE__ */ (() => { class BasePools extends 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(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(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(path `/accounts/${account_id}/load_balancers/pools`, (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(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(path `/accounts/${account_id}/load_balancers/pools`, (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(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(path `/accounts/${account_id}/load_balancers/pools/${poolID}`, options)._thenUnwrap((obj) => obj.result); } } BasePools._key = Object.freeze([ 'loadBalancers', 'pools', ]); return BasePools; })(); export 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; Pools.BaseHealth = BaseHealth; Pools.References = References; Pools.BaseReferences = BaseReferences; return Pools; })(); //# sourceMappingURL=pools.mjs.map