Skip to content

Commit 602008c

Browse files
committed
There are two different event streamed JSON objects that come back
from commands. Create representations for them. Signed-off-by: Nigel Magnay <nigel.magnay@gmail.com>
1 parent 64abb6f commit 602008c

2 files changed

Lines changed: 120 additions & 0 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.github.dockerjava.api.model;
2+
3+
import com.google.common.base.Objects;
4+
5+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
6+
import com.fasterxml.jackson.annotation.JsonProperty;
7+
8+
import java.io.Serializable;
9+
10+
/**
11+
* Represents an event stream
12+
*/
13+
@JsonIgnoreProperties(ignoreUnknown=true)
14+
public class EventStreamItem implements Serializable {
15+
16+
@JsonProperty("stream")
17+
private String stream;
18+
19+
// {"error":"Error...", "errorDetail":{"code": 123, "message": "Error..."}}
20+
@JsonProperty("error")
21+
private String error;
22+
23+
@JsonProperty("errorDetail")
24+
private ErrorDetail errorDetail;
25+
26+
public String getStream() {
27+
return stream;
28+
}
29+
30+
public String getError() {
31+
return error;
32+
}
33+
34+
public ErrorDetail getErrorDetail() {
35+
return errorDetail;
36+
}
37+
38+
@JsonIgnoreProperties(ignoreUnknown=true)
39+
public static class ErrorDetail implements Serializable {
40+
@JsonProperty("code")
41+
String code;
42+
@JsonProperty("message")
43+
String message;
44+
45+
@Override
46+
public String toString() {
47+
return Objects.toStringHelper(this)
48+
.add("code", code)
49+
.add("message", message)
50+
.toString();
51+
}
52+
}
53+
54+
@Override
55+
public String toString() {
56+
return Objects.toStringHelper(this)
57+
.add("stream", stream)
58+
.add("error", error)
59+
.add("errorDetail", errorDetail)
60+
.toString();
61+
}
62+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.github.dockerjava.api.model;
2+
3+
import com.google.common.base.Objects;
4+
5+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
6+
import com.fasterxml.jackson.annotation.JsonProperty;
7+
8+
import java.io.Serializable;
9+
10+
/**
11+
* Represents an item returned from push
12+
*/
13+
@JsonIgnoreProperties(ignoreUnknown=true)
14+
public class PushEventStreamItem implements Serializable {
15+
16+
@JsonProperty("status")
17+
private String status;
18+
19+
@JsonProperty("progress")
20+
private String progress;
21+
22+
@JsonProperty("progressDetail")
23+
private ProgressDetail progressDetail;
24+
25+
26+
public String getStatus() {
27+
return status;
28+
}
29+
30+
public String getProgress() {
31+
return progress;
32+
}
33+
34+
public ProgressDetail getProgressDetail() {
35+
return progressDetail;
36+
}
37+
38+
@JsonIgnoreProperties(ignoreUnknown=true)
39+
public static class ProgressDetail implements Serializable {
40+
@JsonProperty("current")
41+
int current;
42+
43+
44+
@Override
45+
public String toString() {
46+
return "current " + current;
47+
}
48+
}
49+
50+
@Override
51+
public String toString() {
52+
return Objects.toStringHelper(this)
53+
.add("status", status)
54+
.add("progress", progress)
55+
.add("progressDetail", progressDetail)
56+
.toString();
57+
}
58+
}

0 commit comments

Comments
 (0)