/* tslint:disable */
/* eslint-disable */
/**
 * AssistedInstall
 * Assisted installation
 *
 * The version of the OpenAPI document: 1.0.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, AxiosRequestConfig } 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,
} from '../common';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base';
// @ts-ignore
import { ListVersions } from '../models';
// @ts-ignore
import { ModelError } from '../models';
// @ts-ignore
import { OpenshiftVersions } from '../models';
/**
 * VersionsApi - axios parameter creator
 * @export
 */
export const VersionsApiAxiosParamCreator = function (configuration?: Configuration) {
  return {
    /**
     * List of component versions.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    v2ListComponentVersions: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
      const localVarPath = `/v2/component-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: 'GET', ...baseOptions, ...options };
      const localVarHeaderParameter = {} as any;
      const localVarQueryParameter = {} as any;

      // authentication userAuth required
      await setApiKeyToObject(localVarHeaderParameter, 'Authorization', configuration);

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

      return {
        url: toPathString(localVarUrlObj),
        options: localVarRequestOptions,
      };
    },
    /**
     * Retrieves the list of OpenShift supported versions.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    v2ListSupportedOpenshiftVersions: async (
      options: AxiosRequestConfig = {},
    ): Promise<RequestArgs> => {
      const localVarPath = `/v2/openshift-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: 'GET', ...baseOptions, ...options };
      const localVarHeaderParameter = {} as any;
      const localVarQueryParameter = {} as any;

      // authentication userAuth required
      await setApiKeyToObject(localVarHeaderParameter, 'Authorization', configuration);

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

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

/**
 * VersionsApi - functional programming interface
 * @export
 */
export const VersionsApiFp = function (configuration?: Configuration) {
  const localVarAxiosParamCreator = VersionsApiAxiosParamCreator(configuration);
  return {
    /**
     * List of component versions.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async v2ListComponentVersions(
      options?: AxiosRequestConfig,
    ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ListVersions>> {
      const localVarAxiosArgs = await localVarAxiosParamCreator.v2ListComponentVersions(options);
      return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
    },
    /**
     * Retrieves the list of OpenShift supported versions.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async v2ListSupportedOpenshiftVersions(
      options?: AxiosRequestConfig,
    ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<OpenshiftVersions>> {
      const localVarAxiosArgs = await localVarAxiosParamCreator.v2ListSupportedOpenshiftVersions(
        options,
      );
      return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
    },
  };
};

/**
 * VersionsApi - factory interface
 * @export
 */
export const VersionsApiFactory = function (
  configuration?: Configuration,
  basePath?: string,
  axios?: AxiosInstance,
) {
  const localVarFp = VersionsApiFp(configuration);
  return {
    /**
     * List of component versions.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    v2ListComponentVersions(options?: AxiosRequestConfig): AxiosPromise<ListVersions> {
      return localVarFp
        .v2ListComponentVersions(options)
        .then((request) => request(axios, basePath));
    },
    /**
     * Retrieves the list of OpenShift supported versions.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    v2ListSupportedOpenshiftVersions(
      options?: AxiosRequestConfig,
    ): AxiosPromise<OpenshiftVersions> {
      return localVarFp
        .v2ListSupportedOpenshiftVersions(options)
        .then((request) => request(axios, basePath));
    },
  };
};

/**
 * VersionsApi - object-oriented interface
 * @export
 * @class VersionsApi
 * @extends {BaseAPI}
 */
export class VersionsApi extends BaseAPI {
  /**
   * List of component versions.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   * @memberof VersionsApi
   */
  public v2ListComponentVersions(options?: AxiosRequestConfig) {
    return VersionsApiFp(this.configuration)
      .v2ListComponentVersions(options)
      .then((request) => request(this.axios, this.basePath));
  }

  /**
   * Retrieves the list of OpenShift supported versions.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   * @memberof VersionsApi
   */
  public v2ListSupportedOpenshiftVersions(options?: AxiosRequestConfig) {
    return VersionsApiFp(this.configuration)
      .v2ListSupportedOpenshiftVersions(options)
      .then((request) => request(this.axios, this.basePath));
  }
}
