/* tslint:disable */
/* eslint-disable */
/**
 * Halo Next API
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 2.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";
/**
 * V1alpha1CacheApi - axios parameter creator
 * @export
 */
export const V1alpha1CacheApiAxiosParamCreator = function (
  configuration?: Configuration
) {
  return {
    /**
     * Evict a cache.
     * @param {string} name Cache name
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    evictCache: async (
      name: string,
      options: AxiosRequestConfig = {}
    ): Promise<RequestArgs> => {
      // verify required parameter 'name' is not null or undefined
      assertParamExists("evictCache", "name", name);
      const localVarPath =
        `/apis/api.console.halo.run/v1alpha1/caches/{name}`.replace(
          `{${"name"}}`,
          encodeURIComponent(String(name))
        );
      // 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 BasicAuth required
      // http basic authentication required
      setBasicAuthToObject(localVarRequestOptions, configuration);

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

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

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

/**
 * V1alpha1CacheApi - functional programming interface
 * @export
 */
export const V1alpha1CacheApiFp = function (configuration?: Configuration) {
  const localVarAxiosParamCreator =
    V1alpha1CacheApiAxiosParamCreator(configuration);
  return {
    /**
     * Evict a cache.
     * @param {string} name Cache name
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async evictCache(
      name: string,
      options?: AxiosRequestConfig
    ): Promise<
      (axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>
    > {
      const localVarAxiosArgs = await localVarAxiosParamCreator.evictCache(
        name,
        options
      );
      return createRequestFunction(
        localVarAxiosArgs,
        globalAxios,
        BASE_PATH,
        configuration
      );
    },
  };
};

/**
 * V1alpha1CacheApi - factory interface
 * @export
 */
export const V1alpha1CacheApiFactory = function (
  configuration?: Configuration,
  basePath?: string,
  axios?: AxiosInstance
) {
  const localVarFp = V1alpha1CacheApiFp(configuration);
  return {
    /**
     * Evict a cache.
     * @param {V1alpha1CacheApiEvictCacheRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    evictCache(
      requestParameters: V1alpha1CacheApiEvictCacheRequest,
      options?: AxiosRequestConfig
    ): AxiosPromise<void> {
      return localVarFp
        .evictCache(requestParameters.name, options)
        .then((request) => request(axios, basePath));
    },
  };
};

/**
 * Request parameters for evictCache operation in V1alpha1CacheApi.
 * @export
 * @interface V1alpha1CacheApiEvictCacheRequest
 */
export interface V1alpha1CacheApiEvictCacheRequest {
  /**
   * Cache name
   * @type {string}
   * @memberof V1alpha1CacheApiEvictCache
   */
  readonly name: string;
}

/**
 * V1alpha1CacheApi - object-oriented interface
 * @export
 * @class V1alpha1CacheApi
 * @extends {BaseAPI}
 */
export class V1alpha1CacheApi extends BaseAPI {
  /**
   * Evict a cache.
   * @param {V1alpha1CacheApiEvictCacheRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   * @memberof V1alpha1CacheApi
   */
  public evictCache(
    requestParameters: V1alpha1CacheApiEvictCacheRequest,
    options?: AxiosRequestConfig
  ) {
    return V1alpha1CacheApiFp(this.configuration)
      .evictCache(requestParameters.name, options)
      .then((request) => request(this.axios, this.basePath));
  }
}
