// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from 'cloudflaredev/resource';
import * as ScriptsAPI from 'cloudflaredev/resources/workers/scripts/scripts';
import * as ContentAPI from 'cloudflaredev/resources/workers/scripts/content';
import * as DeploymentsAPI from 'cloudflaredev/resources/workers/scripts/deployments';
import * as SchedulesAPI from 'cloudflaredev/resources/workers/scripts/schedules';
import * as SettingsAPI from 'cloudflaredev/resources/workers/scripts/settings';
import * as TailAPI from 'cloudflaredev/resources/workers/scripts/tail';
import * as VersionsAPI from 'cloudflaredev/resources/workers/scripts/versions';
import { maybeMultipartFormRequestOptions } from 'cloudflaredev/core';
import { SinglePage } from 'cloudflaredev/pagination';
export class Scripts extends APIResource {
    constructor() {
        super(...arguments);
        this.schedules = new SchedulesAPI.Schedules(this._client);
        this.tail = new TailAPI.Tail(this._client);
        this.content = new ContentAPI.Content(this._client);
        this.settings = new SettingsAPI.Settings(this._client);
        this.deployments = new DeploymentsAPI.Deployments(this._client);
        this.versions = new VersionsAPI.Versions(this._client);
    }
    /**
     * Upload a worker module.
     */
    update(scriptName, params, options) {
        const { account_id, rollback_to, ...body } = params;
        return this._client.put(`/accounts/${account_id}/workers/scripts/${scriptName}`, maybeMultipartFormRequestOptions({ query: { rollback_to }, body, ...options }))._thenUnwrap((obj) => obj.result);
    }
    /**
     * Fetch a list of uploaded workers.
     */
    list(params, options) {
        const { account_id } = params;
        return this._client.getAPIList(`/accounts/${account_id}/workers/scripts`, ScriptsSinglePage, options);
    }
    /**
     * Delete your worker. This call has no response body on a successful delete.
     */
    delete(scriptName, params, options) {
        const { account_id, force } = params;
        return this._client.delete(`/accounts/${account_id}/workers/scripts/${scriptName}`, {
            query: { force },
            ...options,
            headers: { Accept: '*/*', ...options?.headers },
        });
    }
    /**
     * Fetch raw script content for your worker. Note this is the original script
     * content, not JSON encoded.
     */
    get(scriptName, params, options) {
        const { account_id } = params;
        return this._client.get(`/accounts/${account_id}/workers/scripts/${scriptName}`, {
            ...options,
            __binaryResponse: true,
        });
    }
}
export class ScriptsSinglePage extends SinglePage {
}
(function (Scripts) {
    Scripts.ScriptsSinglePage = ScriptsAPI.ScriptsSinglePage;
    Scripts.Schedules = SchedulesAPI.Schedules;
    Scripts.Tail = TailAPI.Tail;
    Scripts.Content = ContentAPI.Content;
    Scripts.Settings = SettingsAPI.Settings;
    Scripts.Deployments = DeploymentsAPI.Deployments;
    Scripts.Versions = VersionsAPI.Versions;
})(Scripts || (Scripts = {}));
//# sourceMappingURL=scripts.mjs.map