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

import com.bocloud.common.annotations.Log;
import com.bocloud.common.enums.BoCloudService;
import com.bocloud.common.model.BocloudResult;
import com.bocloud.common.model.Pager;
import com.bocloud.common.model.RequestContext;
import com.bocloud.common.utils.Common;
import com.bocloud.ims.entity.resource.Cluster;
import com.bocloud.ims.interfaces.resource.fusionsphere.FusionSphereClusterService;
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.web.bind.annotation.*;

/**
 * @Company: 博云 www.bocloud.com
 * @ClassName: FusionSphereClusterController
 * @Description:集群管理
 * @author: zhenpingLi/李振平
 * @date: 2021/10/20 10:18
 */
@Api(value = "FusionSphereCluster", tags = "FusionSphereCluster管理")
@RestController
@RequestMapping("/v1/fc/clusters")
public class FusionSphereClusterController {

    @Autowired
    private FusionSphereClusterService service;


    /**
     * 查询列表
     *
     * @param pager
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "列表FusionSphereCluster", httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "FusionSphereCluster", operation = "列表FusionSphereCluster")
    @GetMapping
    public BocloudResult list(Pager pager,
                              @Value(Common.REQ_CONTEXT) RequestContext context) {
        return service.list(pager, context);
    }


    /**
     * 查询详情
     *
     * @param id
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "详情FusionSphereCluster", httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "FusionSphereCluster", operation = "详情FusionSphereCluster")
    @GetMapping("/{id}")
    public BocloudResult detail(@PathVariable(value = Common.ID) Long id,
                                @Value(Common.REQ_CONTEXT) RequestContext context) {
        return service.detail(id, context);
    }

    /**
     * 创建
     *
     * @param entityParams
     * @param context
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "创建FusionSphereCluster", httpMethod = "POST")
    @Log(module = BoCloudService.IMS, target = "FusionSphereCluster", operation = "创建FusionSphereCluster")
    @PostMapping
    public BocloudResult create(@RequestBody Cluster entityParams,
                                @Value(Common.REQ_CONTEXT) RequestContext context) {
        return service.create(entityParams, context);
    }

    /**
     * 更新
     *
     * @param entityParams
     * @param context
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "更新FusionSphereCluster", httpMethod = "PUT")
    @Log(module = BoCloudService.IMS, target = "FusionSphereCluster", operation = "更新FusionSphereCluster")
    @PutMapping(value = "/{id}")
    public BocloudResult modify(@PathVariable(value = Common.ID) Long id,
                                @RequestBody Cluster entityParams,
                                @Value(Common.REQ_CONTEXT) RequestContext context) {
        return service.modify(entityParams, context);
    }

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

}