From 65d8b3d6e2a3a95a495e9b3096660e15581d1bed Mon Sep 17 00:00:00 2001 From: Jon Marius Venstad Date: Mon, 11 Jan 2021 09:13:54 +0100 Subject: Add suspension mojo --- .../main/java/ai/vespa/hosted/api/ControllerHttpClient.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (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 3a848b33c76..f17816f224d 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 @@ -121,6 +121,13 @@ public abstract class ControllerHttpClient { DELETE))); } + /** Sets suspension status of the given application in the given zone. */ + public String suspend(ApplicationId id, ZoneId zone, boolean suspend) { + return toMessage(send(request(HttpRequest.newBuilder(suspendPath(id, zone)) + .timeout(Duration.ofSeconds(10)), + suspend ? POST : DELETE))); + } + /** Returns the default {@link ZoneId} for the given environment, if any. */ public ZoneId defaultZone(Environment environment) { Inspector rootObject = toInspector(send(request(HttpRequest.newBuilder(defaultRegionPath(environment)) @@ -225,6 +232,10 @@ public abstract class ControllerHttpClient { "region", zone.region().value()); } + private URI suspendPath(ApplicationId id, ZoneId zone) { + return concatenated(deploymentPath(id, zone), "suspend"); + } + private URI deploymentJobPath(ApplicationId id, ZoneId zone) { return concatenated(instancePath(id), "deploy", jobNameOf(zone)); -- cgit v1.2.3