summaryrefslogtreecommitdiffstats
path: root/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/bindings/GetAclResponse.java
blob: 6e12d55888f4ddba00e3757a54657d6a0f2287be (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.node.admin.configserver.noderepository.bindings;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;

/**
 * This class represents a response from the /nodes/v2/acl/ API.
 *
 * @author mpolden
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class GetAclResponse {

    @JsonProperty("trustedNodes")
    public final List<Node> trustedNodes;

    @JsonProperty("trustedNetworks")
    public final List<Network> trustedNetworks;

    @JsonProperty("trustedPorts")
    public final List<Port> trustedPorts;

    @JsonProperty("trustedUdpPorts")
    public final List<Port> trustedUdpPorts;

    @JsonCreator
    public GetAclResponse(@JsonProperty("trustedNodes") List<Node> trustedNodes,
                          @JsonProperty("trustedNetworks") List<Network> trustedNetworks,
                          @JsonProperty("trustedPorts") List<Port> trustedPorts,
                          @JsonProperty("trustedUdpPorts") List<Port> trustedUdpPorts) {
        this.trustedNodes = trustedNodes == null ? List.of() : List.copyOf(trustedNodes);
        this.trustedNetworks = trustedNetworks == null ? List.of() : List.copyOf(trustedNetworks);
        this.trustedPorts = trustedPorts == null ? List.of() : List.copyOf(trustedPorts);
        this.trustedUdpPorts = trustedUdpPorts == null ? List.of() : List.copyOf(trustedUdpPorts);
    }

    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Node {

        @JsonProperty("hostname")
        public final String hostname;

        @JsonProperty("type")
        public final String nodeType;

        @JsonProperty("ipAddress")
        public final String ipAddress;

        @JsonProperty("ports")
        public final List<Integer> ports;

        @JsonProperty("trustedBy")
        public final String trustedBy;

        @JsonCreator
        public Node(@JsonProperty("hostname") String hostname, @JsonProperty("type") String nodeType,
                    @JsonProperty("ipAddress") String ipAddress, @JsonProperty("ports") List<Integer> ports,
                    @JsonProperty("trustedBy") String trustedBy) {
            this.hostname = hostname;
            this.nodeType = nodeType;
            this.ipAddress = ipAddress;
            this.ports = ports == null ? List.of() : List.copyOf(ports);
            this.trustedBy = trustedBy;
        }

        public String getTrustedBy() {
            return trustedBy;
        }
    }

    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Network {

        @JsonProperty("network")
        public final String network;

        @JsonProperty("trustedBy")
        public final String trustedBy;

        @JsonCreator
        public Network(@JsonProperty("network") String network, @JsonProperty("trustedBy") String trustedBy) {
            this.network = network;
            this.trustedBy = trustedBy;
        }

        public String getTrustedBy() {
            return trustedBy;
        }
    }

    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Port {

        @JsonProperty("port")
        public final Integer port;

        @JsonProperty("trustedBy")
        public final String trustedBy;

        @JsonCreator
        public Port(@JsonProperty("port") Integer port, @JsonProperty("trustedBy") String trustedBy) {
            this.port = port;
            this.trustedBy = trustedBy;
        }

        public String getTrustedBy() {
            return trustedBy;
        }
    }
}