UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

101 lines • 3.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Namespaces = exports.BaseNamespaces = 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 ScriptsAPI = tslib_1.__importStar(require("./scripts/scripts.js")); const scripts_1 = require("./scripts/scripts.js"); const pagination_1 = require("../../../../core/pagination.js"); const path_1 = require("../../../../internal/utils/path.js"); var BaseNamespaces = /* @__PURE__ */ (() => { class BaseNamespaces extends resource_1.APIResource { /** * Create a new Workers for Platforms dispatch namespace. * * @example * ```ts * const namespace = * await client.workersForPlatforms.dispatch.namespaces.create( * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post((0, path_1.path) `/accounts/${account_id}/workers/dispatch/namespaces`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Fetch a list of Workers for Platforms dispatch namespaces. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const namespaceListResponse of client.workersForPlatforms.dispatch.namespaces.list( * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id } = params; return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/workers/dispatch/namespaces`, (pagination_1.SinglePage), options); } /** * Delete a Workers for Platforms dispatch namespace. * * @example * ```ts * const namespace = * await client.workersForPlatforms.dispatch.namespaces.delete( * 'my-dispatch-namespace', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(dispatchNamespace, params, options) { const { account_id } = params; return this._client.delete((0, path_1.path) `/accounts/${account_id}/workers/dispatch/namespaces/${dispatchNamespace}`, options)._thenUnwrap((obj) => obj.result); } /** * Get a Workers for Platforms dispatch namespace. * * @example * ```ts * const namespace = * await client.workersForPlatforms.dispatch.namespaces.get( * 'my-dispatch-namespace', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(dispatchNamespace, params, options) { const { account_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/workers/dispatch/namespaces/${dispatchNamespace}`, options)._thenUnwrap((obj) => obj.result); } } BaseNamespaces._key = Object.freeze([ 'workersForPlatforms', 'dispatch', 'namespaces', ]); return BaseNamespaces; })(); exports.BaseNamespaces = BaseNamespaces; var Namespaces = /* @__PURE__ */ (() => { class Namespaces extends BaseNamespaces { constructor() { super(...arguments); this.scripts = new ScriptsAPI.Scripts(this._client); } } Namespaces.Scripts = scripts_1.Scripts; Namespaces.BaseScripts = scripts_1.BaseScripts; return Namespaces; })(); exports.Namespaces = Namespaces; //# sourceMappingURL=namespaces.js.map