/* 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";
/**
 * ApiConsoleMigrationHaloRunV1alpha1MigrationApi - axios parameter creator
 * @export
 */
export const ApiConsoleMigrationHaloRunV1alpha1MigrationApiAxiosParamCreator =
  function (configuration?: Configuration) {
    return {
      /**
       *
       * @param {string} name Backup name.
       * @param {string} filename Backup filename.
       * @param {*} [options] Override http request option.
       * @throws {RequiredError}
       */
      downloadBackups: async (
        name: string,
        filename: string,
        options: AxiosRequestConfig = {}
      ): Promise<RequestArgs> => {
        // verify required parameter 'name' is not null or undefined
        assertParamExists("downloadBackups", "name", name);
        // verify required parameter 'filename' is not null or undefined
        assertParamExists("downloadBackups", "filename", filename);
        const localVarPath =
          `/apis/api.console.migration.halo.run/v1alpha1/backups/{name}/files/{filename}`
            .replace(`{${"name"}}`, encodeURIComponent(String(name)))
            .replace(`{${"filename"}}`, encodeURIComponent(String(filename)));
        // 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 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,
        };
      },
      /**
       * Restore backup by uploading file or providing download link or backup name.
       * @param {string} [backupName] Backup metadata name.
       * @param {string} [downloadUrl] Remote backup HTTP URL.
       * @param {File} [file]
       * @param {*} [options] Override http request option.
       * @throws {RequiredError}
       */
      restoreBackup: async (
        backupName?: string,
        downloadUrl?: string,
        file?: File,
        options: AxiosRequestConfig = {}
      ): Promise<RequestArgs> => {
        const localVarPath = `/apis/api.console.migration.halo.run/v1alpha1/restorations`;
        // 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;
        const localVarFormParams = new ((configuration &&
          configuration.formDataCtor) ||
          FormData)();

        // authentication BasicAuth required
        // http basic authentication required
        setBasicAuthToObject(localVarRequestOptions, configuration);

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

        if (backupName !== undefined) {
          localVarFormParams.append("backupName", backupName as any);
        }

        if (downloadUrl !== undefined) {
          localVarFormParams.append("downloadUrl", downloadUrl as any);
        }

        if (file !== undefined) {
          localVarFormParams.append("file", file as any);
        }

        localVarHeaderParameter["Content-Type"] = "multipart/form-data";

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

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

/**
 * ApiConsoleMigrationHaloRunV1alpha1MigrationApi - functional programming interface
 * @export
 */
export const ApiConsoleMigrationHaloRunV1alpha1MigrationApiFp = function (
  configuration?: Configuration
) {
  const localVarAxiosParamCreator =
    ApiConsoleMigrationHaloRunV1alpha1MigrationApiAxiosParamCreator(
      configuration
    );
  return {
    /**
     *
     * @param {string} name Backup name.
     * @param {string} filename Backup filename.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async downloadBackups(
      name: string,
      filename: string,
      options?: AxiosRequestConfig
    ): Promise<
      (axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>
    > {
      const localVarAxiosArgs = await localVarAxiosParamCreator.downloadBackups(
        name,
        filename,
        options
      );
      return createRequestFunction(
        localVarAxiosArgs,
        globalAxios,
        BASE_PATH,
        configuration
      );
    },
    /**
     * Restore backup by uploading file or providing download link or backup name.
     * @param {string} [backupName] Backup metadata name.
     * @param {string} [downloadUrl] Remote backup HTTP URL.
     * @param {File} [file]
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    async restoreBackup(
      backupName?: string,
      downloadUrl?: string,
      file?: File,
      options?: AxiosRequestConfig
    ): Promise<
      (axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>
    > {
      const localVarAxiosArgs = await localVarAxiosParamCreator.restoreBackup(
        backupName,
        downloadUrl,
        file,
        options
      );
      return createRequestFunction(
        localVarAxiosArgs,
        globalAxios,
        BASE_PATH,
        configuration
      );
    },
  };
};

/**
 * ApiConsoleMigrationHaloRunV1alpha1MigrationApi - factory interface
 * @export
 */
export const ApiConsoleMigrationHaloRunV1alpha1MigrationApiFactory = function (
  configuration?: Configuration,
  basePath?: string,
  axios?: AxiosInstance
) {
  const localVarFp =
    ApiConsoleMigrationHaloRunV1alpha1MigrationApiFp(configuration);
  return {
    /**
     *
     * @param {ApiConsoleMigrationHaloRunV1alpha1MigrationApiDownloadBackupsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    downloadBackups(
      requestParameters: ApiConsoleMigrationHaloRunV1alpha1MigrationApiDownloadBackupsRequest,
      options?: AxiosRequestConfig
    ): AxiosPromise<void> {
      return localVarFp
        .downloadBackups(
          requestParameters.name,
          requestParameters.filename,
          options
        )
        .then((request) => request(axios, basePath));
    },
    /**
     * Restore backup by uploading file or providing download link or backup name.
     * @param {ApiConsoleMigrationHaloRunV1alpha1MigrationApiRestoreBackupRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    restoreBackup(
      requestParameters: ApiConsoleMigrationHaloRunV1alpha1MigrationApiRestoreBackupRequest = {},
      options?: AxiosRequestConfig
    ): AxiosPromise<void> {
      return localVarFp
        .restoreBackup(
          requestParameters.backupName,
          requestParameters.downloadUrl,
          requestParameters.file,
          options
        )
        .then((request) => request(axios, basePath));
    },
  };
};

/**
 * Request parameters for downloadBackups operation in ApiConsoleMigrationHaloRunV1alpha1MigrationApi.
 * @export
 * @interface ApiConsoleMigrationHaloRunV1alpha1MigrationApiDownloadBackupsRequest
 */
export interface ApiConsoleMigrationHaloRunV1alpha1MigrationApiDownloadBackupsRequest {
  /**
   * Backup name.
   * @type {string}
   * @memberof ApiConsoleMigrationHaloRunV1alpha1MigrationApiDownloadBackups
   */
  readonly name: string;

  /**
   * Backup filename.
   * @type {string}
   * @memberof ApiConsoleMigrationHaloRunV1alpha1MigrationApiDownloadBackups
   */
  readonly filename: string;
}

/**
 * Request parameters for restoreBackup operation in ApiConsoleMigrationHaloRunV1alpha1MigrationApi.
 * @export
 * @interface ApiConsoleMigrationHaloRunV1alpha1MigrationApiRestoreBackupRequest
 */
export interface ApiConsoleMigrationHaloRunV1alpha1MigrationApiRestoreBackupRequest {
  /**
   * Backup metadata name.
   * @type {string}
   * @memberof ApiConsoleMigrationHaloRunV1alpha1MigrationApiRestoreBackup
   */
  readonly backupName?: string;

  /**
   * Remote backup HTTP URL.
   * @type {string}
   * @memberof ApiConsoleMigrationHaloRunV1alpha1MigrationApiRestoreBackup
   */
  readonly downloadUrl?: string;

  /**
   *
   * @type {File}
   * @memberof ApiConsoleMigrationHaloRunV1alpha1MigrationApiRestoreBackup
   */
  readonly file?: File;
}

/**
 * ApiConsoleMigrationHaloRunV1alpha1MigrationApi - object-oriented interface
 * @export
 * @class ApiConsoleMigrationHaloRunV1alpha1MigrationApi
 * @extends {BaseAPI}
 */
export class ApiConsoleMigrationHaloRunV1alpha1MigrationApi extends BaseAPI {
  /**
   *
   * @param {ApiConsoleMigrationHaloRunV1alpha1MigrationApiDownloadBackupsRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   * @memberof ApiConsoleMigrationHaloRunV1alpha1MigrationApi
   */
  public downloadBackups(
    requestParameters: ApiConsoleMigrationHaloRunV1alpha1MigrationApiDownloadBackupsRequest,
    options?: AxiosRequestConfig
  ) {
    return ApiConsoleMigrationHaloRunV1alpha1MigrationApiFp(this.configuration)
      .downloadBackups(
        requestParameters.name,
        requestParameters.filename,
        options
      )
      .then((request) => request(this.axios, this.basePath));
  }

  /**
   * Restore backup by uploading file or providing download link or backup name.
   * @param {ApiConsoleMigrationHaloRunV1alpha1MigrationApiRestoreBackupRequest} requestParameters Request parameters.
   * @param {*} [options] Override http request option.
   * @throws {RequiredError}
   * @memberof ApiConsoleMigrationHaloRunV1alpha1MigrationApi
   */
  public restoreBackup(
    requestParameters: ApiConsoleMigrationHaloRunV1alpha1MigrationApiRestoreBackupRequest = {},
    options?: AxiosRequestConfig
  ) {
    return ApiConsoleMigrationHaloRunV1alpha1MigrationApiFp(this.configuration)
      .restoreBackup(
        requestParameters.backupName,
        requestParameters.downloadUrl,
        requestParameters.file,
        options
      )
      .then((request) => request(this.axios, this.basePath));
  }
}
