/* tslint:disable */
/* eslint-disable */
/**
 * Admin API
 * The Admin API is used to manage the ApeCloud platform. 
 *
 * The version of the OpenAPI document: 1.0.0
 * Contact: support@apecloud.com
 *
 * 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 } from '../common';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base';
// @ts-ignore
import type { APIErrorResponse } from '../models';
// @ts-ignore
import type { DisasterRecoveryClusterList } from '../models';
// @ts-ignore
import type { DisasterRecoveryCreate } from '../models';
// @ts-ignore
import type { DisasterRecoveryTask } from '../models';
/**
 * DisasterRecoveryApi - axios parameter creator
 * @export
 */
export const DisasterRecoveryApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Create a new disaster recovery instance for a database cluster.
         * @summary Create a new disaster recovery instance
         * @param {string} parentClusterID The ID of the parent database cluster
         * @param {string} orgName name of the org
         * @param {DisasterRecoveryCreate} body 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createDisasterRecovery: async (parentClusterID: string, orgName: string, body: DisasterRecoveryCreate, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'parentClusterID' is not null or undefined
            assertParamExists('createDisasterRecovery', 'parentClusterID', parentClusterID)
            // verify required parameter 'orgName' is not null or undefined
            assertParamExists('createDisasterRecovery', 'orgName', orgName)
            // verify required parameter 'body' is not null or undefined
            assertParamExists('createDisasterRecovery', 'body', body)
            const localVarPath = `/admin/v1/organizations/{orgName}/parent/{parentClusterID}/disasterRecovery`
                .replace(`{${"parentClusterID"}}`, encodeURIComponent(String(parentClusterID)))
                .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName)));
            // 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 BearerToken required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            // authentication DigestAuth required
            await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration)


    
            localVarHeaderParameter['Content-Type'] = 'application/json';

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

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Retrieve a list of disaster recovery instances for a specific database cluster.
         * @summary List Disaster Recovery instances under the main cluster
         * @param {string} parentClusterID The ID of the parent database cluster
         * @param {string} orgName name of the org
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listDisasterRecovery: async (parentClusterID: string, orgName: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'parentClusterID' is not null or undefined
            assertParamExists('listDisasterRecovery', 'parentClusterID', parentClusterID)
            // verify required parameter 'orgName' is not null or undefined
            assertParamExists('listDisasterRecovery', 'orgName', orgName)
            const localVarPath = `/admin/v1/organizations/{orgName}/parent/{parentClusterID}/disasterRecovery`
                .replace(`{${"parentClusterID"}}`, encodeURIComponent(String(parentClusterID)))
                .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName)));
            // 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 BearerToken required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

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

/**
 * DisasterRecoveryApi - functional programming interface
 * @export
 */
export const DisasterRecoveryApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = DisasterRecoveryApiAxiosParamCreator(configuration)
    return {
        /**
         * Create a new disaster recovery instance for a database cluster.
         * @summary Create a new disaster recovery instance
         * @param {string} parentClusterID The ID of the parent database cluster
         * @param {string} orgName name of the org
         * @param {DisasterRecoveryCreate} body 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async createDisasterRecovery(parentClusterID: string, orgName: string, body: DisasterRecoveryCreate, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<DisasterRecoveryTask>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.createDisasterRecovery(parentClusterID, orgName, body, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['DisasterRecoveryApi.createDisasterRecovery']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Retrieve a list of disaster recovery instances for a specific database cluster.
         * @summary List Disaster Recovery instances under the main cluster
         * @param {string} parentClusterID The ID of the parent database cluster
         * @param {string} orgName name of the org
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listDisasterRecovery(parentClusterID: string, orgName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<DisasterRecoveryClusterList>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listDisasterRecovery(parentClusterID, orgName, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['DisasterRecoveryApi.listDisasterRecovery']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * DisasterRecoveryApi - factory interface
 * @export
 */
export const DisasterRecoveryApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = DisasterRecoveryApiFp(configuration)
    return {
        /**
         * Create a new disaster recovery instance for a database cluster.
         * @summary Create a new disaster recovery instance
         * @param {DisasterRecoveryApiCreateDisasterRecoveryRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createDisasterRecovery(requestParameters: DisasterRecoveryApiCreateDisasterRecoveryRequest, options?: RawAxiosRequestConfig): AxiosPromise<DisasterRecoveryTask> {
            return localVarFp.createDisasterRecovery(requestParameters.parentClusterID, requestParameters.orgName, requestParameters.body, options).then((request) => request(axios, basePath));
        },
        /**
         * Retrieve a list of disaster recovery instances for a specific database cluster.
         * @summary List Disaster Recovery instances under the main cluster
         * @param {DisasterRecoveryApiListDisasterRecoveryRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listDisasterRecovery(requestParameters: DisasterRecoveryApiListDisasterRecoveryRequest, options?: RawAxiosRequestConfig): AxiosPromise<DisasterRecoveryClusterList> {
            return localVarFp.listDisasterRecovery(requestParameters.parentClusterID, requestParameters.orgName, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * DisasterRecoveryApi - interface
 * @export
 * @interface DisasterRecoveryApi
 */
export interface DisasterRecoveryApiInterface {
    /**
     * Create a new disaster recovery instance for a database cluster.
     * @summary Create a new disaster recovery instance
     * @param {DisasterRecoveryApiCreateDisasterRecoveryRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof DisasterRecoveryApiInterface
     */
    createDisasterRecovery(requestParameters: DisasterRecoveryApiCreateDisasterRecoveryRequest, options?: RawAxiosRequestConfig): AxiosPromise<DisasterRecoveryTask>;

    /**
     * Retrieve a list of disaster recovery instances for a specific database cluster.
     * @summary List Disaster Recovery instances under the main cluster
     * @param {DisasterRecoveryApiListDisasterRecoveryRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof DisasterRecoveryApiInterface
     */
    listDisasterRecovery(requestParameters: DisasterRecoveryApiListDisasterRecoveryRequest, options?: RawAxiosRequestConfig): AxiosPromise<DisasterRecoveryClusterList>;

}

/**
 * Request parameters for createDisasterRecovery operation in DisasterRecoveryApi.
 * @export
 * @interface DisasterRecoveryApiCreateDisasterRecoveryRequest
 */
export interface DisasterRecoveryApiCreateDisasterRecoveryRequest {
    /**
     * The ID of the parent database cluster
     * @type {string}
     * @memberof DisasterRecoveryApiCreateDisasterRecovery
     */
    readonly parentClusterID: string

    /**
     * name of the org
     * @type {string}
     * @memberof DisasterRecoveryApiCreateDisasterRecovery
     */
    readonly orgName: string

    /**
     * 
     * @type {DisasterRecoveryCreate}
     * @memberof DisasterRecoveryApiCreateDisasterRecovery
     */
    readonly body: DisasterRecoveryCreate
}

/**
 * Request parameters for listDisasterRecovery operation in DisasterRecoveryApi.
 * @export
 * @interface DisasterRecoveryApiListDisasterRecoveryRequest
 */
export interface DisasterRecoveryApiListDisasterRecoveryRequest {
    /**
     * The ID of the parent database cluster
     * @type {string}
     * @memberof DisasterRecoveryApiListDisasterRecovery
     */
    readonly parentClusterID: string

    /**
     * name of the org
     * @type {string}
     * @memberof DisasterRecoveryApiListDisasterRecovery
     */
    readonly orgName: string
}

/**
 * DisasterRecoveryApi - object-oriented interface
 * @export
 * @class DisasterRecoveryApi
 * @extends {BaseAPI}
 */
export class DisasterRecoveryApi extends BaseAPI implements DisasterRecoveryApiInterface {
    /**
     * Create a new disaster recovery instance for a database cluster.
     * @summary Create a new disaster recovery instance
     * @param {DisasterRecoveryApiCreateDisasterRecoveryRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof DisasterRecoveryApi
     */
    public createDisasterRecovery(requestParameters: DisasterRecoveryApiCreateDisasterRecoveryRequest, options?: RawAxiosRequestConfig) {
        return DisasterRecoveryApiFp(this.configuration).createDisasterRecovery(requestParameters.parentClusterID, requestParameters.orgName, requestParameters.body, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Retrieve a list of disaster recovery instances for a specific database cluster.
     * @summary List Disaster Recovery instances under the main cluster
     * @param {DisasterRecoveryApiListDisasterRecoveryRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof DisasterRecoveryApi
     */
    public listDisasterRecovery(requestParameters: DisasterRecoveryApiListDisasterRecoveryRequest, options?: RawAxiosRequestConfig) {
        return DisasterRecoveryApiFp(this.configuration).listDisasterRecovery(requestParameters.parentClusterID, requestParameters.orgName, options).then((request) => request(this.axios, this.basePath));
    }
}

