/* tslint:disable */
/* eslint-disable */
/**
 * Fabro Run API
 * HTTP API for managing Fabro workflow run executions.
 *
 * The version of the OpenAPI document: 0.1.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 { DiskUsageResponse } from '../models';
// @ts-ignore
import type { ErrorResponse } from '../models';
// @ts-ignore
import type { PruneRunsRequest } from '../models';
// @ts-ignore
import type { PruneRunsResponse } from '../models';
// @ts-ignore
import type { SystemInfoResponse } from '../models';
/**
 * SystemApi - axios parameter creator
 */
export const SystemApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Opens a server-sent event stream for live run events across the server.
         * @summary Attach Global Events
         * @param {string} [runId] Optional comma-separated list of run IDs to include.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        attachEvents: async (runId?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            const localVarPath = `/api/v1/attach`;
            // 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)

            if (runId !== undefined) {
                localVarQueryParameter['run_id'] = runId;
            }

            localVarHeaderParameter['Accept'] = 'text/event-stream';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Returns disk usage for the server storage directory.
         * @summary Retrieve System Disk Usage
         * @param {boolean} [verbose] Include per-run disk usage rows.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getSystemDiskUsage: async (verbose?: boolean, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            const localVarPath = `/api/v1/system/df`;
            // 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)

            if (verbose !== undefined) {
                localVarQueryParameter['verbose'] = verbose;
            }

            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 runtime details about the active Fabro server process.
         * @summary Retrieve System Info
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getSystemInfo: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            const localVarPath = `/api/v1/system/info`;
            // 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,
            };
        },
        /**
         * Deletes completed runs matching the provided filters, or previews the deletion set when dry-run is enabled.
         * @summary Prune Runs
         * @param {PruneRunsRequest} pruneRunsRequest 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        pruneRuns: async (pruneRunsRequest: PruneRunsRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'pruneRunsRequest' is not null or undefined
            assertParamExists('pruneRuns', 'pruneRunsRequest', pruneRunsRequest)
            const localVarPath = `/api/v1/system/prune/runs`;
            // 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(pruneRunsRequest, localVarRequestOptions, configuration)

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

/**
 * SystemApi - functional programming interface
 */
export const SystemApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = SystemApiAxiosParamCreator(configuration)
    return {
        /**
         * Opens a server-sent event stream for live run events across the server.
         * @summary Attach Global Events
         * @param {string} [runId] Optional comma-separated list of run IDs to include.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async attachEvents(runId?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<string>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.attachEvents(runId, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['SystemApi.attachEvents']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns disk usage for the server storage directory.
         * @summary Retrieve System Disk Usage
         * @param {boolean} [verbose] Include per-run disk usage rows.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getSystemDiskUsage(verbose?: boolean, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<DiskUsageResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getSystemDiskUsage(verbose, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['SystemApi.getSystemDiskUsage']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns runtime details about the active Fabro server process.
         * @summary Retrieve System Info
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getSystemInfo(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<SystemInfoResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getSystemInfo(options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['SystemApi.getSystemInfo']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Deletes completed runs matching the provided filters, or previews the deletion set when dry-run is enabled.
         * @summary Prune Runs
         * @param {PruneRunsRequest} pruneRunsRequest 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async pruneRuns(pruneRunsRequest: PruneRunsRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PruneRunsResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.pruneRuns(pruneRunsRequest, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['SystemApi.pruneRuns']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * SystemApi - factory interface
 */
export const SystemApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = SystemApiFp(configuration)
    return {
        /**
         * Opens a server-sent event stream for live run events across the server.
         * @summary Attach Global Events
         * @param {string} [runId] Optional comma-separated list of run IDs to include.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        attachEvents(runId?: string, options?: RawAxiosRequestConfig): AxiosPromise<string> {
            return localVarFp.attachEvents(runId, options).then((request) => request(axios, basePath));
        },
        /**
         * Returns disk usage for the server storage directory.
         * @summary Retrieve System Disk Usage
         * @param {boolean} [verbose] Include per-run disk usage rows.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getSystemDiskUsage(verbose?: boolean, options?: RawAxiosRequestConfig): AxiosPromise<DiskUsageResponse> {
            return localVarFp.getSystemDiskUsage(verbose, options).then((request) => request(axios, basePath));
        },
        /**
         * Returns runtime details about the active Fabro server process.
         * @summary Retrieve System Info
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getSystemInfo(options?: RawAxiosRequestConfig): AxiosPromise<SystemInfoResponse> {
            return localVarFp.getSystemInfo(options).then((request) => request(axios, basePath));
        },
        /**
         * Deletes completed runs matching the provided filters, or previews the deletion set when dry-run is enabled.
         * @summary Prune Runs
         * @param {PruneRunsRequest} pruneRunsRequest 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        pruneRuns(pruneRunsRequest: PruneRunsRequest, options?: RawAxiosRequestConfig): AxiosPromise<PruneRunsResponse> {
            return localVarFp.pruneRuns(pruneRunsRequest, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * SystemApi - object-oriented interface
 */
export class SystemApi extends BaseAPI {
    /**
     * Opens a server-sent event stream for live run events across the server.
     * @summary Attach Global Events
     * @param {string} [runId] Optional comma-separated list of run IDs to include.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public attachEvents(runId?: string, options?: RawAxiosRequestConfig) {
        return SystemApiFp(this.configuration).attachEvents(runId, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns disk usage for the server storage directory.
     * @summary Retrieve System Disk Usage
     * @param {boolean} [verbose] Include per-run disk usage rows.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public getSystemDiskUsage(verbose?: boolean, options?: RawAxiosRequestConfig) {
        return SystemApiFp(this.configuration).getSystemDiskUsage(verbose, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns runtime details about the active Fabro server process.
     * @summary Retrieve System Info
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public getSystemInfo(options?: RawAxiosRequestConfig) {
        return SystemApiFp(this.configuration).getSystemInfo(options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Deletes completed runs matching the provided filters, or previews the deletion set when dry-run is enabled.
     * @summary Prune Runs
     * @param {PruneRunsRequest} pruneRunsRequest 
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public pruneRuns(pruneRunsRequest: PruneRunsRequest, options?: RawAxiosRequestConfig) {
        return SystemApiFp(this.configuration).pruneRuns(pruneRunsRequest, options).then((request) => request(this.axios, this.basePath));
    }
}

