summaryrefslogtreecommitdiffstats
path: root/orchestrator-restapi
diff options
context:
space:
mode:
authorHåkon Hallingstad <hakon@oath.com>2017-10-25 17:36:20 +0200
committerHåkon Hallingstad <hakon@oath.com>2017-10-25 17:36:20 +0200
commit37ce355370e8483c05bd9a7ce9f4f248e19ad4fb (patch)
treea8f0ec831ee667ecd909fad6b5206fdae5307821 /orchestrator-restapi
parent9606e88b7ca082f36eb38b0e197a0513f76ef6eb (diff)
Provide more info in host Orchestrator REST API
Diffstat (limited to 'orchestrator-restapi')
-rw-r--r--orchestrator-restapi/src/main/java/com/yahoo/vespa/orchestrator/restapi/HostApi.java5
-rw-r--r--orchestrator-restapi/src/main/java/com/yahoo/vespa/orchestrator/restapi/wire/GetHostResponse.java53
-rw-r--r--orchestrator-restapi/src/main/java/com/yahoo/vespa/orchestrator/restapi/wire/HostService.java52
3 files changed, 97 insertions, 13 deletions
diff --git a/orchestrator-restapi/src/main/java/com/yahoo/vespa/orchestrator/restapi/HostApi.java b/orchestrator-restapi/src/main/java/com/yahoo/vespa/orchestrator/restapi/HostApi.java
index 1c4d138acef..7f576f6c4e3 100644
--- a/orchestrator-restapi/src/main/java/com/yahoo/vespa/orchestrator/restapi/HostApi.java
+++ b/orchestrator-restapi/src/main/java/com/yahoo/vespa/orchestrator/restapi/HostApi.java
@@ -14,7 +14,9 @@ import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
/**
* Definition of Orchestrator's REST API for hosts.
@@ -38,7 +40,8 @@ public interface HostApi {
@GET
@Path("/{hostname}")
@Produces(MediaType.APPLICATION_JSON)
- GetHostResponse getHost(@PathParam("hostname") String hostNameString);
+ GetHostResponse getHost(@Context UriInfo uriInfo,
+ @PathParam("hostname") String hostNameString);
/**
* Tweak internal Orchestrator state for host.
diff --git a/orchestrator-restapi/src/main/java/com/yahoo/vespa/orchestrator/restapi/wire/GetHostResponse.java b/orchestrator-restapi/src/main/java/com/yahoo/vespa/orchestrator/restapi/wire/GetHostResponse.java
index 99489b345d4..38801c4c817 100644
--- a/orchestrator-restapi/src/main/java/com/yahoo/vespa/orchestrator/restapi/wire/GetHostResponse.java
+++ b/orchestrator-restapi/src/main/java/com/yahoo/vespa/orchestrator/restapi/wire/GetHostResponse.java
@@ -2,27 +2,48 @@
package com.yahoo.vespa.orchestrator.restapi.wire;
import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
import java.util.Objects;
/*
* @author andreer
*/
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(JsonInclude.Include.NON_NULL)
public class GetHostResponse {
public static final String FIELD_NAME_HOSTNAME = "hostname";
public static final String FIELD_NAME_STATE = "state";
+ public static final String FIELD_NAME_APPLICATION_URL = "applicationUrl";
+ public static final String FIELD_NAME_SERVICES = "services";
private final String hostname;
private final String state;
+ private final String applicationUrl;
+ private final List<HostService> services;
+
+ // Deprecated - kept for backwards compatibility until clients have migrated away
+ public GetHostResponse(String hostname, String state) {
+ this.hostname = hostname;
+ this.state = state;
+ this.applicationUrl = null;
+ this.services = null;
+ }
@JsonCreator
public GetHostResponse(
- @JsonProperty(FIELD_NAME_HOSTNAME) final String hostname,
- @JsonProperty(FIELD_NAME_STATE) final String state) {
+ @JsonProperty(FIELD_NAME_HOSTNAME) String hostname,
+ @JsonProperty(FIELD_NAME_STATE) String state,
+ @JsonProperty(FIELD_NAME_APPLICATION_URL) String applicationUrl,
+ @JsonProperty(FIELD_NAME_SERVICES) List<HostService> services) {
this.hostname = hostname;
this.state = state;
+ this.applicationUrl = applicationUrl;
+ this.services = services;
}
@JsonProperty(FIELD_NAME_HOSTNAME)
@@ -35,21 +56,29 @@ public class GetHostResponse {
return state;
}
- @Override
- public boolean equals(final Object o) {
- if (!(o instanceof GetHostResponse)) {
- return false;
- }
+ @JsonProperty(FIELD_NAME_APPLICATION_URL)
+ public String applicationUrl() {
+ return applicationUrl;
+ }
- final GetHostResponse other = (GetHostResponse) o;
- if (!Objects.equals(this.hostname, other.hostname)) return false;
- if (!Objects.equals(this.state, other.state)) return false;
+ @JsonProperty(FIELD_NAME_SERVICES)
+ public List<HostService> services() {
+ return services;
+ }
- return true;
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ GetHostResponse that = (GetHostResponse) o;
+ return Objects.equals(hostname, that.hostname) &&
+ Objects.equals(state, that.state) &&
+ Objects.equals(applicationUrl, that.applicationUrl) &&
+ Objects.equals(services, that.services);
}
@Override
public int hashCode() {
- return Objects.hash(hostname, state);
+ return Objects.hash(hostname, state, applicationUrl, services);
}
}
diff --git a/orchestrator-restapi/src/main/java/com/yahoo/vespa/orchestrator/restapi/wire/HostService.java b/orchestrator-restapi/src/main/java/com/yahoo/vespa/orchestrator/restapi/wire/HostService.java
new file mode 100644
index 00000000000..70cc9187dd1
--- /dev/null
+++ b/orchestrator-restapi/src/main/java/com/yahoo/vespa/orchestrator/restapi/wire/HostService.java
@@ -0,0 +1,52 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.orchestrator.restapi.wire;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.Objects;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class HostService {
+ @JsonProperty("clusterId")
+ public final String clusterId;
+
+ @JsonProperty("serviceType")
+ public final String serviceType;
+
+ @JsonProperty("configId")
+ public final String configId;
+
+ @JsonProperty("serviceStatus")
+ public final String serviceStatus;
+
+ @JsonCreator
+ public HostService(@JsonProperty("clusterId") String clusterId,
+ @JsonProperty("serviceType") String serviceType,
+ @JsonProperty("configId") String configId,
+ @JsonProperty("serviceStatus") String serviceStatus) {
+ this.clusterId = clusterId;
+ this.serviceType = serviceType;
+ this.configId = configId;
+ this.serviceStatus = serviceStatus;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ HostService that = (HostService) o;
+ return Objects.equals(clusterId, that.clusterId) &&
+ Objects.equals(serviceType, that.serviceType) &&
+ Objects.equals(configId, that.configId) &&
+ Objects.equals(serviceStatus, that.serviceStatus);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(clusterId, serviceType, configId, serviceStatus);
+ }
+}