package com.lanyuanxiaoyao.service.yarn.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.lanyuanxiaoyao.service.configuration.entity.yarn.YarnQueue;
import com.lanyuanxiaoyao.service.yarn.service.QueueService;
import org.eclipse.collections.api.list.ImmutableList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
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;

/**
 * Queue
 *
 * @author lanyuanxiaoyao
 * @date 2023-04-23
 */
@RestController
@RequestMapping("queue")
public class QueueController {
    private static final Logger logger = LoggerFactory.getLogger(QueueController.class);

    private final QueueService queueService;

    public QueueController(@Qualifier("QueueService") QueueService queueService) {
        this.queueService = queueService;
    }

    @GetMapping("list")
    public ImmutableList<YarnQueue> list(@RequestParam("cluster") String cluster) throws JsonProcessingException {
        return queueService.list(cluster);
    }

    @GetMapping("detail")
    public YarnQueue detail(@RequestParam("cluster") String cluster, @RequestParam("name") String name) throws Exception {
        return queueService.detail(cluster, name);
    }
}
