cloudflare
Version:
The official TypeScript library for the Cloudflare API
52 lines • 3.07 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from 'cloudflare/resource';
import * as BindingsAPI from 'cloudflare/resources/workers-for-platforms/dispatch/namespaces/scripts/bindings';
import * as ContentAPI from 'cloudflare/resources/workers-for-platforms/dispatch/namespaces/scripts/content';
import * as SecretsAPI from 'cloudflare/resources/workers-for-platforms/dispatch/namespaces/scripts/secrets';
import * as SettingsAPI from 'cloudflare/resources/workers-for-platforms/dispatch/namespaces/scripts/settings';
import * as TagsAPI from 'cloudflare/resources/workers-for-platforms/dispatch/namespaces/scripts/tags';
import { maybeMultipartFormRequestOptions } from 'cloudflare/core';
export class Scripts extends APIResource {
constructor() {
super(...arguments);
this.content = new ContentAPI.Content(this._client);
this.settings = new SettingsAPI.Settings(this._client);
this.bindings = new BindingsAPI.Bindings(this._client);
this.secrets = new SecretsAPI.Secrets(this._client);
this.tags = new TagsAPI.Tags(this._client);
}
/**
* Upload a worker module to a Workers for Platforms namespace. You can find an
* example of the metadata on our docs:
* https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/reference/metadata/
*/
update(dispatchNamespace, scriptName, params, options) {
const { account_id, ...body } = params;
return this._client.put(`/accounts/${account_id}/workers/dispatch/namespaces/${dispatchNamespace}/scripts/${scriptName}`, maybeMultipartFormRequestOptions({ body, ...options }))._thenUnwrap((obj) => obj.result);
}
/**
* Delete a worker from a Workers for Platforms namespace. This call has no
* response body on a successful delete.
*/
delete(dispatchNamespace, scriptName, params, options) {
const { account_id, body, force } = params;
return this._client.delete(`/accounts/${account_id}/workers/dispatch/namespaces/${dispatchNamespace}/scripts/${scriptName}`, { query: { force }, body: body, ...options, headers: { Accept: '*/*', ...options?.headers } });
}
/**
* Fetch information about a script uploaded to a Workers for Platforms namespace.
*/
get(dispatchNamespace, scriptName, params, options) {
const { account_id } = params;
return this._client.get(`/accounts/${account_id}/workers/dispatch/namespaces/${dispatchNamespace}/scripts/${scriptName}`, options)._thenUnwrap((obj) => obj.result);
}
}
(function (Scripts) {
Scripts.Content = ContentAPI.Content;
Scripts.Settings = SettingsAPI.Settings;
Scripts.Bindings = BindingsAPI.Bindings;
Scripts.Secrets = SecretsAPI.Secrets;
Scripts.SecretListResponsesSinglePage = SecretsAPI.SecretListResponsesSinglePage;
Scripts.Tags = TagsAPI.Tags;
Scripts.TagListResponsesSinglePage = TagsAPI.TagListResponsesSinglePage;
})(Scripts || (Scripts = {}));
//# sourceMappingURL=scripts.mjs.map