package com.bocloud.ims.interfaces.resource;

import com.alibaba.fastjson.JSONObject;
import com.bocloud.cmp.model.VolBean;
import com.bocloud.cmp.model.common.AlterationParam;
import com.bocloud.cmp.model.common.ApplicationParam;
import com.bocloud.cmp.model.common.CancelationParam;
import com.bocloud.cmp.model.common.ExtensionParam;
import com.bocloud.common.model.*;
import com.bocloud.ims.entity.resource.CloudServer;
import com.bocloud.ims.entity.resource.Snapshot;
import com.bocloud.ims.entity.resource.Volume;

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

/**
 * 块设备抽象Service接口
 *
 * @author dongkai
 */
public interface VolumeService {

	/**
	 * 列表展示
	 *
	 * @param page
	 * @param rows
	 * @param params
	 * @param sorter
	 * @param simple
	 * @param context
	 * @param condition
	 * @return
	 */
	public BocloudResult<GridBean<Volume>> list(Pager pager, RequestContext context);

	/**
	 * 详情
	 *
	 * @param id
	 * @return
	 */
	public BocloudResult<Volume> detail(Long id);

	/**
	 * 挂载机器
	 *
	 * @param id
	 * @return
	 */
	public BocloudResult<List<CloudServer>> servers(Long id);

	/**
	 * 查询未添加进映射的卷
	 *
	 * @param page
	 * @param rows
	 * @param paramMap
	 * @param sorter
	 * @return
	 */
	BocloudResult listVolumeNotInView(Integer page, Integer rows, Long accessPathId, Long viewUuid,
			List<Param> paramMap, Map<String, String> sorter);

	/**
	 * 查询已添加进映射的卷
	 *
	 * @param page
	 * @param rows
	 * @param paramMap
	 * @param sorter
	 * @return
	 */
	BocloudResult listVolumeInView(Integer page, Integer rows, Long accessPathId, Long viewUuid, List<Param> paramList,
			Map<String, String> sorter);

	/**
	 * 创建
	 *
	 * @param params
	 * @param context
	 * @return
	 */
	BocloudResult<String> create(Volume volume, RequestContext context);

	/**
	 * 删除
	 *
	 * @param id
	 * @param params
	 * @param context
	 * @return
	 */
	BocloudResult<String> remove(Long id, String params, RequestContext context);

	/**
	 * 修改
	 *
	 * @param bean
	 * @param userId
	 * @return
	 */
	BocloudResult<String> modify(VolBean bean, RequestContext context);

	/**
	 * 卷迁移
	 *
	 * @param bean
	 * @param userId
	 * @return
	 */
	BocloudResult migrateVolume(Volume bean, RequestContext context);

	/**
	 * 查询与客户端组映射的卷
	 *
	 * @param page
	 * @param rows
	 * @param paramMap
	 * @param sorter
	 * @return
	 */
	public BocloudResult<GridBean> listByHost(Integer page, Integer rows, Long accessPathId, Map<String, Object> paramMap,
			Map<String, String> sorter);

	public BocloudResult<GridBean> listInSyncedSet(Integer page, Integer rows, Map<String, Object> paramMap,
			Map<String, String> sorter);

	public BocloudResult<GridBean> listNotInSyncedSet(Integer page, Integer rows, Map<String, Object> paramMap,
			Map<String, String> sorter);

	public BocloudResult attach(VolBean volBean, RequestContext context);

	public BocloudResult snapshot(VolBean volBean, RequestContext context);

	public BocloudResult detach(VolBean volBean, RequestContext context);

	public BocloudResult<List<Volume>> listByStatus(String params, RequestContext context);

	public BocloudResult<List<Volume>> listByVendor(Long vendorId);

	public BocloudResult<List<Volume>> listByImage(Long imageId);

	public BocloudResult<String> batchRemove(List<Long> ids, RequestContext context);

	public BocloudResult extend(VolBean volBean, RequestContext context);

	public BocloudResult<String> uploadToImage(String params, RequestContext context);

	public BocloudResult<Integer> count(Long userId, Long projectId, Long tenantId);

	public BocloudResult attach(Long id, Long serverId, RequestContext context, String mountpoint);

	public BocloudResult<String> onboard(String params, RequestContext context);

	public BocloudResult<String> unmanage(RequestContext context, Long vendorId, Long storageId, List<Long> volumeIds);

	public BocloudResult<List<Volume>> listByStorage(Long storageId);

	public BocloudResult<List<Volume>> listByTemplate(Long templateId);

	public BocloudResult operations(VolBean volBean, RequestContext context );

	public BocloudResult addGroups(Long id, String params, RequestContext context);

	public BocloudResult removeGroups(Long id, String params, RequestContext context);

	/**
	 * 申请云硬盘
	 *
	 * @param param
	 * @return
	 */
	public BocloudResult apply(ApplicationParam param);

	/**
	 * 云硬盘变更
	 *
	 * @param param
	 * @return
	 */
	BocloudResult alteration(AlterationParam param);

	/**
	 * 云硬盘延期
	 *
	 * @param param
	 * @return
	 */
	BocloudResult extension(ExtensionParam param);

	/**
	 * 云硬盘退订
	 *
	 * @param param
	 * @return
	 */
	BocloudResult cancelation(CancelationParam param);

	/**
	 * 查询Powervc云主机创建时可添加的卷
	 *
	 * @param vendorId
	 *
	 */
	public BocloudResult<GridBean> listForPowervcVMCreate(int page, int rows, String keyword, long vendorId);

	/**
	 * 查询Powervc已创建的云主机可附加的卷
	 *
	 * @param vendorId
	 * @param vmId
	 */
	public BocloudResult<GridBean> listForPowervcVMAttach(int page, int rows, String keyword, long vendorId, long vmId);

	/**
	 * 查询Powervc创建映像时可添加的卷
	 *
	 * @param vendorId
	 */
	public BocloudResult<GridBean> listForPowervcImageCreate(int page, int rows, String keyword, long vendorId);

	public BocloudResult<List<Volume>> listByCondition(JSONObject object, RequestContext context);

	public BocloudResult<List<Volume>> listByVmId(JSONObject object);

	public BocloudResult<List<Volume>> listDataDisks(JSONObject object);

	public BocloudResult createOsVolume(JSONObject param, RequestContext context);

	public BocloudResult<Object> listBackupResources(String params, RequestContext context);

	public BocloudResult<GridBean<Snapshot>> listSnapshotById(Long id, Pager pager);
}
