Tanzu Changes
This commit is contained in:
@@ -11,10 +11,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@@ -60,6 +57,67 @@ public class CfDeployController {
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/apps")
|
||||
public ResponseEntity<String> listApps(@RequestBody String requestJson) {
|
||||
try {
|
||||
log.info("Received request to list apps");
|
||||
CfDeployRequest request = objectMapper.readValue(requestJson, CfDeployRequest.class);
|
||||
String output = cfCliService.listApps(request);
|
||||
return ResponseEntity.ok(output);
|
||||
} catch (Exception e) {
|
||||
log.error("Error listing apps", e);
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body("Failed to list apps: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/routes")
|
||||
public ResponseEntity<String> listRoutes(@RequestBody String requestJson) {
|
||||
try {
|
||||
log.info("Received request to list routes");
|
||||
CfDeployRequest request = objectMapper.readValue(requestJson, CfDeployRequest.class);
|
||||
String output = cfCliService.listRoutes(request);
|
||||
return ResponseEntity.ok(output);
|
||||
} catch (Exception e) {
|
||||
log.error("Error listing routes", e);
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body("Failed to list routes: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/app/{appName}")
|
||||
public ResponseEntity<String> getAppDetails(
|
||||
@PathVariable String appName,
|
||||
@RequestBody String requestJson) {
|
||||
try {
|
||||
log.info("Received request to get details for app: {}", appName);
|
||||
CfDeployRequest request = objectMapper.readValue(requestJson, CfDeployRequest.class);
|
||||
String output = cfCliService.getAppDetails(request, appName);
|
||||
return ResponseEntity.ok(output);
|
||||
} catch (Exception e) {
|
||||
log.error("Error getting app details for: {}", appName, e);
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body("Failed to get app details: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/logs/{appName}")
|
||||
public ResponseEntity<String> getAppLogs(
|
||||
@PathVariable String appName,
|
||||
@RequestParam(defaultValue = "true") boolean recent,
|
||||
@RequestBody String requestJson) {
|
||||
try {
|
||||
log.info("Received request to get {} logs for app: {}", recent ? "recent" : "tail", appName);
|
||||
CfDeployRequest request = objectMapper.readValue(requestJson, CfDeployRequest.class);
|
||||
String output = cfCliService.getAppLogs(request, appName, recent);
|
||||
return ResponseEntity.ok(output);
|
||||
} catch (Exception e) {
|
||||
log.error("Error getting logs for: {}", appName, e);
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body("Failed to get app logs: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void validateFiles(MultipartFile jarFile, MultipartFile manifest) {
|
||||
if (jarFile.isEmpty()) {
|
||||
throw new IllegalArgumentException("JAR file is empty");
|
||||
|
||||
Reference in New Issue
Block a user