Skip to content

Commit 05367a9

Browse files
committed
Add model classes for Services
1 parent ea40071 commit 05367a9

34 files changed

+1299
-0
lines changed

src/main/java/com/github/dockerjava/api/DockerClient.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.github.dockerjava.api.command.ListContainersCmd;
3535
import com.github.dockerjava.api.command.ListImagesCmd;
3636
import com.github.dockerjava.api.command.ListNetworksCmd;
37+
import com.github.dockerjava.api.command.ListServicesCmd;
3738
import com.github.dockerjava.api.command.ListVolumesCmd;
3839
import com.github.dockerjava.api.command.LoadImageCmd;
3940
import com.github.dockerjava.api.command.LogContainerCmd;
@@ -251,6 +252,8 @@ public interface DockerClient extends Closeable {
251252

252253
DisconnectFromNetworkCmd disconnectFromNetworkCmd();
253254

255+
ListServicesCmd listServicesCmd();
256+
254257
@Override
255258
void close() throws IOException;
256259

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

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

118118
DisconnectFromNetworkCmd.Exec createDisconnectFromNetworkCmdExec();
119119

120+
ListServicesCmd.Exec createListServicesCmdExec();
121+
120122
@Override
121123
void close() throws IOException;
122124

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.github.dockerjava.api.command;
2+
3+
import com.github.dockerjava.api.model.Service;
4+
5+
import javax.annotation.CheckForNull;
6+
import java.util.List;
7+
import java.util.Map;
8+
9+
/**
10+
* List services
11+
*
12+
*/
13+
public interface ListServicesCmd extends SyncDockerCmd<List<Service>> {
14+
15+
@CheckForNull
16+
Map<String, List<String>> getFilters();
17+
18+
/**
19+
* @param ids
20+
* - Show only services with the given ids
21+
*/
22+
ListServicesCmd withIdFilter(List<String> ids);
23+
/**
24+
*
25+
* @param names
26+
* - Show only services with the given names
27+
*/
28+
ListServicesCmd withNameFilter(List<String> names);
29+
30+
interface Exec extends DockerCmdSyncExec<ListServicesCmd, List<Service>> {
31+
}
32+
33+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.github.dockerjava.api.model;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import org.apache.commons.lang.builder.EqualsBuilder;
5+
import org.apache.commons.lang.builder.HashCodeBuilder;
6+
import org.apache.commons.lang.builder.ToStringBuilder;
7+
8+
/**
9+
* For TaskTemplate
10+
*/
11+
public class ContainerSpec {
12+
13+
@JsonProperty("Image")
14+
private String image;
15+
16+
public String getImage() {
17+
return image;
18+
}
19+
20+
@Override
21+
public String toString() {
22+
return ToStringBuilder.reflectionToString(this);
23+
}
24+
25+
@Override
26+
public boolean equals(Object o) {
27+
return EqualsBuilder.reflectionEquals(this, o);
28+
}
29+
30+
@Override
31+
public int hashCode() {
32+
return HashCodeBuilder.reflectionHashCode(this);
33+
}
34+
35+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.github.dockerjava.api.model;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import org.apache.commons.lang.builder.EqualsBuilder;
5+
import org.apache.commons.lang.builder.HashCodeBuilder;
6+
import org.apache.commons.lang.builder.ToStringBuilder;
7+
8+
public class Endpoint {
9+
10+
@JsonProperty("Spec")
11+
private EndpointSpec spec;
12+
13+
@JsonProperty("Ports")
14+
private PortConfig[] ports;
15+
16+
@JsonProperty("VirtualIPs")
17+
private EndpointVirtualIP[] virtualIPs;
18+
19+
public EndpointSpec getSpec() {
20+
return spec;
21+
}
22+
23+
public Endpoint withSpec(EndpointSpec spec) {
24+
this.spec = spec;
25+
return this;
26+
}
27+
28+
public PortConfig[] getPorts() {
29+
return ports;
30+
}
31+
32+
public Endpoint withPorts(PortConfig[] ports) {
33+
this.ports = ports;
34+
return this;
35+
}
36+
37+
public EndpointVirtualIP[] getVirtualIPs() {
38+
return virtualIPs;
39+
}
40+
41+
public Endpoint withVirtualIPs(EndpointVirtualIP[] virtualIPs) {
42+
this.virtualIPs = virtualIPs;
43+
return this;
44+
}
45+
46+
@Override
47+
public String toString() {
48+
return ToStringBuilder.reflectionToString(this);
49+
}
50+
51+
@Override
52+
public boolean equals(Object o) {
53+
return EqualsBuilder.reflectionEquals(this, o);
54+
}
55+
56+
@Override
57+
public int hashCode() {
58+
return HashCodeBuilder.reflectionHashCode(this);
59+
}
60+
61+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.github.dockerjava.api.model;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import org.apache.commons.lang.builder.EqualsBuilder;
5+
import org.apache.commons.lang.builder.HashCodeBuilder;
6+
import org.apache.commons.lang.builder.ToStringBuilder;
7+
8+
public class EndpointSpec {
9+
10+
@JsonProperty("Mode")
11+
ResolutionMode mode;
12+
13+
@JsonProperty("Ports")
14+
PortConfig[] ports;
15+
16+
public ResolutionMode getMode() {
17+
return mode;
18+
}
19+
20+
public EndpointSpec withMode(ResolutionMode mode) {
21+
this.mode = mode;
22+
return this;
23+
}
24+
25+
public PortConfig[] getPorts() {
26+
return ports;
27+
}
28+
29+
public EndpointSpec withPorts(PortConfig[] ports) {
30+
this.ports = ports;
31+
return this;
32+
}
33+
34+
@Override
35+
public String toString() {
36+
return ToStringBuilder.reflectionToString(this);
37+
}
38+
39+
@Override
40+
public boolean equals(Object o) {
41+
return EqualsBuilder.reflectionEquals(this, o);
42+
}
43+
44+
@Override
45+
public int hashCode() {
46+
return HashCodeBuilder.reflectionHashCode(this);
47+
}
48+
49+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.github.dockerjava.api.model;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import org.apache.commons.lang.builder.EqualsBuilder;
5+
import org.apache.commons.lang.builder.HashCodeBuilder;
6+
import org.apache.commons.lang.builder.ToStringBuilder;
7+
8+
public class EndpointVirtualIP {
9+
10+
@JsonProperty("NetworkID")
11+
private String networkID;
12+
13+
@JsonProperty("Addr")
14+
private String addr;
15+
16+
public String getNetworkID() {
17+
return networkID;
18+
}
19+
20+
public EndpointVirtualIP withNetworkID(String networkID) {
21+
this.networkID = networkID;
22+
return this;
23+
}
24+
25+
public String getAddr() {
26+
return addr;
27+
}
28+
29+
public EndpointVirtualIP withAddr(String addr) {
30+
this.addr = addr;
31+
return this;
32+
}
33+
34+
@Override
35+
public String toString() {
36+
return ToStringBuilder.reflectionToString(this);
37+
}
38+
39+
@Override
40+
public boolean equals(Object o) {
41+
return EqualsBuilder.reflectionEquals(this, o);
42+
}
43+
44+
@Override
45+
public int hashCode() {
46+
return HashCodeBuilder.reflectionHashCode(this);
47+
}
48+
49+
}

src/main/java/com/github/dockerjava/api/model/EventNode.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
/**
811
* A node as returned by the /events API, for instance, when Swarm is used.
@@ -26,15 +29,46 @@ public String getName() {
2629
return name;
2730
}
2831

32+
public void setName(String name) {
33+
this.name = name;
34+
}
35+
2936
public String getId() {
3037
return id;
3138
}
3239

40+
public void setId(String id) {
41+
this.id = id;
42+
}
43+
3344
public String getAddr() {
3445
return addr;
3546
}
3647

48+
public void setAddr(String addr) {
49+
this.addr = addr;
50+
}
51+
3752
public String getIp() {
3853
return ip;
3954
}
55+
56+
public void setIp(String ip) {
57+
this.ip = ip;
58+
}
59+
60+
@Override
61+
public String toString() {
62+
return ToStringBuilder.reflectionToString(this);
63+
}
64+
65+
@Override
66+
public boolean equals(Object o) {
67+
return EqualsBuilder.reflectionEquals(this, o);
68+
}
69+
70+
@Override
71+
public int hashCode() {
72+
return HashCodeBuilder.reflectionHashCode(this);
73+
}
4074
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package com.github.dockerjava.api.model;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import org.apache.commons.lang.builder.EqualsBuilder;
5+
import org.apache.commons.lang.builder.HashCodeBuilder;
6+
import org.apache.commons.lang.builder.ToStringBuilder;
7+
8+
public class PortConfig {
9+
10+
@JsonProperty("Name")
11+
private String name;
12+
13+
@JsonProperty("Protocol")
14+
private PortConfigProtocol protocol;
15+
16+
@JsonProperty("TargetPort")
17+
private int targetPort;
18+
19+
@JsonProperty("PublishedPort")
20+
private int publishedPort;
21+
22+
public String getName() {
23+
return name;
24+
}
25+
26+
public PortConfig withName(String name) {
27+
this.name = name;
28+
return this;
29+
}
30+
31+
public PortConfigProtocol getProtocol() {
32+
return protocol;
33+
}
34+
35+
public PortConfig withProtocol(PortConfigProtocol protocol) {
36+
this.protocol = protocol;
37+
return this;
38+
}
39+
40+
public int getTargetPort() {
41+
return targetPort;
42+
}
43+
44+
public PortConfig withTargetPort(int targetPort) {
45+
this.targetPort = targetPort;
46+
return this;
47+
}
48+
49+
public int getPublishedPort() {
50+
return publishedPort;
51+
}
52+
53+
public PortConfig withPublishedPort(int publishedPort) {
54+
this.publishedPort = publishedPort;
55+
return this;
56+
}
57+
58+
@Override
59+
public String toString() {
60+
return ToStringBuilder.reflectionToString(this);
61+
}
62+
63+
@Override
64+
public boolean equals(Object o) {
65+
return EqualsBuilder.reflectionEquals(this, o);
66+
}
67+
68+
@Override
69+
public int hashCode() {
70+
return HashCodeBuilder.reflectionHashCode(this);
71+
}
72+
}

0 commit comments

Comments
 (0)