UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

135 lines • 5.51 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../../core/resource.mjs"; import * as ConfigurationsAPI from "./configurations.mjs"; import { BaseConfigurations, Configurations, } from "./configurations.mjs"; import * as ConnectionsAPI from "./connections.mjs"; import { BaseConnections, Connections, } from "./connections.mjs"; import * as ConnectorsAPI from "./connectors.mjs"; import { BaseConnectors, Connectors } from "./connectors.mjs"; import * as ManagementAPI from "./management.mjs"; import { BaseManagement, Management } from "./management.mjs"; import * as TokenAPI from "./token.mjs"; import { BaseToken, Token } from "./token.mjs"; import { V4PagePaginationArray, } from "../../../../core/pagination.mjs"; import { path } from "../../../../internal/utils/path.mjs"; export var BaseCloudflared = /* @__PURE__ */ (() => { class BaseCloudflared extends APIResource { /** * Creates a remotely or locally managed Cloudflare Tunnel in an account. After * creation, retrieve its token and run cloudflared to establish the connector * connection. * * @example * ```ts * const cloudflareTunnel = * await client.zeroTrust.tunnels.cloudflared.create({ * account_id: '699d98642c564d2e855e9661899b7252', * name: 'blog', * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/cfd_tunnel`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Lists and filters Cloudflare Tunnels in an account. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const cloudflareTunnel of client.zeroTrust.tunnels.cloudflared.list( * { account_id: '699d98642c564d2e855e9661899b7252' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id, ...query } = params; return this._client.getAPIList(path `/accounts/${account_id}/cfd_tunnel`, (V4PagePaginationArray), { query, ...options }); } /** * Permanently deletes a Cloudflare Tunnel from an account. The tunnel must have no * active connections. * * @example * ```ts * const cloudflareTunnel = * await client.zeroTrust.tunnels.cloudflared.delete( * 'f70ff985-a4ef-4643-bbbc-4a0ed4fc8415', * { account_id: '699d98642c564d2e855e9661899b7252' }, * ); * ``` */ delete(tunnelID, params, options) { const { account_id } = params; return this._client.delete(path `/accounts/${account_id}/cfd_tunnel/${tunnelID}`, options)._thenUnwrap((obj) => obj.result); } /** * Updates the name or secret of an existing Cloudflare Tunnel. * * @example * ```ts * const cloudflareTunnel = * await client.zeroTrust.tunnels.cloudflared.edit( * 'f70ff985-a4ef-4643-bbbc-4a0ed4fc8415', * { account_id: '699d98642c564d2e855e9661899b7252' }, * ); * ``` */ edit(tunnelID, params, options) { const { account_id, ...body } = params; return this._client.patch(path `/accounts/${account_id}/cfd_tunnel/${tunnelID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Fetches a single Cloudflare Tunnel. * * @example * ```ts * const cloudflareTunnel = * await client.zeroTrust.tunnels.cloudflared.get( * 'f70ff985-a4ef-4643-bbbc-4a0ed4fc8415', * { account_id: '699d98642c564d2e855e9661899b7252' }, * ); * ``` */ get(tunnelID, params, options) { const { account_id } = params; return this._client.get(path `/accounts/${account_id}/cfd_tunnel/${tunnelID}`, options)._thenUnwrap((obj) => obj.result); } } BaseCloudflared._key = Object.freeze([ 'zeroTrust', 'tunnels', 'cloudflared', ]); return BaseCloudflared; })(); export var Cloudflared = /* @__PURE__ */ (() => { class Cloudflared extends BaseCloudflared { constructor() { super(...arguments); this.configurations = new ConfigurationsAPI.Configurations(this._client); this.connections = new ConnectionsAPI.Connections(this._client); this.token = new TokenAPI.Token(this._client); this.connectors = new ConnectorsAPI.Connectors(this._client); this.management = new ManagementAPI.Management(this._client); } } Cloudflared.Configurations = Configurations; Cloudflared.BaseConfigurations = BaseConfigurations; Cloudflared.Connections = Connections; Cloudflared.BaseConnections = BaseConnections; Cloudflared.Token = Token; Cloudflared.BaseToken = BaseToken; Cloudflared.Connectors = Connectors; Cloudflared.BaseConnectors = BaseConnectors; Cloudflared.Management = Management; Cloudflared.BaseManagement = BaseManagement; return Cloudflared; })(); //# sourceMappingURL=cloudflared.mjs.map