Skip to content

Commit 284949e

Browse files
committed
Add ListNodes implementation
1 parent cd934c7 commit 284949e

File tree

18 files changed

+401
-120
lines changed

18 files changed

+401
-120
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.github.dockerjava.api.command;
2+
3+
import com.github.dockerjava.api.model.SwarmNode;
4+
5+
import javax.annotation.CheckForNull;
6+
import java.util.List;
7+
import java.util.Map;
8+
9+
/**
10+
* List SwarmNodes
11+
*/
12+
public interface ListNodesCmd extends SyncDockerCmd<List<SwarmNode>> {
13+
14+
@CheckForNull
15+
Map<String, List<String>> getFilters();
16+
17+
/**
18+
* @param ids - Show only services with the given ids
19+
*/
20+
ListNodesCmd withIdFilter(List<String> ids);
21+
22+
/**
23+
* @param names - Show only services with the given names
24+
*/
25+
ListNodesCmd withNameFilter(List<String> names);
26+
27+
interface Exec extends DockerCmdSyncExec<ListNodesCmd, List<SwarmNode>> {
28+
}
29+
30+
}

src/main/java/com/github/dockerjava/api/model/Event.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public class Event {
4141
/**
4242
* ??
4343
*/
44-
@JsonProperty("eventNode")
45-
private EventNode eventNode;
44+
@JsonProperty("node")
45+
private Node node;
4646

4747
/*
4848
* @since 1.
@@ -183,17 +183,17 @@ public Event withTimenano(Long timenano) {
183183
}
184184

185185
/**
186-
* Returns the eventNode when working against docker swarm
186+
* Returns the node when working against docker swarm
187187
*/
188-
public EventNode getEventNode() {
189-
return eventNode;
188+
public Node getNode() {
189+
return node;
190190
}
191191

192192
/**
193-
* @see #eventNode
193+
* @see #node
194194
*/
195-
public Event withNode(EventNode eventNode) {
196-
this.eventNode = eventNode;
195+
public Event withNode(Node node) {
196+
this.node = node;
197197
return this;
198198
}
199199

src/main/java/com/github/dockerjava/api/model/EventNode.java

Lines changed: 0 additions & 74 deletions
This file was deleted.
Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,74 @@
11
package com.github.dockerjava.api.model;
22

3-
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
43
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import com.fasterxml.jackson.annotation.JsonInclude.Include;
55
import com.fasterxml.jackson.annotation.JsonProperty;
6+
import org.apache.commons.lang.builder.EqualsBuilder;
7+
import org.apache.commons.lang.builder.HashCodeBuilder;
8+
import org.apache.commons.lang.builder.ToStringBuilder;
69

710
/**
8-
* Used for Listing containers.
9-
*
10-
* @author Martin Root
11+
* A node as returned by the /events API, for instance, when Swarm is used.
1112
*/
12-
@JsonIgnoreProperties(ignoreUnknown = true)
13-
@JsonInclude(JsonInclude.Include.NON_NULL)
13+
@JsonInclude(Include.NON_NULL)
1414
public class Node {
15-
@JsonProperty("Id")
16-
private String id;
17-
18-
@JsonProperty("Version")
19-
private String[] version;
2015

21-
@JsonProperty("CreatedAt")
22-
private String createdAt;
16+
@JsonProperty("Name")
17+
private String name;
2318

24-
@JsonProperty("UpdatedAt")
25-
private String updatedAt;
19+
@JsonProperty("Id")
20+
private String id;
2621

27-
@JsonProperty("Spec")
28-
private NodeSpec spec;
22+
@JsonProperty("Addr")
23+
private String addr;
2924

30-
@JsonProperty("Description")
31-
private NodeDescription description;
25+
@JsonProperty("Ip")
26+
private String ip;
3227

33-
@JsonProperty("Status")
34-
private NodeStatus status;
28+
public String getName() {
29+
return name;
30+
}
3531

36-
@JsonProperty("ManagerStatus")
37-
private NodeManagerStatus managerStatus;
32+
public void setName(String name) {
33+
this.name = name;
34+
}
3835

3936
public String getId() {
4037
return id;
4138
}
4239

43-
public String[] getVersion() {
44-
return version;
40+
public void setId(String id) {
41+
this.id = id;
42+
}
43+
44+
public String getAddr() {
45+
return addr;
4546
}
4647

47-
public String getCreatedAt() {
48-
return createdAt;
48+
public void setAddr(String addr) {
49+
this.addr = addr;
4950
}
5051

51-
public String getUpdatedAt() {
52-
return updatedAt;
52+
public String getIp() {
53+
return ip;
5354
}
5455

55-
public NodeSpec getSpec() {
56-
return spec;
56+
public void setIp(String ip) {
57+
this.ip = ip;
5758
}
5859

59-
public NodeDescription getDescription() {
60-
return description;
60+
@Override
61+
public String toString() {
62+
return ToStringBuilder.reflectionToString(this);
6163
}
6264

63-
public NodeStatus getStatus() {
64-
return status;
65+
@Override
66+
public boolean equals(Object o) {
67+
return EqualsBuilder.reflectionEquals(this, o);
6568
}
6669

67-
public NodeManagerStatus getManagerStatus() {
68-
return managerStatus;
70+
@Override
71+
public int hashCode() {
72+
return HashCodeBuilder.reflectionHashCode(this);
6973
}
7074
}

src/main/java/com/github/dockerjava/api/model/NodeDescription.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,20 @@ public NodeResources getResources() {
3535
public NodeEngine getEngine() {
3636
return engine;
3737
}
38+
39+
public void setHostname(String hostname) {
40+
this.hostname = hostname;
41+
}
42+
43+
public void setPlatform(NodePlatform platform) {
44+
this.platform = platform;
45+
}
46+
47+
public void setResources(NodeResources resources) {
48+
this.resources = resources;
49+
}
50+
51+
public void setEngine(NodeEngine engine) {
52+
this.engine = engine;
53+
}
3854
}

src/main/java/com/github/dockerjava/api/model/NodeEngine.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,16 @@ public Map<String, String> getLabels() {
3232
public NodePlugin[] getPlugins() {
3333
return plugins;
3434
}
35+
36+
public void setEngineVersion(String engineVersion) {
37+
this.engineVersion = engineVersion;
38+
}
39+
40+
public void setLabels(Map<String, String> labels) {
41+
this.labels = labels;
42+
}
43+
44+
public void setPlugins(NodePlugin[] plugins) {
45+
this.plugins = plugins;
46+
}
3547
}

src/main/java/com/github/dockerjava/api/model/NodeManagerStatus.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,16 @@ public String getReachability() {
3030
public String getAddr() {
3131
return addr;
3232
}
33+
34+
public void setLeader(boolean leader) {
35+
this.leader = leader;
36+
}
37+
38+
public void setReachability(String reachability) {
39+
this.reachability = reachability;
40+
}
41+
42+
public void setAddr(String addr) {
43+
this.addr = addr;
44+
}
3345
}

src/main/java/com/github/dockerjava/api/model/NodePlatform.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,12 @@ public class NodePlatform {
1010

1111
@JsonProperty("OS")
1212
private String os;
13+
14+
public void setArchitecture(String architecture) {
15+
this.architecture = architecture;
16+
}
17+
18+
public void setOs(String os) {
19+
this.os = os;
20+
}
1321
}

src/main/java/com/github/dockerjava/api/model/NodePlugin.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,12 @@ public String getType() {
2323
public String getName() {
2424
return name;
2525
}
26+
27+
public void setType(String type) {
28+
this.type = type;
29+
}
30+
31+
public void setName(String name) {
32+
this.name = name;
33+
}
2634
}

src/main/java/com/github/dockerjava/api/model/NodeResources.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,12 @@ public Long getNanoCPUs() {
2323
public Long getMemoryBytes() {
2424
return memoryBytes;
2525
}
26+
27+
public void setNanoCPUs(Long nanoCPUs) {
28+
this.nanoCPUs = nanoCPUs;
29+
}
30+
31+
public void setMemoryBytes(Long memoryBytes) {
32+
this.memoryBytes = memoryBytes;
33+
}
2634
}

0 commit comments

Comments
 (0)