/* tslint:disable */
/* eslint-disable */
/**
 * Daytona
 * Daytona AI platform API Docs
 *
 * The version of the OpenAPI document: 1.0
 * Contact: support@daytona.com
 *
 * 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';
/**
 * PreviewApi - axios parameter creator
 */
export const PreviewApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * 
         * @summary Get sandbox ID from signed preview URL token
         * @param {string} signedPreviewToken Signed preview URL token
         * @param {number} port Port number to get sandbox ID from signed preview URL token
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getSandboxIdFromSignedPreviewUrlToken: async (signedPreviewToken: string, port: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'signedPreviewToken' is not null or undefined
            assertParamExists('getSandboxIdFromSignedPreviewUrlToken', 'signedPreviewToken', signedPreviewToken)
            // verify required parameter 'port' is not null or undefined
            assertParamExists('getSandboxIdFromSignedPreviewUrlToken', 'port', port)
            const localVarPath = `/preview/{signedPreviewToken}/{port}/sandbox-id`
                .replace(`{${"signedPreviewToken"}}`, encodeURIComponent(String(signedPreviewToken)))
                .replace(`{${"port"}}`, encodeURIComponent(String(port)));
            // 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;

            // authentication bearer required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            // authentication oauth2 required

            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,
            };
        },
        /**
         * 
         * @summary Check if user has access to the sandbox
         * @param {string} sandboxId 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        hasSandboxAccess: async (sandboxId: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'sandboxId' is not null or undefined
            assertParamExists('hasSandboxAccess', 'sandboxId', sandboxId)
            const localVarPath = `/preview/{sandboxId}/access`
                .replace(`{${"sandboxId"}}`, encodeURIComponent(String(sandboxId)));
            // 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;

            // authentication bearer required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            // authentication oauth2 required

            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,
            };
        },
        /**
         * 
         * @summary Check if sandbox is public
         * @param {string} sandboxId ID of the sandbox
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        isSandboxPublic: async (sandboxId: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'sandboxId' is not null or undefined
            assertParamExists('isSandboxPublic', 'sandboxId', sandboxId)
            const localVarPath = `/preview/{sandboxId}/public`
                .replace(`{${"sandboxId"}}`, encodeURIComponent(String(sandboxId)));
            // 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;

            // authentication bearer required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            // authentication oauth2 required

            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,
            };
        },
        /**
         * 
         * @summary Check if sandbox auth token is valid
         * @param {string} sandboxId ID of the sandbox
         * @param {string} authToken Auth token of the sandbox
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        isValidAuthToken: async (sandboxId: string, authToken: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'sandboxId' is not null or undefined
            assertParamExists('isValidAuthToken', 'sandboxId', sandboxId)
            // verify required parameter 'authToken' is not null or undefined
            assertParamExists('isValidAuthToken', 'authToken', authToken)
            const localVarPath = `/preview/{sandboxId}/validate/{authToken}`
                .replace(`{${"sandboxId"}}`, encodeURIComponent(String(sandboxId)))
                .replace(`{${"authToken"}}`, encodeURIComponent(String(authToken)));
            // 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;

            // authentication bearer required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            // authentication oauth2 required

            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,
            };
        },
    }
};

/**
 * PreviewApi - functional programming interface
 */
export const PreviewApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = PreviewApiAxiosParamCreator(configuration)
    return {
        /**
         * 
         * @summary Get sandbox ID from signed preview URL token
         * @param {string} signedPreviewToken Signed preview URL token
         * @param {number} port Port number to get sandbox ID from signed preview URL token
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getSandboxIdFromSignedPreviewUrlToken(signedPreviewToken: string, port: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<string>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getSandboxIdFromSignedPreviewUrlToken(signedPreviewToken, port, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['PreviewApi.getSandboxIdFromSignedPreviewUrlToken']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * 
         * @summary Check if user has access to the sandbox
         * @param {string} sandboxId 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async hasSandboxAccess(sandboxId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<boolean>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.hasSandboxAccess(sandboxId, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['PreviewApi.hasSandboxAccess']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * 
         * @summary Check if sandbox is public
         * @param {string} sandboxId ID of the sandbox
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async isSandboxPublic(sandboxId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<boolean>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.isSandboxPublic(sandboxId, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['PreviewApi.isSandboxPublic']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * 
         * @summary Check if sandbox auth token is valid
         * @param {string} sandboxId ID of the sandbox
         * @param {string} authToken Auth token of the sandbox
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async isValidAuthToken(sandboxId: string, authToken: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<boolean>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.isValidAuthToken(sandboxId, authToken, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['PreviewApi.isValidAuthToken']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * PreviewApi - factory interface
 */
export const PreviewApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = PreviewApiFp(configuration)
    return {
        /**
         * 
         * @summary Get sandbox ID from signed preview URL token
         * @param {string} signedPreviewToken Signed preview URL token
         * @param {number} port Port number to get sandbox ID from signed preview URL token
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getSandboxIdFromSignedPreviewUrlToken(signedPreviewToken: string, port: number, options?: RawAxiosRequestConfig): AxiosPromise<string> {
            return localVarFp.getSandboxIdFromSignedPreviewUrlToken(signedPreviewToken, port, options).then((request) => request(axios, basePath));
        },
        /**
         * 
         * @summary Check if user has access to the sandbox
         * @param {string} sandboxId 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        hasSandboxAccess(sandboxId: string, options?: RawAxiosRequestConfig): AxiosPromise<boolean> {
            return localVarFp.hasSandboxAccess(sandboxId, options).then((request) => request(axios, basePath));
        },
        /**
         * 
         * @summary Check if sandbox is public
         * @param {string} sandboxId ID of the sandbox
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        isSandboxPublic(sandboxId: string, options?: RawAxiosRequestConfig): AxiosPromise<boolean> {
            return localVarFp.isSandboxPublic(sandboxId, options).then((request) => request(axios, basePath));
        },
        /**
         * 
         * @summary Check if sandbox auth token is valid
         * @param {string} sandboxId ID of the sandbox
         * @param {string} authToken Auth token of the sandbox
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        isValidAuthToken(sandboxId: string, authToken: string, options?: RawAxiosRequestConfig): AxiosPromise<boolean> {
            return localVarFp.isValidAuthToken(sandboxId, authToken, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * PreviewApi - object-oriented interface
 */
export class PreviewApi extends BaseAPI {
    /**
     * 
     * @summary Get sandbox ID from signed preview URL token
     * @param {string} signedPreviewToken Signed preview URL token
     * @param {number} port Port number to get sandbox ID from signed preview URL token
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public getSandboxIdFromSignedPreviewUrlToken(signedPreviewToken: string, port: number, options?: RawAxiosRequestConfig) {
        return PreviewApiFp(this.configuration).getSandboxIdFromSignedPreviewUrlToken(signedPreviewToken, port, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * 
     * @summary Check if user has access to the sandbox
     * @param {string} sandboxId 
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public hasSandboxAccess(sandboxId: string, options?: RawAxiosRequestConfig) {
        return PreviewApiFp(this.configuration).hasSandboxAccess(sandboxId, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * 
     * @summary Check if sandbox is public
     * @param {string} sandboxId ID of the sandbox
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public isSandboxPublic(sandboxId: string, options?: RawAxiosRequestConfig) {
        return PreviewApiFp(this.configuration).isSandboxPublic(sandboxId, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * 
     * @summary Check if sandbox auth token is valid
     * @param {string} sandboxId ID of the sandbox
     * @param {string} authToken Auth token of the sandbox
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public isValidAuthToken(sandboxId: string, authToken: string, options?: RawAxiosRequestConfig) {
        return PreviewApiFp(this.configuration).isValidAuthToken(sandboxId, authToken, options).then((request) => request(this.axios, this.basePath));
    }
}

