aboutsummaryrefslogtreecommitdiffstats
path: root/hosted-api
diff options
context:
space:
mode:
authorØyvind Grønnesby <oyving@verizonmedia.com>2019-10-08 13:00:36 +0200
committerØyvind Grønnesby <oyving@verizonmedia.com>2019-10-08 13:00:36 +0200
commit948500c2a4d52aef59ec18706ae4b8d793afb060 (patch)
treece305f94dbf4f90423255adc3b02fd441bcf211b /hosted-api
parent0d9892df0aa99e13ff83bfdeb3de8f1e8305bdcd (diff)
parent64d8a699b668a5ed1dae0b86bd88bd3a2b40e48c (diff)
Merge remote-tracking branch 'origin/master' into ogronnesby/let-plugin-get-key-as-parameter
Conflicts: hosted-api/src/main/java/ai/vespa/hosted/api/Properties.java
Diffstat (limited to 'hosted-api')
-rw-r--r--hosted-api/src/main/java/ai/vespa/hosted/api/Properties.java35
1 files changed, 30 insertions, 5 deletions
diff --git a/hosted-api/src/main/java/ai/vespa/hosted/api/Properties.java b/hosted-api/src/main/java/ai/vespa/hosted/api/Properties.java
index d578f937485..68656f06d7d 100644
--- a/hosted-api/src/main/java/ai/vespa/hosted/api/Properties.java
+++ b/hosted-api/src/main/java/ai/vespa/hosted/api/Properties.java
@@ -16,42 +16,67 @@ import java.util.Optional;
*/
public class Properties {
+ /**
+ * Returns the relevant application ID. This is the 'tenant', 'application' and 'instance' properties.
+ * The instance defaults to the user name of the current user, if not explicitly set.
+ */
public static ApplicationId application() {
return ApplicationId.from(requireNonBlankProperty("tenant"),
requireNonBlankProperty("application"),
- getNonBlankProperty("instance").orElse("default"));
+ getNonBlankProperty("instance").orElse(user()));
}
+ /** Returns the relevant environment, if this is set with the 'environment' property */
public static Optional<Environment> environment() {
return getNonBlankProperty("environment").map(Environment::from);
}
+ /** Returns the relevant region, if this is set with the 'region' property */
public static Optional<RegionName> region() {
return getNonBlankProperty("region").map(RegionName::from);
}
- public static URI endpoint() {
+ /** Returns the URL of the API endpoint of the Vespa cloud. This must be set with the 'endpoint' property. */
+ public static URI apiEndpoint() {
return URI.create(requireNonBlankProperty("endpoint"));
}
- public static Path privateKeyFile() {
+ /** Returns the path of the API private key. This must be set with the 'privateKeyFile' property. */
+ public static Path apiPrivateKeyFile() {
return Paths.get(requireNonBlankProperty("privateKeyFile"));
}
- public static Optional<Path> certificateFile() {
+ /** Returns the path of the API certificate, if this is set with the 'certificateFile' property. */
+ public static Optional<Path> apiCertificateFile() {
return getNonBlankProperty("certificateFile").map(Paths::get);
}
+ /** Returns the actual private key as a string */
public static Optional<String> privateKey() {
return getNonBlankProperty("privateKey");
}
+ /** Returns the path of the data plane certificate file, if this is set with the 'dataPlaneCertificateFile' property. */
+ public static Optional<Path> dataPlaneCertificateFile() {
+ return getNonBlankProperty("dataPlaneCertificateFile").map(Paths::get);
+ }
+
+ /** Returns the path of the data plane private key file, if this is set with the 'dataPlanePrivateKeyFile' property. */
+ public static Optional<Path> dataPlanePrivateKeyFile() {
+ return getNonBlankProperty("dataPlaneKeyFile").map(Paths::get);
+ }
+
+ /** Returns the user name of the current user. This is set with the 'user.name' property. */
+ public static String user() {
+ return System.getProperty("user.name");
+ }
+
/** Returns the system property with the given name if it is set, or empty. */
public static Optional<String> getNonBlankProperty(String name) {
return Optional.ofNullable(System.getProperty(name)).filter(value -> ! value.isBlank());
}
- /** Returns the system property with the given name if it is set, or throws. */
+ /** Returns the system property with the given name if it is set, or throws an IllegalStateException. */
public static String requireNonBlankProperty(String name) {
return getNonBlankProperty(name).orElseThrow(() -> new IllegalStateException("Missing required property '" + name + "'"));
}