package com.bocloud.ims.interfaces.resource;

import com.bocloud.cmp.model.CloudServerBean;
import com.bocloud.cmp.model.common.ApplicationParam;
import com.bocloud.cmp.model.fusionsphere.CdromModel;
import com.bocloud.cmp.vm.model.*;
import com.bocloud.common.model.*;
import com.bocloud.ims.entity.resource.CloudServer;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

/**
 * 云主机实现类接口
 *
 * @author wangyu
 * @version 1.0
 * @since 2018年7月19日
 */
public interface CloudServerService {

    /**
     * 查询云主机列表
     *
     * @param pager
     * @param context
     * @return
     */
    BocloudResult<GridBean<CloudServer>> list(Pager pager, RequestContext context);


    /**
     * 查询云主机列表(自服务专用)
     *
     * @author sxp
     * @since 2023/8/1
     */
    BocloudResult<GridBean<CloudServer>> listForTenant(Pager pager, RequestContext context);

    /**
     * 添加云主机
     *
     * @param params
     * @param context
     * @return
     */
    BocloudResult create(VmGenericParam params, RequestContext context);

    /**
     * 克隆云主机
     *
     * @param context
     * @return
     */
    BocloudResult clone(VmGenericParam vmGenericParam, RequestContext context);

    /**
     * 迁移
     *
     * @param context
     * @return
     */
    BocloudResult migrate(VmGenericParam vmGenericParam, RequestContext context);

    /**
     * openstack迁移
     *
     * @param context
     * @return
     */
    BocloudResult osMigrate(VmGenericParam vmGenericParam, RequestContext context);

    /**
     * 创建快照
     *
     * @param params
     * @param context
     * @return
     */
    BocloudResult snapshot(VmSnapshotParam params, RequestContext context);

    /**
     * 更新云主机
     *
     * @param bean
     * @param context
     * @param queue
     * @return
     */
    BocloudResult modify(CloudServerBean bean, RequestContext context, String queue);

    /**
     * 修改数据库中的云主机信息
     *
     * @author sxp
     * @since 2023/8/3
     */
    BocloudResult modifyServerOfDb(CloudServer bean, RequestContext context, String queue);



    BocloudResult remove(Long id, VmDeleteParam vmDeleteParam, RequestContext context);

    /**
     * 云主机批量删除
     *
     * @param ids
     * @param context
     * @return
     */
    BocloudResult batchRemove(List<Long> ids, RequestContext context);

    /**
     * 得到当前云主机的基本信息和统计信息
     *
     * @param id
     * @return the result
     */
    BocloudResult detail(Long id);

    /**
     * 云主机基本信息
     *
     * @param id
     * @return the result
     */
    BocloudResult basic(Long id);

    /**
     * 启动云主机
     *
     * @param id
     * @param context
     * @return the result
     */
    BocloudResult start(Long id, RequestContext context);

    /**
     * 云主机批量启动
     *
     * @param ids
     * @param context
     * @return
     */
    BocloudResult batchStart(List<Long> ids, RequestContext context);

    /**
     * 重启云主机
     *
     * @param id
     * @param context
     * @return the result
     */
    BocloudResult restart(Long id, RequestContext context);

    /**
     * 软重启云主机
     *
     * @param serverId
     * @param context
     * @return
     */
    BocloudResult softRestart(Long serverId, RequestContext context);

    /**
     * 云主机批量重启
     *
     * @param ids
     * @param context
     * @return
     */
    BocloudResult batchReboot(List<Long> ids, RequestContext context);

    /**
     * 云主机批量软重启
     *
     * @param ids
     * @param context
     * @return
     */
    BocloudResult batchSoftReboot(List<Long> ids, RequestContext context);

    /**
     * 关闭云主机
     *
     * @param id
     * @param context
     * @return the result
     */
    BocloudResult stop(Long id, RequestContext context);

    /**
     * 软关闭云主机
     *
     * @param serverId
     * @param context
     * @return
     */
    BocloudResult softStop(Long serverId, RequestContext context);

    /**
     * 休眠
     *
     * @param id
     * @param context
     * @return
     */
    BocloudResult hibernated(Long id, RequestContext context);

    /**
     * 云主机批量停止
     *
     * @param ids
     * @param context
     * @return
     */
    BocloudResult batchStop(List<Long> ids, RequestContext context);

    /**
     * 云主机批量软停止
     *
     * @param ids
     * @param context
     * @return
     */
    BocloudResult batchSoftStop(List<Long> ids, RequestContext context);

    /**
     * 暂停
     *
     * @param id
     * @param context
     * @return
     */
    BocloudResult pause(Long id, RequestContext context);

    /**
     * 挂起
     *
     * @param id
     * @param context
     * @return
     */
    BocloudResult suspend(Long id, RequestContext context);

    BocloudResult resume(Long serverId, RequestContext context);

    /**
     * 激活
     *
     * @param id
     * @param context
     * @return
     */
    BocloudResult active(Long id, RequestContext context);

    /**
     * 备份云主机
     *
     * @param id
     * @param context
     * @return
     */
    BocloudResult backup(Long id, RequestContext context);

    /**
     * 恢复云主机
     *
     * @param id
     * @param context
     * @return
     */
    BocloudResult recovery(Long id, RequestContext context);

    /**
     * 指定资源池创建云主机(vcenter)
     *
     * @param params
     * @param context
     * @return
     */
    BocloudResult createInResPool(VmGenericParam params, RequestContext context);

    /**
     * 判断名称是否已存在
     *
     * @param name
     * @param vendorId
     * @return
     */
    BocloudResult exists(String name, Long vendorId);

    /**
     * 按照平台类型查询
     *
     * @param params
     * @param context
     * @return
     */
    BocloudResult list(List<Param> params, RequestContext context);

    /**
     * 批量克隆云主机
     *
     * @param params
     * @param context
     * @return
     */
    BocloudResult batchClone(String params, RequestContext context);

    /**
     * 批量云主机快照
     *
     * @param params
     * @param context
     * @return
     */
    BocloudResult batchSnapshot(BatchSnapshotParam params, RequestContext context);

    /**
     * 汇总云主机数量
     *
     * @param userId
     * @param projectId
     * @param tenantId
     * @return
     */
    BocloudResult count(Long userId, Long projectId, Long tenantId);

    /**
     * 查询指定数据中心的模板
     *
     * @param vendorId
     * @param vdcId
     * @return
     */
    BocloudResult<List<CloudServer>> listTemplate(Long vendorId, Long vdcId);

    /**
     * 取消定时快照任务
     *
     * @param serverId
     * @param context
     * @return
     */
    BocloudResult cancelSnapshotTask(Long serverId, RequestContext context);

    /**
     * 云主机操作类
     *
     * @param params
     * @param context
     * @return
     */
    BocloudResult operations(Long id, VmGenericParam params, RequestContext context);

    /**
     * 查询云主机信息
     *
     * @param id
     * @param context
     * @param action
     * @param params
     * @return
     */
    BocloudResult details(Long id, RequestContext context, String action, String params);

    BocloudResult condition(Integer page, Integer rows, String condition, RequestContext context);

    BocloudResult listAvailableVm(Long vendorId, String regionId, RequestContext context);

    BocloudResult getBusinessById(Long id);

    BocloudResult configSeq(String params, RequestContext context);

    /**
     * 批量操作
     *
     * @param batchOperationParam
     * @param context
     * @return
     */
    BocloudResult batchOperations(VmBatchOperationParam batchOperationParam, RequestContext context);

    BocloudResult availableSizes(Long id);

    BocloudResult generalize(Long id, RequestContext context);

    /**
     * 批量暂停
     *
     * @param ids
     * @param context
     * @return
     */
    BocloudResult batchPause(List<Long> ids, RequestContext context);

    /**
     * 批量恢复
     *
     * @param ids
     * @param context
     * @return
     */
    BocloudResult batchRecovery(List<Long> ids, RequestContext context);


    BocloudResult attachCdrom(CdromModel cdromModel, RequestContext context);

    BocloudResult detachCdrom(CdromModel cdromModel, RequestContext context);

    BocloudResult listVmGroups(Long vendorId, String azId, RequestContext context);

    BocloudResult listLabels(Long vendorId, RequestContext context);

    BocloudResult listcon(Long vendorId, String storage, RequestContext context);

    BocloudResult listIso(Long vendorId, String storage, RequestContext context);

    BocloudResult vnc(Long vendorId, String instanceId, RequestContext context);

    BocloudResult pricing(ApplicationParam applicationParam, RequestContext context);


    BocloudResult vmDataStore(Long id);

    BocloudResult<GridBean<CloudServer>> countByUser(Pager pager, RequestContext context);

    void importData(MultipartFile multipartFile, RequestContext requestContext) throws IOException;

    void sendNotice(boolean b, String s, RequestContext requestContext);
}
