aboutsummaryrefslogtreecommitdiffstats
path: root/orchestrator-restapi/src/main/java/com/yahoo/vespa/orchestrator/restapi/wire/GetHostResponse.java
blob: 4cf3290029193875b3b1443b38eb172408b0062e (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// 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.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_SUSPENDED_SINCE = "suspendedSince";
    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;
    private final String suspendedSince;

    @JsonCreator
    public GetHostResponse(
            @JsonProperty(FIELD_NAME_HOSTNAME) String hostname,
            @JsonProperty(FIELD_NAME_STATE) String state,
            @JsonProperty(FIELD_NAME_SUSPENDED_SINCE) String suspendedSince,
            @JsonProperty(FIELD_NAME_APPLICATION_URL) String applicationUrl,
            @JsonProperty(FIELD_NAME_SERVICES) List<HostService> services) {
        this.hostname = hostname;
        this.state = state;
        this.suspendedSince = suspendedSince;
        this.applicationUrl = applicationUrl;
        this.services = services;
    }

    @JsonProperty(FIELD_NAME_HOSTNAME)
    public String hostname() {
        return hostname;
    }

    @JsonProperty(FIELD_NAME_STATE)
    public String state() {
        return state;
    }

    @JsonProperty(FIELD_NAME_SUSPENDED_SINCE)
    public String suspendedSince() {
        return suspendedSince;
    }

    @JsonProperty(FIELD_NAME_APPLICATION_URL)
    public String applicationUrl() {
        return applicationUrl;
    }

    @JsonProperty(FIELD_NAME_SERVICES)
    public List<HostService> services() {
        return services;
    }

    @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(suspendedSince, that.suspendedSince) &&
                Objects.equals(applicationUrl, that.applicationUrl) &&
                Objects.equals(services, that.services);
    }

    @Override
    public int hashCode() {
        return Objects.hash(hostname, state, suspendedSince, applicationUrl, services);
    }
}