/* 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 { IsPortInUseResponse } from '../models';
// @ts-ignore
import type { PortList } from '../models';
/**
 * PortApi - axios parameter creator
 */
export const PortApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Get a list of all currently active ports
         * @summary Get active ports
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getPorts: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            const localVarPath = `/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;

            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,
            };
        },
        /**
         * Check if a specific port is currently in use
         * @summary Check if port is in use
         * @param {number} port Port number (3000-9999)
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        isPortInUse: async (port: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'port' is not null or undefined
            assertParamExists('isPortInUse', 'port', port)
            const localVarPath = `/port/{port}/in-use`
                .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;

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

/**
 * PortApi - functional programming interface
 */
export const PortApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = PortApiAxiosParamCreator(configuration)
    return {
        /**
         * Get a list of all currently active ports
         * @summary Get active ports
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getPorts(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PortList>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getPorts(options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['PortApi.getPorts']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Check if a specific port is currently in use
         * @summary Check if port is in use
         * @param {number} port Port number (3000-9999)
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async isPortInUse(port: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<IsPortInUseResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.isPortInUse(port, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['PortApi.isPortInUse']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * PortApi - factory interface
 */
export const PortApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = PortApiFp(configuration)
    return {
        /**
         * Get a list of all currently active ports
         * @summary Get active ports
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getPorts(options?: RawAxiosRequestConfig): AxiosPromise<PortList> {
            return localVarFp.getPorts(options).then((request) => request(axios, basePath));
        },
        /**
         * Check if a specific port is currently in use
         * @summary Check if port is in use
         * @param {number} port Port number (3000-9999)
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        isPortInUse(port: number, options?: RawAxiosRequestConfig): AxiosPromise<IsPortInUseResponse> {
            return localVarFp.isPortInUse(port, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * PortApi - object-oriented interface
 */
export class PortApi extends BaseAPI {
    /**
     * Get a list of all currently active ports
     * @summary Get active ports
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public getPorts(options?: RawAxiosRequestConfig) {
        return PortApiFp(this.configuration).getPorts(options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Check if a specific port is currently in use
     * @summary Check if port is in use
     * @param {number} port Port number (3000-9999)
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public isPortInUse(port: number, options?: RawAxiosRequestConfig) {
        return PortApiFp(this.configuration).isPortInUse(port, options).then((request) => request(this.axios, this.basePath));
    }
}

