From e6780b1e4ca482a0712f1990b835574fff96ed10 Mon Sep 17 00:00:00 2001 From: jonmv Date: Fri, 6 Jan 2023 11:58:17 +0100 Subject: Add method for fetching runs to controller client --- .../ai/vespa/hosted/api/ControllerHttpClient.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'hosted-api/src/main') diff --git a/hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java b/hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java index 0c84404208c..22e81f1b7ab 100644 --- a/hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java +++ b/hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java @@ -104,10 +104,10 @@ public abstract class ControllerHttpClient { var certificates = unchecked(() -> X509CertificateUtils.certificateListFromPem(Files.readString(certificateFile, UTF_8))); for (var certificate : certificates) - if ( Instant.now().isBefore(certificate.getNotBefore().toInstant()) - || Instant.now().isAfter(certificate.getNotAfter().toInstant())) - throw new IllegalStateException("Certificate at '" + certificateFile + "' is valid between " + - certificate.getNotBefore() + " and " + certificate.getNotAfter() + " — not now."); + if ( Instant.now().isBefore(certificate.getNotBefore().toInstant()) + || Instant.now().isAfter(certificate.getNotAfter().toInstant())) + throw new IllegalStateException("Certificate at '" + certificateFile + "' is valid between " + + certificate.getNotBefore() + " and " + certificate.getNotAfter() + " — not now."); return new MutualTlsControllerHttpClient(endpoint, privateKey, certificates); } @@ -179,12 +179,6 @@ public abstract class ControllerHttpClient { GET))); } - /** Returns the application package of the given id. */ - // TODO(mpolden): Remove after all callers have switched to the method below - public HttpResponse applicationPackage(ApplicationId id) { - return applicationPackage(id, false); - } - /** * Returns the latest submitted application package of the given id. If latestDeployed is true, return the latest * package that has been deployed to a production zone. @@ -258,6 +252,10 @@ public abstract class ControllerHttpClient { return deploymentLog(id, zone, run, -1); } + public Inspector runs(ApplicationId id, String jobName) { + return toInspector(send(request(HttpRequest.newBuilder(jobPath(id, jobName)).timeout(Duration.ofSeconds(10)), GET))); + } + /** Returns an authenticated request from the given input. Override this for, e.g., request signing. */ protected HttpRequest request(HttpRequest.Builder request, Method method, Supplier data) { return request.method(method.name(), ofInputStream(data)).build(); @@ -314,6 +312,10 @@ public abstract class ControllerHttpClient { "deploy", jobNameOf(zone)); } + private URI jobPath(ApplicationId id, String jobName) { + return concatenated(instancePath(id), "job", jobName); + } + private URI jobPath(ApplicationId id, ZoneId zone) { return concatenated(instancePath(id), "job", jobNameOf(zone)); } -- cgit v1.2.3