summaryrefslogtreecommitdiffstats
path: root/hosted-api
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2023-01-06 11:58:17 +0100
committerjonmv <venstad@gmail.com>2023-01-06 11:58:17 +0100
commite6780b1e4ca482a0712f1990b835574fff96ed10 (patch)
tree312e41a2b7fdef24f79417db993f1fa6ab5c558c /hosted-api
parent3c97f369d607f64d5a41c42cd707c9c5af36c453 (diff)
Add method for fetching runs to controller client
Diffstat (limited to 'hosted-api')
-rw-r--r--hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java22
1 files changed, 12 insertions, 10 deletions
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<byte[]> 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<InputStream> 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));
}