UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

104 lines • 3.9 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../core/resource.mjs"; import { SinglePage } from "../../../core/pagination.mjs"; import { path } from "../../../internal/utils/path.mjs"; export var BaseVirtualNetworks = /* @__PURE__ */ (() => { class BaseVirtualNetworks extends APIResource { /** * Adds a new virtual network to an account. * * @example * ```ts * const virtualNetwork = * await client.zeroTrust.networks.virtualNetworks.create({ * account_id: '699d98642c564d2e855e9661899b7252', * name: 'us-east-1-vpc', * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/teamnet/virtual_networks`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Lists and filters virtual networks in an account. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const virtualNetwork of client.zeroTrust.networks.virtualNetworks.list( * { account_id: '699d98642c564d2e855e9661899b7252' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id, ...query } = params; return this._client.getAPIList(path `/accounts/${account_id}/teamnet/virtual_networks`, (SinglePage), { query, ...options }); } /** * Deletes an existing virtual network. * * @example * ```ts * const virtualNetwork = * await client.zeroTrust.networks.virtualNetworks.delete( * 'f70ff985-a4ef-4643-bbbc-4a0ed4fc8415', * { account_id: '699d98642c564d2e855e9661899b7252' }, * ); * ``` */ delete(virtualNetworkID, params, options) { const { account_id } = params; return this._client.delete(path `/accounts/${account_id}/teamnet/virtual_networks/${virtualNetworkID}`, options)._thenUnwrap((obj) => obj.result); } /** * Updates an existing virtual network. * * @example * ```ts * const virtualNetwork = * await client.zeroTrust.networks.virtualNetworks.edit( * 'f70ff985-a4ef-4643-bbbc-4a0ed4fc8415', * { account_id: '699d98642c564d2e855e9661899b7252' }, * ); * ``` */ edit(virtualNetworkID, params, options) { const { account_id, ...body } = params; return this._client.patch(path `/accounts/${account_id}/teamnet/virtual_networks/${virtualNetworkID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Get a virtual network. * * @example * ```ts * const virtualNetwork = * await client.zeroTrust.networks.virtualNetworks.get( * 'f70ff985-a4ef-4643-bbbc-4a0ed4fc8415', * { account_id: '699d98642c564d2e855e9661899b7252' }, * ); * ``` */ get(virtualNetworkID, params, options) { const { account_id } = params; return this._client.get(path `/accounts/${account_id}/teamnet/virtual_networks/${virtualNetworkID}`, options)._thenUnwrap((obj) => obj.result); } } BaseVirtualNetworks._key = Object.freeze([ 'zeroTrust', 'networks', 'virtualNetworks', ]); return BaseVirtualNetworks; })(); export class VirtualNetworks extends BaseVirtualNetworks { } //# sourceMappingURL=virtual-networks.mjs.map