11package com .github .dockerjava .api .model ;
22
3+ import com .fasterxml .jackson .annotation .JsonIgnore ;
34import com .fasterxml .jackson .annotation .JsonIgnoreProperties ;
45import com .fasterxml .jackson .annotation .JsonProperty ;
56import com .github .dockerjava .core .RemoteApiVersion ;
89import org .apache .commons .lang .builder .ToStringBuilder ;
910
1011import javax .annotation .CheckForNull ;
12+ import java .util .Arrays ;
1113import java .util .List ;
1214
1315/**
16+ * Types taken form
17+ * {@see https://github.com/docker/engine-api/blob/release/1.10/types/network/network.go}
18+ * Docker named it EndpointSettings
19+ *
1420 * @see ContainerNetworkSettings
1521 * @author Kanstantsin Shautsou
1622 */
@@ -20,16 +26,16 @@ public class ContainerNetwork {
2026 * FIXME verify
2127 */
2228 @ JsonProperty ("IPAMConfig" )
23- private Network . Ipam . Config ipamConfig ;
29+ private Ipam ipamConfig ;
2430
2531 /**
2632 * FIXME verify
2733 */
2834 @ JsonProperty ("Links" )
29- private List < String > links ;
35+ private Links links ;
3036
3137 /**
32- * FIXME no docs, unknown field.
38+ * Add network-scoped alias for the container
3339 * Type picked from `docker/vendor/src/github.com/docker/engine-api/types/network/network.go`
3440 *
3541 * @since {@link RemoteApiVersion#VERSION_1_22}
@@ -80,6 +86,14 @@ public ContainerNetwork withAliases(List<String> aliases) {
8086 return this ;
8187 }
8288
89+ /**
90+ * @see #aliases
91+ */
92+ public ContainerNetwork withAliases (String ... aliases ) {
93+ this .aliases = Arrays .asList (aliases );
94+ return this ;
95+ }
96+
8397 /**
8498 * @see #endpointId
8599 */
@@ -155,7 +169,7 @@ public String getIpAddress() {
155169 /**
156170 * @see #ipAddress
157171 */
158- public ContainerNetwork withIpAddress (String ipAddress ) {
172+ public ContainerNetwork withIpv4Address (String ipAddress ) {
159173 this .ipAddress = ipAddress ;
160174 return this ;
161175 }
@@ -164,14 +178,14 @@ public ContainerNetwork withIpAddress(String ipAddress) {
164178 * @see #ipamConfig
165179 */
166180 @ CheckForNull
167- public Network . Ipam . Config getIpamConfig () {
181+ public Ipam getIpamConfig () {
168182 return ipamConfig ;
169183 }
170184
171185 /**
172186 * @see #ipamConfig
173187 */
174- public ContainerNetwork withIpamConfig (Network . Ipam . Config ipamConfig ) {
188+ public ContainerNetwork withIpamConfig (Ipam ipamConfig ) {
175189 this .ipamConfig = ipamConfig ;
176190 return this ;
177191 }
@@ -212,15 +226,24 @@ public ContainerNetwork withIpV6Gateway(String ipV6Gateway) {
212226 * @see #links
213227 */
214228 @ CheckForNull
215- public List <String > getLinks () {
216- return links ;
229+ @ JsonIgnore
230+ public Link [] getLinks () {
231+ return links == null ? new Link [0 ] : links .getLinks ();
232+ }
233+
234+ /**
235+ * @see #links
236+ */
237+ public ContainerNetwork withLinks (List <Link > links ) {
238+ this .links = new Links (links );
239+ return this ;
217240 }
218241
219242 /**
220243 * @see #links
221244 */
222- public ContainerNetwork withLinks (List < String > links ) {
223- this .links = links ;
245+ public ContainerNetwork withLinks (Link ... links ) {
246+ this .links = new Links ( links ) ;
224247 return this ;
225248 }
226249
@@ -270,4 +293,34 @@ public boolean equals(Object o) {
270293 public int hashCode () {
271294 return HashCodeBuilder .reflectionHashCode (this );
272295 }
296+
297+ /**
298+ * Docker named it EndpointIPAMConfig
299+ */
300+ public static class Ipam {
301+
302+ @ JsonProperty ("IPv4Address" )
303+ private String ipv4Address ;
304+
305+ @ JsonProperty ("IPv6Address" )
306+ private String ipv6Address ;
307+
308+ public String getIpv4Address () {
309+ return ipv4Address ;
310+ }
311+
312+ public String getIpv6Address () {
313+ return ipv6Address ;
314+ }
315+
316+ public Ipam withIpv4Address (String ipv4Address ) {
317+ this .ipv4Address = ipv4Address ;
318+ return this ;
319+ }
320+
321+ public Ipam withIpv6Address (String ipv6Address ) {
322+ this .ipv6Address = ipv6Address ;
323+ return this ;
324+ }
325+ }
273326}
0 commit comments