/* tslint:disable */
/* eslint-disable */
/**
 * Daytona Toolbox API
 * Daytona Toolbox API
 *
 * The version of the OpenAPI document: v0.0.0-dev
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


import type { Configuration } from '../configuration';
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
// Some imports not used depending on template conditions
// @ts-ignore
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, replaceWithSerializableTypeIfNeeded } from '../common';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base';
// @ts-ignore
import type { CreateContextRequest } from '../models';
// @ts-ignore
import type { InterpreterContext } from '../models';
// @ts-ignore
import type { ListContextsResponse } from '../models';
/**
 * InterpreterApi - axios parameter creator
 */
export const InterpreterApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Creates a new isolated interpreter context with optional working directory and language
         * @summary Create a new interpreter context
         * @param {CreateContextRequest} request Context configuration
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createInterpreterContext: async (request: CreateContextRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'request' is not null or undefined
            assertParamExists('createInterpreterContext', 'request', request)
            const localVarPath = `/process/interpreter/context`;
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            localVarHeaderParameter['Content-Type'] = 'application/json';
            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
            localVarRequestOptions.data = serializeDataIfNeeded(request, localVarRequestOptions, configuration)

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Deletes an interpreter context and shuts down its worker process
         * @summary Delete an interpreter context
         * @param {string} id Context ID
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        deleteInterpreterContext: async (id: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('deleteInterpreterContext', 'id', id)
            const localVarPath = `/process/interpreter/context/{id}`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Executes code in a specified context (or default context if not specified) via WebSocket streaming
         * @summary Execute code in an interpreter context
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        executeInterpreterCode: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            const localVarPath = `/process/interpreter/execute`;
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Returns information about all user-created interpreter contexts (excludes default context)
         * @summary List all user-created interpreter contexts
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listInterpreterContexts: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            const localVarPath = `/process/interpreter/context`;
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
    }
};

/**
 * InterpreterApi - functional programming interface
 */
export const InterpreterApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = InterpreterApiAxiosParamCreator(configuration)
    return {
        /**
         * Creates a new isolated interpreter context with optional working directory and language
         * @summary Create a new interpreter context
         * @param {CreateContextRequest} request Context configuration
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async createInterpreterContext(request: CreateContextRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<InterpreterContext>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.createInterpreterContext(request, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['InterpreterApi.createInterpreterContext']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Deletes an interpreter context and shuts down its worker process
         * @summary Delete an interpreter context
         * @param {string} id Context ID
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async deleteInterpreterContext(id: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<{ [key: string]: string; }>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.deleteInterpreterContext(id, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['InterpreterApi.deleteInterpreterContext']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Executes code in a specified context (or default context if not specified) via WebSocket streaming
         * @summary Execute code in an interpreter context
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async executeInterpreterCode(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.executeInterpreterCode(options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['InterpreterApi.executeInterpreterCode']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns information about all user-created interpreter contexts (excludes default context)
         * @summary List all user-created interpreter contexts
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listInterpreterContexts(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ListContextsResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listInterpreterContexts(options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['InterpreterApi.listInterpreterContexts']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * InterpreterApi - factory interface
 */
export const InterpreterApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = InterpreterApiFp(configuration)
    return {
        /**
         * Creates a new isolated interpreter context with optional working directory and language
         * @summary Create a new interpreter context
         * @param {CreateContextRequest} request Context configuration
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createInterpreterContext(request: CreateContextRequest, options?: RawAxiosRequestConfig): AxiosPromise<InterpreterContext> {
            return localVarFp.createInterpreterContext(request, options).then((request) => request(axios, basePath));
        },
        /**
         * Deletes an interpreter context and shuts down its worker process
         * @summary Delete an interpreter context
         * @param {string} id Context ID
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        deleteInterpreterContext(id: string, options?: RawAxiosRequestConfig): AxiosPromise<{ [key: string]: string; }> {
            return localVarFp.deleteInterpreterContext(id, options).then((request) => request(axios, basePath));
        },
        /**
         * Executes code in a specified context (or default context if not specified) via WebSocket streaming
         * @summary Execute code in an interpreter context
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        executeInterpreterCode(options?: RawAxiosRequestConfig): AxiosPromise<void> {
            return localVarFp.executeInterpreterCode(options).then((request) => request(axios, basePath));
        },
        /**
         * Returns information about all user-created interpreter contexts (excludes default context)
         * @summary List all user-created interpreter contexts
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listInterpreterContexts(options?: RawAxiosRequestConfig): AxiosPromise<ListContextsResponse> {
            return localVarFp.listInterpreterContexts(options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * InterpreterApi - object-oriented interface
 */
export class InterpreterApi extends BaseAPI {
    /**
     * Creates a new isolated interpreter context with optional working directory and language
     * @summary Create a new interpreter context
     * @param {CreateContextRequest} request Context configuration
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public createInterpreterContext(request: CreateContextRequest, options?: RawAxiosRequestConfig) {
        return InterpreterApiFp(this.configuration).createInterpreterContext(request, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Deletes an interpreter context and shuts down its worker process
     * @summary Delete an interpreter context
     * @param {string} id Context ID
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public deleteInterpreterContext(id: string, options?: RawAxiosRequestConfig) {
        return InterpreterApiFp(this.configuration).deleteInterpreterContext(id, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Executes code in a specified context (or default context if not specified) via WebSocket streaming
     * @summary Execute code in an interpreter context
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public executeInterpreterCode(options?: RawAxiosRequestConfig) {
        return InterpreterApiFp(this.configuration).executeInterpreterCode(options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns information about all user-created interpreter contexts (excludes default context)
     * @summary List all user-created interpreter contexts
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public listInterpreterContexts(options?: RawAxiosRequestConfig) {
        return InterpreterApiFp(this.configuration).listInterpreterContexts(options).then((request) => request(this.axios, this.basePath));
    }
}

