package com.bocloud.ims.interfaces.resource;

import com.alibaba.fastjson.JSONObject;
import com.bocloud.cmp.model.KeypairParam;
import com.bocloud.cmp.model.SecurityGroupOperationParam;
import com.bocloud.cmp.vm.model.*;
import com.bocloud.common.model.BocloudResult;
import com.bocloud.common.model.GridBean;
import com.bocloud.common.model.Pager;
import com.bocloud.common.model.RequestContext;
import com.bocloud.ims.entity.params.ServerPerformanceParam;
import com.bocloud.ims.entity.resource.*;

import java.util.List;

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

    /**
     * 修改账号密码
     *
     * @param account
     * @param password
     * @param context
     * @return
     */
    BocloudResult modifyAccount(Long id, String account, String password, RequestContext context);

    /**
     * 实时查看云主机详细信息
     *
     * @param id
     * @return the result
     */
    BocloudResult detailInRealTime(Long id);

    BocloudResult vncconsole(String params, RequestContext context);

    /**
     * 根据hostId查询网络
     *
     * @param hostId
     * @return
     */
    BocloudResult<List<PortGroup>> networks(Long hostId);

    /**
     * 更新云主机的资源分组
     *
     * @param cloudIds
     * @param resourceGroup
     * @param userId
     * @return
     */
    BocloudResult updateResourceGroup(String[] cloudIds, String resourceGroup, Long userId);

    /**
     * 修改OpenStack云主机密码
     *
     * @param vendorId
     * @param id
     * @param password
     * @param context
     * @return
     */
    BocloudResult osChangePwd(Long vendorId, Long id, String password, RequestContext context);

    BocloudResult attachNetwork(AttachNetworkParam params, RequestContext context);

    BocloudResult detachNetwork(Long id, Long portId, RequestContext context);

    BocloudResult detachAllPorts(Long id, RequestContext context);

    BocloudResult resize(String params, RequestContext context);

    BocloudResult confirmResize(String params, RequestContext context);

    BocloudResult revertResize(String params, RequestContext context);

    BocloudResult listFlavor(Long serverId, Long vendorId);

    BocloudResult listPort(Long serverId, Long vendorId);

    BocloudResult queryFlavorByServerId(Long serverId);

    /**
     * 查询账号密码
     *
     * @param serverId
     * @return
     */
    BocloudResult<CloudServer> queryAccount(Long serverId);

    BocloudResult batchJoinSGroup(Long id, SecurityGroupOperationParam securityGroupOperationParam,
        RequestContext context);

    BocloudResult joinSGroup(Long id, Long groupId, RequestContext context);

    BocloudResult leaveSGroup(Long id, Long groupId, RequestContext context);

    BocloudResult listSGroup(Long id);

    BocloudResult listUnboundSGroup(Long id, RequestContext context, String vpcUuid);

    /**
     * CPU或内存热插拔设置(VCenter)
     *
     * @param serverId
     * @param userId
     * @param cpuHotEnable
     * @param memHotEnable
     * @return
     */
    BocloudResult hotConfigEnable(Long serverId, Long userId, Boolean cpuHotEnable, Boolean memHotEnable);

    /**
     * 获得vcenter访问remote console的ticket
     *
     * @param serverId
     * @return
     */
    BocloudResult getTicket(Long serverId);

    /**
     * 卸载vmware tools安装镜像
     *
     * @param id
     * @return
     */
    BocloudResult unmountToolsInstaller(Long id, RequestContext context);

    /**
     * 升级vmware tools
     *
     * @param id
     * @param options
     * @param context
     * @return
     */
    BocloudResult upgradeToolsTask(Long id, String options, RequestContext context);

    /**
     * 获取云主机图表信息
     *
     * @param params
     * @return
     */
    BocloudResult chart(String params);

    /**
     * 标记为模板(vmware)
     *
     * @param id
     * @param context
     * @return
     */
    BocloudResult markAsTemplate(Long id, RequestContext context);

    /**
     * vcenter修改密码
     *
     * @param params
     * @param context
     * @return
     */
    BocloudResult vcChangePasswd(VmModifyParam vmModifyParam, RequestContext context);

    /**
     * 修改云主机标签
     *
     * @param params
     * @param context
     * @return
     */
    BocloudResult batchModifyLabel(BatchModifyLabelParam params, RequestContext context);

    /**
     * 查询性能数据
     *
     * @param params
     * @return
     */
    BocloudResult performance(ServerPerformanceParam params);

    /**
     * vcenter云主机磁盘扩容
     *
     * @param params
     * @param context
     * @return
     */
    BocloudResult diskExtend(String params, RequestContext context);

    /**
     * 获取vcenter客户端控制台URL
     *
     * @param id
     * @return
     */
    BocloudResult vmrcConsole(Long id);

    /**
     * 安装vmware tools
     *
     * @param params
     * @param context
     * @return
     */
    BocloudResult vmToolsInstall(String params, RequestContext context);

    BocloudResult resetInstance(String params, RequestContext context);

    BocloudResult setMaxBandwidth(VmGenericParam vmGenericParam, RequestContext context);

    BocloudResult listunBindKeyPair(Long id, RequestContext context);

    BocloudResult listBindedKeyPair(Long id);

    BocloudResult bindKeypair(KeypairParam keypairParam, RequestContext context);

    BocloudResult unbindKeypair(KeypairParam keypairParam, RequestContext context);

    BocloudResult listByPoolGroupId(Integer page, Integer rows, String params, RequestContext context);

    BocloudResult createDisk(String params, RequestContext context, String queue);

    BocloudResult<List<Volume>> listVolume(String params);

    BocloudResult attachVolume(Long serverId, Volume volume, RequestContext context);

    BocloudResult detachVolume(Long serverId, long volumeId, RequestContext context);

    BocloudResult beforeCaptureImage(String params, RequestContext context);

    BocloudResult captureImage(String params, RequestContext context);

    BocloudResult listServerByKeypair(JSONObject object, RequestContext context);

    /**
     * 根据imageUuid查询云主机
     *
     * @param imageUuid
     * @return
     */
    BocloudResult listByImageUuid(String imageUuid);

    /**
     * 按照宿主机查询云主机
     *
     * @param hostId
     * @return
     */
    BocloudResult listByHostId(long hostId);

    /**
     * 按照网络查询云主机
     *
     * @param networkId
     * @return
     */
    BocloudResult listByNetworkId(long networkId);

    /**
     * 挂载vmware tools安装镜像
     *
     * @param id
     * @return
     */
    BocloudResult mountToolsInstaller(Long id, RequestContext context);

    /**
     * vmware tools配置
     *
     * @param object
     * @param userId
     * @return
     */
    BocloudResult vmToolsConfig(JSONObject object, Long userId);

    /**
     * 根据uuid查询云主机id
     *
     * @param uuid
     * @return
     */
    BocloudResult queryByUuid(String uuid);

    BocloudResult resetStatus(Long serverId, RequestContext context);

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

    BocloudResult detachNetworks(Long id, Long portId, RequestContext context, String action);

    BocloudResult addPortPolicy(String params, RequestContext context);

    BocloudResult resizes(VmModifyParam vmModifyParam, RequestContext context);

    BocloudResult flavors(String params, RequestContext context, String action);

    BocloudResult vmtools(Long id, VmModifyParam vmModifyParam, RequestContext context);

    BocloudResult joinGroups(SecurityGroupOperationParam securityGroupOperationParam, RequestContext context);

    BocloudResult allocationSGroups(Long id, String params, RequestContext context);

    BocloudResult<List<SecurityGroup>> sgroups(Long id, RequestContext context, String action, String vpcUuid);

    BocloudResult vncconsoles(Long id, String vncType, String serverId, String region, RequestContext context,
        String action);

    /**
     * 安装vmtools
     *
     * @param params
     * @param context
     * @param action
     * @return
     */
    BocloudResult vmToolsInstalls(String params, RequestContext context, String action);

    BocloudResult<List<Keypair>> keypairs(Long id, RequestContext context, String action);

    BocloudResult bindKeypairs(KeypairParam keypairParam, RequestContext context);

    BocloudResult volumes(String params, String action, RequestContext context);

    /**
     * 查询可供云主机挂载的卷
     * @param serverId 云主机id
     * @param pager 查询参数
     * @return
     */
    BocloudResult<GridBean<Volume>> listVolumeForAttach(Long serverId, Pager pager);

    /**
     * 查询已经挂载给云主机的卷
     * @param serverId 云主机id
     * @param pager 查询参数
     * @return
     */
    BocloudResult<GridBean<Volume>> listVolumeOfAttached(Long serverId, Pager pager);

    /**
     * 查询可供云主机挂载的ISO映像
     * @param serverId 云主机id
     * @param pager 查询参数
     * @return
     */
    BocloudResult<GridBean<Image>> listImageForAttach(Long serverId, Pager pager);

    /**
     * 查询已经挂载给云主机的ISO映像
     * @param serverId 云主机id
     * @param pager 查询参数
     * @return
     */
    BocloudResult<GridBean<Image>> listImageOfAttached(Long serverId, Pager pager);

    BocloudResult<GridBean<Image>> listImageOfCloneable(Long serverId, Pager pager);

    BocloudResult<List<Port>> ports(String params, RequestContext context, String action);

    /**
     * 云主机规格变更
     *
     * @param params
     * @param context
     * @return
     */
    BocloudResult cpuAndMemoryExpansion(JSONObject params, RequestContext context);

    /**
     * 云主机增加磁盘
     *
     * @param params
     * @param context
     * @return
     */
    BocloudResult diskExpansion(JSONObject params, RequestContext context);

    /**
     * 根据instanceId删除
     *
     * @param params
     * @param context
     * @return
     */
    BocloudResult removeByInstanceIds(String params, RequestContext context);

    /**
     * 统计
     *
     * @param range
     * @param context
     * @return
     */
    BocloudResult stats(String range, Long hostId, RequestContext context);

    /**
     * 根据instanceId查询
     *
     * @param instanceId
     * @return
     */
    CloudServer getByInstanceId(String instanceId);

    BocloudResult batchAttachNetwork(List<AttachNetworkParam> params, RequestContext context);

    /**
     * vcenter磁盘操作
     *
     * @param params
     * @param context
     * @return
     */
    BocloudResult diskOperation(DiskOperationParam params, RequestContext context);

    /**
     * 根据vdc 集群 宿主机查询网络端口组
     *
     * @param resourceIds
     * @param type
     * @return
     */
    BocloudResult networkResources(String resourceIds, String type);

    /**
     * @param context
     * @return com.bocloud.common.model.BocloudResult
     * @Author: lxy
     * @Description: 云平台下云主机信息（个数、cpu、men、disk）统计
     * @Date 2021/5/26 16:45
     * @Param venderId
     * @throws:
     **/
    BocloudResult selectAllByVendorId(Long vendorId, RequestContext context);

    BocloudResult getVnc(Long id);

    BocloudResult<List<SangforVlanGroup>> sangforNetwork(String azUuid);
}
