UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

121 lines • 4.88 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../core/resource.mjs"; import { SinglePage } from "../../../core/pagination.mjs"; import { path } from "../../../internal/utils/path.mjs"; export var BaseBGPPrefixes = /* @__PURE__ */ (() => { class BaseBGPPrefixes extends APIResource { /** * Create a BGP prefix, controlling the BGP advertisement status of a specific * subnet. When created, BGP prefixes are initially withdrawn, and can be * advertised with the Update BGP Prefix API. * * @example * ```ts * const bgpPrefix = * await client.addressing.prefixes.bgpPrefixes.create( * '2af39739cc4e3b5910c918468bb89828', * { * account_id: '258def64c72dae45f3e4c8516e2111f2', * cidr: '192.0.2.0/24', * }, * ); * ``` */ create(prefixID, params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/addressing/prefixes/${prefixID}/bgp/prefixes`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * List all BGP Prefixes within the specified IP Prefix. BGP Prefixes are used to * control which specific subnets are advertised to the Internet. It is possible to * advertise subnets more specific than an IP Prefix by creating more specific BGP * Prefixes. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const bgpPrefix of client.addressing.prefixes.bgpPrefixes.list( * '2af39739cc4e3b5910c918468bb89828', * { account_id: '258def64c72dae45f3e4c8516e2111f2' }, * )) { * // ... * } * ``` */ list(prefixID, params, options) { const { account_id } = params; return this._client.getAPIList(path `/accounts/${account_id}/addressing/prefixes/${prefixID}/bgp/prefixes`, (SinglePage), options); } /** * Delete a BGP Prefix associated with the specified IP Prefix. A BGP Prefix must * be withdrawn before it can be deleted. * * @example * ```ts * const bgpPrefix = * await client.addressing.prefixes.bgpPrefixes.delete( * '7009ba364c7a5760798ceb430e603b74', * { * account_id: '258def64c72dae45f3e4c8516e2111f2', * prefix_id: '2af39739cc4e3b5910c918468bb89828', * }, * ); * ``` */ delete(bgpPrefixID, params, options) { const { account_id, prefix_id } = params; return this._client.delete(path `/accounts/${account_id}/addressing/prefixes/${prefix_id}/bgp/prefixes/${bgpPrefixID}`, options); } /** * Update the properties of a BGP Prefix, such as the on demand advertisement * status (advertised or withdrawn). * * @example * ```ts * const bgpPrefix = * await client.addressing.prefixes.bgpPrefixes.edit( * '7009ba364c7a5760798ceb430e603b74', * { * account_id: '258def64c72dae45f3e4c8516e2111f2', * prefix_id: '2af39739cc4e3b5910c918468bb89828', * }, * ); * ``` */ edit(bgpPrefixID, params, options) { const { account_id, prefix_id, ...body } = params; return this._client.patch(path `/accounts/${account_id}/addressing/prefixes/${prefix_id}/bgp/prefixes/${bgpPrefixID}`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Retrieve a single BGP Prefix according to its identifier * * @example * ```ts * const bgpPrefix = * await client.addressing.prefixes.bgpPrefixes.get( * '7009ba364c7a5760798ceb430e603b74', * { * account_id: '258def64c72dae45f3e4c8516e2111f2', * prefix_id: '2af39739cc4e3b5910c918468bb89828', * }, * ); * ``` */ get(bgpPrefixID, params, options) { const { account_id, prefix_id } = params; return this._client.get(path `/accounts/${account_id}/addressing/prefixes/${prefix_id}/bgp/prefixes/${bgpPrefixID}`, options)._thenUnwrap((obj) => obj.result); } } BaseBGPPrefixes._key = Object.freeze([ 'addressing', 'prefixes', 'bgpPrefixes', ]); return BaseBGPPrefixes; })(); export class BGPPrefixes extends BaseBGPPrefixes { } //# sourceMappingURL=bgp-prefixes.mjs.map