package com.bocloud.ims.interfaces.resource;

import com.alibaba.fastjson.JSONObject;
import com.bocloud.cmp.vm.model.IpScanParam;
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.IpPatchParams;
import com.bocloud.ims.entity.resource.Ip;

import java.util.List;

public interface IpService {

	/**
	 * 列表展示
	 *
	 * @param pager
	 * @return
	 */
	BocloudResult<GridBean<Ip>> list(Pager pager);

	/**
	 * 根据condition列表展示
	 *
	 * @param condition
	 * @param context
	 * @return
	 */
	BocloudResult condition(String condition, RequestContext context);

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

	/**
	 * 根据平台ID以及请求IP数量获取IP
	 *
	 * @param vendorId
	 * @param count
	 * @param version
	 * @return
	 */
	BocloudResult<List<Ip>> achieveIps(Long count, String version);

	/**
	 * 从指定IP池分配IP
	 *
	 * @param poolId
	 * @param count
	 * @param version
	 * @return
	 */
	BocloudResult<List<Ip>> achievePoolIps(Long poolId, Long count, String version);

	/**
	 * 根据IP池ID以及请求IP数量获取IP(随机分配，不按照顺序分配)
	 *
	 * @param poolId
	 * @param count
	 * @param version
	 * @return
	 */
	BocloudResult<List<Ip>> achieveDhcpIps(Long poolId, Long count, String version);

	/**
	 * 处理平台垃圾下的IP垃圾数据
	 *
	 * @param vendorId
	 * @return
	 */
	BocloudResult processRubbishIp(Long vendorId);

	/**
	 * 从网络资源池下的IP池中分配IP地址
	 *
	 * @param vendorId
	 * @param poolGroupId
	 * @param count
	 * @return
	 */
	BocloudResult<List<Ip>> achieveIps(Long vendorId, Long poolGroupId, Integer count);

	/**
	 * 从nsx路由器端口下子网IP池中分配
	 *
	 * @param routerPortId
	 * @param count
	 * @param version
	 * @return
	 */
	BocloudResult<List<Ip>> achieveNsxIps(Long routerPortId, Integer count, String version);

	/**
	 * 从nsx分段下子网ip池中分配
	 *
	 * @param segmentId
	 * @param count
	 * @param version
	 * @return
	 */
	BocloudResult<List<Ip>> achieveNsxSegmentIps(Long segmentId, Integer count, String version);

	BocloudResult alarmIps(Long vendorId);

	/**
	 * 根据子网id删除
	 *
	 * @param ip
	 * @param subnetId
	 * @return
	 */
	BocloudResult deleteBySubnetId(String ip, Long subnetId);

	/**
	 * 批量保存
	 *
	 * @param object
	 * @param context
	 * @return
	 */
	BocloudResult batchSave(JSONObject object, RequestContext context);

	/**
	 * 删除IP
	 *
	 * @param id
	 * @return
	 */
	BocloudResult remove(Long id);

	/**
	 * ip扫描
	 *
	 * @param param
	 * @param context
	 * @return
	 */
	BocloudResult scan(IpScanParam param, RequestContext context);

	/**
	 * 预分配IP地址
	 *
	 * @param poolId
	 * @param count
	 * @param context
	 * @return
	 */
	BocloudResult preAllocation(Long poolId, Integer count, RequestContext context);

	/**
	 * 检查IP是否被占用
	 *
	 * @param poolId
	 * @param ips
	 * @param context
	 * @return
	 */
	BocloudResult checkIp(Long poolId, List<String> ips, RequestContext context);

	/**
	 * ip操作
	 *
	 * @param id
	 * @param status
	 * @param remark
	 * @param context
	 * @return
	 */
	BocloudResult action(Long id, IpPatchParams.Action status, String remark, RequestContext context);

	/**
	 * IP批量操作
	 *
	 * @param ids
	 * @param action
	 * @param remark
	 * @param context
	 * @return
	 */
	BocloudResult batchUpdate(List<Long> ids, IpPatchParams.Action action, String remark, RequestContext context);

	/**
	 * 根据IP池查询可用ip
	 * 
	 * @param poolId
	 * @param count
	 * @param version
	 * @return
	 */
	BocloudResult<List<Ip>> assginIps(Long poolId, Long count, String version);
}
