diff options
author | Øyvind Grønnesby <oyving@verizonmedia.com> | 2021-11-03 14:28:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-03 14:28:31 +0100 |
commit | ee06a78195081442dd2254288fa11758adf6c2f2 (patch) | |
tree | a2411ca0bc778fd25aed47715df673f649c4bbba | |
parent | 4dc0a746074c06c46deb2f47a31c31464b8c0f00 (diff) | |
parent | c440b1915acb576fc937d44170cf7999223afa10 (diff) |
Merge pull request #19841 from vespa-engine/olaa/include-dashboard-id
Pass along dashboard ID
3 files changed, 12 insertions, 3 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/horizon/HorizonClient.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/horizon/HorizonClient.java index 07489c931b6..3dd102222c7 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/horizon/HorizonClient.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/horizon/HorizonClient.java @@ -10,7 +10,7 @@ public interface HorizonClient { HorizonResponse getUser(); - HorizonResponse getDashboard(); + HorizonResponse getDashboard(int dashboardId); HorizonResponse getTopFolders(); diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/horizon/MockHorizonClient.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/horizon/MockHorizonClient.java index 79c53734efb..06966b6e47c 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/horizon/MockHorizonClient.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/horizon/MockHorizonClient.java @@ -17,7 +17,7 @@ public class MockHorizonClient implements HorizonClient { } @Override - public HorizonResponse getDashboard() { + public HorizonResponse getDashboard(int dashboardId) { return HorizonResponse.empty(); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/horizon/HorizonApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/horizon/HorizonApiHandler.java index 7601129c12f..70e55034887 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/horizon/HorizonApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/horizon/HorizonApiHandler.java @@ -82,7 +82,7 @@ public class HorizonApiHandler extends LoggingRequestHandler { private HttpResponse get(HttpRequest request) { Path path = new Path(request.getUri()); if (path.matches("/horizon/v1/config/dashboard/topFolders")) return new JsonInputStreamResponse(client.getTopFolders()); - if (path.matches("/horizon/v1/config/dashboard/file/{id}")) return new JsonInputStreamResponse(client.getDashboard()); + if (path.matches("/horizon/v1/config/dashboard/file/{id}")) return getDashboard(path.get("id")); return ErrorResponse.notFoundError("Nothing at " + path); } @@ -121,6 +121,15 @@ public class HorizonApiHandler extends LoggingRequestHandler { } } + private HttpResponse getDashboard(String id) { + try { + int dashboardId = Integer.parseInt(id); + return new JsonInputStreamResponse(client.getDashboard(dashboardId)); + } catch (NumberFormatException e) { + return ErrorResponse.badRequest("Dashboard ID must be integer, was " + id); + } + } + private static Set<Role> getRoles(HttpRequest request) { return Optional.ofNullable(request.getJDiscRequest().context().get(SecurityContext.ATTRIBUTE_NAME)) .filter(SecurityContext.class::isInstance) |