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

import com.bocloud.cmp.params.azure.CloudMonitorParams;
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.interfaces.resource.azure.monitor.MonitorService;
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: MonitorServiceController
 * @Description:
 * @author: zhenpingLi/李振平
 * @date: 2020/12/30 10:36
 */
@Api(value = "azureMonitor", tags = "azureMonitor管理")
@RestController
@RequestMapping("/v1/azure/monitors")
public class MonitorServiceController {

    @Autowired
    private MonitorService service;

    /**
     * 查询命名空间
     *
     * @param params
     * @param context
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "查询命名空间", httpMethod = "POST")
    @Log(module = BoCloudService.IMS, target = "azure_monitor", operation = "查询命名空间")
    @PostMapping("/metric/namespaces")
    public BocloudResult metricNamespaces(@RequestBody CloudMonitorParams params,
                                          @Value(Common.REQ_CONTEXT) RequestContext context) {
        return service.metricNamespaces(params, context);
    }

    /**
     * 查询定义指标
     *
     * @param params
     * @param context
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "查询定义指标", httpMethod = "POST")
    @Log(module = BoCloudService.IMS, target = "azureMonitor", operation = "查询定义指标")
    @PostMapping("/metric/definitions")
    public BocloudResult metricDefinitions(@RequestBody CloudMonitorParams params,
                                           @Value(Common.REQ_CONTEXT) RequestContext context) {
        return service.metricDefinitions(params, context);
    }

    /**
     * 查询监控数据
     *
     * @param params
     * @param context
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "查询监控数据", httpMethod = "POST")
    @Log(module = BoCloudService.IMS, target = "azureMonitor", operation = "查询监控数据")
    @PostMapping("/metrics")
    public BocloudResult metrics(@RequestBody CloudMonitorParams params,
                                 @Value(Common.REQ_CONTEXT) RequestContext context) {
        return service.metrics(params, context);
    }

}