diff options
-rw-r--r-- | hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java | 13 | ||||
-rw-r--r-- | vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/CompileVersionMojo.java | 18 |
2 files changed, 29 insertions, 2 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 f561e2766c7..ca812f92c49 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 @@ -82,6 +82,7 @@ public abstract class ControllerHttpClient { toDataStream(deployment)))); } + /** Deactivates the deployment of the given application in the given zone. */ public String deactivate(ApplicationId id, ZoneId zone) { return asText(send(request(HttpRequest.newBuilder(deploymentPath(id, zone)) .timeout(Duration.ofSeconds(10)), @@ -91,11 +92,19 @@ public abstract class ControllerHttpClient { /** Returns the default {@link Environment#dev} {@link ZoneId}, to use for development deployments. */ public ZoneId devZone() { Inspector rootObject = toInspector(send(request(HttpRequest.newBuilder(defaultRegionPath()) - .timeout(Duration.ofSeconds(10)), - GET))); + .timeout(Duration.ofSeconds(10)), + GET))); return ZoneId.from("dev", rootObject.field("name").asString()); } + /** Returns the Vespa version to compile against, for a hosted Vespa application. This is its lowest runtime version. */ + public String compileVersion(ApplicationId id) { + return toInspector(send(request(HttpRequest.newBuilder(applicationPath(id.tenant(), id.application())) + .timeout(Duration.ofSeconds(10)), + GET))) + .field("compileVersion").asString(); + } + protected HttpRequest request(HttpRequest.Builder request, Method method, Supplier<InputStream> data) { return request.method(method.name(), ofInputStream(data)).build(); } diff --git a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/CompileVersionMojo.java b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/CompileVersionMojo.java new file mode 100644 index 00000000000..24e2c42d756 --- /dev/null +++ b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/CompileVersionMojo.java @@ -0,0 +1,18 @@ +package ai.vespa.hosted.plugin; + +import org.apache.maven.plugins.annotations.Mojo; + +/** + * Finds the Vespa version to compile against, for a hosted Vespa application. + * + * @author jonmv + */ +@Mojo(name = "compileVersion") +public class CompileVersionMojo extends AbstractVespaMojo { + + @Override + protected void doExecute() { + System.out.println(controller.compileVersion(id)); + } + +} |