cloudflare
Version:
The official TypeScript library for the Cloudflare API
151 lines • 5.35 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import * as ACLsAPI from "./acls.mjs";
import { ACLs, BaseACLs, } from "./acls.mjs";
import * as LANsAPI from "./lans.mjs";
import { BaseLANs, LANs, } from "./lans.mjs";
import * as WANsAPI from "./wans.mjs";
import { BaseWANs, WANs, } from "./wans.mjs";
import { SinglePage } from "../../../core/pagination.mjs";
import { buildHeaders } from "../../../internal/headers.mjs";
import { path } from "../../../internal/utils/path.mjs";
export var BaseSites = /* @__PURE__ */ (() => {
class BaseSites extends 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(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(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(path `/accounts/${account_id}/magic/sites`, (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(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(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(path `/accounts/${account_id}/magic/sites/${siteID}`, {
...options,
headers: 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;
})();
export 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;
Sites.BaseACLs = BaseACLs;
Sites.LANs = LANs;
Sites.BaseLANs = BaseLANs;
Sites.WANs = WANs;
Sites.BaseWANs = BaseWANs;
return Sites;
})();
//# sourceMappingURL=sites.mjs.map