cloudflare
Version:
The official TypeScript library for the Cloudflare API
150 lines • 6.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Prefixes = exports.BasePrefixes = 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 AdvertisementStatusAPI = tslib_1.__importStar(require("./advertisement-status.js"));
const advertisement_status_1 = require("./advertisement-status.js");
const BGPPrefixesAPI = tslib_1.__importStar(require("./bgp-prefixes.js"));
const bgp_prefixes_1 = require("./bgp-prefixes.js");
const DelegationsAPI = tslib_1.__importStar(require("./delegations.js"));
const delegations_1 = require("./delegations.js");
const ServiceBindingsAPI = tslib_1.__importStar(require("./service-bindings.js"));
const service_bindings_1 = require("./service-bindings.js");
const pagination_1 = require("../../../core/pagination.js");
const path_1 = require("../../../internal/utils/path.js");
var BasePrefixes = /* @__PURE__ */ (() => {
class BasePrefixes extends resource_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/addressing/prefixes`, (pagination_1.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((0, path_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/addressing/prefixes/${prefixID}/validate`, options)._thenUnwrap((obj) => obj.result);
}
}
BasePrefixes._key = Object.freeze([
'addressing',
'prefixes',
]);
return BasePrefixes;
})();
exports.BasePrefixes = BasePrefixes;
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 = service_bindings_1.ServiceBindings;
Prefixes.BaseServiceBindings = service_bindings_1.BaseServiceBindings;
Prefixes.BGPPrefixes = bgp_prefixes_1.BGPPrefixes;
Prefixes.BaseBGPPrefixes = bgp_prefixes_1.BaseBGPPrefixes;
Prefixes.AdvertisementStatus = advertisement_status_1.AdvertisementStatus;
Prefixes.BaseAdvertisementStatus = advertisement_status_1.BaseAdvertisementStatus;
Prefixes.BaseDelegations = delegations_1.BaseDelegations;
return Prefixes;
})();
exports.Prefixes = Prefixes;
//# sourceMappingURL=prefixes.js.map