/* 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 { CreateVariableRequest } from '../models';
// @ts-ignore
import type { ErrorResponse } from '../models';
// @ts-ignore
import type { UpdateVariableRequest } from '../models';
// @ts-ignore
import type { Variable } from '../models';
// @ts-ignore
import type { VariableListResponse } from '../models';
/**
 * VariablesApi - axios parameter creator
 */
export const VariablesApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Stores a non-sensitive variable for run config interpolation.
         * @summary Store or update a variable
         * @param {CreateVariableRequest} createVariableRequest
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createVariable: async (createVariableRequest: CreateVariableRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'createVariableRequest' is not null or undefined
            assertParamExists('createVariable', 'createVariableRequest', createVariableRequest)
            const localVarPath = `/api/v1/variables`;
            // 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;

            // authentication SessionCookie required

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

            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(createVariableRequest, localVarRequestOptions, configuration)

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         *
         * @summary Delete a variable
         * @param {string} name Variable name.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        deleteVariable: async (name: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'name' is not null or undefined
            assertParamExists('deleteVariable', 'name', name)
            const localVarPath = `/api/v1/variables/{name}`
                .replace(`{${"name"}}`, encodeURIComponent(String(name)));
            // 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,
            };
        },
        /**
         *
         * @summary Get a variable
         * @param {string} name Variable name.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getVariable: async (name: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'name' is not null or undefined
            assertParamExists('getVariable', 'name', name)
            const localVarPath = `/api/v1/variables/{name}`
                .replace(`{${"name"}}`, encodeURIComponent(String(name)));
            // 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 non-sensitive variables, including values.
         * @summary List variables
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listVariables: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            const localVarPath = `/api/v1/variables`;
            // 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,
            };
        },
        /**
         * Replaces a variable value and preserves the existing description when omitted.
         * @summary Replace a variable value
         * @param {string} name Variable name.
         * @param {UpdateVariableRequest} updateVariableRequest
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        updateVariable: async (name: string, updateVariableRequest: UpdateVariableRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'name' is not null or undefined
            assertParamExists('updateVariable', 'name', name)
            // verify required parameter 'updateVariableRequest' is not null or undefined
            assertParamExists('updateVariable', 'updateVariableRequest', updateVariableRequest)
            const localVarPath = `/api/v1/variables/{name}`
                .replace(`{${"name"}}`, encodeURIComponent(String(name)));
            // 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: 'PUT', ...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['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(updateVariableRequest, localVarRequestOptions, configuration)

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

/**
 * VariablesApi - functional programming interface
 */
export const VariablesApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = VariablesApiAxiosParamCreator(configuration)
    return {
        /**
         * Stores a non-sensitive variable for run config interpolation.
         * @summary Store or update a variable
         * @param {CreateVariableRequest} createVariableRequest
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async createVariable(createVariableRequest: CreateVariableRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Variable>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.createVariable(createVariableRequest, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['VariablesApi.createVariable']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         *
         * @summary Delete a variable
         * @param {string} name Variable name.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async deleteVariable(name: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.deleteVariable(name, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['VariablesApi.deleteVariable']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         *
         * @summary Get a variable
         * @param {string} name Variable name.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getVariable(name: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Variable>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getVariable(name, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['VariablesApi.getVariable']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns non-sensitive variables, including values.
         * @summary List variables
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listVariables(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<VariableListResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listVariables(options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['VariablesApi.listVariables']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Replaces a variable value and preserves the existing description when omitted.
         * @summary Replace a variable value
         * @param {string} name Variable name.
         * @param {UpdateVariableRequest} updateVariableRequest
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async updateVariable(name: string, updateVariableRequest: UpdateVariableRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Variable>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.updateVariable(name, updateVariableRequest, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['VariablesApi.updateVariable']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * VariablesApi - factory interface
 */
export const VariablesApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = VariablesApiFp(configuration)
    return {
        /**
         * Stores a non-sensitive variable for run config interpolation.
         * @summary Store or update a variable
         * @param {CreateVariableRequest} createVariableRequest
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createVariable(createVariableRequest: CreateVariableRequest, options?: RawAxiosRequestConfig): AxiosPromise<Variable> {
            return localVarFp.createVariable(createVariableRequest, options).then((request) => request(axios, basePath));
        },
        /**
         *
         * @summary Delete a variable
         * @param {string} name Variable name.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        deleteVariable(name: string, options?: RawAxiosRequestConfig): AxiosPromise<void> {
            return localVarFp.deleteVariable(name, options).then((request) => request(axios, basePath));
        },
        /**
         *
         * @summary Get a variable
         * @param {string} name Variable name.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getVariable(name: string, options?: RawAxiosRequestConfig): AxiosPromise<Variable> {
            return localVarFp.getVariable(name, options).then((request) => request(axios, basePath));
        },
        /**
         * Returns non-sensitive variables, including values.
         * @summary List variables
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listVariables(options?: RawAxiosRequestConfig): AxiosPromise<VariableListResponse> {
            return localVarFp.listVariables(options).then((request) => request(axios, basePath));
        },
        /**
         * Replaces a variable value and preserves the existing description when omitted.
         * @summary Replace a variable value
         * @param {string} name Variable name.
         * @param {UpdateVariableRequest} updateVariableRequest
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        updateVariable(name: string, updateVariableRequest: UpdateVariableRequest, options?: RawAxiosRequestConfig): AxiosPromise<Variable> {
            return localVarFp.updateVariable(name, updateVariableRequest, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * VariablesApi - object-oriented interface
 */
export class VariablesApi extends BaseAPI {
    /**
     * Stores a non-sensitive variable for run config interpolation.
     * @summary Store or update a variable
     * @param {CreateVariableRequest} createVariableRequest
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public createVariable(createVariableRequest: CreateVariableRequest, options?: RawAxiosRequestConfig) {
        return VariablesApiFp(this.configuration).createVariable(createVariableRequest, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     *
     * @summary Delete a variable
     * @param {string} name Variable name.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public deleteVariable(name: string, options?: RawAxiosRequestConfig) {
        return VariablesApiFp(this.configuration).deleteVariable(name, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     *
     * @summary Get a variable
     * @param {string} name Variable name.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public getVariable(name: string, options?: RawAxiosRequestConfig) {
        return VariablesApiFp(this.configuration).getVariable(name, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns non-sensitive variables, including values.
     * @summary List variables
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public listVariables(options?: RawAxiosRequestConfig) {
        return VariablesApiFp(this.configuration).listVariables(options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Replaces a variable value and preserves the existing description when omitted.
     * @summary Replace a variable value
     * @param {string} name Variable name.
     * @param {UpdateVariableRequest} updateVariableRequest
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public updateVariable(name: string, updateVariableRequest: UpdateVariableRequest, options?: RawAxiosRequestConfig) {
        return VariablesApiFp(this.configuration).updateVariable(name, updateVariableRequest, options).then((request) => request(this.axios, this.basePath));
    }
}
