// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../../../../resource'; import * as Core from '../../../../../core'; import * as WorkersAPI from '../../../../workers/workers'; import * as ScriptsAPI from '../../../../workers/scripts/scripts'; import * as TailAPI from '../../../../workers/scripts/tail'; import * as AssetUploadAPI from './asset-upload'; import { AssetUpload, AssetUploadCreateParams, AssetUploadCreateResponse } from './asset-upload'; import * as BindingsAPI from './bindings'; import { BindingGetParams, BindingGetResponse, BindingGetResponsesSinglePage, Bindings } from './bindings'; import * as ContentAPI from './content'; import { Content, ContentGetParams, ContentUpdateParams } from './content'; import * as SecretsAPI from './secrets'; import { SecretDeleteParams, SecretDeleteResponse, SecretGetParams, SecretGetResponse, SecretListParams, SecretListResponse, SecretListResponsesSinglePage, SecretUpdateParams, SecretUpdateResponse, Secrets, } from './secrets'; import * as SettingsAPI from './settings'; import { SettingEditParams, SettingEditResponse, SettingGetParams, SettingGetResponse, Settings, } from './settings'; import * as TagsAPI from './tags'; import { TagDeleteParams, TagDeleteResponse, TagListParams, TagListResponse, TagListResponsesSinglePage, TagUpdateParams, TagUpdateResponse, TagUpdateResponsesSinglePage, Tags, } from './tags'; export class Scripts extends APIResource { assetUpload: AssetUploadAPI.AssetUpload = new AssetUploadAPI.AssetUpload(this._client); content: ContentAPI.Content = new ContentAPI.Content(this._client); settings: SettingsAPI.Settings = new SettingsAPI.Settings(this._client); bindings: BindingsAPI.Bindings = new BindingsAPI.Bindings(this._client); secrets: SecretsAPI.Secrets = new SecretsAPI.Secrets(this._client); tags: TagsAPI.Tags = new TagsAPI.Tags(this._client); /** * Upload a worker module to a Workers for Platforms namespace. You can find more * about the multipart metadata on our docs: * https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/. */ update( dispatchNamespace: string, scriptName: string, params: ScriptUpdateParams, options?: Core.RequestOptions, ): Core.APIPromise { const { account_id, ...body } = params; return ( this._client.put( `/accounts/${account_id}/workers/dispatch/namespaces/${dispatchNamespace}/scripts/${scriptName}`, Core.maybeMultipartFormRequestOptions({ body, ...options, headers: { 'Content-Type': 'application/javascript', ...options?.headers }, }), ) as Core.APIPromise<{ result: ScriptUpdateResponse }> )._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: string, scriptName: string, params: ScriptDeleteParams, options?: Core.RequestOptions, ): Core.APIPromise { const { account_id, force } = params; return this._client.delete( `/accounts/${account_id}/workers/dispatch/namespaces/${dispatchNamespace}/scripts/${scriptName}`, { query: { force }, ...options, headers: { Accept: '*/*', ...options?.headers } }, ); } /** * Fetch information about a script uploaded to a Workers for Platforms namespace. */ get( dispatchNamespace: string, scriptName: string, params: ScriptGetParams, options?: Core.RequestOptions, ): Core.APIPromise