package com.cloudhandson.vpdbackoffice.web; import com.cloudhandson.vpdbackoffice.domain.probe.ProbeCommand; import com.cloudhandson.vpdbackoffice.service.BearerTokenService; import com.cloudhandson.vpdbackoffice.service.OrdsProbeService; import com.cloudhandson.vpdbackoffice.service.ProtectedObjectService; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; @Controller public class ProbeController { private final OrdsProbeService probeService; private final ProtectedObjectService protectedObjectService; private final BearerTokenService tokenService; public ProbeController( OrdsProbeService probeService, ProtectedObjectService protectedObjectService, BearerTokenService tokenService ) { this.probeService = probeService; this.protectedObjectService = protectedObjectService; this.tokenService = tokenService; } @GetMapping("/probe") public String probe(Model model) { model.addAttribute("objects", protectedObjectService.findEnabled()); model.addAttribute("tokens", tokenService.findTokenContextOptions()); return "probe"; } @PostMapping("/probe") public String run( @RequestParam(required = false) Long tokenKeyId, @RequestParam long objectId, @RequestParam String bearerToken, @RequestParam(defaultValue = "50") int limit, Model model ) { model.addAttribute("result", probeService.runProbe(new ProbeCommand(tokenKeyId, objectId, bearerToken, limit))); return "fragments/probe-result :: result"; } }