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.Snapshot;
import com.bocloud.ims.interfaces.h3c.H3cSnapshotService;
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/snapshots")
public class H3cSnapshotController {

	@Autowired
	H3cSnapshotService h3cSnapshotService;

	/**
	 * 创建云主机快照
	 * 
	 * @param snapshot
	 * @param context
	 * @return
	 */
	@ApiOperation(tags = { "CMC",
			"CSC" }, value = "创建H3C云云主机快照",  httpMethod = "POST")
	@Log(module = BoCloudService.IMS, target = "h3c快照", operation = "添加快照")
	@PostMapping
	public BocloudResult<String> create(@RequestBody Snapshot snapshot, @Value(Common.REQ_CONTEXT) RequestContext context) {
		return h3cSnapshotService.create(snapshot, context);
	}

	/**
	 * 删除
	 *
	 * @param id
	 * @return
	 */
	@ApiOperation(tags = { "CMC",
			"CSC" }, value = "删除快照",  httpMethod = "DELETE")
	@Log(module = BoCloudService.IMS, target = "快照", operation = "删除快照")
	@DeleteMapping("/{id}")
	public BocloudResult<String> remove(@PathVariable(value = Common.ID) Long id,
			@Value(Common.REQ_CONTEXT) RequestContext context) {
		return h3cSnapshotService.remove(id, context);
	}

	/**
	 * 添加
	 *
	 * @return 添加结果
	 */
	@ApiOperation(tags = { "CMC",
			"CSC" }, value = "恢复快照",  httpMethod = "PATCH")
	@Log(module = BoCloudService.IMS, target = "h3c快照", operation = "添加快照")
	@PatchMapping("/{id}")
	public BocloudResult<String> revert(@PathVariable(value = Common.ID) Long id,
			@Value(Common.REQ_CONTEXT) RequestContext context) {
		return h3cSnapshotService.revert(id, context);
	}

}
