Skip to content

Commit 9116e14

Browse files
authored
Merge pull request docker-java#1100 from dtretyakov/filters
Add withFilter methods in ListNetworksCmd & ListVolumesCmd
2 parents a097fac + 2c2e301 commit 9116e14

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import javax.annotation.CheckForNull;
77

8+
import java.util.Collection;
89
import java.util.List;
910
import java.util.Map;
1011

@@ -22,6 +23,13 @@ public interface ListNetworksCmd extends SyncDockerCmd<List<Network>> {
2223

2324
ListNetworksCmd withIdFilter(String... networkId);
2425

26+
/**
27+
* @param filterName
28+
* @param filterValues
29+
* - Show only networks where the filter matches the given values
30+
*/
31+
ListNetworksCmd withFilter(String filterName, Collection<String> filterValues);
32+
2533
interface Exec extends DockerCmdSyncExec<ListNetworksCmd, List<Network>> {
2634
}
2735
}

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

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

3+
import java.util.Collection;
34
import java.util.List;
45
import java.util.Map;
56

@@ -21,6 +22,13 @@ public interface ListVolumesCmd extends SyncDockerCmd<ListVolumesResponse> {
2122
*/
2223
ListVolumesCmd withDanglingFilter(Boolean dangling);
2324

25+
/**
26+
* @param filterName
27+
* @param filterValues
28+
* - Show only volumes where the filter matches the given values
29+
*/
30+
ListVolumesCmd withFilter(String filterName, Collection<String> filterValues);
31+
2432
interface Exec extends DockerCmdSyncExec<ListVolumesCmd, ListVolumesResponse> {
2533
}
2634
}

src/main/java/com/github/dockerjava/core/command/ListNetworksCmdImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
import com.github.dockerjava.api.model.Network;
55
import com.github.dockerjava.core.util.FiltersBuilder;
66

7+
import java.util.Collection;
78
import java.util.List;
89
import java.util.Map;
910

11+
import static com.google.common.base.Preconditions.checkNotNull;
12+
1013
public class ListNetworksCmdImpl extends AbstrDockerCmd<ListNetworksCmd, List<Network>> implements ListNetworksCmd {
1114

1215
private FiltersBuilder filtersBuilder = new FiltersBuilder();
@@ -31,4 +34,11 @@ public ListNetworksCmd withNameFilter(String... networkName) {
3134
this.filtersBuilder.withFilter("name", networkName);
3235
return this;
3336
}
37+
38+
@Override
39+
public ListNetworksCmd withFilter(String filterName, Collection<String> filterValues) {
40+
checkNotNull(filterValues, filterName + " was not specified");
41+
this.filtersBuilder.withFilter(filterName, filterValues);
42+
return this;
43+
}
3444
}

src/main/java/com/github/dockerjava/core/command/ListVolumesCmdImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static com.google.common.base.Preconditions.checkNotNull;
44

5+
import java.util.Collection;
56
import java.util.List;
67
import java.util.Map;
78

@@ -33,4 +34,11 @@ public ListVolumesCmd withDanglingFilter(Boolean dangling) {
3334
this.filters.withFilter("dangling", dangling.toString());
3435
return this;
3536
}
37+
38+
@Override
39+
public ListVolumesCmd withFilter(String filterName, Collection<String> filterValues) {
40+
checkNotNull(filterValues, filterName + " was not specified");
41+
this.filters.withFilter(filterName, filterValues);
42+
return this;
43+
}
3644
}

0 commit comments

Comments
 (0)