diff options
author | jonmv <venstad@gmail.com> | 2023-08-23 14:23:13 +0200 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2023-08-23 14:23:13 +0200 |
commit | 69f547d7370020f3d7222c993e68ff178a8733a5 (patch) | |
tree | 7219733207c7c3ce5344ae2991c3b07d6ec88604 /hosted-api | |
parent | d4ffa9cc1f32fa2024e13f5ee7f1d515f071aa87 (diff) |
Return build number with submit response
Diffstat (limited to 'hosted-api')
-rw-r--r-- | hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java | 24 |
1 files changed, 16 insertions, 8 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 87bf2057bc6..7768c1a1712 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 @@ -68,6 +68,8 @@ public abstract class ControllerHttpClient { private final HttpClient client; private final URI endpoint; + public record SubmitResult(String message, long id) { } + /** Creates an HTTP client against the given endpoint, using the given HTTP client builder to create a client. */ protected ControllerHttpClient(URI endpoint, SSLContext sslContext) { if (sslContext == null) { @@ -113,14 +115,14 @@ public abstract class ControllerHttpClient { } /** Sends the given submission to the remote controller and returns the version of the accepted package, or throws if this fails. */ - public String submit(Submission submission, TenantName tenant, ApplicationName application) { - return toMessage(send(request(HttpRequest.newBuilder(applicationPath(tenant, application).resolve("submit")) - .timeout(Duration.ofMinutes(30)), - POST, - new MultiPartStreamer().addJson("submitOptions", metaToJson(submission)) - .addFile("applicationZip", submission.applicationZip()) - .addFile("applicationTestZip", submission.applicationTestZip())), - 1)); + public SubmitResult submit(Submission submission, TenantName tenant, ApplicationName application) { + return toSubmitResult(send(request(HttpRequest.newBuilder(applicationPath(tenant, application).resolve("submit")) + .timeout(Duration.ofMinutes(30)), + POST, + new MultiPartStreamer().addJson("submitOptions", metaToJson(submission)) + .addFile("applicationZip", submission.applicationZip()) + .addFile("applicationTestZip", submission.applicationTestZip())), + 1)); } /** Sends the given deployment to the given application in the given zone, or throws if this fails. */ @@ -462,6 +464,12 @@ public abstract class ControllerHttpClient { return toInspector(response).field("message").asString(); } + private static SubmitResult toSubmitResult(HttpResponse<byte[]> response) { + Inspector rootObject = toInspector(response); + return new SubmitResult(rootObject.field("message").asString(), + rootObject.field("build").asLong()); + } + private static DeploymentResult toDeploymentResult(HttpResponse<byte[]> response) { Inspector rootObject = toInspector(response); return new DeploymentResult(rootObject.field("message").asString(), |