UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

144 lines • 5.69 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../core/resource.mjs"; import * as AdvertisementStatusAPI from "./advertisement-status.mjs"; import { AdvertisementStatus, BaseAdvertisementStatus, } from "./advertisement-status.mjs"; import * as BGPPrefixesAPI from "./bgp-prefixes.mjs"; import { BGPPrefixes, BaseBGPPrefixes, } from "./bgp-prefixes.mjs"; import * as DelegationsAPI from "./delegations.mjs"; import { BaseDelegations, } from "./delegations.mjs"; import * as ServiceBindingsAPI from "./service-bindings.mjs"; import { BaseServiceBindings, ServiceBindings, } from "./service-bindings.mjs"; import { SinglePage } from "../../../core/pagination.mjs"; import { path } from "../../../internal/utils/path.mjs"; export var BasePrefixes = /* @__PURE__ */ (() => { class BasePrefixes extends APIResource { /** * Add a new prefix under the account. * * @example * ```ts * const prefix = await client.addressing.prefixes.create({ * account_id: '258def64c72dae45f3e4c8516e2111f2', * asn: 13335, * cidr: '192.0.2.0/24', * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/addressing/prefixes`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * List all prefixes owned by the account. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const prefix of client.addressing.prefixes.list({ * account_id: '258def64c72dae45f3e4c8516e2111f2', * })) { * // ... * } * ``` */ list(params, options) { const { account_id } = params; return this._client.getAPIList(path `/accounts/${account_id}/addressing/prefixes`, (SinglePage), options); } /** * Delete an unapproved prefix owned by the account. * * @example * ```ts * const prefix = await client.addressing.prefixes.delete( * '2af39739cc4e3b5910c918468bb89828', * { account_id: '258def64c72dae45f3e4c8516e2111f2' }, * ); * ``` */ delete(prefixID, params, options) { const { account_id } = params; return this._client.delete(path `/accounts/${account_id}/addressing/prefixes/${prefixID}`, options); } /** * Modify the description for a prefix owned by the account. * * @example * ```ts * const prefix = await client.addressing.prefixes.edit( * '2af39739cc4e3b5910c918468bb89828', * { * account_id: '258def64c72dae45f3e4c8516e2111f2', * description: 'Internal test prefix', * }, * ); * ``` */ edit(prefixID, params, options) { const { account_id, ...body } = params; return this._client.patch(path `/accounts/${account_id}/addressing/prefixes/${prefixID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * List a particular prefix owned by the account. * * @example * ```ts * const prefix = await client.addressing.prefixes.get( * '2af39739cc4e3b5910c918468bb89828', * { account_id: '258def64c72dae45f3e4c8516e2111f2' }, * ); * ``` */ get(prefixID, params, options) { const { account_id } = params; return this._client.get(path `/accounts/${account_id}/addressing/prefixes/${prefixID}`, options)._thenUnwrap((obj) => obj.result); } /** * Triggers a new prefix validation. The checks are run asynchronously and include * IRR, RPKI, and prefix ownership. * * @example * ```ts * const prefix = await client.addressing.prefixes.validate( * '2af39739cc4e3b5910c918468bb89828', * { account_id: '258def64c72dae45f3e4c8516e2111f2' }, * ); * ``` */ validate(prefixID, params, options) { const { account_id } = params; return this._client.post(path `/accounts/${account_id}/addressing/prefixes/${prefixID}/validate`, options)._thenUnwrap((obj) => obj.result); } } BasePrefixes._key = Object.freeze([ 'addressing', 'prefixes', ]); return BasePrefixes; })(); export var Prefixes = /* @__PURE__ */ (() => { class Prefixes extends BasePrefixes { constructor() { super(...arguments); this.serviceBindings = new ServiceBindingsAPI.ServiceBindings(this._client); this.bgpPrefixes = new BGPPrefixesAPI.BGPPrefixes(this._client); this.advertisementStatus = new AdvertisementStatusAPI.AdvertisementStatus(this._client); this.delegations = new DelegationsAPI.Delegations(this._client); } } Prefixes.ServiceBindings = ServiceBindings; Prefixes.BaseServiceBindings = BaseServiceBindings; Prefixes.BGPPrefixes = BGPPrefixes; Prefixes.BaseBGPPrefixes = BaseBGPPrefixes; Prefixes.AdvertisementStatus = AdvertisementStatus; Prefixes.BaseAdvertisementStatus = BaseAdvertisementStatus; Prefixes.BaseDelegations = BaseDelegations; return Prefixes; })(); //# sourceMappingURL=prefixes.mjs.map