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

import com.bocloud.cmp.params.azure.NicIpConfigurationOperationParams;
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.network.NicIpConfiguration;
import com.bocloud.ims.interfaces.resource.azure.network.NicIpConfigurationService;
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.*;

/**
 * @ClassName: NicIpConfigurationController
 * @Description:
 * @author: zhenpingLi/李振平
 * @date: 2021/3/23 21:58
 */
@Api(value = "NicIpConfiguration", tags = "NicIpConfiguration管理")
@RestController
@RequestMapping("/v1/azure/nics/ips")
public class NicIpConfigurationController {

    @Autowired
    private NicIpConfigurationService service;

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

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


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

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

    /**
     * NicIpConfiguration相关操作
     *
     * @param id
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "NicIpConfiguration操作", httpMethod = "PATCH")
    @Log(module = BoCloudService.IMS, target = "NicIpConfiguration", operation = "NicIpConfiguration相关操作")
    @PatchMapping("/{id}")
    public BocloudResult operations(@PathVariable(value = Common.ID) Long id,
                                    @Value(Common.REQ_CONTEXT) RequestContext context,
                                    @RequestBody NicIpConfigurationOperationParams params) {
        return service.operations(params, context);
    }


}