/* 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 { CreateWorkflowVersionResponse } from '../models';
// @ts-ignore
import type { ErrorResponse } from '../models';
// @ts-ignore
import type { WorkflowVersion } from '../models';
/**
 * WorkflowVersionsApi - axios parameter creator
 */
export const WorkflowVersionsApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Validates and stores an immutable workflow package in content-addressed storage. Repeating the same canonical content returns the same identifier.
         * @summary Create Workflow Version
         * @param {WorkflowVersion} workflowVersion
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createWorkflowVersion: async (workflowVersion: WorkflowVersion, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'workflowVersion' is not null or undefined
            assertParamExists('createWorkflowVersion', 'workflowVersion', workflowVersion)
            const localVarPath = `/api/v1/workflow-versions`;
            // 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(workflowVersion, localVarRequestOptions, configuration)

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

/**
 * WorkflowVersionsApi - functional programming interface
 */
export const WorkflowVersionsApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = WorkflowVersionsApiAxiosParamCreator(configuration)
    return {
        /**
         * Validates and stores an immutable workflow package in content-addressed storage. Repeating the same canonical content returns the same identifier.
         * @summary Create Workflow Version
         * @param {WorkflowVersion} workflowVersion
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async createWorkflowVersion(workflowVersion: WorkflowVersion, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CreateWorkflowVersionResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.createWorkflowVersion(workflowVersion, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['WorkflowVersionsApi.createWorkflowVersion']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * WorkflowVersionsApi - factory interface
 */
export const WorkflowVersionsApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = WorkflowVersionsApiFp(configuration)
    return {
        /**
         * Validates and stores an immutable workflow package in content-addressed storage. Repeating the same canonical content returns the same identifier.
         * @summary Create Workflow Version
         * @param {WorkflowVersion} workflowVersion
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createWorkflowVersion(workflowVersion: WorkflowVersion, options?: RawAxiosRequestConfig): AxiosPromise<CreateWorkflowVersionResponse> {
            return localVarFp.createWorkflowVersion(workflowVersion, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * WorkflowVersionsApi - object-oriented interface
 */
export class WorkflowVersionsApi extends BaseAPI {
    /**
     * Validates and stores an immutable workflow package in content-addressed storage. Repeating the same canonical content returns the same identifier.
     * @summary Create Workflow Version
     * @param {WorkflowVersion} workflowVersion
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public createWorkflowVersion(workflowVersion: WorkflowVersion, options?: RawAxiosRequestConfig) {
        return WorkflowVersionsApiFp(this.configuration).createWorkflowVersion(workflowVersion, options).then((request) => request(this.axios, this.basePath));
    }
}
