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.GridBean;
import com.bocloud.common.model.Pager;
import com.bocloud.common.model.RequestContext;
import com.bocloud.common.utils.Common;
import com.bocloud.ims.entity.resource.DataStore;
import com.bocloud.ims.entity.resource.DataStoreFile;
import com.bocloud.ims.interfaces.h3c.H3cDataStoreService;
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/datastores")
public class H3cDataStoreController {

	@Autowired
	private H3cDataStoreService h3CDataStoreService;

	/**
	 * 查看存储池列表
	 * 
	 * @param pager
	 * @param context
	 * @return
	 */
	@ApiOperation(tags = { "CMC",
			"CSC" }, value = "查询数据中心文件列表",  httpMethod = "GET")
	@Log(module = BoCloudService.IMS, target = "存储池", operation = "查看存储池列表")
	@GetMapping
	public BocloudResult<GridBean<DataStore>> list(Pager pager, @Value(Common.REQ_CONTEXT) RequestContext context) {
		return h3CDataStoreService.listStores(pager, context);
	}

	/**
	 * 查看存储池中的文件
	 *
	 * @param pager
	 * @return
	 */
	@ApiOperation(tags = { "CMC",
			"CSC" }, value = "查询数据中心文件列表",  httpMethod = "GET")
	@Log(module = BoCloudService.IMS, target = "存储池", operation = "查看存储池中的文件")
	@GetMapping("/files")
	public BocloudResult<GridBean<DataStoreFile>> listStoreFiles(Pager pager, @Value(Common.REQ_CONTEXT) RequestContext context) {
		return h3CDataStoreService.listStoreFiles(pager, context);
	}

	@ApiOperation(tags = { "CMC",
			"CSC" }, value = "查询数据中心文件列表",  httpMethod = "GET")
	@Log(module = BoCloudService.IMS, target = "存储池", operation = "查看存储池中的文件")
	@DeleteMapping("/files/{id}")
	public BocloudResult<String> removeStoreFile(@PathVariable(value = Common.ID) Long id,
			@Value(Common.REQ_CONTEXT) RequestContext context) {
		return h3CDataStoreService.removeStoreFile(id, context);
	}

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

}
