Skip to content

Commit d322eb5

Browse files
martin894KostyaSha
authored andcommitted
Add node to model package
Add ListNodes implementation Fix error in ListNodesCmdExec Add FilterBuilder for swarmNodes, renamed Node to SwarmNode Update model classes for SwarmNodes add implementation for update,list,remove and inspect of a swarmNode Update model classes for docker-swarm-node Add methods for swarmNode to execFactories
1 parent d3b7ce5 commit d322eb5

36 files changed

+2033
-4
lines changed

src/main/java/com/github/dockerjava/api/command/DockerCmdExecFactory.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public interface DockerCmdExecFactory extends Closeable {
117117

118118
DisconnectFromNetworkCmd.Exec createDisconnectFromNetworkCmdExec();
119119

120+
// swarm
120121
InitializeSwarmCmd.Exec createInitializeSwarmCmdExec();
121122

122123
InspectSwarmCmd.Exec createInspectSwarmCmdExec();
@@ -127,6 +128,39 @@ public interface DockerCmdExecFactory extends Closeable {
127128

128129
UpdateSwarmCmd.Exec createUpdateSwarmCmdExec();
129130

131+
// nodes
132+
/**
133+
* List all nodes. Node operations require the engine to be part of a swarm
134+
*
135+
* @since {@link RemoteApiVersion#VERSION_1_24}
136+
*/
137+
ListSwarmNodesCmd.Exec listSwarmNodeCmdExec();
138+
139+
/**
140+
* Return low-level information on the node. Node operations require the engine to be part of a swarm
141+
*
142+
* @since {@link RemoteApiVersion#VERSION_1_24}
143+
*/
144+
InspectSwarmNodeCmd.Exec inspectSwarmNodeCmdExec();
145+
146+
/**
147+
* Remove a node from the swarm. Node operations require the engine to be part of a swarm
148+
*
149+
* @since {@link RemoteApiVersion#VERSION_1_24}
150+
*/
151+
RemoveSwarmNodeCmd.Exec removeSwarmNodeCmdExec();
152+
153+
/**
154+
* Update a node. Node operations require the engine to be part of a swarm
155+
*
156+
* @since {@link RemoteApiVersion#VERSION_1_24}
157+
*/
158+
UpdateSwarmNodeCmd.Exec updateSwarmNodeCmdExec();
159+
160+
161+
162+
130163
@Override
131164
void close() throws IOException;
165+
132166
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.github.dockerjava.api.command;
2+
3+
4+
import com.github.dockerjava.api.exception.NotFoundException;
5+
import com.github.dockerjava.api.model.SwarmNode;
6+
import com.github.dockerjava.core.RemoteApiVersion;
7+
8+
import javax.annotation.CheckForNull;
9+
import javax.annotation.Nonnull;
10+
11+
/**
12+
* Inspect a swarmNode.
13+
*
14+
* @since {@link RemoteApiVersion#VERSION_1_24}
15+
*/
16+
public interface InspectSwarmNodeCmd extends SyncDockerCmd<SwarmNode> {
17+
18+
@CheckForNull
19+
String getSwarmNodeId();
20+
21+
InspectSwarmNodeCmd withSwarmNodeId(@Nonnull String swarmNodeId);
22+
23+
/**
24+
* @throws NotFoundException No such swarmNode
25+
*/
26+
@Override
27+
SwarmNode exec() throws NotFoundException;
28+
29+
interface Exec extends DockerCmdSyncExec<InspectSwarmNodeCmd, SwarmNode> {
30+
}
31+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.github.dockerjava.api.command;
2+
3+
import com.github.dockerjava.api.model.SwarmNode;
4+
import com.github.dockerjava.core.RemoteApiVersion;
5+
6+
import javax.annotation.CheckForNull;
7+
import java.util.List;
8+
import java.util.Map;
9+
10+
/**
11+
* List SwarmNodes
12+
*
13+
* @since {@link RemoteApiVersion#VERSION_1_24}
14+
*/
15+
public interface ListSwarmNodesCmd extends SyncDockerCmd<List<SwarmNode>> {
16+
17+
@CheckForNull
18+
Map<String, List<String>> getFilters();
19+
20+
/**
21+
* @param ids - Show only swarmNodes with the given ids
22+
*/
23+
ListSwarmNodesCmd withIdFilter(List<String> ids);
24+
25+
/**
26+
* @param names - Show only swarmNodes with the given names
27+
*/
28+
ListSwarmNodesCmd withNameFilter(List<String> names);
29+
30+
/**
31+
* @param memberships - Show only swarmNodes with the given memberships
32+
*/
33+
ListSwarmNodesCmd withMembershipFilter(List<String> memberships);
34+
35+
/**
36+
* @param roles - Show only swarmNodes with the given roles
37+
*/
38+
ListSwarmNodesCmd withRoleFilter(List<String> roles);
39+
40+
interface Exec extends DockerCmdSyncExec<ListSwarmNodesCmd, List<SwarmNode>> {
41+
}
42+
43+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.github.dockerjava.api.command;
2+
3+
import com.github.dockerjava.api.exception.NotFoundException;
4+
import com.github.dockerjava.core.RemoteApiVersion;
5+
6+
import javax.annotation.CheckForNull;
7+
import javax.annotation.Nonnull;
8+
9+
/**
10+
* Remove a swarmNode.
11+
*
12+
* @since {@link RemoteApiVersion#VERSION_1_24}
13+
*/
14+
public interface RemoveSwarmNodeCmd extends SyncDockerCmd<Void> {
15+
16+
@CheckForNull
17+
String getSwarmNodeId();
18+
19+
@CheckForNull
20+
Boolean hasForceEnabled();
21+
22+
RemoveSwarmNodeCmd withContainerId(@Nonnull String containerId);
23+
24+
RemoveSwarmNodeCmd withForce(Boolean force);
25+
26+
/**
27+
* @throws NotFoundException No such swarmNode
28+
*/
29+
@Override
30+
Void exec() throws NotFoundException;
31+
32+
interface Exec extends DockerCmdSyncExec<RemoveSwarmNodeCmd, Void> {
33+
}
34+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.github.dockerjava.api.command;
2+
3+
import com.github.dockerjava.api.model.SwarmNodeSpec;
4+
import com.github.dockerjava.core.RemoteApiVersion;
5+
6+
import javax.annotation.CheckForNull;
7+
import javax.annotation.Nonnull;
8+
9+
/**
10+
* Update swarmNode spec
11+
*
12+
* @since {@link RemoteApiVersion#VERSION_1_24}
13+
*/
14+
public interface UpdateSwarmNodeCmd extends SyncDockerCmd<Void> {
15+
16+
@CheckForNull
17+
String getSwarmNodeId();
18+
19+
UpdateSwarmNodeCmd withSwarmNodeId(@Nonnull String swarmNodeId);
20+
21+
@CheckForNull
22+
SwarmNodeSpec getSwarmNodeSpec();
23+
24+
UpdateSwarmNodeCmd withSwarmNodeSpec(SwarmNodeSpec swarmNodeSpec);
25+
26+
interface Exec extends DockerCmdSyncExec<UpdateSwarmNodeCmd, Void> {
27+
}
28+
}

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import com.fasterxml.jackson.annotation.JsonInclude;
44
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
import java.io.Serializable;
811

@@ -29,15 +32,46 @@ public String getName() {
2932
return name;
3033
}
3134

35+
public void setName(String name) {
36+
this.name = name;
37+
}
38+
3239
public String getId() {
3340
return id;
3441
}
3542

43+
public void setId(String id) {
44+
this.id = id;
45+
}
46+
3647
public String getAddr() {
3748
return addr;
3849
}
3950

51+
public void setAddr(String addr) {
52+
this.addr = addr;
53+
}
54+
4055
public String getIp() {
4156
return ip;
4257
}
58+
59+
public void setIp(String ip) {
60+
this.ip = ip;
61+
}
62+
63+
@Override
64+
public String toString() {
65+
return ToStringBuilder.reflectionToString(this);
66+
}
67+
68+
@Override
69+
public boolean equals(Object o) {
70+
return EqualsBuilder.reflectionEquals(this, o);
71+
}
72+
73+
@Override
74+
public int hashCode() {
75+
return HashCodeBuilder.reflectionHashCode(this);
76+
}
4377
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.github.dockerjava.api.model;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import com.github.dockerjava.core.RemoteApiVersion;
5+
6+
/**
7+
* @since {@link RemoteApiVersion#VERSION_1_24}
8+
*/
9+
public enum Reachability {
10+
11+
@JsonProperty("unknown")
12+
UNKNOWN,
13+
14+
@JsonProperty("unreachable")
15+
UNREACHABLE,
16+
17+
@JsonProperty("reachable")
18+
REACHABLE
19+
}

0 commit comments

Comments
 (0)