/* 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 { PostgresqlLockAnalysis } from '../models';
// @ts-ignore
import type { PostgresqlSession } from '../models';
/**
 * DiagnosticsApi - axios parameter creator
 * @export
 */
export const DiagnosticsApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Get one PostgreSQL session basic diagnostics record by backend pid.
         * @summary Get PostgreSQL session basic diagnostics
         * @param {string} orgName Organization name
         * @param {string} clusterName Cluster name
         * @param {number} pid PostgreSQL backend process id.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getDiagnosticsPostgresqlSession: async (orgName: string, clusterName: string, pid: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'orgName' is not null or undefined
            assertParamExists('getDiagnosticsPostgresqlSession', 'orgName', orgName)
            // verify required parameter 'clusterName' is not null or undefined
            assertParamExists('getDiagnosticsPostgresqlSession', 'clusterName', clusterName)
            // verify required parameter 'pid' is not null or undefined
            assertParamExists('getDiagnosticsPostgresqlSession', 'pid', pid)
            const localVarPath = `/api/v1/organizations/{orgName}/clusters/{clusterName}/diagnostics/postgresql/sessions/{pid}`
                .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName)))
                .replace(`{${"clusterName"}}`, encodeURIComponent(String(clusterName)))
                .replace(`{${"pid"}}`, encodeURIComponent(String(pid)));
            // 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,
            };
        },
        /**
         * Get read-only lock analysis for one PostgreSQL backend pid from the current DMS PostgreSQL lock snapshot.
         * @summary Get PostgreSQL session lock analysis
         * @param {string} orgName Organization name
         * @param {string} clusterName Cluster name
         * @param {number} pid PostgreSQL backend process id.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getDiagnosticsPostgresqlSessionLockAnalysis: async (orgName: string, clusterName: string, pid: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'orgName' is not null or undefined
            assertParamExists('getDiagnosticsPostgresqlSessionLockAnalysis', 'orgName', orgName)
            // verify required parameter 'clusterName' is not null or undefined
            assertParamExists('getDiagnosticsPostgresqlSessionLockAnalysis', 'clusterName', clusterName)
            // verify required parameter 'pid' is not null or undefined
            assertParamExists('getDiagnosticsPostgresqlSessionLockAnalysis', 'pid', pid)
            const localVarPath = `/api/v1/organizations/{orgName}/clusters/{clusterName}/diagnostics/postgresql/sessions/{pid}/lockAnalysis`
                .replace(`{${"orgName"}}`, encodeURIComponent(String(orgName)))
                .replace(`{${"clusterName"}}`, encodeURIComponent(String(clusterName)))
                .replace(`{${"pid"}}`, encodeURIComponent(String(pid)));
            // 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,
            };
        },
    }
};

/**
 * DiagnosticsApi - functional programming interface
 * @export
 */
export const DiagnosticsApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = DiagnosticsApiAxiosParamCreator(configuration)
    return {
        /**
         * Get one PostgreSQL session basic diagnostics record by backend pid.
         * @summary Get PostgreSQL session basic diagnostics
         * @param {string} orgName Organization name
         * @param {string} clusterName Cluster name
         * @param {number} pid PostgreSQL backend process id.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getDiagnosticsPostgresqlSession(orgName: string, clusterName: string, pid: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PostgresqlSession>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getDiagnosticsPostgresqlSession(orgName, clusterName, pid, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['DiagnosticsApi.getDiagnosticsPostgresqlSession']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Get read-only lock analysis for one PostgreSQL backend pid from the current DMS PostgreSQL lock snapshot.
         * @summary Get PostgreSQL session lock analysis
         * @param {string} orgName Organization name
         * @param {string} clusterName Cluster name
         * @param {number} pid PostgreSQL backend process id.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getDiagnosticsPostgresqlSessionLockAnalysis(orgName: string, clusterName: string, pid: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PostgresqlLockAnalysis>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getDiagnosticsPostgresqlSessionLockAnalysis(orgName, clusterName, pid, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['DiagnosticsApi.getDiagnosticsPostgresqlSessionLockAnalysis']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * DiagnosticsApi - factory interface
 * @export
 */
export const DiagnosticsApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = DiagnosticsApiFp(configuration)
    return {
        /**
         * Get one PostgreSQL session basic diagnostics record by backend pid.
         * @summary Get PostgreSQL session basic diagnostics
         * @param {DiagnosticsApiGetDiagnosticsPostgresqlSessionRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getDiagnosticsPostgresqlSession(requestParameters: DiagnosticsApiGetDiagnosticsPostgresqlSessionRequest, options?: RawAxiosRequestConfig): AxiosPromise<PostgresqlSession> {
            return localVarFp.getDiagnosticsPostgresqlSession(requestParameters.orgName, requestParameters.clusterName, requestParameters.pid, options).then((request) => request(axios, basePath));
        },
        /**
         * Get read-only lock analysis for one PostgreSQL backend pid from the current DMS PostgreSQL lock snapshot.
         * @summary Get PostgreSQL session lock analysis
         * @param {DiagnosticsApiGetDiagnosticsPostgresqlSessionLockAnalysisRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getDiagnosticsPostgresqlSessionLockAnalysis(requestParameters: DiagnosticsApiGetDiagnosticsPostgresqlSessionLockAnalysisRequest, options?: RawAxiosRequestConfig): AxiosPromise<PostgresqlLockAnalysis> {
            return localVarFp.getDiagnosticsPostgresqlSessionLockAnalysis(requestParameters.orgName, requestParameters.clusterName, requestParameters.pid, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * DiagnosticsApi - interface
 * @export
 * @interface DiagnosticsApi
 */
export interface DiagnosticsApiInterface {
    /**
     * Get one PostgreSQL session basic diagnostics record by backend pid.
     * @summary Get PostgreSQL session basic diagnostics
     * @param {DiagnosticsApiGetDiagnosticsPostgresqlSessionRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof DiagnosticsApiInterface
     */
    getDiagnosticsPostgresqlSession(requestParameters: DiagnosticsApiGetDiagnosticsPostgresqlSessionRequest, options?: RawAxiosRequestConfig): AxiosPromise<PostgresqlSession>;

    /**
     * Get read-only lock analysis for one PostgreSQL backend pid from the current DMS PostgreSQL lock snapshot.
     * @summary Get PostgreSQL session lock analysis
     * @param {DiagnosticsApiGetDiagnosticsPostgresqlSessionLockAnalysisRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof DiagnosticsApiInterface
     */
    getDiagnosticsPostgresqlSessionLockAnalysis(requestParameters: DiagnosticsApiGetDiagnosticsPostgresqlSessionLockAnalysisRequest, options?: RawAxiosRequestConfig): AxiosPromise<PostgresqlLockAnalysis>;

}

/**
 * Request parameters for getDiagnosticsPostgresqlSession operation in DiagnosticsApi.
 * @export
 * @interface DiagnosticsApiGetDiagnosticsPostgresqlSessionRequest
 */
export interface DiagnosticsApiGetDiagnosticsPostgresqlSessionRequest {
    /**
     * Organization name
     * @type {string}
     * @memberof DiagnosticsApiGetDiagnosticsPostgresqlSession
     */
    readonly orgName: string

    /**
     * Cluster name
     * @type {string}
     * @memberof DiagnosticsApiGetDiagnosticsPostgresqlSession
     */
    readonly clusterName: string

    /**
     * PostgreSQL backend process id.
     * @type {number}
     * @memberof DiagnosticsApiGetDiagnosticsPostgresqlSession
     */
    readonly pid: number
}

/**
 * Request parameters for getDiagnosticsPostgresqlSessionLockAnalysis operation in DiagnosticsApi.
 * @export
 * @interface DiagnosticsApiGetDiagnosticsPostgresqlSessionLockAnalysisRequest
 */
export interface DiagnosticsApiGetDiagnosticsPostgresqlSessionLockAnalysisRequest {
    /**
     * Organization name
     * @type {string}
     * @memberof DiagnosticsApiGetDiagnosticsPostgresqlSessionLockAnalysis
     */
    readonly orgName: string

    /**
     * Cluster name
     * @type {string}
     * @memberof DiagnosticsApiGetDiagnosticsPostgresqlSessionLockAnalysis
     */
    readonly clusterName: string

    /**
     * PostgreSQL backend process id.
     * @type {number}
     * @memberof DiagnosticsApiGetDiagnosticsPostgresqlSessionLockAnalysis
     */
    readonly pid: number
}

/**
 * DiagnosticsApi - object-oriented interface
 * @export
 * @class DiagnosticsApi
 * @extends {BaseAPI}
 */
export class DiagnosticsApi extends BaseAPI implements DiagnosticsApiInterface {
    /**
     * Get one PostgreSQL session basic diagnostics record by backend pid.
     * @summary Get PostgreSQL session basic diagnostics
     * @param {DiagnosticsApiGetDiagnosticsPostgresqlSessionRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof DiagnosticsApi
     */
    public getDiagnosticsPostgresqlSession(requestParameters: DiagnosticsApiGetDiagnosticsPostgresqlSessionRequest, options?: RawAxiosRequestConfig) {
        return DiagnosticsApiFp(this.configuration).getDiagnosticsPostgresqlSession(requestParameters.orgName, requestParameters.clusterName, requestParameters.pid, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Get read-only lock analysis for one PostgreSQL backend pid from the current DMS PostgreSQL lock snapshot.
     * @summary Get PostgreSQL session lock analysis
     * @param {DiagnosticsApiGetDiagnosticsPostgresqlSessionLockAnalysisRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof DiagnosticsApi
     */
    public getDiagnosticsPostgresqlSessionLockAnalysis(requestParameters: DiagnosticsApiGetDiagnosticsPostgresqlSessionLockAnalysisRequest, options?: RawAxiosRequestConfig) {
        return DiagnosticsApiFp(this.configuration).getDiagnosticsPostgresqlSessionLockAnalysis(requestParameters.orgName, requestParameters.clusterName, requestParameters.pid, options).then((request) => request(this.axios, this.basePath));
    }
}

