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

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.automation.LogAnalytic;
import com.bocloud.ims.interfaces.resource.azure.automation.LogAnalyticService;
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: LogAnalyticController
 * @Description:
 * @author: zhenpingLi/李振平
 * @date: 2020/8/10 11:23
 */
@Api(value = "logAnalytic", tags = "logAnalytic管理")
@RestController
@RequestMapping("/v1/log/analytics")
public class LogAnalyticController {
    @Autowired
    private LogAnalyticService service;

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


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

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


    //----------------星巴克poc专用 ，数据不入库-------------------------------------------------------------

    /**
     * 查询列表
     *
     * @param params
     * @return
     */
    @ApiOperation(value = "查询列表", response = BocloudResult.class, httpMethod = "GET", produces = MediaType.APPLICATION_JSON_VALUE)
    @Log(module = BoCloudService.IMS, target = "logAnalytic", operation = "logAnalytic列表")
    @GetMapping("/list")
    public BocloudResult list(@RequestParam(value = Common.PARAMS) String params) {
        return service.list(params);
    }

    /**
     * 查询共享密钥
     *
     * @param params
     * @return
     */
    @ApiOperation(value = "查询共享密钥", response = BocloudResult.class, httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @Log(module = BoCloudService.IMS, target = "logAnalytic", operation = "logAnalytic共享密钥")
    @PostMapping("/shared/keys")
    public BocloudResult sharedKeys(@RequestParam(value = Common.PARAMS) String params) {
        return service.sharedKeys(params);
    }

    /**
     * 关联自动化账户
     *
     * @param params
     * @return
     */
    @ApiOperation(value = "关联自动化账户", response = BocloudResult.class, httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @Log(module = BoCloudService.IMS, target = "logAnalytic", operation = "关联自动化账户")
    @PostMapping("/linked/services")
    public BocloudResult linkedServices(@RequestParam(value = Common.PARAMS) String params) {
        return service.linkedServices(params);
    }

    /**
     * 查询详情
     *
     * @param entityParams
     * @return
     */
    @ApiOperation(value = "查询详情", response = BocloudResult.class, httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @Log(module = BoCloudService.IMS, target = "logAnalytic", operation = "logAnalytic详情")
    @PostMapping("/detail")
    public BocloudResult detail(@RequestBody LogAnalytic entityParams) {
        return service.detail(entityParams);
    }

    /**
     * 删除logAnalytic
     *
     * @param params
     * @return
     */
    @ApiOperation(value = "查询详情", response = BocloudResult.class, httpMethod = "DELETE", produces = MediaType.APPLICATION_JSON_VALUE)
    @Log(module = BoCloudService.IMS, target = "logAnalytic", operation = "删除logAnalytic")
    @DeleteMapping("/remove")
    public BocloudResult remove(@RequestParam(value = Common.PARAMS) String params) {
        return service.remove(params);
    }

    /**
     * 查询待更新的计算级等信息
     *
     * @param params
     * @return
     */
    @ApiOperation(value = "查询信息", response = BocloudResult.class, httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @Log(module = BoCloudService.IMS, target = "logAnalytic", operation = "查询信息")
    @PostMapping("/query")
    public BocloudResult queryLogAnalytic(@RequestParam(value = Common.PARAMS) String params) {
        return service.queryLogAnalytic(params);
    }
}