/* tslint:disable */
/* eslint-disable */
/**
 * Fabro Run API
 * HTTP API for managing Fabro workflow run executions.
 *
 * The version of the OpenAPI document: 0.2.0
 *
 *
 * 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 { AuthConfigResponse } from '../models';
// @ts-ignore
import type { AuthMeResponse } from '../models';
// @ts-ignore
import type { AuthSessionsResponse } from '../models';
// @ts-ignore
import type { DevTokenLoginRequest } from '../models';
// @ts-ignore
import type { DevTokenLoginResponse } from '../models';
// @ts-ignore
import type { ErrorResponse } from '../models';
/**
 * AuthApi - axios parameter creator
 */
export const AuthApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Revokes an active CLI session chain. Browser sessions are not revocable in this API version.
         * @summary Revoke an authenticated session
         * @param {string} id
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        deleteAuthSession: async (id: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('deleteAuthSession', 'id', id)
            const localVarPath = `/api/v1/auth/sessions/{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;

            // authentication SessionCookie required

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

            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 the browser login methods enabled for this server.
         * @summary Retrieve auth configuration
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getAuthConfig: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            const localVarPath = `/api/v1/auth/config`;
            // 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 the authenticated browser session user and demo-mode state.
         * @summary Retrieve current browser user
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getAuthMe: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            const localVarPath = `/api/v1/auth/me`;
            // 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 SessionCookie required

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

            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 the current browser session and active CLI session chains for the authenticated user.
         * @summary List authenticated sessions
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listAuthSessions: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            const localVarPath = `/api/v1/auth/sessions`;
            // 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 SessionCookie required

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

            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,
            };
        },
        /**
         * Creates a browser session from an enabled development token.
         * @summary Login with development token
         * @param {DevTokenLoginRequest} devTokenLoginRequest
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        loginDevToken: async (devTokenLoginRequest: DevTokenLoginRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'devTokenLoginRequest' is not null or undefined
            assertParamExists('loginDevToken', 'devTokenLoginRequest', devTokenLoginRequest)
            const localVarPath = `/auth/login/dev-token`;
            // 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(devTokenLoginRequest, localVarRequestOptions, configuration)

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

/**
 * AuthApi - functional programming interface
 */
export const AuthApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = AuthApiAxiosParamCreator(configuration)
    return {
        /**
         * Revokes an active CLI session chain. Browser sessions are not revocable in this API version.
         * @summary Revoke an authenticated session
         * @param {string} id
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async deleteAuthSession(id: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.deleteAuthSession(id, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['AuthApi.deleteAuthSession']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns the browser login methods enabled for this server.
         * @summary Retrieve auth configuration
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getAuthConfig(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<AuthConfigResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getAuthConfig(options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['AuthApi.getAuthConfig']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns the authenticated browser session user and demo-mode state.
         * @summary Retrieve current browser user
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getAuthMe(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<AuthMeResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getAuthMe(options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['AuthApi.getAuthMe']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns the current browser session and active CLI session chains for the authenticated user.
         * @summary List authenticated sessions
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listAuthSessions(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<AuthSessionsResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listAuthSessions(options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['AuthApi.listAuthSessions']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Creates a browser session from an enabled development token.
         * @summary Login with development token
         * @param {DevTokenLoginRequest} devTokenLoginRequest
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async loginDevToken(devTokenLoginRequest: DevTokenLoginRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<DevTokenLoginResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.loginDevToken(devTokenLoginRequest, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['AuthApi.loginDevToken']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * AuthApi - factory interface
 */
export const AuthApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = AuthApiFp(configuration)
    return {
        /**
         * Revokes an active CLI session chain. Browser sessions are not revocable in this API version.
         * @summary Revoke an authenticated session
         * @param {string} id
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        deleteAuthSession(id: string, options?: RawAxiosRequestConfig): AxiosPromise<void> {
            return localVarFp.deleteAuthSession(id, options).then((request) => request(axios, basePath));
        },
        /**
         * Returns the browser login methods enabled for this server.
         * @summary Retrieve auth configuration
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getAuthConfig(options?: RawAxiosRequestConfig): AxiosPromise<AuthConfigResponse> {
            return localVarFp.getAuthConfig(options).then((request) => request(axios, basePath));
        },
        /**
         * Returns the authenticated browser session user and demo-mode state.
         * @summary Retrieve current browser user
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getAuthMe(options?: RawAxiosRequestConfig): AxiosPromise<AuthMeResponse> {
            return localVarFp.getAuthMe(options).then((request) => request(axios, basePath));
        },
        /**
         * Returns the current browser session and active CLI session chains for the authenticated user.
         * @summary List authenticated sessions
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listAuthSessions(options?: RawAxiosRequestConfig): AxiosPromise<AuthSessionsResponse> {
            return localVarFp.listAuthSessions(options).then((request) => request(axios, basePath));
        },
        /**
         * Creates a browser session from an enabled development token.
         * @summary Login with development token
         * @param {DevTokenLoginRequest} devTokenLoginRequest
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        loginDevToken(devTokenLoginRequest: DevTokenLoginRequest, options?: RawAxiosRequestConfig): AxiosPromise<DevTokenLoginResponse> {
            return localVarFp.loginDevToken(devTokenLoginRequest, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * AuthApi - object-oriented interface
 */
export class AuthApi extends BaseAPI {
    /**
     * Revokes an active CLI session chain. Browser sessions are not revocable in this API version.
     * @summary Revoke an authenticated session
     * @param {string} id
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public deleteAuthSession(id: string, options?: RawAxiosRequestConfig) {
        return AuthApiFp(this.configuration).deleteAuthSession(id, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns the browser login methods enabled for this server.
     * @summary Retrieve auth configuration
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public getAuthConfig(options?: RawAxiosRequestConfig) {
        return AuthApiFp(this.configuration).getAuthConfig(options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns the authenticated browser session user and demo-mode state.
     * @summary Retrieve current browser user
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public getAuthMe(options?: RawAxiosRequestConfig) {
        return AuthApiFp(this.configuration).getAuthMe(options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns the current browser session and active CLI session chains for the authenticated user.
     * @summary List authenticated sessions
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public listAuthSessions(options?: RawAxiosRequestConfig) {
        return AuthApiFp(this.configuration).listAuthSessions(options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Creates a browser session from an enabled development token.
     * @summary Login with development token
     * @param {DevTokenLoginRequest} devTokenLoginRequest
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public loginDevToken(devTokenLoginRequest: DevTokenLoginRequest, options?: RawAxiosRequestConfig) {
        return AuthApiFp(this.configuration).loginDevToken(devTokenLoginRequest, options).then((request) => request(this.axios, this.basePath));
    }
}
