UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

111 lines • 4.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Networks = exports.BaseNetworks = void 0; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../../core/resource.js"); const pagination_1 = require("../../../core/pagination.js"); const path_1 = require("../../../internal/utils/path.js"); var BaseNetworks = /* @__PURE__ */ (() => { class BaseNetworks extends resource_1.APIResource { /** * Creates a new device managed network. * * @example * ```ts * const deviceNetwork = * await client.zeroTrust.devices.networks.create({ * account_id: '699d98642c564d2e855e9661899b7252', * config: { tls_sockaddr: 'foo.bar:1234' }, * name: 'managed-network-1', * type: 'tls', * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post((0, path_1.path) `/accounts/${account_id}/devices/networks`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Updates a configured device managed network. * * @example * ```ts * const deviceNetwork = * await client.zeroTrust.devices.networks.update( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { account_id: '699d98642c564d2e855e9661899b7252' }, * ); * ``` */ update(networkID, params, options) { const { account_id, ...body } = params; return this._client.put((0, path_1.path) `/accounts/${account_id}/devices/networks/${networkID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Fetches a list of managed networks for an account. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const deviceNetwork of client.zeroTrust.devices.networks.list( * { account_id: '699d98642c564d2e855e9661899b7252' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id } = params; return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/devices/networks`, (pagination_1.SinglePage), options); } /** * Deletes a device managed network and fetches a list of the remaining device * managed networks for an account. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const deviceNetwork of client.zeroTrust.devices.networks.delete( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { account_id: '699d98642c564d2e855e9661899b7252' }, * )) { * // ... * } * ``` */ delete(networkID, params, options) { const { account_id } = params; return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/devices/networks/${networkID}`, (pagination_1.SinglePage), { method: 'delete', ...options }); } /** * Fetches details for a single managed network. * * @example * ```ts * const deviceNetwork = * await client.zeroTrust.devices.networks.get( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { account_id: '699d98642c564d2e855e9661899b7252' }, * ); * ``` */ get(networkID, params, options) { const { account_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/devices/networks/${networkID}`, options)._thenUnwrap((obj) => obj.result); } } BaseNetworks._key = Object.freeze([ 'zeroTrust', 'devices', 'networks', ]); return BaseNetworks; })(); exports.BaseNetworks = BaseNetworks; class Networks extends BaseNetworks { } exports.Networks = Networks; //# sourceMappingURL=networks.js.map