aboutsummaryrefslogtreecommitdiffstats
path: root/hosted-zone-api
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2021-10-31 15:11:59 +0100
committerJon Bratseth <bratseth@gmail.com>2021-10-31 15:11:59 +0100
commite5c94e10a6edb9e1fd67898313dafb4020ee2a49 (patch)
tree04cfe47c85d4bfdba5e1a196b0197e0856142b1e /hosted-zone-api
parent728576fef4bd8ec18f4baf57f1d45bda4423b47e (diff)
Add ZoneInfo
Diffstat (limited to 'hosted-zone-api')
-rw-r--r--hosted-zone-api/abi-spec.json12
-rw-r--r--hosted-zone-api/src/main/java/ai/vespa/cloud/ZoneInfo.java27
2 files changed, 39 insertions, 0 deletions
diff --git a/hosted-zone-api/abi-spec.json b/hosted-zone-api/abi-spec.json
index 4195fd5f10c..6a6da57a2a1 100644
--- a/hosted-zone-api/abi-spec.json
+++ b/hosted-zone-api/abi-spec.json
@@ -78,5 +78,17 @@
"public static ai.vespa.cloud.Zone from(java.lang.String)"
],
"fields": []
+ },
+ "ai.vespa.cloud.ZoneInfo": {
+ "superClass": "java.lang.Object",
+ "interfaces": [],
+ "attributes": [
+ "public"
+ ],
+ "methods": [
+ "public void <init>(ai.vespa.cloud.Zone)",
+ "public ai.vespa.cloud.Zone zone()"
+ ],
+ "fields": []
}
} \ No newline at end of file
diff --git a/hosted-zone-api/src/main/java/ai/vespa/cloud/ZoneInfo.java b/hosted-zone-api/src/main/java/ai/vespa/cloud/ZoneInfo.java
new file mode 100644
index 00000000000..d9af2421ab9
--- /dev/null
+++ b/hosted-zone-api/src/main/java/ai/vespa/cloud/ZoneInfo.java
@@ -0,0 +1,27 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ai.vespa.cloud;
+
+import java.util.Objects;
+
+/**
+ * Provides information about the zone in which this container is running.
+ * This is available and can be injected when running in a cloud environment.
+ * If you don't need any other information than the zone this should be preferred
+ * to SystemInfo as it will never change at runtime and therefore does not
+ * cause unnecessary reconstruction.
+ *
+ * @author bratseth
+ */
+public class ZoneInfo {
+
+ private final Zone zone;
+
+ public ZoneInfo(Zone zone) {
+ Objects.requireNonNull(zone, "Zone cannot be null!");
+ this.zone = zone;
+ }
+
+ /** Returns the zone this is running in */
+ public Zone zone() { return zone; }
+
+}