cloudflare
Version:
The official TypeScript library for the Cloudflare API
95 lines • 3.58 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../../core/resource.mjs";
import * as ScriptsAPI from "./scripts/scripts.mjs";
import { BaseScripts, Scripts, } from "./scripts/scripts.mjs";
import { SinglePage } from "../../../../core/pagination.mjs";
import { path } from "../../../../internal/utils/path.mjs";
export var BaseNamespaces = /* @__PURE__ */ (() => {
class BaseNamespaces extends 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(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(path `/accounts/${account_id}/workers/dispatch/namespaces`, (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(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(path `/accounts/${account_id}/workers/dispatch/namespaces/${dispatchNamespace}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseNamespaces._key = Object.freeze([
'workersForPlatforms',
'dispatch',
'namespaces',
]);
return BaseNamespaces;
})();
export var Namespaces = /* @__PURE__ */ (() => {
class Namespaces extends BaseNamespaces {
constructor() {
super(...arguments);
this.scripts = new ScriptsAPI.Scripts(this._client);
}
}
Namespaces.Scripts = Scripts;
Namespaces.BaseScripts = BaseScripts;
return Namespaces;
})();
//# sourceMappingURL=namespaces.mjs.map