Skip to content

Commit 2b60888

Browse files
committed
Add missing properties in Version response
1 parent a091bda commit 2b60888

File tree

5 files changed

+265
-0
lines changed

5 files changed

+265
-0
lines changed

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import javax.annotation.CheckForNull;
1111
import java.io.Serializable;
12+
import java.util.List;
1213

1314
/**
1415
* Used for `/version`
@@ -53,6 +54,24 @@ public class Version implements Serializable {
5354
@JsonProperty("Experimental")
5455
private Boolean experimental;
5556

57+
/**
58+
* @since ~{@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_25}
59+
*/
60+
@JsonProperty("MinAPIVersion")
61+
private String minAPIVersion;
62+
63+
/**
64+
* @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_35}
65+
*/
66+
@JsonProperty("Platform")
67+
private VersionPlatform platform;
68+
69+
/**
70+
* @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_35}
71+
*/
72+
@JsonProperty("Components")
73+
private List<VersionComponent> components;
74+
5675
public String getVersion() {
5776
return version;
5877
}
@@ -97,6 +116,30 @@ public Boolean getExperimental() {
97116
return experimental;
98117
}
99118

119+
/**
120+
* @see #minAPIVersion
121+
*/
122+
@CheckForNull
123+
public String getMinAPIVersion() {
124+
return minAPIVersion;
125+
}
126+
127+
/**
128+
* @see #platform
129+
*/
130+
@CheckForNull
131+
public VersionPlatform getPlatform() {
132+
return platform;
133+
}
134+
135+
/**
136+
* @see #components
137+
*/
138+
@CheckForNull
139+
public List<VersionComponent> getComponents() {
140+
return components;
141+
}
142+
100143
@Override
101144
public String toString() {
102145
return ToStringBuilder.reflectionToString(this);
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
package com.github.dockerjava.api.model;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import org.apache.commons.lang.builder.EqualsBuilder;
6+
import org.apache.commons.lang.builder.HashCodeBuilder;
7+
import org.apache.commons.lang.builder.ToStringBuilder;
8+
9+
import javax.annotation.CheckForNull;
10+
import java.util.Map;
11+
12+
/**
13+
* Part of {@link Version}
14+
*
15+
* @author Dmitry Tretyakov
16+
*/
17+
@JsonIgnoreProperties(ignoreUnknown = true)
18+
public class VersionComponent {
19+
20+
@JsonProperty("Details")
21+
private Map<String, String> details;
22+
23+
@JsonProperty("Name")
24+
private String name;
25+
26+
@JsonProperty("Version")
27+
private String version;
28+
29+
/**
30+
* @see #details
31+
*/
32+
@CheckForNull
33+
public Map<String, String> getDetails() {
34+
return details;
35+
}
36+
37+
/**
38+
* @see #details
39+
*/
40+
public VersionComponent withDetails(Map<String, String> details) {
41+
this.details = details;
42+
return this;
43+
}
44+
45+
/**
46+
* @see #name
47+
*/
48+
@CheckForNull
49+
public String getName() {
50+
return name;
51+
}
52+
53+
/**
54+
* @see #name
55+
*/
56+
public VersionComponent withName(String name) {
57+
this.name = name;
58+
return this;
59+
}
60+
61+
/**
62+
* @see #version
63+
*/
64+
@CheckForNull
65+
public String getVersion() {
66+
return version;
67+
}
68+
69+
/**
70+
* @see #version
71+
*/
72+
public VersionComponent withVersion(String version) {
73+
this.version = version;
74+
return this;
75+
}
76+
77+
@Override
78+
public String toString() {
79+
return ToStringBuilder.reflectionToString(this);
80+
}
81+
82+
@Override
83+
public boolean equals(Object o) {
84+
return EqualsBuilder.reflectionEquals(this, o);
85+
}
86+
87+
@Override
88+
public int hashCode() {
89+
return HashCodeBuilder.reflectionHashCode(this);
90+
}
91+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.github.dockerjava.api.model;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import org.apache.commons.lang.builder.EqualsBuilder;
6+
import org.apache.commons.lang.builder.HashCodeBuilder;
7+
import org.apache.commons.lang.builder.ToStringBuilder;
8+
9+
import javax.annotation.CheckForNull;
10+
11+
/**
12+
* Part of {@link Version}
13+
*
14+
* @author Dmitry Tretyakov
15+
*/
16+
@JsonIgnoreProperties(ignoreUnknown = true)
17+
public class VersionPlatform {
18+
19+
@JsonProperty("Name")
20+
private String name;
21+
22+
/**
23+
* @see #name
24+
*/
25+
@CheckForNull
26+
public String getName() {
27+
return name;
28+
}
29+
30+
/**
31+
* @see #name
32+
*/
33+
public VersionPlatform withName(String name) {
34+
this.name = name;
35+
return this;
36+
}
37+
38+
@Override
39+
public String toString() {
40+
return ToStringBuilder.reflectionToString(this);
41+
}
42+
43+
@Override
44+
public boolean equals(Object o) {
45+
return EqualsBuilder.reflectionEquals(this, o);
46+
}
47+
48+
@Override
49+
public int hashCode() {
50+
return HashCodeBuilder.reflectionHashCode(this);
51+
}
52+
}

src/test/java/com/github/dockerjava/api/model/VersionTest.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@
55
import com.github.dockerjava.core.RemoteApiVersion;
66
import org.junit.Test;
77

8+
import java.util.Collections;
9+
import java.util.LinkedHashMap;
10+
import java.util.List;
11+
import java.util.Map;
12+
813
import static com.github.dockerjava.test.serdes.JSONSamples.testRoundTrip;
914
import static org.hamcrest.CoreMatchers.is;
1015
import static org.hamcrest.MatcherAssert.assertThat;
16+
import static org.hamcrest.Matchers.equalTo;
1117
import static org.hamcrest.Matchers.notNullValue;
1218

1319
/**
@@ -37,4 +43,46 @@ public void testSerDer1() throws Exception {
3743
assertThat(version.getBuildTime(), is("2016-02-11T20:39:58.688092588+00:00"));
3844
}
3945

46+
@Test
47+
public void version_1_38() throws Exception {
48+
final ObjectMapper mapper = new ObjectMapper();
49+
final JavaType type = mapper.getTypeFactory().uncheckedSimpleType(Version.class);
50+
51+
final Version version = testRoundTrip(RemoteApiVersion.VERSION_1_38,
52+
"/version/lcow.json",
53+
type
54+
);
55+
56+
assertThat(version, notNullValue());
57+
assertThat(version.getApiVersion(), is("1.38"));
58+
assertThat(version.getArch(), is("amd64"));
59+
assertThat(version.getBuildTime(), is("2018-08-21T17:36:40.000000000+00:00"));
60+
61+
Map<String, String> details = new LinkedHashMap<>();
62+
details.put("ApiVersion", "1.38");
63+
details.put("Arch", "amd64");
64+
details.put("BuildTime", "2018-08-21T17:36:40.000000000+00:00");
65+
details.put("Experimental", "true");
66+
details.put("GitCommit", "e68fc7a");
67+
details.put("GoVersion", "go1.10.3");
68+
details.put("KernelVersion", "10.0 17134 (17134.1.amd64fre.rs4_release.180410-1804)");
69+
details.put("MinAPIVersion", "1.24");
70+
details.put("Os", "windows");
71+
72+
List<VersionComponent> components = Collections.singletonList(new VersionComponent()
73+
.withDetails(details)
74+
.withName("Engine")
75+
.withVersion("18.06.1-ce")
76+
);
77+
assertThat(version.getComponents(), equalTo(components));
78+
79+
assertThat(version.getExperimental(), is(true));
80+
assertThat(version.getGitCommit(), is("e68fc7a"));
81+
assertThat(version.getGoVersion(), is("go1.10.3"));
82+
assertThat(version.getKernelVersion(), is("10.0 17134 (17134.1.amd64fre.rs4_release.180410-1804)"));
83+
assertThat(version.getMinAPIVersion(), is("1.24"));
84+
assertThat(version.getOperatingSystem(), is("windows"));
85+
assertThat(version.getPlatform(), equalTo(new VersionPlatform().withName("")));
86+
assertThat(version.getVersion(), is("18.06.1-ce"));
87+
}
4088
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"ApiVersion": "1.38",
3+
"Arch": "amd64",
4+
"BuildTime": "2018-08-21T17:36:40.000000000+00:00",
5+
"Components": [{
6+
"Details": {
7+
"ApiVersion": "1.38",
8+
"Arch": "amd64",
9+
"BuildTime": "2018-08-21T17:36:40.000000000+00:00",
10+
"Experimental": "true",
11+
"GitCommit": "e68fc7a",
12+
"GoVersion": "go1.10.3",
13+
"KernelVersion": "10.0 17134 (17134.1.amd64fre.rs4_release.180410-1804)",
14+
"MinAPIVersion": "1.24",
15+
"Os": "windows"
16+
},
17+
"Name": "Engine",
18+
"Version": "18.06.1-ce"
19+
}
20+
],
21+
"Experimental": true,
22+
"GitCommit": "e68fc7a",
23+
"GoVersion": "go1.10.3",
24+
"KernelVersion": "10.0 17134 (17134.1.amd64fre.rs4_release.180410-1804)",
25+
"MinAPIVersion": "1.24",
26+
"Os": "windows",
27+
"Platform": {
28+
"Name": ""
29+
},
30+
"Version": "18.06.1-ce"
31+
}

0 commit comments

Comments
 (0)