cloudflare
Version:
The official TypeScript library for the Cloudflare API
126 lines • 5.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BGPPrefixes = exports.BaseBGPPrefixes = void 0;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../core/resource.js");
const pagination_1 = require("../../../core/pagination.js");
const path_1 = require("../../../internal/utils/path.js");
var BaseBGPPrefixes = /* @__PURE__ */ (() => {
class BaseBGPPrefixes extends resource_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/addressing/prefixes/${prefixID}/bgp/prefixes`, (pagination_1.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((0, path_1.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((0, path_1.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((0, path_1.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;
})();
exports.BaseBGPPrefixes = BaseBGPPrefixes;
class BGPPrefixes extends BaseBGPPrefixes {
}
exports.BGPPrefixes = BGPPrefixes;
//# sourceMappingURL=bgp-prefixes.js.map