/*-
 * ~~~~~~licensing~~~~~~
 * application-management
 * ==========
 * Copyright (C) 2020 - 2025 EmDev LLC
 * ==========
 * You may not use this file except in accordance with the License Terms of the Copyright
 * Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
 * rights to the Software and any copies are the property of the Copyright Holder. Unless
 * it is explicitly allowed the Copyright Holder, the User is prohibited from using the
 * Software for commercial purposes to provide services to third parties.
 * 
 * The Copyright Holder hereby declares that the Software is provided on an "AS IS".
 * Under no circumstances does the Copyright Holder guarantee or promise that the
 * Software provided by him will be suitable or not suitable for the specific purposes
 * of the User, that the Software will meet all commercial and personal subjective
 * expectations of the User, that the Software will work properly, without technical
 * errors, quickly and uninterruptedly.
 * 
 * Under no circumstances shall the Copyright Holder or its Affiliates is not liable
 * to the User for any direct or indirect losses of the User, his expenses or actual
 * damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
 * or damage to data, property, etc.
 * ~~~~~~/licensing~~~~~~
 */
package ru.entaxy.platform.integration.applications.management;

import ru.entaxy.esb.platform.base.management.core.Qualifier;
import ru.entaxy.esb.platform.base.management.core.api.MBeanAnnotated;
import ru.entaxy.esb.platform.base.management.core.api.MBeanExportPolicy;
import ru.entaxy.esb.platform.base.management.core.api.Operation;
import ru.entaxy.esb.platform.base.management.core.api.Parameter;

import java.util.List;
import java.util.Map;

@MBeanAnnotated(policy = MBeanExportPolicy.ANNOTATED_ONLY)
public interface ProjectsMBean {

    public static final String MODULE_JMX_DOMAIN = "ru.entaxy.cicd";

    public static final String MAIN_MODULE_KEY = "module";

    public static final String MAIN_MODULE_KEY_VALUE = "projects";

    public static final Qualifier Q_MAIN_MODULE = new Qualifier(MAIN_MODULE_KEY, MAIN_MODULE_KEY_VALUE);

    public static final String Q_MAIN_MODULE_S = MODULE_JMX_DOMAIN + ":" + MAIN_MODULE_KEY + "=" + MAIN_MODULE_KEY_VALUE;

    @Operation(desc = "Gets tree")
    String readAsTree() throws Exception;

    @Operation(desc = "List project items")
    List<Map<String, Object>> listProjectItems(
            @Parameter(name = "storage", desc = "Name of the storage") String storage,
            @Parameter(name = "projectName", desc = "Name of the project") String projectName,
            @Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion
    ) throws Exception;

    @Operation(desc = "Read project item statuses")
    List<String> readProjectItemStatuses();

    @Operation(desc = "Create project")
    void createProject(
            @Parameter(name = "projectName", desc = "Name of created project") String projectName,
            @Parameter(name = "storage", desc = "Name of the storage") String storage,
            @Parameter(name = "initialVersion", desc = "Initial version for the created project") String initialVersion
    ) throws Exception;

    @Operation(desc = "Remove project")
    void removeProject(
            @Parameter(name = "storage", desc = "Name of the storage") String storage,
            @Parameter(name = "projectName", desc = "Name of the project") String projectName
    ) throws Exception;

    @Operation(desc = "Add object to the project")
    List<Map<String, String>> addObject(
            @Parameter(name = "storage", desc = "Name of the storage") String storage,
            @Parameter(name = "projectName", desc = "Name of the project") String projectName,
            @Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion,
            @Parameter(name = "objectId", desc = "Id of the object") String objectId
    ) throws Exception;

    @Operation(desc = "List objects")
    List<Map<String, String>> listObjects() throws Exception;

    @Operation(desc = "Get related objects")
    List<Map<String, String>> getRelatedObjects(
            @Parameter(name = "objectId", desc = "Id of the object") String objectId
    ) throws Exception;

    @Operation(desc = "Add resource to the project")
    void addResource(
            @Parameter(name = "storage", desc = "Name of the storage") String storage,
            @Parameter(name = "projectName", desc = "Name of the project") String projectName,
            @Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion,
            @Parameter(name = "location", desc = "Location of the resource") String location
    ) throws Exception;

    @Operation(desc = "Add item to the project")
    void addItem(
            @Parameter(name = "storage", desc = "Name of the storage") String storage,
            @Parameter(name = "projectName", desc = "Name of the project") String projectName,
            @Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion,
            @Parameter(name = "itemId", desc = "Id of the item") String itemId
    ) throws Exception;

    @Operation(desc = "Ignore item from the project")
    void ignoreItem(
            @Parameter(name = "storage", desc = "Name of the storage") String storage,
            @Parameter(name = "projectName", desc = "Name of the project") String projectName,
            @Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion,
            @Parameter(name = "itemId", desc = "Id of the item") String itemId
    ) throws Exception;

    @Operation(desc = "Remove item from the project")
    void removeItem(
            @Parameter(name = "storage", desc = "Name of the storage") String storage,
            @Parameter(name = "projectName", desc = "Name of the project") String projectName,
            @Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion,
            @Parameter(name = "itemId", desc = "Id of the item") String itemId
    ) throws Exception;

    @Operation(desc = "Remove items from the project")
    Map<String, List<String>> removeItems(
            @Parameter(name = "storage", desc = "Name of the storage") String storage,
            @Parameter(name = "projectName", desc = "Name of the project") String projectName,
            @Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion,
            @Parameter(name = "itemIds", desc = "Ids of the items") List<String> itemIds
    ) throws Exception;

    @Operation(desc = "Create version")
    void createVersion(
            @Parameter(name = "storage", desc = "Name of the storage") String storage,
            @Parameter(name = "projectName", desc = "Name of the project") String projectName,
            @Parameter(name = "createdVersion", desc = "Created version") String createdVersion,
            @Parameter(name = "prototypeVersion", desc = "Existent version to base on") String prototypeVersion
    ) throws Exception;

    @Operation(desc = "Remove version")
    void removeVersion(
            @Parameter(name = "storage", desc = "Name of the storage") String storage,
            @Parameter(name = "projectName", desc = "Name of the project") String projectName,
            @Parameter(name = "versionToRemove", desc = "Version to remove") String versionToRemove
    ) throws Exception;

    @Operation(desc = "Save project version")
    void saveProjectVersion(
            @Parameter(name = "storage", desc = "Name of the storage") String storage,
            @Parameter(name = "projectName", desc = "Name of the project") String projectName,
            @Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion
    ) throws Exception;

    @Operation(desc = "Build project version")
    void buildProjectVersion(
            @Parameter(name = "storage", desc = "Name of the storage") String storage,
            @Parameter(name = "projectName", desc = "Name of the project") String projectName,
            @Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion
    ) throws Exception;

    @Operation(desc = "List built project items")
    List<Map<String, String>> listBuiltProjectItems(
            @Parameter(name = "storage", desc = "Name of the storage") String storage,
            @Parameter(name = "projectName", desc = "Name of the project") String projectName,
            @Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion
    ) throws Exception;

    @Operation(desc = "List built project requirements")
    List<Map<String, Object>> listBuiltProjectRequirements(
            @Parameter(name = "storage", desc = "Name of the storage") String storage,
            @Parameter(name = "projectName", desc = "Name of the project") String projectName,
            @Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion
    ) throws Exception;

    @Operation(desc = "List built project components")
    List<Map<String, String>> listBuiltProjectComponents(
            @Parameter(name = "storage", desc = "Name of the storage") String storage,
            @Parameter(name = "projectName", desc = "Name of the project") String projectName,
            @Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion
    ) throws Exception;

    @Operation(desc = "Read build info")
    String readMavenUrl(
            @Parameter(name = "storage", desc = "Name of the storage") String storage,
            @Parameter(name = "projectName", desc = "Name of the project") String projectName,
            @Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion
    ) throws Exception;

    @Operation(desc = "List repositories")
    List<String> listRepositories() throws Exception;

    @Operation(desc = "Export project to repository")
    void exportToRepository(
            @Parameter(name = "storage", desc = "Name of the storage") String storage,
            @Parameter(name = "projectName", desc = "Name of the project") String projectName,
            @Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion,
            @Parameter(name = "repositoryName", desc = "Name of the repository") String repositoryName
    ) throws Exception;

    @Operation(desc = "Export project to file")
    String exportToFile(
            @Parameter(name = "storage", desc = "Name of the storage") String storage,
            @Parameter(name = "projectName", desc = "Name of the project") String projectName,
            @Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion
    ) throws Exception;
}
