/* tslint:disable */
/* eslint-disable */
/**
 * KubeBlocks Cloud API
 * KubeBlocks Cloud API is a RESTful API for managing KubeBlocks Cloud resources.  The API is organized around REST.  Our API has predictable resource-oriented URLs, accepts `JSON-encoded` request bodies, returns `JSON-encoded` responses, and uses standard HTTP response codes, authentication, and verbs.  We use standard HTTP authentication and provide API keys to identify who you are. Your API keys carry many privileges, so be sure to keep them secret! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth. 
 *
 * 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 { AvailableClusterListInner } from '../models';
// @ts-ignore
import type { RelatedClusterListItem } from '../models';
/**
 * RelationApi - axios parameter creator
 * @export
 */
export const RelationApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * 
         * @summary create a relation between the clusters in the organization
         * @param {string} orgName 
         * @param {string} clusterName 
         * @param {string} target 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createRelation: async (orgName: string, clusterName: string, target: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'orgName' is not null or undefined
            assertParamExists('createRelation', 'orgName', orgName)
            // verify required parameter 'clusterName' is not null or undefined
            assertParamExists('createRelation', 'clusterName', clusterName)
            // verify required parameter 'target' is not null or undefined
            assertParamExists('createRelation', 'target', target)
            const localVarPath = `/api/v1/organizations/{orgName}/clusters/{clusterName}/relations`
                .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName)))
                .replace(`{${"clusterName"}}`, encodeURIComponent(String(clusterName)));
            // 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)

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


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

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * 
         * @summary delete a existed relation between the clusters in the organization
         * @param {string} orgName 
         * @param {string} clusterName 
         * @param {string} target 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        deleteRelation: async (orgName: string, clusterName: string, target: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'orgName' is not null or undefined
            assertParamExists('deleteRelation', 'orgName', orgName)
            // verify required parameter 'clusterName' is not null or undefined
            assertParamExists('deleteRelation', 'clusterName', clusterName)
            // verify required parameter 'target' is not null or undefined
            assertParamExists('deleteRelation', 'target', target)
            const localVarPath = `/api/v1/organizations/{orgName}/clusters/{clusterName}/relation/{target}`
                .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName)))
                .replace(`{${"clusterName"}}`, encodeURIComponent(String(clusterName)))
                .replace(`{${"target"}}`, encodeURIComponent(String(target)));
            // 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 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,
            };
        },
        /**
         * 
         * @summary list the available clusters for the organization to create the a relation
         * @param {string} orgName 
         * @param {string} clusterName 
         * @param {string} targetType 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listAvailableClustersForRelation: async (orgName: string, clusterName: string, targetType: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'orgName' is not null or undefined
            assertParamExists('listAvailableClustersForRelation', 'orgName', orgName)
            // verify required parameter 'clusterName' is not null or undefined
            assertParamExists('listAvailableClustersForRelation', 'clusterName', clusterName)
            // verify required parameter 'targetType' is not null or undefined
            assertParamExists('listAvailableClustersForRelation', 'targetType', targetType)
            const localVarPath = `/api/v1/organizations/{orgName}/cluster/{clusterName}/available-relations`
                .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName)))
                .replace(`{${"clusterName"}}`, encodeURIComponent(String(clusterName)));
            // 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)

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


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

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * 
         * @summary list the clusters that have built a relation to the specified cluster
         * @param {string} orgName 
         * @param {string} clusterName 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listRelatedClusters: async (orgName: string, clusterName: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'orgName' is not null or undefined
            assertParamExists('listRelatedClusters', 'orgName', orgName)
            // verify required parameter 'clusterName' is not null or undefined
            assertParamExists('listRelatedClusters', 'clusterName', clusterName)
            const localVarPath = `/api/v1/organizations/{orgName}/clusters/{clusterName}/relations`
                .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName)))
                .replace(`{${"clusterName"}}`, encodeURIComponent(String(clusterName)));
            // 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,
            };
        },
    }
};

/**
 * RelationApi - functional programming interface
 * @export
 */
export const RelationApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = RelationApiAxiosParamCreator(configuration)
    return {
        /**
         * 
         * @summary create a relation between the clusters in the organization
         * @param {string} orgName 
         * @param {string} clusterName 
         * @param {string} target 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async createRelation(orgName: string, clusterName: string, target: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.createRelation(orgName, clusterName, target, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RelationApi.createRelation']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * 
         * @summary delete a existed relation between the clusters in the organization
         * @param {string} orgName 
         * @param {string} clusterName 
         * @param {string} target 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async deleteRelation(orgName: string, clusterName: string, target: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.deleteRelation(orgName, clusterName, target, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RelationApi.deleteRelation']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * 
         * @summary list the available clusters for the organization to create the a relation
         * @param {string} orgName 
         * @param {string} clusterName 
         * @param {string} targetType 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listAvailableClustersForRelation(orgName: string, clusterName: string, targetType: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<AvailableClusterListInner>>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listAvailableClustersForRelation(orgName, clusterName, targetType, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RelationApi.listAvailableClustersForRelation']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * 
         * @summary list the clusters that have built a relation to the specified cluster
         * @param {string} orgName 
         * @param {string} clusterName 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listRelatedClusters(orgName: string, clusterName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<RelatedClusterListItem>>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listRelatedClusters(orgName, clusterName, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RelationApi.listRelatedClusters']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * RelationApi - factory interface
 * @export
 */
export const RelationApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = RelationApiFp(configuration)
    return {
        /**
         * 
         * @summary create a relation between the clusters in the organization
         * @param {RelationApiCreateRelationRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createRelation(requestParameters: RelationApiCreateRelationRequest, options?: RawAxiosRequestConfig): AxiosPromise<void> {
            return localVarFp.createRelation(requestParameters.orgName, requestParameters.clusterName, requestParameters.target, options).then((request) => request(axios, basePath));
        },
        /**
         * 
         * @summary delete a existed relation between the clusters in the organization
         * @param {RelationApiDeleteRelationRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        deleteRelation(requestParameters: RelationApiDeleteRelationRequest, options?: RawAxiosRequestConfig): AxiosPromise<void> {
            return localVarFp.deleteRelation(requestParameters.orgName, requestParameters.clusterName, requestParameters.target, options).then((request) => request(axios, basePath));
        },
        /**
         * 
         * @summary list the available clusters for the organization to create the a relation
         * @param {RelationApiListAvailableClustersForRelationRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listAvailableClustersForRelation(requestParameters: RelationApiListAvailableClustersForRelationRequest, options?: RawAxiosRequestConfig): AxiosPromise<Array<AvailableClusterListInner>> {
            return localVarFp.listAvailableClustersForRelation(requestParameters.orgName, requestParameters.clusterName, requestParameters.targetType, options).then((request) => request(axios, basePath));
        },
        /**
         * 
         * @summary list the clusters that have built a relation to the specified cluster
         * @param {RelationApiListRelatedClustersRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listRelatedClusters(requestParameters: RelationApiListRelatedClustersRequest, options?: RawAxiosRequestConfig): AxiosPromise<Array<RelatedClusterListItem>> {
            return localVarFp.listRelatedClusters(requestParameters.orgName, requestParameters.clusterName, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * RelationApi - interface
 * @export
 * @interface RelationApi
 */
export interface RelationApiInterface {
    /**
     * 
     * @summary create a relation between the clusters in the organization
     * @param {RelationApiCreateRelationRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof RelationApiInterface
     */
    createRelation(requestParameters: RelationApiCreateRelationRequest, options?: RawAxiosRequestConfig): AxiosPromise<void>;

    /**
     * 
     * @summary delete a existed relation between the clusters in the organization
     * @param {RelationApiDeleteRelationRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof RelationApiInterface
     */
    deleteRelation(requestParameters: RelationApiDeleteRelationRequest, options?: RawAxiosRequestConfig): AxiosPromise<void>;

    /**
     * 
     * @summary list the available clusters for the organization to create the a relation
     * @param {RelationApiListAvailableClustersForRelationRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof RelationApiInterface
     */
    listAvailableClustersForRelation(requestParameters: RelationApiListAvailableClustersForRelationRequest, options?: RawAxiosRequestConfig): AxiosPromise<Array<AvailableClusterListInner>>;

    /**
     * 
     * @summary list the clusters that have built a relation to the specified cluster
     * @param {RelationApiListRelatedClustersRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof RelationApiInterface
     */
    listRelatedClusters(requestParameters: RelationApiListRelatedClustersRequest, options?: RawAxiosRequestConfig): AxiosPromise<Array<RelatedClusterListItem>>;

}

/**
 * Request parameters for createRelation operation in RelationApi.
 * @export
 * @interface RelationApiCreateRelationRequest
 */
export interface RelationApiCreateRelationRequest {
    /**
     * 
     * @type {string}
     * @memberof RelationApiCreateRelation
     */
    readonly orgName: string

    /**
     * 
     * @type {string}
     * @memberof RelationApiCreateRelation
     */
    readonly clusterName: string

    /**
     * 
     * @type {string}
     * @memberof RelationApiCreateRelation
     */
    readonly target: string
}

/**
 * Request parameters for deleteRelation operation in RelationApi.
 * @export
 * @interface RelationApiDeleteRelationRequest
 */
export interface RelationApiDeleteRelationRequest {
    /**
     * 
     * @type {string}
     * @memberof RelationApiDeleteRelation
     */
    readonly orgName: string

    /**
     * 
     * @type {string}
     * @memberof RelationApiDeleteRelation
     */
    readonly clusterName: string

    /**
     * 
     * @type {string}
     * @memberof RelationApiDeleteRelation
     */
    readonly target: string
}

/**
 * Request parameters for listAvailableClustersForRelation operation in RelationApi.
 * @export
 * @interface RelationApiListAvailableClustersForRelationRequest
 */
export interface RelationApiListAvailableClustersForRelationRequest {
    /**
     * 
     * @type {string}
     * @memberof RelationApiListAvailableClustersForRelation
     */
    readonly orgName: string

    /**
     * 
     * @type {string}
     * @memberof RelationApiListAvailableClustersForRelation
     */
    readonly clusterName: string

    /**
     * 
     * @type {string}
     * @memberof RelationApiListAvailableClustersForRelation
     */
    readonly targetType: string
}

/**
 * Request parameters for listRelatedClusters operation in RelationApi.
 * @export
 * @interface RelationApiListRelatedClustersRequest
 */
export interface RelationApiListRelatedClustersRequest {
    /**
     * 
     * @type {string}
     * @memberof RelationApiListRelatedClusters
     */
    readonly orgName: string

    /**
     * 
     * @type {string}
     * @memberof RelationApiListRelatedClusters
     */
    readonly clusterName: string
}

/**
 * RelationApi - object-oriented interface
 * @export
 * @class RelationApi
 * @extends {BaseAPI}
 */
export class RelationApi extends BaseAPI implements RelationApiInterface {
    /**
     * 
     * @summary create a relation between the clusters in the organization
     * @param {RelationApiCreateRelationRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof RelationApi
     */
    public createRelation(requestParameters: RelationApiCreateRelationRequest, options?: RawAxiosRequestConfig) {
        return RelationApiFp(this.configuration).createRelation(requestParameters.orgName, requestParameters.clusterName, requestParameters.target, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * 
     * @summary delete a existed relation between the clusters in the organization
     * @param {RelationApiDeleteRelationRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof RelationApi
     */
    public deleteRelation(requestParameters: RelationApiDeleteRelationRequest, options?: RawAxiosRequestConfig) {
        return RelationApiFp(this.configuration).deleteRelation(requestParameters.orgName, requestParameters.clusterName, requestParameters.target, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * 
     * @summary list the available clusters for the organization to create the a relation
     * @param {RelationApiListAvailableClustersForRelationRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof RelationApi
     */
    public listAvailableClustersForRelation(requestParameters: RelationApiListAvailableClustersForRelationRequest, options?: RawAxiosRequestConfig) {
        return RelationApiFp(this.configuration).listAvailableClustersForRelation(requestParameters.orgName, requestParameters.clusterName, requestParameters.targetType, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * 
     * @summary list the clusters that have built a relation to the specified cluster
     * @param {RelationApiListRelatedClustersRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof RelationApi
     */
    public listRelatedClusters(requestParameters: RelationApiListRelatedClustersRequest, options?: RawAxiosRequestConfig) {
        return RelationApiFp(this.configuration).listRelatedClusters(requestParameters.orgName, requestParameters.clusterName, options).then((request) => request(this.axios, this.basePath));
    }
}

