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

import com.bocloud.ims.entity.resource.hmc.params.HmcNimInstallParams;
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.*;

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.hmc.HmcNimService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * nim 安装小型机操作系统的controller
 *
 * @author lkx007
 */
@RestController
@RequestMapping("/v1/nim")
@Api(value = "AIX系统安装", tags = "AIX系统安装")
public class HmcNimController {
    @Autowired
    private HmcNimService nimService;

    /**
     * AIX系统安装
     *
     * @param params
     * @param context
     * @return
     */
    @Log(module = BoCloudService.IMS, target = "AIX系统安装", operation = "安装")
    @PostMapping
    @ApiOperation(tags={"CMC","CSC"},value = "安装操作系统",  httpMethod = "POST")
    public BocloudResult install(@RequestBody HmcNimInstallParams params,
                                 @Value(Common.REQ_CONTEXT) RequestContext context) {
        return nimService.install(params, context);
    }

    /**
     * AIX系统安装进度查询
     *
     * @param id
     * @param context
     * @return
     */
    @Log(module = BoCloudService.IMS, target = "AIX系统安装", operation = "查询安装进度查询")
    @GetMapping("/{id}")
    @ApiOperation(tags={"CMC","CSC"},value = "查询安装进度查询",  httpMethod = "GET")
    public BocloudResult process(@PathVariable(value = Common.ID) long id,
                                 @Value(Common.REQ_CONTEXT) RequestContext context) {
        return nimService.process(id, context);
    }

    /**
     * AIX系统取消安装
     *
     * @param id
     * @param context
     * @return
     */
    @Log(module = BoCloudService.IMS, target = "AIX系统安装", operation = "取消系统安装")
    @PatchMapping("/{id}")
    @ApiOperation(tags={"CMC","CSC"},value = "取消系统安装",  httpMethod = "PATCH")
    public BocloudResult cancel(@PathVariable(value = Common.ID) long id,
                                @Value(Common.REQ_CONTEXT) RequestContext context) {
        return nimService.cancel(id, context);
    }

}
