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

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.redis.CloudRedisFirewallRule;
import com.bocloud.ims.interfaces.resource.azure.redis.CloudRedisFirewallRuleService;
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: CloudRedisFirewallRuleController
 * @Description:
 * @author: zhenpingLi/李振平
 * @date: 2021/3/1 15:12
 */
@Api(value = "CloudRedisFirewallRule", tags = "CloudRedisFirewallRule管理")
@RestController
@RequestMapping("/v1/cloud/redis/firewall/rules")
public class CloudRedisFirewallRuleController {
    @Autowired
    private CloudRedisFirewallRuleService service;

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

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


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