UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

157 lines • 5.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Sites = exports.BaseSites = 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 ACLsAPI = tslib_1.__importStar(require("./acls.js")); const acls_1 = require("./acls.js"); const LANsAPI = tslib_1.__importStar(require("./lans.js")); const lans_1 = require("./lans.js"); const WANsAPI = tslib_1.__importStar(require("./wans.js")); const wans_1 = require("./wans.js"); const pagination_1 = require("../../../core/pagination.js"); const headers_1 = require("../../../internal/headers.js"); const path_1 = require("../../../internal/utils/path.js"); var BaseSites = /* @__PURE__ */ (() => { class BaseSites extends resource_1.APIResource { /** * Creates a new Site * * @example * ```ts * const site = await client.magicTransit.sites.create({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * name: 'site_1', * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post((0, path_1.path) `/accounts/${account_id}/magic/sites`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Update a specific Site. * * @example * ```ts * const site = await client.magicTransit.sites.update( * '023e105f4ecef8ad9ca31a8372d0c353', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ update(siteID, params, options) { const { account_id, ...body } = params; return this._client.put((0, path_1.path) `/accounts/${account_id}/magic/sites/${siteID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Lists Sites associated with an account. Use connectorid query param to return * sites where connectorid matches either site.ConnectorID or * site.SecondaryConnectorID. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const site of client.magicTransit.sites.list({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * })) { * // ... * } * ``` */ list(params, options) { const { account_id, ...query } = params; return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/magic/sites`, (pagination_1.SinglePage), { query, ...options, }); } /** * Remove a specific Site. * * @example * ```ts * const site = await client.magicTransit.sites.delete( * '023e105f4ecef8ad9ca31a8372d0c353', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(siteID, params, options) { const { account_id } = params; return this._client.delete((0, path_1.path) `/accounts/${account_id}/magic/sites/${siteID}`, options)._thenUnwrap((obj) => obj.result); } /** * Patch a specific Site. * * @example * ```ts * const site = await client.magicTransit.sites.edit( * '023e105f4ecef8ad9ca31a8372d0c353', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ edit(siteID, params, options) { const { account_id, ...body } = params; return this._client.patch((0, path_1.path) `/accounts/${account_id}/magic/sites/${siteID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Get a specific Site. * * @example * ```ts * const site = await client.magicTransit.sites.get( * '023e105f4ecef8ad9ca31a8372d0c353', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(siteID, params, options) { const { account_id, 'x-magic-new-hc-target': xMagicNewHcTarget } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/magic/sites/${siteID}`, { ...options, headers: (0, headers_1.buildHeaders)([ { ...(xMagicNewHcTarget?.toString() != null ? { 'x-magic-new-hc-target': xMagicNewHcTarget?.toString() } : undefined), }, options?.headers, ]), })._thenUnwrap((obj) => obj.result); } } BaseSites._key = Object.freeze([ 'magicTransit', 'sites', ]); return BaseSites; })(); exports.BaseSites = BaseSites; var Sites = /* @__PURE__ */ (() => { class Sites extends BaseSites { constructor() { super(...arguments); this.acls = new ACLsAPI.ACLs(this._client); this.lans = new LANsAPI.LANs(this._client); this.wans = new WANsAPI.WANs(this._client); } } Sites.ACLs = acls_1.ACLs; Sites.BaseACLs = acls_1.BaseACLs; Sites.LANs = lans_1.LANs; Sites.BaseLANs = lans_1.BaseLANs; Sites.WANs = wans_1.WANs; Sites.BaseWANs = wans_1.BaseWANs; return Sites; })(); exports.Sites = Sites; //# sourceMappingURL=sites.js.map