X Tutup
Skip to content

Commit fc9fb32

Browse files
committed
Merge pull request #426 from docker-java/rebased-refact-filters
Refactored filters API
2 parents aabf07b + acfe65d commit fc9fb32

33 files changed

+412
-268
lines changed

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

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,66 @@
11
package com.github.dockerjava.api.command;
22

3+
import java.util.List;
4+
import java.util.Map;
5+
36
import javax.annotation.CheckForNull;
47

58
import com.github.dockerjava.api.model.Event;
6-
import com.github.dockerjava.api.model.Filters;
79

810
/**
911
* Get events
10-
*
11-
* @param since
12-
* - Show all events created since timestamp
13-
* @param until
14-
* - Stream events until this timestamp
1512
*/
1613
public interface EventsCmd extends AsyncDockerCmd<EventsCmd, Event> {
1714

1815
@CheckForNull
19-
public Filters getFilters();
16+
public Map<String, List<String>> getFilters();
2017

2118
@CheckForNull
2219
public String getSince();
2320

2421
@CheckForNull
2522
public String getUntil();
2623

27-
public EventsCmd withFilters(Filters filters);
24+
/**
25+
* @param container
26+
* - container to filter
27+
*/
28+
public EventsCmd withContainerFilter(String... container);
29+
30+
/**
31+
* @param event
32+
* - event to filter (pull | create | attach | start | stop | kill)
33+
*/
34+
public EventsCmd withEventFilter(String... event);
35+
36+
/**
37+
* @param image
38+
* - image to filter
39+
*/
40+
public EventsCmd withImageFilter(String... image);
41+
42+
/**
43+
* @param label
44+
* - label to filter
45+
*/
46+
public EventsCmd withLabelFilter(String... label);
47+
48+
/**
49+
* @param labels
50+
* - labels to filter (map of names and values)
51+
*/
52+
public EventsCmd withLabelFilter(Map<String, String> labels);
2853

54+
/**
55+
* @param since
56+
* - Show all events created since timestamp
57+
*/
2958
public EventsCmd withSince(String since);
3059

60+
/**
61+
* @param until
62+
* - Show all events created until timestamp
63+
*/
3164
public EventsCmd withUntil(String until);
3265

3366
public static interface Exec extends DockerCmdAsyncExec<EventsCmd, Event> {

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

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,23 @@
11
package com.github.dockerjava.api.command;
22

33
import java.util.List;
4+
import java.util.Map;
45

56
import javax.annotation.CheckForNull;
67

78
import com.github.dockerjava.api.model.Container;
8-
import com.github.dockerjava.api.model.Filters;
99

1010
/**
1111
* List containers
1212
*
13-
* @param showAll
14-
* - true or false, Show all containers. Only running containers are shown by default.
15-
* @param showSize
16-
* - true or false, Show the containers sizes. This is false by default.
17-
* @param limit
18-
* - Show `limit` last created containers, include non-running ones. There is no limit by default.
19-
* @param sinceId
20-
* - Show only containers created since Id, include non-running ones.
21-
* @param beforeId
22-
* - Show only containers created before Id, include non-running ones.
23-
*
2413
*/
2514
public interface ListContainersCmd extends SyncDockerCmd<List<Container>> {
2615

2716
@CheckForNull
2817
public String getBeforeId();
2918

3019
@CheckForNull
31-
public Filters getFilters();
20+
public Map<String, List<String>> getFilters();
3221

3322
@CheckForNull
3423
public Integer getLimit();
@@ -42,16 +31,59 @@ public interface ListContainersCmd extends SyncDockerCmd<List<Container>> {
4231
@CheckForNull
4332
public Boolean hasShowSizeEnabled();
4433

34+
/**
35+
* @param beforeId
36+
* - Show only containers created before Id, include non-running ones.
37+
*/
4538
public ListContainersCmd withBefore(String before);
4639

47-
public ListContainersCmd withFilters(Filters filters);
48-
40+
/**
41+
* @param exitcode
42+
* - Show only containers that exited with the passed exitcode.
43+
*/
44+
public ListContainersCmd withExitcodeFilter(Integer exitcode);
45+
46+
/**
47+
* @param exitcode
48+
* - Show only containers with the passed status (created|restarting|running|paused|exited).
49+
*/
50+
public ListContainersCmd withStatusFilter(String status);
51+
52+
/**
53+
* @param labels
54+
* - Show only containers with the passed labels.
55+
*/
56+
public ListContainersCmd withLabelFilter(String... labels);
57+
58+
/**
59+
* @param labels
60+
* - Show only containers with the passed labels. Labels is a {@link Map} that contains label keys and
61+
* values
62+
*/
63+
public ListContainersCmd withLabelFilter(Map<String, String> labels);
64+
65+
/**
66+
* @param limit
67+
* - Show `limit` last created containers, include non-running ones. There is no limit by default.
68+
*/
4969
public ListContainersCmd withLimit(Integer limit);
5070

71+
/**
72+
* @param showAll
73+
* - Show all containers. Only running containers are shown by default.
74+
*/
5175
public ListContainersCmd withShowAll(Boolean showAll);
5276

77+
/**
78+
* @param showSize
79+
* - Show the containers sizes. This is false by default.
80+
*/
5381
public ListContainersCmd withShowSize(Boolean showSize);
5482

83+
/**
84+
* @param sinceId
85+
* - Show only containers created since Id, include non-running ones.
86+
*/
5587
public ListContainersCmd withSince(String since);
5688

5789
public static interface Exec extends DockerCmdSyncExec<ListContainersCmd, List<Container>> {

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

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,48 @@
11
package com.github.dockerjava.api.command;
22

33
import java.util.List;
4+
import java.util.Map;
45

56
import javax.annotation.CheckForNull;
67

78
import com.github.dockerjava.api.model.Image;
89

910
/**
1011
* List images
11-
*
12-
* @param showAll
13-
* - Show all images (by default filter out the intermediate images used to build)
14-
* @param filters
15-
* - a json encoded value of the filters (a map[string][]string) to process on the images list.
1612
*/
1713
public interface ListImagesCmd extends SyncDockerCmd<List<Image>> {
1814

1915
@CheckForNull
20-
public String getFilters();
16+
public Map<String, List<String>> getFilters();
17+
18+
public String getImageNameFilter();
2119

2220
@CheckForNull
2321
public Boolean hasShowAllEnabled();
2422

23+
/**
24+
* Show all images (by default filter out the intermediate images used to build)
25+
*/
2526
public ListImagesCmd withShowAll(Boolean showAll);
2627

27-
public ListImagesCmd withFilters(String filters);
28+
public ListImagesCmd withImageNameFilter(String imageName);
29+
30+
/**
31+
* Filter dangling images
32+
*/
33+
public ListImagesCmd withDanglingFilter(Boolean dangling);
34+
35+
/**
36+
* @param labels
37+
* - string array in the form ["key"] or ["key=value"] or a mix of both
38+
*/
39+
public ListImagesCmd withLabelFilter(String... label);
40+
41+
/**
42+
* @param labels
43+
* - {@link Map} of labels that contains label keys and values
44+
*/
45+
public ListImagesCmd withLabelFilter(Map<String, String> labels);
2846

2947
public static interface Exec extends DockerCmdSyncExec<ListImagesCmd, List<Image>> {
3048
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package com.github.dockerjava.api.command;
22

3-
import com.github.dockerjava.api.model.Filters;
43
import com.github.dockerjava.api.model.Network;
54
import com.github.dockerjava.core.RemoteApiVersion;
65

76
import javax.annotation.CheckForNull;
87

98
import java.util.List;
9+
import java.util.Map;
1010

1111
/**
1212
* List networks.
@@ -16,9 +16,11 @@
1616
public interface ListNetworksCmd extends SyncDockerCmd<List<Network>> {
1717

1818
@CheckForNull
19-
public Filters getFilters();
19+
public Map<String, List<String>> getFilters();
2020

21-
ListNetworksCmd withFilters(Filters filters);
21+
ListNetworksCmd withNameFilter(String... networkName);
22+
23+
ListNetworksCmd withIdFilter(String... networkId);
2224

2325
public static interface Exec extends DockerCmdSyncExec<ListNetworksCmd, List<Network>> {
2426
}

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
package com.github.dockerjava.api.command;
22

3+
import java.util.List;
4+
import java.util.Map;
5+
36
import javax.annotation.CheckForNull;
47

58
/**
69
* List volumes.
710
*
8-
*
911
* @author Marcus Linke
1012
*/
1113
public interface ListVolumesCmd extends SyncDockerCmd<ListVolumesResponse> {
1214

1315
@CheckForNull
14-
public String getFilters();
16+
public Map<String, List<String>> getFilters();
1517

1618
/**
17-
* @param filters
18-
* - JSON encoded value of the filters (a map[string][]string) to process on the volumes list. There is
19-
* one available filter: dangling=true
19+
* @param dangling
20+
* - Show dangling volumes filter
2021
*/
21-
public ListVolumesCmd withFilters(String filters);
22+
public ListVolumesCmd withDanglingFilter(Boolean dangling);
2223

2324
public static interface Exec extends DockerCmdSyncExec<ListVolumesCmd, ListVolumesResponse> {
2425
}

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

Lines changed: 0 additions & 37 deletions
This file was deleted.

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

Lines changed: 0 additions & 15 deletions
This file was deleted.

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,4 @@ public boolean isPullSuccessIndicated() {
3333
return (getStatus().contains(DOWNLOAD_COMPLETE) || getStatus().contains(IMAGE_UP_TO_DATE)
3434
|| getStatus().contains(DOWNLOADED_NEWER_IMAGE) || getStatus().contains(LEGACY_REGISTRY));
3535
}
36-
3736
}

0 commit comments

Comments
 (0)
X Tutup