package com.bocloud.ims.booter.controller.resource.h3c;

import com.bocloud.common.annotations.Log;
import com.bocloud.common.enums.BoCloudService;
import com.bocloud.common.model.BocloudResult;
import com.bocloud.common.model.RequestContext;
import com.bocloud.common.utils.Common;
import com.bocloud.ims.entity.resource.Vdc;
import com.bocloud.ims.interfaces.h3c.H3cHostPoolService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

@Api(value = "h3c主机池", tags = "h3c主机池")
@RestController
@RequestMapping("/v1/h3c/pools")
public class H3cHostPoolController {

	@Autowired
	private H3cHostPoolService h3CHostPoolService;

	/**
	 * 添加数据中心
	 *
	 * @param vdc
	 * @param context
	 * @return
	 */
	@ApiOperation(tags = { "CMC",
			"CSC" }, value = "创建主机池",  httpMethod = "POST")
	@Log(module = BoCloudService.IMS, target = "h3c数据中心", operation = "添加数据中心")
	@PostMapping
	public BocloudResult<String> create(@RequestBody Vdc vdc, @Value(Common.REQ_CONTEXT) RequestContext context) {
		vdc.setCreatorId(context.getTarget());
		vdc.setMenderId(context.getTarget());
		return h3CHostPoolService.create(vdc, context);
	}

	/**
	 * 删除
	 *
	 * @return 添加结果
	 */
	@ApiOperation(tags = { "CMC",
			"CSC" }, value = "删除主机池",  httpMethod = "DELETE")
	@Log(module = BoCloudService.IMS, target = "h3c数据中心", operation = "删除数据中心")
	@DeleteMapping("/{id}")
	public BocloudResult<String> remove(@PathVariable(Common.ID) Long id, @Value(Common.REQ_CONTEXT) RequestContext context) {
		return h3CHostPoolService.remove(id, context);
	}
}
