package com.bocloud.ims.interfaces.resource;

import com.bocloud.cmp.model.CloudServerBean;
import com.bocloud.cmp.vm.model.*;
import com.bocloud.common.model.*;
import com.bocloud.ims.entity.resource.CloudServer;

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);

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

    /**
     * 克隆虚拟机
     *
     * @param params
     * @param context
     * @return
     */
    BocloudResult clone(VmGenericParam vmGenericParam, RequestContext context);

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

    /**
     * openstack迁移
     *
     * @param params
     * @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);

    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 id
     * @param context
     * @return the result
     */
    BocloudResult stop(Long id, RequestContext context);

    /**
     * 虚拟机批量停止
     *
     * @param ids
     * @param context
     * @return
     */
    BocloudResult batchStop(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
     * @param action
     * @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 params
     * @param action
     * @param context
     * @return
     */
    BocloudResult batchOperations(VmBatchOperationParam batchOperationParam, RequestContext context);

}
