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

import com.bocloud.cmp.params.fusionsphere.StorageDeviceParams;
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.interfaces.resource.fusionsphere.FusionSphereStorageDeviceService;
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.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Company: 博云 www.bocloud.com
 * @ClassName: FusionSphereStorageDeviceController
 * @Description:存储设备
 * @author: zhenpingLi/李振平
 * @date: 2021/10/20 17:53
 */
@Api(value = "FusionSphereStorageDevice", tags = "FusionSphereStorageDevice管理")
@RestController
@RequestMapping("/v1/fc/devices")
public class FusionSphereStorageDeviceController {

    @Autowired
    private FusionSphereStorageDeviceService service;

    /**
     * 查询列表
     *
     * @param pager
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "列表FusionSphereStorageDevice", httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "FusionSphereStorageDevice", operation = "列表FusionSphereStorageDevice")
    @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 = "详情FusionSphereStorageDevice", httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "FusionSphereStorageDevice", operation = "详情FusionSphereStorageDevice")
    @GetMapping("/{id}")
    public BocloudResult detail(@PathVariable(value = Common.ID) Long id,
                                @Value(Common.REQ_CONTEXT) RequestContext context) {
        return service.detail(id, context);
    }

    /**
     * 查询主机或站点下可用存储设备
     *
     * @param params
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "查询主机或站点下可用存储设备", httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "FusionSphereStorageDevice", operation = "查询主机或站点下可用存储设备")
    @GetMapping("/listStorage")
    public BocloudResult listStorage(StorageDeviceParams params,
                                     @Value(Common.REQ_CONTEXT) RequestContext context) {
        return service.listStorage(params, context);
    }
}