
package cn.orionsec.ops.expose;

import cn.orionsec.ops.annotation.RestWrapper;
import cn.orionsec.ops.constant.monitor.MonitorStatus;
import cn.orionsec.ops.entity.domain.MachineMonitorDO;
import cn.orionsec.ops.service.api.MachineMonitorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags = "暴露服务-机器监控")
@RestController
@RestWrapper
@RequestMapping("/orion/expose-api/machine-monitor")
public class MachineMonitorExposeController {

    @Resource
    private MachineMonitorService machineMonitorService;

    @GetMapping("/started")
    @ApiOperation(value = "监控启动回调")
    public Integer getAlarmConfig(@RequestParam("machineId") Long machineId, @RequestParam("version") String version) {
        MachineMonitorDO update = new MachineMonitorDO();
        update.setMonitorStatus(MonitorStatus.RUNNING.getStatus());
        update.setAgentVersion(version);
        return machineMonitorService.updateMonitorConfigByMachineId(machineId, update);
    }

}
