package com.lanyuanxiaoyao.service.web.controller;

import com.lanyuanxiaoyao.service.configuration.entity.AmisResponse;
import com.lanyuanxiaoyao.service.forest.service.CompactionYarnService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;

/**
 * Sync Yarn
 *
 * @author lanyuanxiaoyao
 * @date 2023-04-21
 */
@RestController
@RequestMapping("compaction_yarn")
public class CompactionYarnController extends BaseController {
    private static final Logger logger = LoggerFactory.getLogger(CompactionYarnController.class);

    private final CompactionYarnService compactionYarnService;

    @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
    public CompactionYarnController(CompactionYarnService compactionYarnService) {
        this.compactionYarnService = compactionYarnService;
    }

    @GetMapping("job_list")
    public AmisResponse jobList(
            @RequestParam(value = "page", defaultValue = "1") Integer page,
            @RequestParam(value = "count", defaultValue = "10") Integer count,
            @RequestParam(value = "order", defaultValue = "startedTime") String order,
            @RequestParam(value = "direction", defaultValue = "desc") String direction,
            @RequestParam(value = "filter_state", defaultValue = "") String filterState,
            @RequestParam(value = "filter_final_status", defaultValue = "") String filterFinalStatus,
            @RequestParam(value = "search_id", defaultValue = "") String searchId,
            @RequestParam(value = "search_name", defaultValue = "") String searchName,
            @RequestParam(value = "precise", defaultValue = "false") Boolean precise
    ) {
        return jobList(compactionYarnService, page, count, order, direction, filterState, filterFinalStatus, searchId, searchName, precise);
    }

    @GetMapping("queue_list")
    public AmisResponse queueList(@RequestParam(value = "names", defaultValue = "") String names) {
        return queueList(compactionYarnService, names);
    }

    @GetMapping("queue_names")
    public AmisResponse queueNames() {
        return queueNames(compactionYarnService);
    }

    @GetMapping("cluster")
    public AmisResponse cluster() {
        return cluster(compactionYarnService);
    }
}
