aboutsummaryrefslogtreecommitdiffstats
path: root/orchestrator-restapi/src/main/java/com/yahoo/vespa/orchestrator/restapi/wire/WireHostInfo.java
blob: 4f1190e4980e223d089aef6ad7071c9a588a8151 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright Yahoo. 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.time.Instant;
import java.util.Objects;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class WireHostInfo {
    private static final String HOST_STATUS_FIELD = "hostStatus";
    private static final String SUSPENDED_SINCE_FIELD = "suspendedSince";

    private final String hostStatus;
    private final String suspendedSinceUtcOrNull;

    /**
     * @param hostStatus              The host status, e.g. NO_REMARKS.
     * @param suspendedSinceUtcOrNull The time the host was suspended in the format
     *                                {@link Instant#toString()}, or null if not suspended
     *                                (NO_REMARKS).
     */
    @JsonCreator
    public WireHostInfo(@JsonProperty(HOST_STATUS_FIELD) String hostStatus,
                        @JsonProperty(SUSPENDED_SINCE_FIELD) String suspendedSinceUtcOrNull) {
        this.hostStatus = Objects.requireNonNull(hostStatus);
        this.suspendedSinceUtcOrNull = suspendedSinceUtcOrNull;
    }

    @JsonProperty(HOST_STATUS_FIELD)
    public String hostStatus() { return hostStatus; }

    @JsonProperty(SUSPENDED_SINCE_FIELD)
    public String getSuspendedSinceUtcOrNull() { return suspendedSinceUtcOrNull; }
}