package com.bocloud.ims.booter.controller.resource.azure.monitor;

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.azure.monitor.MetricAlert;
import com.bocloud.ims.interfaces.resource.azure.monitor.MetricAlertService;
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.*;

/**
 * @Company: 博云 www.bocloud.com
 * @ClassName: MetricAlertController
 * @Description:
 * @author: zhenpingLi/李振平
 * @date: 2021/1/13 15:09
 */
@Api(value = "metricAlert", tags = "metricAlert管理")
@RestController
@RequestMapping("/v1/azure/metric/alerts")
public class MetricAlertController {

    @Autowired
    private MetricAlertService service;

    /**
     * 查询列表
     *
     * @param pager
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "列表metricAlert", httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "metricAlert", operation = "列表metricAlert")
    @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 = "详情metricAlert", httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "metricAlert", operation = "详情metricAlert")
    @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 = "创建metricAlert", httpMethod = "POST")
    @Log(module = BoCloudService.IMS, target = "metricAlert", operation = "创建metricAlert")
    @PostMapping
    public BocloudResult create(@RequestBody MetricAlert entityParams,
                                @Value(Common.REQ_CONTEXT) RequestContext context) {
        return service.create(entityParams, context);
    }

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

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

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

    /**
     * 多样查询
     *
     * @param condition
     * @param context
     * @return
     */
    @ApiOperation(value = "多样查询", response = BocloudResult.class, httpMethod = "GET", produces = MediaType.APPLICATION_JSON_VALUE)
    @Log(module = BoCloudService.IMS, target = "metricAlert", operation = "metricAlert多样查询")
    @GetMapping("/multiples")
    public BocloudResult multipleQueries(@RequestParam(Common.CONDITION) String condition,
                                         @Value(Common.REQ_CONTEXT) RequestContext context) {
        return service.multipleQueries(condition, context);
    }


}