package cn.reghao.devops.web.mgr.machine.controller;

import cn.reghao.devops.web.mgr.machine.model.dto.KeepalivedState;
import cn.reghao.devops.web.mgr.machine.service.KeepalivedService;
import cn.reghao.jutil.jdk.result.WebResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author reghao
 * @date 2024-01-04 15:34:39
 */
@Api(tags = "机器接口")
@RestController
@RequestMapping("/api/cluster")
public class ClusterController {
    private final KeepalivedService keepalivedService;

    public ClusterController(KeepalivedService keepalivedService) {
        this.keepalivedService = keepalivedService;
    }

    @ApiOperation(value = "设置机器环境")
    @PostMapping(value = "/notify/keepalived", produces = MediaType.APPLICATION_JSON_VALUE)
    public String notify(@Validated KeepalivedState keepalivedState) {
        keepalivedService.stateNotify(keepalivedState);
        return WebResult.success();
    }
}
