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

import com.bocloud.cmp.model.HostOperateModel;
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.common.utils.ResultTools;
import com.bocloud.ims.interfaces.h3c.H3cHostService;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "h3c主机", tags = "h3c主机")
@RestController
@RequestMapping("/v1/h3c/hosts")
public class H3cHostController {

	@Autowired
	private H3cHostService h3cHostService;

	/**
	 * 添加
	 *
	 * @param params 属性信息的json字符串，在数据转换时会发生异常，对外抛出400异常【Bad Request】
	 * @return 添加结果
	 */
	@ApiOperation(tags = { "CMC",
			"CSC" }, value = "创建主机",  httpMethod = "POST")
	@Log(module = BoCloudService.IMS, target = "物理服务器", operation = "增加物理服务器")
	@PostMapping
	public BocloudResult<String> add(@RequestBody HostOperateModel model, @Value(Common.REQ_CONTEXT) RequestContext context) {
		if (null != model) {
			return h3cHostService.create(model, context);
		} else {
			return ResultTools.formatErrResult();
		}
	}

}
