/* 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 { CreateMcpServerRequest } from '../models';
// @ts-ignore
import type { ErrorResponse } from '../models';
// @ts-ignore
import type { McpServer } from '../models';
// @ts-ignore
import type { McpServerListResponse } from '../models';
// @ts-ignore
import type { ReplaceMcpServerRequest } from '../models';
/**
 * MCPServersApi - axios parameter creator
 */
export const MCPServersApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Creates a new MCP server definition. The id is the runtime MCP server name used in qualified tool names.
         * @summary Create MCP server
         * @param {CreateMcpServerRequest} createMcpServerRequest
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createMcpServer: async (createMcpServerRequest: CreateMcpServerRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'createMcpServerRequest' is not null or undefined
            assertParamExists('createMcpServer', 'createMcpServerRequest', createMcpServerRequest)
            const localVarPath = `/api/v1/mcp-servers`;
            // 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(createMcpServerRequest, localVarRequestOptions, configuration)

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Deletes an MCP server definition when `If-Match` matches the current MCP server revision.
         * @summary Delete MCP server
         * @param {string} id Stable MCP server identifier, used as the runtime MCP server name in qualified tool names.
         * @param {string} ifMatch Current resource revision used for optimistic concurrency, as returned in the &#x60;ETag&#x60; response header.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        deleteMcpServer: async (id: string, ifMatch: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('deleteMcpServer', 'id', id)
            // verify required parameter 'ifMatch' is not null or undefined
            assertParamExists('deleteMcpServer', 'ifMatch', ifMatch)
            const localVarPath = `/api/v1/mcp-servers/{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';

            if (ifMatch != null) {
                localVarHeaderParameter['If-Match'] = String(ifMatch);
            }
            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Returns all server-managed MCP server definitions with transport env/header values omitted.
         * @summary List MCP servers
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listMcpServers: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            const localVarPath = `/api/v1/mcp-servers`;
            // 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 an MCP server definition when `If-Match` matches the current MCP server revision.
         * @summary Replace MCP server
         * @param {string} id Stable MCP server identifier, used as the runtime MCP server name in qualified tool names.
         * @param {string} ifMatch Current resource revision used for optimistic concurrency, as returned in the &#x60;ETag&#x60; response header.
         * @param {ReplaceMcpServerRequest} replaceMcpServerRequest
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        replaceMcpServer: async (id: string, ifMatch: string, replaceMcpServerRequest: ReplaceMcpServerRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('replaceMcpServer', 'id', id)
            // verify required parameter 'ifMatch' is not null or undefined
            assertParamExists('replaceMcpServer', 'ifMatch', ifMatch)
            // verify required parameter 'replaceMcpServerRequest' is not null or undefined
            assertParamExists('replaceMcpServer', 'replaceMcpServerRequest', replaceMcpServerRequest)
            const localVarPath = `/api/v1/mcp-servers/{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: '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';

            if (ifMatch != null) {
                localVarHeaderParameter['If-Match'] = String(ifMatch);
            }
            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
            localVarRequestOptions.data = serializeDataIfNeeded(replaceMcpServerRequest, localVarRequestOptions, configuration)

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Returns one MCP server definition by id with transport env/header values omitted.
         * @summary Retrieve MCP server
         * @param {string} id Stable MCP server identifier, used as the runtime MCP server name in qualified tool names.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        retrieveMcpServer: async (id: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('retrieveMcpServer', 'id', id)
            const localVarPath = `/api/v1/mcp-servers/{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: '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,
            };
        },
    }
};

/**
 * MCPServersApi - functional programming interface
 */
export const MCPServersApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = MCPServersApiAxiosParamCreator(configuration)
    return {
        /**
         * Creates a new MCP server definition. The id is the runtime MCP server name used in qualified tool names.
         * @summary Create MCP server
         * @param {CreateMcpServerRequest} createMcpServerRequest
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async createMcpServer(createMcpServerRequest: CreateMcpServerRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<McpServer>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.createMcpServer(createMcpServerRequest, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['MCPServersApi.createMcpServer']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Deletes an MCP server definition when `If-Match` matches the current MCP server revision.
         * @summary Delete MCP server
         * @param {string} id Stable MCP server identifier, used as the runtime MCP server name in qualified tool names.
         * @param {string} ifMatch Current resource revision used for optimistic concurrency, as returned in the &#x60;ETag&#x60; response header.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async deleteMcpServer(id: string, ifMatch: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.deleteMcpServer(id, ifMatch, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['MCPServersApi.deleteMcpServer']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns all server-managed MCP server definitions with transport env/header values omitted.
         * @summary List MCP servers
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listMcpServers(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<McpServerListResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listMcpServers(options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['MCPServersApi.listMcpServers']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Replaces an MCP server definition when `If-Match` matches the current MCP server revision.
         * @summary Replace MCP server
         * @param {string} id Stable MCP server identifier, used as the runtime MCP server name in qualified tool names.
         * @param {string} ifMatch Current resource revision used for optimistic concurrency, as returned in the &#x60;ETag&#x60; response header.
         * @param {ReplaceMcpServerRequest} replaceMcpServerRequest
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async replaceMcpServer(id: string, ifMatch: string, replaceMcpServerRequest: ReplaceMcpServerRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<McpServer>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.replaceMcpServer(id, ifMatch, replaceMcpServerRequest, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['MCPServersApi.replaceMcpServer']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns one MCP server definition by id with transport env/header values omitted.
         * @summary Retrieve MCP server
         * @param {string} id Stable MCP server identifier, used as the runtime MCP server name in qualified tool names.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async retrieveMcpServer(id: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<McpServer>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.retrieveMcpServer(id, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['MCPServersApi.retrieveMcpServer']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * MCPServersApi - factory interface
 */
export const MCPServersApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = MCPServersApiFp(configuration)
    return {
        /**
         * Creates a new MCP server definition. The id is the runtime MCP server name used in qualified tool names.
         * @summary Create MCP server
         * @param {CreateMcpServerRequest} createMcpServerRequest
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createMcpServer(createMcpServerRequest: CreateMcpServerRequest, options?: RawAxiosRequestConfig): AxiosPromise<McpServer> {
            return localVarFp.createMcpServer(createMcpServerRequest, options).then((request) => request(axios, basePath));
        },
        /**
         * Deletes an MCP server definition when `If-Match` matches the current MCP server revision.
         * @summary Delete MCP server
         * @param {string} id Stable MCP server identifier, used as the runtime MCP server name in qualified tool names.
         * @param {string} ifMatch Current resource revision used for optimistic concurrency, as returned in the &#x60;ETag&#x60; response header.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        deleteMcpServer(id: string, ifMatch: string, options?: RawAxiosRequestConfig): AxiosPromise<void> {
            return localVarFp.deleteMcpServer(id, ifMatch, options).then((request) => request(axios, basePath));
        },
        /**
         * Returns all server-managed MCP server definitions with transport env/header values omitted.
         * @summary List MCP servers
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listMcpServers(options?: RawAxiosRequestConfig): AxiosPromise<McpServerListResponse> {
            return localVarFp.listMcpServers(options).then((request) => request(axios, basePath));
        },
        /**
         * Replaces an MCP server definition when `If-Match` matches the current MCP server revision.
         * @summary Replace MCP server
         * @param {string} id Stable MCP server identifier, used as the runtime MCP server name in qualified tool names.
         * @param {string} ifMatch Current resource revision used for optimistic concurrency, as returned in the &#x60;ETag&#x60; response header.
         * @param {ReplaceMcpServerRequest} replaceMcpServerRequest
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        replaceMcpServer(id: string, ifMatch: string, replaceMcpServerRequest: ReplaceMcpServerRequest, options?: RawAxiosRequestConfig): AxiosPromise<McpServer> {
            return localVarFp.replaceMcpServer(id, ifMatch, replaceMcpServerRequest, options).then((request) => request(axios, basePath));
        },
        /**
         * Returns one MCP server definition by id with transport env/header values omitted.
         * @summary Retrieve MCP server
         * @param {string} id Stable MCP server identifier, used as the runtime MCP server name in qualified tool names.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        retrieveMcpServer(id: string, options?: RawAxiosRequestConfig): AxiosPromise<McpServer> {
            return localVarFp.retrieveMcpServer(id, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * MCPServersApi - object-oriented interface
 */
export class MCPServersApi extends BaseAPI {
    /**
     * Creates a new MCP server definition. The id is the runtime MCP server name used in qualified tool names.
     * @summary Create MCP server
     * @param {CreateMcpServerRequest} createMcpServerRequest
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public createMcpServer(createMcpServerRequest: CreateMcpServerRequest, options?: RawAxiosRequestConfig) {
        return MCPServersApiFp(this.configuration).createMcpServer(createMcpServerRequest, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Deletes an MCP server definition when `If-Match` matches the current MCP server revision.
     * @summary Delete MCP server
     * @param {string} id Stable MCP server identifier, used as the runtime MCP server name in qualified tool names.
     * @param {string} ifMatch Current resource revision used for optimistic concurrency, as returned in the &#x60;ETag&#x60; response header.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public deleteMcpServer(id: string, ifMatch: string, options?: RawAxiosRequestConfig) {
        return MCPServersApiFp(this.configuration).deleteMcpServer(id, ifMatch, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns all server-managed MCP server definitions with transport env/header values omitted.
     * @summary List MCP servers
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public listMcpServers(options?: RawAxiosRequestConfig) {
        return MCPServersApiFp(this.configuration).listMcpServers(options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Replaces an MCP server definition when `If-Match` matches the current MCP server revision.
     * @summary Replace MCP server
     * @param {string} id Stable MCP server identifier, used as the runtime MCP server name in qualified tool names.
     * @param {string} ifMatch Current resource revision used for optimistic concurrency, as returned in the &#x60;ETag&#x60; response header.
     * @param {ReplaceMcpServerRequest} replaceMcpServerRequest
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public replaceMcpServer(id: string, ifMatch: string, replaceMcpServerRequest: ReplaceMcpServerRequest, options?: RawAxiosRequestConfig) {
        return MCPServersApiFp(this.configuration).replaceMcpServer(id, ifMatch, replaceMcpServerRequest, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns one MCP server definition by id with transport env/header values omitted.
     * @summary Retrieve MCP server
     * @param {string} id Stable MCP server identifier, used as the runtime MCP server name in qualified tool names.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public retrieveMcpServer(id: string, options?: RawAxiosRequestConfig) {
        return MCPServersApiFp(this.configuration).retrieveMcpServer(id, options).then((request) => request(this.axios, this.basePath));
    }
}
