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

import com.bocloud.common.annotations.Log;
import com.bocloud.common.enums.BoCloudService;
import com.bocloud.common.model.BocloudResult;
import com.bocloud.common.model.GridBean;
import com.bocloud.common.model.Pager;
import com.bocloud.common.model.RequestContext;
import com.bocloud.common.utils.Common;
import com.bocloud.ims.entity.resource.Firewall;
import com.bocloud.ims.entity.resource.FirewallRule;
import com.bocloud.ims.entity.resource.SangforServerGroup;
import com.bocloud.ims.interfaces.resource.sangfor.SangforFireWallService;
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.*;

@RestController
@RequestMapping("/v1/sangfor/fireWall")
@Api(value = "深信服SCP防火墙管理", tags = "深信服SCP防火墙管理")
public class SangforFireWallController {
    @Autowired
    private SangforFireWallService fireWallService;

    @ApiOperation(tags = {"CMC",
            "CSC"}, value = "深信服SCP防火墙列表查询",  httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "深信服SCP防火墙列表查询", operation = "深信服SCP防火墙列表查询")
    @PostMapping
    public BocloudResult<GridBean<FirewallRule>> create(Pager pager, @Value(Common.REQ_CONTEXT) RequestContext context,
                                                        @RequestBody FirewallRule firewallRule) {
        return fireWallService.create(pager, context,firewallRule);
    }

    @ApiOperation(tags = {"CMC",
            "CSC"}, value = "深信服SCP防火墙列表查询",  httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "深信服SCP防火墙列表查询", operation = "深信服SCP防火墙列表查询")
    @DeleteMapping("/{id}")
    public BocloudResult<GridBean<FirewallRule>> remove(@Value(Common.REQ_CONTEXT) RequestContext context,
                                                    @PathVariable Long id) {
        return fireWallService.remove(context,id);
    }

    @ApiOperation(tags = {"CMC",
            "CSC"}, value = "深信服SCP防火墙列表查询",  httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "深信服SCP防火墙列表查询", operation = "深信服SCP防火墙列表查询")
    @PutMapping("/{id}")
    public BocloudResult<GridBean<FirewallRule>> update(Pager pager, @Value(Common.REQ_CONTEXT) RequestContext context,
                                                    @PathVariable Long id,@RequestBody FirewallRule firewallRule) {
        return fireWallService.update(pager, context,id,firewallRule);
    }
}
