/* 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 { Project } from '../models';
// @ts-ignore
import type { ProjectCreate } from '../models';
// @ts-ignore
import type { ProjectList } from '../models';
// @ts-ignore
import type { ProjectUpdate } from '../models';
/**
 * ProjectApi - axios parameter creator
 * @export
 */
export const ProjectApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * 
         * @summary Create a project in an environment
         * @param {string} environmentName environment name
         * @param {ProjectCreate} projectCreate 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createProject: async (environmentName: string, projectCreate: ProjectCreate, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'environmentName' is not null or undefined
            assertParamExists('createProject', 'environmentName', environmentName)
            // verify required parameter 'projectCreate' is not null or undefined
            assertParamExists('createProject', 'projectCreate', projectCreate)
            const localVarPath = `/admin/v1/environments/{environmentName}/projects`
                .replace(`{${"environmentName"}}`, encodeURIComponent(String(environmentName)));
            // 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(projectCreate, localVarRequestOptions, configuration)

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * 
         * @summary Delete a project in an environment
         * @param {string} environmentName environment name
         * @param {string} projectName project name
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        deleteProject: async (environmentName: string, projectName: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'environmentName' is not null or undefined
            assertParamExists('deleteProject', 'environmentName', environmentName)
            // verify required parameter 'projectName' is not null or undefined
            assertParamExists('deleteProject', 'projectName', projectName)
            const localVarPath = `/admin/v1/environments/{environmentName}/projects/{projectName}`
                .replace(`{${"environmentName"}}`, encodeURIComponent(String(environmentName)))
                .replace(`{${"projectName"}}`, encodeURIComponent(String(projectName)));
            // 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 projects in an environment
         * @param {string} environmentName environment name
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listProjects: async (environmentName: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'environmentName' is not null or undefined
            assertParamExists('listProjects', 'environmentName', environmentName)
            const localVarPath = `/admin/v1/environments/{environmentName}/projects`
                .replace(`{${"environmentName"}}`, encodeURIComponent(String(environmentName)));
            // 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,
            };
        },
        /**
         * 
         * @summary Update a project in an environment
         * @param {string} environmentName environment name
         * @param {string} projectName project name
         * @param {ProjectUpdate} projectUpdate 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        updateProject: async (environmentName: string, projectName: string, projectUpdate: ProjectUpdate, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'environmentName' is not null or undefined
            assertParamExists('updateProject', 'environmentName', environmentName)
            // verify required parameter 'projectName' is not null or undefined
            assertParamExists('updateProject', 'projectName', projectName)
            // verify required parameter 'projectUpdate' is not null or undefined
            assertParamExists('updateProject', 'projectUpdate', projectUpdate)
            const localVarPath = `/admin/v1/environments/{environmentName}/projects/{projectName}`
                .replace(`{${"environmentName"}}`, encodeURIComponent(String(environmentName)))
                .replace(`{${"projectName"}}`, encodeURIComponent(String(projectName)));
            // 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: 'PATCH', ...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(projectUpdate, localVarRequestOptions, configuration)

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

/**
 * ProjectApi - functional programming interface
 * @export
 */
export const ProjectApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = ProjectApiAxiosParamCreator(configuration)
    return {
        /**
         * 
         * @summary Create a project in an environment
         * @param {string} environmentName environment name
         * @param {ProjectCreate} projectCreate 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async createProject(environmentName: string, projectCreate: ProjectCreate, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Project>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.createProject(environmentName, projectCreate, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['ProjectApi.createProject']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * 
         * @summary Delete a project in an environment
         * @param {string} environmentName environment name
         * @param {string} projectName project name
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async deleteProject(environmentName: string, projectName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.deleteProject(environmentName, projectName, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['ProjectApi.deleteProject']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * 
         * @summary List projects in an environment
         * @param {string} environmentName environment name
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listProjects(environmentName: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ProjectList>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listProjects(environmentName, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['ProjectApi.listProjects']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * 
         * @summary Update a project in an environment
         * @param {string} environmentName environment name
         * @param {string} projectName project name
         * @param {ProjectUpdate} projectUpdate 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async updateProject(environmentName: string, projectName: string, projectUpdate: ProjectUpdate, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Project>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.updateProject(environmentName, projectName, projectUpdate, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['ProjectApi.updateProject']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * ProjectApi - factory interface
 * @export
 */
export const ProjectApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = ProjectApiFp(configuration)
    return {
        /**
         * 
         * @summary Create a project in an environment
         * @param {ProjectApiCreateProjectRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        createProject(requestParameters: ProjectApiCreateProjectRequest, options?: RawAxiosRequestConfig): AxiosPromise<Project> {
            return localVarFp.createProject(requestParameters.environmentName, requestParameters.projectCreate, options).then((request) => request(axios, basePath));
        },
        /**
         * 
         * @summary Delete a project in an environment
         * @param {ProjectApiDeleteProjectRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        deleteProject(requestParameters: ProjectApiDeleteProjectRequest, options?: RawAxiosRequestConfig): AxiosPromise<void> {
            return localVarFp.deleteProject(requestParameters.environmentName, requestParameters.projectName, options).then((request) => request(axios, basePath));
        },
        /**
         * 
         * @summary List projects in an environment
         * @param {ProjectApiListProjectsRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listProjects(requestParameters: ProjectApiListProjectsRequest, options?: RawAxiosRequestConfig): AxiosPromise<ProjectList> {
            return localVarFp.listProjects(requestParameters.environmentName, options).then((request) => request(axios, basePath));
        },
        /**
         * 
         * @summary Update a project in an environment
         * @param {ProjectApiUpdateProjectRequest} requestParameters Request parameters.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        updateProject(requestParameters: ProjectApiUpdateProjectRequest, options?: RawAxiosRequestConfig): AxiosPromise<Project> {
            return localVarFp.updateProject(requestParameters.environmentName, requestParameters.projectName, requestParameters.projectUpdate, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * ProjectApi - interface
 * @export
 * @interface ProjectApi
 */
export interface ProjectApiInterface {
    /**
     * 
     * @summary Create a project in an environment
     * @param {ProjectApiCreateProjectRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ProjectApiInterface
     */
    createProject(requestParameters: ProjectApiCreateProjectRequest, options?: RawAxiosRequestConfig): AxiosPromise<Project>;

    /**
     * 
     * @summary Delete a project in an environment
     * @param {ProjectApiDeleteProjectRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ProjectApiInterface
     */
    deleteProject(requestParameters: ProjectApiDeleteProjectRequest, options?: RawAxiosRequestConfig): AxiosPromise<void>;

    /**
     * 
     * @summary List projects in an environment
     * @param {ProjectApiListProjectsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ProjectApiInterface
     */
    listProjects(requestParameters: ProjectApiListProjectsRequest, options?: RawAxiosRequestConfig): AxiosPromise<ProjectList>;

    /**
     * 
     * @summary Update a project in an environment
     * @param {ProjectApiUpdateProjectRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ProjectApiInterface
     */
    updateProject(requestParameters: ProjectApiUpdateProjectRequest, options?: RawAxiosRequestConfig): AxiosPromise<Project>;

}

/**
 * Request parameters for createProject operation in ProjectApi.
 * @export
 * @interface ProjectApiCreateProjectRequest
 */
export interface ProjectApiCreateProjectRequest {
    /**
     * environment name
     * @type {string}
     * @memberof ProjectApiCreateProject
     */
    readonly environmentName: string

    /**
     * 
     * @type {ProjectCreate}
     * @memberof ProjectApiCreateProject
     */
    readonly projectCreate: ProjectCreate
}

/**
 * Request parameters for deleteProject operation in ProjectApi.
 * @export
 * @interface ProjectApiDeleteProjectRequest
 */
export interface ProjectApiDeleteProjectRequest {
    /**
     * environment name
     * @type {string}
     * @memberof ProjectApiDeleteProject
     */
    readonly environmentName: string

    /**
     * project name
     * @type {string}
     * @memberof ProjectApiDeleteProject
     */
    readonly projectName: string
}

/**
 * Request parameters for listProjects operation in ProjectApi.
 * @export
 * @interface ProjectApiListProjectsRequest
 */
export interface ProjectApiListProjectsRequest {
    /**
     * environment name
     * @type {string}
     * @memberof ProjectApiListProjects
     */
    readonly environmentName: string
}

/**
 * Request parameters for updateProject operation in ProjectApi.
 * @export
 * @interface ProjectApiUpdateProjectRequest
 */
export interface ProjectApiUpdateProjectRequest {
    /**
     * environment name
     * @type {string}
     * @memberof ProjectApiUpdateProject
     */
    readonly environmentName: string

    /**
     * project name
     * @type {string}
     * @memberof ProjectApiUpdateProject
     */
    readonly projectName: string

    /**
     * 
     * @type {ProjectUpdate}
     * @memberof ProjectApiUpdateProject
     */
    readonly projectUpdate: ProjectUpdate
}

/**
 * ProjectApi - object-oriented interface
 * @export
 * @class ProjectApi
 * @extends {BaseAPI}
 */
export class ProjectApi extends BaseAPI implements ProjectApiInterface {
    /**
     * 
     * @summary Create a project in an environment
     * @param {ProjectApiCreateProjectRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ProjectApi
     */
    public createProject(requestParameters: ProjectApiCreateProjectRequest, options?: RawAxiosRequestConfig) {
        return ProjectApiFp(this.configuration).createProject(requestParameters.environmentName, requestParameters.projectCreate, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * 
     * @summary Delete a project in an environment
     * @param {ProjectApiDeleteProjectRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ProjectApi
     */
    public deleteProject(requestParameters: ProjectApiDeleteProjectRequest, options?: RawAxiosRequestConfig) {
        return ProjectApiFp(this.configuration).deleteProject(requestParameters.environmentName, requestParameters.projectName, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * 
     * @summary List projects in an environment
     * @param {ProjectApiListProjectsRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ProjectApi
     */
    public listProjects(requestParameters: ProjectApiListProjectsRequest, options?: RawAxiosRequestConfig) {
        return ProjectApiFp(this.configuration).listProjects(requestParameters.environmentName, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * 
     * @summary Update a project in an environment
     * @param {ProjectApiUpdateProjectRequest} requestParameters Request parameters.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     * @memberof ProjectApi
     */
    public updateProject(requestParameters: ProjectApiUpdateProjectRequest, options?: RawAxiosRequestConfig) {
        return ProjectApiFp(this.configuration).updateProject(requestParameters.environmentName, requestParameters.projectName, requestParameters.projectUpdate, options).then((request) => request(this.axios, this.basePath));
    }
}

