/* 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 { ErrorResponse } from '../models';
// @ts-ignore
import type { PaginatedRetroList } from '../models';
// @ts-ignore
import type { RetroDetail } from '../models';
// @ts-ignore
import type { SmoothnessRating } from '../models';
/**
 * RetrosApi - axios parameter creator
 */
export const RetrosApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Returns a paginated list of run retrospectives ordered by recency, with smoothness ratings and summary statistics.
         * @summary List Retros
         * @param {string} [workflow] Filter retros by workflow slug.
         * @param {SmoothnessRating} [smoothness] Filter retros by smoothness rating.
         * @param {number} [pageLimit] Maximum number of items to return per page.
         * @param {number} [pageOffset] Number of items to skip before returning results.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listRetros: async (workflow?: string, smoothness?: SmoothnessRating, pageLimit?: number, pageOffset?: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            const localVarPath = `/retros`;
            // 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 mTLS required
            await setApiKeyToObject(localVarHeaderParameter, "X-mTLS-Client-CN", configuration)

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

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

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

            if (pageLimit !== undefined) {
                localVarQueryParameter['page[limit]'] = pageLimit;
            }

            if (pageOffset !== undefined) {
                localVarQueryParameter['page[offset]'] = pageOffset;
            }

            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 retrospective analysis for a completed run, or null if the retro has not been generated yet.
         * @summary Retrieve Retro
         * @param {string} id Unique run identifier (ULID).
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        retrieveRetro: async (id: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('retrieveRetro', 'id', id)
            const localVarPath = `/runs/{id}/retro`
                .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 mTLS required
            await setApiKeyToObject(localVarHeaderParameter, "X-mTLS-Client-CN", configuration)

            // 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,
            };
        },
    }
};

/**
 * RetrosApi - functional programming interface
 */
export const RetrosApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = RetrosApiAxiosParamCreator(configuration)
    return {
        /**
         * Returns a paginated list of run retrospectives ordered by recency, with smoothness ratings and summary statistics.
         * @summary List Retros
         * @param {string} [workflow] Filter retros by workflow slug.
         * @param {SmoothnessRating} [smoothness] Filter retros by smoothness rating.
         * @param {number} [pageLimit] Maximum number of items to return per page.
         * @param {number} [pageOffset] Number of items to skip before returning results.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listRetros(workflow?: string, smoothness?: SmoothnessRating, pageLimit?: number, pageOffset?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PaginatedRetroList>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listRetros(workflow, smoothness, pageLimit, pageOffset, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RetrosApi.listRetros']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns the retrospective analysis for a completed run, or null if the retro has not been generated yet.
         * @summary Retrieve Retro
         * @param {string} id Unique run identifier (ULID).
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async retrieveRetro(id: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<RetroDetail>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.retrieveRetro(id, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RetrosApi.retrieveRetro']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * RetrosApi - factory interface
 */
export const RetrosApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = RetrosApiFp(configuration)
    return {
        /**
         * Returns a paginated list of run retrospectives ordered by recency, with smoothness ratings and summary statistics.
         * @summary List Retros
         * @param {string} [workflow] Filter retros by workflow slug.
         * @param {SmoothnessRating} [smoothness] Filter retros by smoothness rating.
         * @param {number} [pageLimit] Maximum number of items to return per page.
         * @param {number} [pageOffset] Number of items to skip before returning results.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listRetros(workflow?: string, smoothness?: SmoothnessRating, pageLimit?: number, pageOffset?: number, options?: RawAxiosRequestConfig): AxiosPromise<PaginatedRetroList> {
            return localVarFp.listRetros(workflow, smoothness, pageLimit, pageOffset, options).then((request) => request(axios, basePath));
        },
        /**
         * Returns the retrospective analysis for a completed run, or null if the retro has not been generated yet.
         * @summary Retrieve Retro
         * @param {string} id Unique run identifier (ULID).
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        retrieveRetro(id: string, options?: RawAxiosRequestConfig): AxiosPromise<RetroDetail> {
            return localVarFp.retrieveRetro(id, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * RetrosApi - object-oriented interface
 */
export class RetrosApi extends BaseAPI {
    /**
     * Returns a paginated list of run retrospectives ordered by recency, with smoothness ratings and summary statistics.
     * @summary List Retros
     * @param {string} [workflow] Filter retros by workflow slug.
     * @param {SmoothnessRating} [smoothness] Filter retros by smoothness rating.
     * @param {number} [pageLimit] Maximum number of items to return per page.
     * @param {number} [pageOffset] Number of items to skip before returning results.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public listRetros(workflow?: string, smoothness?: SmoothnessRating, pageLimit?: number, pageOffset?: number, options?: RawAxiosRequestConfig) {
        return RetrosApiFp(this.configuration).listRetros(workflow, smoothness, pageLimit, pageOffset, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns the retrospective analysis for a completed run, or null if the retro has not been generated yet.
     * @summary Retrieve Retro
     * @param {string} id Unique run identifier (ULID).
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public retrieveRetro(id: string, options?: RawAxiosRequestConfig) {
        return RetrosApiFp(this.configuration).retrieveRetro(id, options).then((request) => request(this.axios, this.basePath));
    }
}

