diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2019-05-09 13:59:06 +0200 |
---|---|---|
committer | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2019-05-09 13:59:06 +0200 |
commit | c3edc95cda1d87a2446e892017738b0ddac4c9f7 (patch) | |
tree | ba448d3083af448986c255851e90567e57d107b1 /hosted-api | |
parent | 02e883daacb9aac085d18d848395cad568373a17 (diff) |
Deploy to the new deployment path, for asynch deployments
Diffstat (limited to 'hosted-api')
-rw-r--r-- | hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java | 19 | ||||
-rw-r--r-- | hosted-api/src/main/java/ai/vespa/hosted/api/DeploymentResult.java | 18 |
2 files changed, 22 insertions, 15 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 ca812f92c49..17cf38a9118 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 @@ -76,7 +76,7 @@ public abstract class ControllerHttpClient { /** Sends the given deployment to the given application in the given zone, or throws if this fails. */ public DeploymentResult deploy(Deployment deployment, ApplicationId id, ZoneId zone) { - return toDeploymentResult(send(request(HttpRequest.newBuilder(deploymentPath(id, zone)) + return toDeploymentResult(send(request(HttpRequest.newBuilder(deploymentJobPath(id, zone)) .timeout(Duration.ofMinutes(60)), POST, toDataStream(deployment)))); @@ -144,6 +144,11 @@ public abstract class ControllerHttpClient { "instance", id.instance().value()); } + private URI deploymentJobPath(ApplicationId id, ZoneId zone) { + return concatenated(instancePath(id), + "job", zone.environment().value() + "-" + zone.region().value()); + } + private URI defaultRegionPath() { return concatenated(endpoint, "zone", "v1", "environment", Environment.dev.value(), "default"); } @@ -228,15 +233,9 @@ public abstract class ControllerHttpClient { } private static DeploymentResult toDeploymentResult(HttpResponse<byte[]> response) { - try { - Inspector responseObject = toInspector(response); - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - new JsonFormat(false).encode(buffer, responseObject); // Pretty-print until done properly. - return new DeploymentResult(buffer.toString(UTF_8)); - } - catch (IOException e) { - throw new UncheckedIOException(e); - } + Inspector rootObject = toInspector(response); + return new DeploymentResult(rootObject.field("message").asString(), + URI.create(rootObject.field("location").asString())); } private static Slime toSlime(byte[] data) { diff --git a/hosted-api/src/main/java/ai/vespa/hosted/api/DeploymentResult.java b/hosted-api/src/main/java/ai/vespa/hosted/api/DeploymentResult.java index 63142ffbbf1..f13453b7416 100644 --- a/hosted-api/src/main/java/ai/vespa/hosted/api/DeploymentResult.java +++ b/hosted-api/src/main/java/ai/vespa/hosted/api/DeploymentResult.java @@ -1,6 +1,8 @@ package ai.vespa.hosted.api; +import java.net.URI; + /** * Contains information about the result of a {@link Deployment} against a {@link ControllerHttpClient}. * @@ -8,14 +10,20 @@ package ai.vespa.hosted.api; */ public class DeploymentResult { - private final String json; // TODO probably do this properly. + private final String message; + private final URI location; + + public DeploymentResult(String message, URI location) { + this.message = message; + this.location = location; + } - public DeploymentResult(String json) { - this.json = json; + public String message() { + return message; } - public String json() { - return json; + public URI location() { + return location; } } |