cloudflare
Version:
The official TypeScript library for the Cloudflare API
145 lines • 5.46 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Routes = exports.BaseRoutes = void 0;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../core/resource.js");
const path_1 = require("../../internal/utils/path.js");
var BaseRoutes = /* @__PURE__ */ (() => {
class BaseRoutes extends resource_1.APIResource {
/**
* Creates a new Magic static route. Use `?validate_only=true` as an optional query
* parameter to run validation only without persisting changes.
*
* @example
* ```ts
* const route = await client.magicTransit.routes.create({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* nexthop: '203.0.113.1',
* prefix: '192.0.2.0/24',
* priority: 0,
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/magic/routes`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Update a specific Magic static route. Use `?validate_only=true` as an optional
* query parameter to run validation only without persisting changes.
*
* @example
* ```ts
* const route = await client.magicTransit.routes.update(
* '023e105f4ecef8ad9ca31a8372d0c353',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* nexthop: '203.0.113.1',
* prefix: '192.0.2.0/24',
* priority: 0,
* },
* );
* ```
*/
update(routeID, params, options) {
const { account_id, ...body } = params;
return this._client.put((0, path_1.path) `/accounts/${account_id}/magic/routes/${routeID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* List all Magic static routes.
*
* @example
* ```ts
* const routes = await client.magicTransit.routes.list({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
list(params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/magic/routes`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Disable and remove a specific Magic static route.
*
* @example
* ```ts
* const route = await client.magicTransit.routes.delete(
* '023e105f4ecef8ad9ca31a8372d0c353',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(routeID, params, options) {
const { account_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/magic/routes/${routeID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Update multiple Magic static routes. Use `?validate_only=true` as an optional
* query parameter to run validation only without persisting changes. Only fields
* for a route that need to be changed need be provided.
*
* @example
* ```ts
* const response =
* await client.magicTransit.routes.bulkUpdate({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* routes: [
* {
* id: '023e105f4ecef8ad9ca31a8372d0c353',
* nexthop: '203.0.113.1',
* prefix: '192.0.2.0/24',
* priority: 0,
* },
* ],
* });
* ```
*/
bulkUpdate(params, options) {
const { account_id, ...body } = params;
return this._client.put((0, path_1.path) `/accounts/${account_id}/magic/routes`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Delete multiple Magic static routes.
*
* @example
* ```ts
* const response = await client.magicTransit.routes.empty({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
empty(params, options) {
const { account_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/magic/routes`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Get a specific Magic static route.
*
* @example
* ```ts
* const route = await client.magicTransit.routes.get(
* '023e105f4ecef8ad9ca31a8372d0c353',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(routeID, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/magic/routes/${routeID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseRoutes._key = Object.freeze([
'magicTransit',
'routes',
]);
return BaseRoutes;
})();
exports.BaseRoutes = BaseRoutes;
class Routes extends BaseRoutes {
}
exports.Routes = Routes;
//# sourceMappingURL=routes.js.map