From 95a92ae9e5e9c0520c99cb8106571f198e7f729e Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Sat, 11 Apr 2026 23:16:18 +0200 Subject: [PATCH] feat: add vendor InfrastructureController for platform:admin Co-Authored-By: Claude Sonnet 4.6 --- .../saas/vendor/InfrastructureController.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/main/java/net/siegeln/cameleer/saas/vendor/InfrastructureController.java diff --git a/src/main/java/net/siegeln/cameleer/saas/vendor/InfrastructureController.java b/src/main/java/net/siegeln/cameleer/saas/vendor/InfrastructureController.java new file mode 100644 index 0000000..cc710bd --- /dev/null +++ b/src/main/java/net/siegeln/cameleer/saas/vendor/InfrastructureController.java @@ -0,0 +1,57 @@ +package net.siegeln.cameleer.saas.vendor; + +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping("/api/vendor/infrastructure") +@PreAuthorize("hasAuthority('SCOPE_platform:admin')") +public class InfrastructureController { + + private final InfrastructureService infraService; + + public InfrastructureController(InfrastructureService infraService) { + this.infraService = infraService; + } + + public record InfraOverviewResponse( + InfrastructureService.PostgresOverview postgres, + InfrastructureService.ClickHouseOverview clickhouse) {} + + @GetMapping + public ResponseEntity overview() { + return ResponseEntity.ok(new InfraOverviewResponse( + infraService.getPostgresOverview(), + infraService.getClickHouseOverview())); + } + + @GetMapping("/postgres") + public ResponseEntity> postgres() { + return ResponseEntity.ok(Map.of( + "overview", infraService.getPostgresOverview(), + "tenants", infraService.getPostgresTenantStats())); + } + + @GetMapping("/postgres/{slug}") + public ResponseEntity> postgresDetail( + @PathVariable String slug) { + return ResponseEntity.ok(infraService.getPostgresTenantDetail(slug)); + } + + @GetMapping("/clickhouse") + public ResponseEntity> clickhouse() { + return ResponseEntity.ok(Map.of( + "overview", infraService.getClickHouseOverview(), + "tenants", infraService.getClickHouseTenantStats())); + } + + @GetMapping("/clickhouse/{tenantId}") + public ResponseEntity> clickhouseDetail( + @PathVariable String tenantId) { + return ResponseEntity.ok(infraService.getClickHouseTenantDetail(tenantId)); + } +}