diff options
author | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2021-04-12 17:00:13 +0200 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2021-04-12 20:53:51 +0200 |
commit | 52de2547b77cda5fca3dd8369d27a440841f4fb8 (patch) | |
tree | e667734cd5952f25e72c37e9336339a438743347 | |
parent | f9c48dbeeaae4318226d3661591690790d085999 (diff) |
Allow Jackson deserialization of model types
2 files changed, 13 insertions, 1 deletions
diff --git a/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceStatusInfo.java b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceStatusInfo.java index e781195eb2a..36cf6f4101e 100644 --- a/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceStatusInfo.java +++ b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceStatusInfo.java @@ -1,6 +1,7 @@ // Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.applicationmodel; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -37,6 +38,15 @@ public class ServiceStatusInfo { this.endpoint = endpoint; } + @JsonCreator + public ServiceStatusInfo(@JsonProperty("serviceStatus") ServiceStatus status, + @JsonProperty("since") Instant since, + @JsonProperty("lastChecked") Instant lastChecked, + @JsonProperty("error") String error, + @JsonProperty("endpoint") String endpoint) { + this(status, Optional.ofNullable(since), Optional.ofNullable(lastChecked), Optional.ofNullable(error), Optional.ofNullable(endpoint)); + } + @JsonProperty("endpoint") public String endpointOrNull() { return endpoint.orElse(null); diff --git a/orchestrator-restapi/src/main/java/com/yahoo/vespa/orchestrator/restapi/wire/SlobrokEntryResponse.java b/orchestrator-restapi/src/main/java/com/yahoo/vespa/orchestrator/restapi/wire/SlobrokEntryResponse.java index 062fa186cb6..672f391a4cd 100644 --- a/orchestrator-restapi/src/main/java/com/yahoo/vespa/orchestrator/restapi/wire/SlobrokEntryResponse.java +++ b/orchestrator-restapi/src/main/java/com/yahoo/vespa/orchestrator/restapi/wire/SlobrokEntryResponse.java @@ -1,6 +1,7 @@ // 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.JsonProperty; @@ -17,7 +18,8 @@ public class SlobrokEntryResponse { @JsonProperty("spec") public final String spec; - public SlobrokEntryResponse(String name, String spec) { + @JsonCreator + public SlobrokEntryResponse(@JsonProperty("name") String name, @JsonProperty("spec") String spec) { this.name = name; this.spec = spec; } |