From 527e55bfbf07b233a9ec906142c0b0d729f6ebf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Kov=C3=A1=C5=99?= Date: Fri, 15 Feb 2019 16:23:05 +0100 Subject: [PATCH 1/5] add Prune operations --- .../github/dockerjava/api/DockerClient.java | 78 ++-------- .../api/command/DockerCmdExecFactory.java | 7 + .../dockerjava/api/command/PruneCmd.java | 53 +++++++ .../dockerjava/api/model/PruneResponse.java | 64 ++++++++ .../dockerjava/api/model/PruneType.java | 9 ++ .../core/AbstractDockerCmdExecFactory.java | 142 +---------------- .../dockerjava/core/DockerClientImpl.java | 143 +----------------- .../dockerjava/core/command/PruneCmdImpl.java | 102 +++++++++++++ .../dockerjava/core/exec/PruneCmdExec.java | 40 +++++ .../dockerjava/core/util/FiltersBuilder.java | 30 ++++ .../jaxrs/JerseyDockerCmdExecFactory.java | 74 +-------- .../github/dockerjava/jaxrs/PruneCmdExec.java | 39 +++++ .../core/TestDockerCmdExecFactory.java | 77 +--------- 13 files changed, 380 insertions(+), 478 deletions(-) create mode 100644 src/main/java/com/github/dockerjava/api/command/PruneCmd.java create mode 100644 src/main/java/com/github/dockerjava/api/model/PruneResponse.java create mode 100644 src/main/java/com/github/dockerjava/api/model/PruneType.java create mode 100644 src/main/java/com/github/dockerjava/core/command/PruneCmdImpl.java create mode 100644 src/main/java/com/github/dockerjava/core/exec/PruneCmdExec.java create mode 100644 src/main/java/com/github/dockerjava/jaxrs/PruneCmdExec.java diff --git a/src/main/java/com/github/dockerjava/api/DockerClient.java b/src/main/java/com/github/dockerjava/api/DockerClient.java index 24ed54dcf..2e810da95 100644 --- a/src/main/java/com/github/dockerjava/api/DockerClient.java +++ b/src/main/java/com/github/dockerjava/api/DockerClient.java @@ -1,75 +1,8 @@ package com.github.dockerjava.api; -import com.github.dockerjava.api.command.AttachContainerCmd; -import com.github.dockerjava.api.command.AuthCmd; -import com.github.dockerjava.api.command.BuildImageCmd; -import com.github.dockerjava.api.command.CommitCmd; -import com.github.dockerjava.api.command.ConnectToNetworkCmd; -import com.github.dockerjava.api.command.ContainerDiffCmd; -import com.github.dockerjava.api.command.CopyArchiveFromContainerCmd; -import com.github.dockerjava.api.command.CopyArchiveToContainerCmd; -import com.github.dockerjava.api.command.CopyFileFromContainerCmd; -import com.github.dockerjava.api.command.CreateContainerCmd; -import com.github.dockerjava.api.command.CreateImageCmd; -import com.github.dockerjava.api.command.CreateNetworkCmd; -import com.github.dockerjava.api.command.CreateServiceCmd; -import com.github.dockerjava.api.command.CreateVolumeCmd; -import com.github.dockerjava.api.command.DisconnectFromNetworkCmd; -import com.github.dockerjava.api.command.EventsCmd; -import com.github.dockerjava.api.command.ExecCreateCmd; -import com.github.dockerjava.api.command.ExecStartCmd; -import com.github.dockerjava.api.command.InfoCmd; -import com.github.dockerjava.api.command.InitializeSwarmCmd; -import com.github.dockerjava.api.command.InspectContainerCmd; -import com.github.dockerjava.api.command.InspectExecCmd; -import com.github.dockerjava.api.command.InspectImageCmd; -import com.github.dockerjava.api.command.InspectNetworkCmd; -import com.github.dockerjava.api.command.InspectServiceCmd; -import com.github.dockerjava.api.command.InspectSwarmCmd; -import com.github.dockerjava.api.command.InspectVolumeCmd; -import com.github.dockerjava.api.command.JoinSwarmCmd; -import com.github.dockerjava.api.command.KillContainerCmd; -import com.github.dockerjava.api.command.LeaveSwarmCmd; -import com.github.dockerjava.api.command.ListContainersCmd; -import com.github.dockerjava.api.command.ListImagesCmd; -import com.github.dockerjava.api.command.ListNetworksCmd; -import com.github.dockerjava.api.command.ListServicesCmd; -import com.github.dockerjava.api.command.ListSwarmNodesCmd; -import com.github.dockerjava.api.command.ListTasksCmd; -import com.github.dockerjava.api.command.ListVolumesCmd; -import com.github.dockerjava.api.command.LoadImageCmd; -import com.github.dockerjava.api.command.LogContainerCmd; -import com.github.dockerjava.api.command.LogSwarmObjectCmd; -import com.github.dockerjava.api.command.PauseContainerCmd; -import com.github.dockerjava.api.command.PingCmd; -import com.github.dockerjava.api.command.PullImageCmd; -import com.github.dockerjava.api.command.PushImageCmd; -import com.github.dockerjava.api.command.RemoveContainerCmd; -import com.github.dockerjava.api.command.RemoveImageCmd; -import com.github.dockerjava.api.command.RemoveNetworkCmd; -import com.github.dockerjava.api.command.RemoveServiceCmd; -import com.github.dockerjava.api.command.RemoveVolumeCmd; -import com.github.dockerjava.api.command.RenameContainerCmd; -import com.github.dockerjava.api.command.RestartContainerCmd; -import com.github.dockerjava.api.command.SaveImageCmd; -import com.github.dockerjava.api.command.SearchImagesCmd; -import com.github.dockerjava.api.command.StartContainerCmd; -import com.github.dockerjava.api.command.StatsCmd; -import com.github.dockerjava.api.command.StopContainerCmd; -import com.github.dockerjava.api.command.TagImageCmd; -import com.github.dockerjava.api.command.TopContainerCmd; -import com.github.dockerjava.api.command.UnpauseContainerCmd; -import com.github.dockerjava.api.command.UpdateContainerCmd; -import com.github.dockerjava.api.command.UpdateServiceCmd; -import com.github.dockerjava.api.command.UpdateSwarmCmd; -import com.github.dockerjava.api.command.UpdateSwarmNodeCmd; -import com.github.dockerjava.api.command.VersionCmd; -import com.github.dockerjava.api.command.WaitContainerCmd; +import com.github.dockerjava.api.command.*; import com.github.dockerjava.api.exception.DockerException; -import com.github.dockerjava.api.model.AuthConfig; -import com.github.dockerjava.api.model.Identifier; -import com.github.dockerjava.api.model.ServiceSpec; -import com.github.dockerjava.api.model.SwarmSpec; +import com.github.dockerjava.api.model.*; import com.github.dockerjava.core.RemoteApiVersion; import javax.annotation.Nonnull; @@ -391,6 +324,13 @@ public interface DockerClient extends Closeable { */ LogSwarmObjectCmd logTaskCmd(String taskId); + /** + * Command to delete unused containers + * + * @since {@link RemoteApiVersion#VERSION_1_25} + */ + PruneCmd createPruneContainersCmd(PruneType pruneType); + @Override void close() throws IOException; diff --git a/src/main/java/com/github/dockerjava/api/command/DockerCmdExecFactory.java b/src/main/java/com/github/dockerjava/api/command/DockerCmdExecFactory.java index 3392ce372..f9c142255 100644 --- a/src/main/java/com/github/dockerjava/api/command/DockerCmdExecFactory.java +++ b/src/main/java/com/github/dockerjava/api/command/DockerCmdExecFactory.java @@ -207,6 +207,13 @@ public interface DockerCmdExecFactory extends Closeable { */ ListTasksCmd.Exec listTasksCmdExec(); + /** + * Delete unused content (containers, images, volumes, networks, build relicts) + * + * @since {@link RemoteApiVersion#VERSION_1_25} + */ + PruneCmd.Exec pruneCmdExec(); + @Override void close() throws IOException; diff --git a/src/main/java/com/github/dockerjava/api/command/PruneCmd.java b/src/main/java/com/github/dockerjava/api/command/PruneCmd.java new file mode 100644 index 000000000..23bca4879 --- /dev/null +++ b/src/main/java/com/github/dockerjava/api/command/PruneCmd.java @@ -0,0 +1,53 @@ +package com.github.dockerjava.api.command; + +import com.github.dockerjava.api.model.PruneResponse; +import com.github.dockerjava.api.model.PruneType; +import com.github.dockerjava.core.RemoteApiVersion; + +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; +import java.util.List; +import java.util.Map; + +/** + * Delete unused content (containers, images, volumes, networks, build relicts) + * + * @since {@link RemoteApiVersion#VERSION_1_25} + */ +public interface PruneCmd extends SyncDockerCmd { + + @Nonnull + PruneType getPruneType(); + + @Nonnull + String getApiPath(); + + @CheckForNull + Map> getFilters(); + + PruneCmd withPruneType(final PruneType pruneType); + /** + * Prune containers created before this timestamp + * Meaningful only for CONTAINERS and IMAGES prune type + * @param until Can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. 10m, 1h30m) computed relative to the daemon machine’s time. + */ + PruneCmd withUntilFilter(String until); + + /** + * When set to true, prune only unused and untagged images. When set to false, all unused images are pruned. + * Meaningful only for IMAGES prune type + */ + PruneCmd withDangling(Boolean dangling); + + /** + * Prune containers with the specified labels + */ + PruneCmd withLabelFilter(String... label); + + @Override + PruneResponse exec(); + + interface Exec extends DockerCmdSyncExec { + } + +} diff --git a/src/main/java/com/github/dockerjava/api/model/PruneResponse.java b/src/main/java/com/github/dockerjava/api/model/PruneResponse.java new file mode 100644 index 000000000..ceee08d8a --- /dev/null +++ b/src/main/java/com/github/dockerjava/api/model/PruneResponse.java @@ -0,0 +1,64 @@ +package com.github.dockerjava.api.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; + +import java.io.Serializable; + +/** + * Delete unused content (containers, images, volumes, networks, build relicts) + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class PruneResponse implements Serializable { + private static final long serialVersionUID = 1L; + + @JsonProperty("SpaceReclaimed") + private Long spaceReclaimed; + + /** + * Default constructor for the deserialization. + */ + public PruneResponse() { + } + + /** + * Constructor. + * + * @param spaceReclaimed Space reclaimed after purification + */ + public PruneResponse(Long spaceReclaimed) { + this.spaceReclaimed = spaceReclaimed; + } + + /** + * Disk space reclaimed in bytes + */ + public Long getSpaceReclaimed() { + return spaceReclaimed; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("PruneResponse {"); + sb.append(" spaceReclaimed: ").append(getSpaceReclaimed()); + sb.append("}"); + return sb.toString(); + } + + @Override + public boolean equals(Object o) { + if (o instanceof Ulimit) { + Ulimit other = (Ulimit) o; + return new EqualsBuilder().append(spaceReclaimed, other.getName()).isEquals(); + } else + return super.equals(o); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(spaceReclaimed).toHashCode(); + } +} diff --git a/src/main/java/com/github/dockerjava/api/model/PruneType.java b/src/main/java/com/github/dockerjava/api/model/PruneType.java new file mode 100644 index 000000000..10d8704fd --- /dev/null +++ b/src/main/java/com/github/dockerjava/api/model/PruneType.java @@ -0,0 +1,9 @@ +package com.github.dockerjava.api.model; + +public enum PruneType { + BUILD, + CONTAINERS, + IMAGES, + NETWORKS, + VOLUMES +} diff --git a/src/main/java/com/github/dockerjava/core/AbstractDockerCmdExecFactory.java b/src/main/java/com/github/dockerjava/core/AbstractDockerCmdExecFactory.java index 91347de2b..be493c623 100644 --- a/src/main/java/com/github/dockerjava/core/AbstractDockerCmdExecFactory.java +++ b/src/main/java/com/github/dockerjava/core/AbstractDockerCmdExecFactory.java @@ -1,140 +1,7 @@ package com.github.dockerjava.core; -import com.github.dockerjava.api.command.AttachContainerCmd; -import com.github.dockerjava.api.command.AuthCmd; -import com.github.dockerjava.api.command.BuildImageCmd; -import com.github.dockerjava.api.command.CommitCmd; -import com.github.dockerjava.api.command.ConnectToNetworkCmd; -import com.github.dockerjava.api.command.ContainerDiffCmd; -import com.github.dockerjava.api.command.CopyArchiveFromContainerCmd; -import com.github.dockerjava.api.command.CopyArchiveToContainerCmd; -import com.github.dockerjava.api.command.CopyFileFromContainerCmd; -import com.github.dockerjava.api.command.CreateContainerCmd; -import com.github.dockerjava.api.command.CreateImageCmd; -import com.github.dockerjava.api.command.CreateNetworkCmd; -import com.github.dockerjava.api.command.CreateServiceCmd; -import com.github.dockerjava.api.command.CreateVolumeCmd; -import com.github.dockerjava.api.command.DisconnectFromNetworkCmd; -import com.github.dockerjava.api.command.DockerCmdExecFactory; -import com.github.dockerjava.api.command.EventsCmd; -import com.github.dockerjava.api.command.ExecCreateCmd; -import com.github.dockerjava.api.command.ExecStartCmd; -import com.github.dockerjava.api.command.InfoCmd; -import com.github.dockerjava.api.command.InitializeSwarmCmd; -import com.github.dockerjava.api.command.InspectContainerCmd; -import com.github.dockerjava.api.command.InspectExecCmd; -import com.github.dockerjava.api.command.InspectImageCmd; -import com.github.dockerjava.api.command.InspectNetworkCmd; -import com.github.dockerjava.api.command.InspectServiceCmd; -import com.github.dockerjava.api.command.InspectSwarmCmd; -import com.github.dockerjava.api.command.InspectSwarmNodeCmd; -import com.github.dockerjava.api.command.InspectVolumeCmd; -import com.github.dockerjava.api.command.JoinSwarmCmd; -import com.github.dockerjava.api.command.KillContainerCmd; -import com.github.dockerjava.api.command.LeaveSwarmCmd; -import com.github.dockerjava.api.command.ListContainersCmd; -import com.github.dockerjava.api.command.ListImagesCmd; -import com.github.dockerjava.api.command.ListNetworksCmd; -import com.github.dockerjava.api.command.ListServicesCmd; -import com.github.dockerjava.api.command.ListSwarmNodesCmd; -import com.github.dockerjava.api.command.ListTasksCmd; -import com.github.dockerjava.api.command.ListVolumesCmd; -import com.github.dockerjava.api.command.LoadImageCmd; -import com.github.dockerjava.api.command.LogContainerCmd; -import com.github.dockerjava.api.command.LogSwarmObjectCmd; -import com.github.dockerjava.api.command.PauseContainerCmd; -import com.github.dockerjava.api.command.PingCmd; -import com.github.dockerjava.api.command.PullImageCmd; -import com.github.dockerjava.api.command.PushImageCmd; -import com.github.dockerjava.api.command.RemoveContainerCmd; -import com.github.dockerjava.api.command.RemoveImageCmd; -import com.github.dockerjava.api.command.RemoveNetworkCmd; -import com.github.dockerjava.api.command.RemoveServiceCmd; -import com.github.dockerjava.api.command.RemoveSwarmNodeCmd; -import com.github.dockerjava.api.command.RemoveVolumeCmd; -import com.github.dockerjava.api.command.RenameContainerCmd; -import com.github.dockerjava.api.command.RestartContainerCmd; -import com.github.dockerjava.api.command.SaveImageCmd; -import com.github.dockerjava.api.command.SearchImagesCmd; -import com.github.dockerjava.api.command.StartContainerCmd; -import com.github.dockerjava.api.command.StatsCmd; -import com.github.dockerjava.api.command.StopContainerCmd; -import com.github.dockerjava.api.command.TagImageCmd; -import com.github.dockerjava.api.command.TopContainerCmd; -import com.github.dockerjava.api.command.UnpauseContainerCmd; -import com.github.dockerjava.api.command.UpdateContainerCmd; -import com.github.dockerjava.api.command.UpdateServiceCmd; -import com.github.dockerjava.api.command.UpdateSwarmCmd; -import com.github.dockerjava.api.command.UpdateSwarmNodeCmd; -import com.github.dockerjava.api.command.VersionCmd; -import com.github.dockerjava.api.command.WaitContainerCmd; -import com.github.dockerjava.core.exec.AttachContainerCmdExec; -import com.github.dockerjava.core.exec.AuthCmdExec; -import com.github.dockerjava.core.exec.BuildImageCmdExec; -import com.github.dockerjava.core.exec.CommitCmdExec; -import com.github.dockerjava.core.exec.ConnectToNetworkCmdExec; -import com.github.dockerjava.core.exec.ContainerDiffCmdExec; -import com.github.dockerjava.core.exec.CopyArchiveFromContainerCmdExec; -import com.github.dockerjava.core.exec.CopyArchiveToContainerCmdExec; -import com.github.dockerjava.core.exec.CopyFileFromContainerCmdExec; -import com.github.dockerjava.core.exec.CreateContainerCmdExec; -import com.github.dockerjava.core.exec.CreateImageCmdExec; -import com.github.dockerjava.core.exec.CreateNetworkCmdExec; -import com.github.dockerjava.core.exec.CreateServiceCmdExec; -import com.github.dockerjava.core.exec.CreateVolumeCmdExec; -import com.github.dockerjava.core.exec.DisconnectFromNetworkCmdExec; -import com.github.dockerjava.core.exec.EventsCmdExec; -import com.github.dockerjava.core.exec.ExecCreateCmdExec; -import com.github.dockerjava.core.exec.ExecStartCmdExec; -import com.github.dockerjava.core.exec.InfoCmdExec; -import com.github.dockerjava.core.exec.InitializeSwarmCmdExec; -import com.github.dockerjava.core.exec.InspectContainerCmdExec; -import com.github.dockerjava.core.exec.InspectExecCmdExec; -import com.github.dockerjava.core.exec.InspectImageCmdExec; -import com.github.dockerjava.core.exec.InspectNetworkCmdExec; -import com.github.dockerjava.core.exec.InspectServiceCmdExec; -import com.github.dockerjava.core.exec.InspectSwarmCmdExec; -import com.github.dockerjava.core.exec.InspectSwarmNodeCmdExec; -import com.github.dockerjava.core.exec.InspectVolumeCmdExec; -import com.github.dockerjava.core.exec.JoinSwarmCmdExec; -import com.github.dockerjava.core.exec.KillContainerCmdExec; -import com.github.dockerjava.core.exec.LeaveSwarmCmdExec; -import com.github.dockerjava.core.exec.ListContainersCmdExec; -import com.github.dockerjava.core.exec.ListImagesCmdExec; -import com.github.dockerjava.core.exec.ListNetworksCmdExec; -import com.github.dockerjava.core.exec.ListServicesCmdExec; -import com.github.dockerjava.core.exec.ListSwarmNodesCmdExec; -import com.github.dockerjava.core.exec.ListTasksCmdExec; -import com.github.dockerjava.core.exec.ListVolumesCmdExec; -import com.github.dockerjava.core.exec.LoadImageCmdExec; -import com.github.dockerjava.core.exec.LogContainerCmdExec; -import com.github.dockerjava.core.exec.PauseContainerCmdExec; -import com.github.dockerjava.core.exec.PingCmdExec; -import com.github.dockerjava.core.exec.PullImageCmdExec; -import com.github.dockerjava.core.exec.PushImageCmdExec; -import com.github.dockerjava.core.exec.RemoveContainerCmdExec; -import com.github.dockerjava.core.exec.RemoveImageCmdExec; -import com.github.dockerjava.core.exec.RemoveNetworkCmdExec; -import com.github.dockerjava.core.exec.RemoveServiceCmdExec; -import com.github.dockerjava.core.exec.RemoveSwarmNodeCmdExec; -import com.github.dockerjava.core.exec.RemoveVolumeCmdExec; -import com.github.dockerjava.core.exec.RenameContainerCmdExec; -import com.github.dockerjava.core.exec.RestartContainerCmdExec; -import com.github.dockerjava.core.exec.SaveImageCmdExec; -import com.github.dockerjava.core.exec.SearchImagesCmdExec; -import com.github.dockerjava.core.exec.StartContainerCmdExec; -import com.github.dockerjava.core.exec.StatsCmdExec; -import com.github.dockerjava.core.exec.StopContainerCmdExec; -import com.github.dockerjava.core.exec.TagImageCmdExec; -import com.github.dockerjava.core.exec.TopContainerCmdExec; -import com.github.dockerjava.core.exec.UnpauseContainerCmdExec; -import com.github.dockerjava.core.exec.UpdateContainerCmdExec; -import com.github.dockerjava.core.exec.UpdateServiceCmdExec; -import com.github.dockerjava.core.exec.UpdateSwarmCmdExec; -import com.github.dockerjava.core.exec.UpdateSwarmNodeCmdExec; -import com.github.dockerjava.core.exec.VersionCmdExec; -import com.github.dockerjava.core.exec.WaitContainerCmdExec; -import com.github.dockerjava.core.exec.LogSwarmObjectExec; +import com.github.dockerjava.api.command.*; +import com.github.dockerjava.core.exec.*; import static com.google.common.base.Preconditions.checkNotNull; @@ -492,5 +359,10 @@ public LogSwarmObjectCmd.Exec logSwarmObjectExec(String endpoint) { return new LogSwarmObjectExec(getBaseResource(), getDockerClientConfig(), endpoint); } + @Override + public PruneCmd.Exec pruneCmdExec() { + return new PruneCmdExec(getBaseResource(), getDockerClientConfig()); + } + protected abstract WebTarget getBaseResource(); } diff --git a/src/main/java/com/github/dockerjava/core/DockerClientImpl.java b/src/main/java/com/github/dockerjava/core/DockerClientImpl.java index edc634cb9..efe617b64 100644 --- a/src/main/java/com/github/dockerjava/core/DockerClientImpl.java +++ b/src/main/java/com/github/dockerjava/core/DockerClientImpl.java @@ -1,141 +1,9 @@ package com.github.dockerjava.core; import com.github.dockerjava.api.DockerClient; -import com.github.dockerjava.api.command.AttachContainerCmd; -import com.github.dockerjava.api.command.AuthCmd; -import com.github.dockerjava.api.command.BuildImageCmd; -import com.github.dockerjava.api.command.CommitCmd; -import com.github.dockerjava.api.command.ConnectToNetworkCmd; -import com.github.dockerjava.api.command.ContainerDiffCmd; -import com.github.dockerjava.api.command.CopyArchiveFromContainerCmd; -import com.github.dockerjava.api.command.CopyArchiveToContainerCmd; -import com.github.dockerjava.api.command.CopyFileFromContainerCmd; -import com.github.dockerjava.api.command.CreateContainerCmd; -import com.github.dockerjava.api.command.CreateImageCmd; -import com.github.dockerjava.api.command.CreateNetworkCmd; -import com.github.dockerjava.api.command.CreateServiceCmd; -import com.github.dockerjava.api.command.CreateVolumeCmd; -import com.github.dockerjava.api.command.DisconnectFromNetworkCmd; -import com.github.dockerjava.api.command.DockerCmdExecFactory; -import com.github.dockerjava.api.command.EventsCmd; -import com.github.dockerjava.api.command.ExecCreateCmd; -import com.github.dockerjava.api.command.ExecStartCmd; -import com.github.dockerjava.api.command.InfoCmd; -import com.github.dockerjava.api.command.InitializeSwarmCmd; -import com.github.dockerjava.api.command.InspectContainerCmd; -import com.github.dockerjava.api.command.InspectExecCmd; -import com.github.dockerjava.api.command.InspectImageCmd; -import com.github.dockerjava.api.command.InspectNetworkCmd; -import com.github.dockerjava.api.command.InspectServiceCmd; -import com.github.dockerjava.api.command.InspectSwarmCmd; -import com.github.dockerjava.api.command.InspectVolumeCmd; -import com.github.dockerjava.api.command.JoinSwarmCmd; -import com.github.dockerjava.api.command.KillContainerCmd; -import com.github.dockerjava.api.command.LeaveSwarmCmd; -import com.github.dockerjava.api.command.ListContainersCmd; -import com.github.dockerjava.api.command.ListImagesCmd; -import com.github.dockerjava.api.command.ListNetworksCmd; -import com.github.dockerjava.api.command.ListServicesCmd; -import com.github.dockerjava.api.command.ListSwarmNodesCmd; -import com.github.dockerjava.api.command.ListTasksCmd; -import com.github.dockerjava.api.command.ListVolumesCmd; -import com.github.dockerjava.api.command.LoadImageCmd; -import com.github.dockerjava.api.command.LogContainerCmd; -import com.github.dockerjava.api.command.LogSwarmObjectCmd; -import com.github.dockerjava.api.command.PauseContainerCmd; -import com.github.dockerjava.api.command.PingCmd; -import com.github.dockerjava.api.command.PullImageCmd; -import com.github.dockerjava.api.command.PushImageCmd; -import com.github.dockerjava.api.command.RemoveContainerCmd; -import com.github.dockerjava.api.command.RemoveImageCmd; -import com.github.dockerjava.api.command.RemoveNetworkCmd; -import com.github.dockerjava.api.command.RemoveServiceCmd; -import com.github.dockerjava.api.command.RemoveVolumeCmd; -import com.github.dockerjava.api.command.RenameContainerCmd; -import com.github.dockerjava.api.command.RestartContainerCmd; -import com.github.dockerjava.api.command.SaveImageCmd; -import com.github.dockerjava.api.command.SearchImagesCmd; -import com.github.dockerjava.api.command.StartContainerCmd; -import com.github.dockerjava.api.command.StatsCmd; -import com.github.dockerjava.api.command.StopContainerCmd; -import com.github.dockerjava.api.command.TagImageCmd; -import com.github.dockerjava.api.command.TopContainerCmd; -import com.github.dockerjava.api.command.UnpauseContainerCmd; -import com.github.dockerjava.api.command.UpdateContainerCmd; -import com.github.dockerjava.api.command.UpdateServiceCmd; -import com.github.dockerjava.api.command.UpdateSwarmCmd; -import com.github.dockerjava.api.command.UpdateSwarmNodeCmd; -import com.github.dockerjava.api.command.VersionCmd; -import com.github.dockerjava.api.command.WaitContainerCmd; -import com.github.dockerjava.api.model.AuthConfig; -import com.github.dockerjava.api.model.Identifier; -import com.github.dockerjava.api.model.ServiceSpec; -import com.github.dockerjava.api.model.SwarmSpec; -import com.github.dockerjava.core.command.AttachContainerCmdImpl; -import com.github.dockerjava.core.command.AuthCmdImpl; -import com.github.dockerjava.core.command.BuildImageCmdImpl; -import com.github.dockerjava.core.command.CommitCmdImpl; -import com.github.dockerjava.core.command.ConnectToNetworkCmdImpl; -import com.github.dockerjava.core.command.ContainerDiffCmdImpl; -import com.github.dockerjava.core.command.CopyArchiveFromContainerCmdImpl; -import com.github.dockerjava.core.command.CopyArchiveToContainerCmdImpl; -import com.github.dockerjava.core.command.CopyFileFromContainerCmdImpl; -import com.github.dockerjava.core.command.CreateContainerCmdImpl; -import com.github.dockerjava.core.command.CreateImageCmdImpl; -import com.github.dockerjava.core.command.CreateNetworkCmdImpl; -import com.github.dockerjava.core.command.CreateServiceCmdImpl; -import com.github.dockerjava.core.command.CreateVolumeCmdImpl; -import com.github.dockerjava.core.command.DisconnectFromNetworkCmdImpl; -import com.github.dockerjava.core.command.EventsCmdImpl; -import com.github.dockerjava.core.command.ExecCreateCmdImpl; -import com.github.dockerjava.core.command.ExecStartCmdImpl; -import com.github.dockerjava.core.command.InfoCmdImpl; -import com.github.dockerjava.core.command.InitializeSwarmCmdImpl; -import com.github.dockerjava.core.command.InpectNetworkCmdImpl; -import com.github.dockerjava.core.command.InspectContainerCmdImpl; -import com.github.dockerjava.core.command.InspectExecCmdImpl; -import com.github.dockerjava.core.command.InspectImageCmdImpl; -import com.github.dockerjava.core.command.InspectServiceCmdImpl; -import com.github.dockerjava.core.command.InspectSwarmCmdImpl; -import com.github.dockerjava.core.command.InspectVolumeCmdImpl; -import com.github.dockerjava.core.command.JoinSwarmCmdImpl; -import com.github.dockerjava.core.command.KillContainerCmdImpl; -import com.github.dockerjava.core.command.LeaveSwarmCmdImpl; -import com.github.dockerjava.core.command.ListContainersCmdImpl; -import com.github.dockerjava.core.command.ListImagesCmdImpl; -import com.github.dockerjava.core.command.ListNetworksCmdImpl; -import com.github.dockerjava.core.command.ListServicesCmdImpl; -import com.github.dockerjava.core.command.ListSwarmNodesCmdImpl; -import com.github.dockerjava.core.command.ListTasksCmdImpl; -import com.github.dockerjava.core.command.ListVolumesCmdImpl; -import com.github.dockerjava.core.command.LoadImageCmdImpl; -import com.github.dockerjava.core.command.LogContainerCmdImpl; -import com.github.dockerjava.core.command.LogSwarmObjectImpl; -import com.github.dockerjava.core.command.PauseContainerCmdImpl; -import com.github.dockerjava.core.command.PingCmdImpl; -import com.github.dockerjava.core.command.PullImageCmdImpl; -import com.github.dockerjava.core.command.PushImageCmdImpl; -import com.github.dockerjava.core.command.RemoveContainerCmdImpl; -import com.github.dockerjava.core.command.RemoveImageCmdImpl; -import com.github.dockerjava.core.command.RemoveNetworkCmdImpl; -import com.github.dockerjava.core.command.RemoveServiceCmdImpl; -import com.github.dockerjava.core.command.RemoveVolumeCmdImpl; -import com.github.dockerjava.core.command.RenameContainerCmdImpl; -import com.github.dockerjava.core.command.RestartContainerCmdImpl; -import com.github.dockerjava.core.command.SaveImageCmdImpl; -import com.github.dockerjava.core.command.SearchImagesCmdImpl; -import com.github.dockerjava.core.command.StartContainerCmdImpl; -import com.github.dockerjava.core.command.StatsCmdImpl; -import com.github.dockerjava.core.command.StopContainerCmdImpl; -import com.github.dockerjava.core.command.TagImageCmdImpl; -import com.github.dockerjava.core.command.TopContainerCmdImpl; -import com.github.dockerjava.core.command.UnpauseContainerCmdImpl; -import com.github.dockerjava.core.command.UpdateContainerCmdImpl; -import com.github.dockerjava.core.command.UpdateServiceCmdImpl; -import com.github.dockerjava.core.command.UpdateSwarmCmdImpl; -import com.github.dockerjava.core.command.UpdateSwarmNodeCmdImpl; -import com.github.dockerjava.core.command.VersionCmdImpl; -import com.github.dockerjava.core.command.WaitContainerCmdImpl; +import com.github.dockerjava.api.command.*; +import com.github.dockerjava.api.model.*; +import com.github.dockerjava.core.command.*; import javax.annotation.Nonnull; import java.io.Closeable; @@ -579,6 +447,11 @@ public LogSwarmObjectCmd logTaskCmd(String taskId) { return new LogSwarmObjectImpl(getDockerCmdExecFactory().logSwarmObjectExec("tasks"), taskId); } + @Override + public PruneCmd createPruneContainersCmd(PruneType pruneType) { + return new PruneCmdImpl(getDockerCmdExecFactory().pruneCmdExec(), pruneType); + } + @Override public ListTasksCmd listTasksCmd() { return new ListTasksCmdImpl(getDockerCmdExecFactory().listTasksCmdExec()); diff --git a/src/main/java/com/github/dockerjava/core/command/PruneCmdImpl.java b/src/main/java/com/github/dockerjava/core/command/PruneCmdImpl.java new file mode 100644 index 000000000..a191099ed --- /dev/null +++ b/src/main/java/com/github/dockerjava/core/command/PruneCmdImpl.java @@ -0,0 +1,102 @@ +package com.github.dockerjava.core.command; + +import com.github.dockerjava.api.command.PruneCmd; +import com.github.dockerjava.api.model.PruneResponse; +import com.github.dockerjava.api.model.PruneType; +import com.github.dockerjava.core.util.FiltersBuilder; + +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; +import java.util.List; +import java.util.Map; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Delete unused content (containers, images, volumes, networks, build relicts) + */ +public class PruneCmdImpl extends AbstrDockerCmd implements PruneCmd { + + private static final String BUILD_API_PATH = "/build/prune"; + private static final String CONTAINERS_API_PATH = "/containers/prune"; + private static final String IMAGES_API_PATH = "/images/prune"; + private static final String VOLUMES_API_PATH = "/volumes/prune"; + private static final String NETWORKS_API_PATH = "/networks/prune"; + + private FiltersBuilder filters = new FiltersBuilder(); + private PruneType pruneType; + + public PruneCmdImpl(Exec exec, PruneType pruneType) { + super(exec); + this.pruneType = pruneType; + } + + @Nonnull + @Override + public PruneType getPruneType() { + return pruneType; + } + + @Nonnull + @Override + public String getApiPath() { + String apiPath; + switch (getPruneType()) { + case BUILD: + apiPath = BUILD_API_PATH; + break; + case IMAGES: + apiPath = IMAGES_API_PATH; + break; + case NETWORKS: + apiPath = NETWORKS_API_PATH; + break; + case VOLUMES: + apiPath = VOLUMES_API_PATH; + break; + default: + apiPath = CONTAINERS_API_PATH; + break; + } + return apiPath; + } + + @CheckForNull + @Override + public Map> getFilters() { + return filters.build(); + } + + @Override + public PruneCmd withPruneType(final PruneType pruneType) { + checkNotNull(pruneType, "pruneType has not been specified"); + this.pruneType = pruneType; + return this; + } + + @Override + public PruneCmd withDangling(Boolean dangling) { + checkNotNull(dangling, "dangling has not been specified"); + filters.withFilter("dangling", dangling ? "1" : "0"); + return this; + } + + @Override + public PruneCmd withUntilFilter(final String until) { + checkNotNull(until, "until has not been specified"); + filters.withUntil(until); + return this; + } + + @Override + public PruneCmd withLabelFilter(final String... labels) { + checkNotNull(labels, "labels have not been specified"); + filters.withLabels(labels); + return this; + } + + @Override + public PruneResponse exec() { + return super.exec(); + } +} diff --git a/src/main/java/com/github/dockerjava/core/exec/PruneCmdExec.java b/src/main/java/com/github/dockerjava/core/exec/PruneCmdExec.java new file mode 100644 index 000000000..ef28e5586 --- /dev/null +++ b/src/main/java/com/github/dockerjava/core/exec/PruneCmdExec.java @@ -0,0 +1,40 @@ +package com.github.dockerjava.core.exec; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.github.dockerjava.api.command.PruneCmd; +import com.github.dockerjava.api.model.PruneResponse; +import com.github.dockerjava.core.DockerClientConfig; +import com.github.dockerjava.core.MediaType; +import com.github.dockerjava.core.WebTarget; +import com.github.dockerjava.core.util.FiltersEncoder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class PruneCmdExec extends AbstrSyncDockerCmdExec implements PruneCmd.Exec { + + private static final Logger LOGGER = LoggerFactory.getLogger(PruneCmdExec.class); + + + public PruneCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) { + super(baseResource, dockerClientConfig); + } + + @Override + protected PruneResponse execute(PruneCmd command) { + WebTarget webTarget = getBaseResource().path(command.getApiPath()); + + if (command.getFilters() != null && !command.getFilters().isEmpty()) { + webTarget = webTarget.queryParam("filters", FiltersEncoder.jsonEncode(command.getFilters())); + } + + LOGGER.trace("POST: {}", webTarget); + + PruneResponse response = webTarget.request().accept(MediaType.APPLICATION_JSON) + .post(null, new TypeReference() {}); + + LOGGER.trace("Response: {}", response); + + return response; + } + +} diff --git a/src/main/java/com/github/dockerjava/core/util/FiltersBuilder.java b/src/main/java/com/github/dockerjava/core/util/FiltersBuilder.java index 0c414f983..8ec85dee2 100644 --- a/src/main/java/com/github/dockerjava/core/util/FiltersBuilder.java +++ b/src/main/java/com/github/dockerjava/core/util/FiltersBuilder.java @@ -1,5 +1,7 @@ package com.github.dockerjava.core.util; +import com.google.common.base.Strings; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -7,6 +9,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.regex.Pattern; /** * Representation of Docker filters. @@ -16,6 +19,13 @@ */ public class FiltersBuilder { + private static final Pattern UNTIL_TIMESTAMP_PATTERN = + Pattern.compile("^\\d{1,10}$"); + private static final Pattern UNTIL_DATETIME_PATTERN = + Pattern.compile("^([0-9]+)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])([Tt]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\\.[0-9]+)?)?(([Zz])|([\\+|\\-]([01][0-9]|2[0-3]):[0-5][0-9]))?$"); + private static final Pattern UNTIL_GO_PATTERN = + Pattern.compile("^([1-9][0-9]*h)?([1-9][0-9]*m)?([1-9][0-9]*s)?$"); + private Map> filters = new HashMap>(); public FiltersBuilder() { @@ -75,6 +85,14 @@ public FiltersBuilder withLabels(Map labels) { return this; } + public FiltersBuilder withUntil(String until) throws NumberFormatException { + if (!isValidUntil(until)) { + throw new NumberFormatException("Not valid format of 'until': " + until); + } + + return withFilter("until", until); + } + private static List labelsMapToList(Map labels) { List result = new ArrayList(); for (Entry entry : labels.entrySet()) { @@ -87,6 +105,18 @@ private static List labelsMapToList(Map labels) { return result; } + private boolean isValidUntil(String until) { + if (UNTIL_DATETIME_PATTERN.matcher(until).matches()) { + return true; + } else if (!Strings.isNullOrEmpty(until) && UNTIL_GO_PATTERN.matcher(until).matches()) { + return true; + } else if (UNTIL_TIMESTAMP_PATTERN.matcher(until).matches()) { + return true; + } + + return false; + } + // CHECKSTYLE:OFF @Override public boolean equals(Object o) { diff --git a/src/main/java/com/github/dockerjava/jaxrs/JerseyDockerCmdExecFactory.java b/src/main/java/com/github/dockerjava/jaxrs/JerseyDockerCmdExecFactory.java index 5712163d1..12c60090e 100644 --- a/src/main/java/com/github/dockerjava/jaxrs/JerseyDockerCmdExecFactory.java +++ b/src/main/java/com/github/dockerjava/jaxrs/JerseyDockerCmdExecFactory.java @@ -3,74 +3,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; -import com.github.dockerjava.api.command.AttachContainerCmd; -import com.github.dockerjava.api.command.AuthCmd; -import com.github.dockerjava.api.command.BuildImageCmd; -import com.github.dockerjava.api.command.CommitCmd; -import com.github.dockerjava.api.command.ConnectToNetworkCmd; -import com.github.dockerjava.api.command.ContainerDiffCmd; -import com.github.dockerjava.api.command.CopyArchiveFromContainerCmd; -import com.github.dockerjava.api.command.CopyArchiveToContainerCmd; -import com.github.dockerjava.api.command.CopyFileFromContainerCmd; -import com.github.dockerjava.api.command.CreateContainerCmd; -import com.github.dockerjava.api.command.CreateImageCmd; -import com.github.dockerjava.api.command.CreateNetworkCmd; -import com.github.dockerjava.api.command.CreateServiceCmd; -import com.github.dockerjava.api.command.CreateVolumeCmd; -import com.github.dockerjava.api.command.DisconnectFromNetworkCmd; -import com.github.dockerjava.api.command.DockerCmdExecFactory; -import com.github.dockerjava.api.command.EventsCmd; -import com.github.dockerjava.api.command.ExecCreateCmd; -import com.github.dockerjava.api.command.ExecStartCmd; -import com.github.dockerjava.api.command.InfoCmd; -import com.github.dockerjava.api.command.InitializeSwarmCmd; -import com.github.dockerjava.api.command.InspectContainerCmd; -import com.github.dockerjava.api.command.InspectExecCmd; -import com.github.dockerjava.api.command.InspectImageCmd; -import com.github.dockerjava.api.command.InspectNetworkCmd; -import com.github.dockerjava.api.command.InspectServiceCmd; -import com.github.dockerjava.api.command.InspectSwarmCmd; -import com.github.dockerjava.api.command.InspectSwarmNodeCmd; -import com.github.dockerjava.api.command.InspectVolumeCmd; -import com.github.dockerjava.api.command.JoinSwarmCmd; -import com.github.dockerjava.api.command.KillContainerCmd; -import com.github.dockerjava.api.command.LeaveSwarmCmd; -import com.github.dockerjava.api.command.ListContainersCmd; -import com.github.dockerjava.api.command.ListImagesCmd; -import com.github.dockerjava.api.command.ListNetworksCmd; -import com.github.dockerjava.api.command.ListServicesCmd; -import com.github.dockerjava.api.command.ListSwarmNodesCmd; -import com.github.dockerjava.api.command.ListTasksCmd; -import com.github.dockerjava.api.command.ListVolumesCmd; -import com.github.dockerjava.api.command.LoadImageCmd; -import com.github.dockerjava.api.command.LogContainerCmd; -import com.github.dockerjava.api.command.LogSwarmObjectCmd; -import com.github.dockerjava.api.command.PauseContainerCmd; -import com.github.dockerjava.api.command.PingCmd; -import com.github.dockerjava.api.command.PullImageCmd; -import com.github.dockerjava.api.command.PushImageCmd; -import com.github.dockerjava.api.command.RemoveContainerCmd; -import com.github.dockerjava.api.command.RemoveImageCmd; -import com.github.dockerjava.api.command.RemoveNetworkCmd; -import com.github.dockerjava.api.command.RemoveServiceCmd; -import com.github.dockerjava.api.command.RemoveSwarmNodeCmd; -import com.github.dockerjava.api.command.RemoveVolumeCmd; -import com.github.dockerjava.api.command.RenameContainerCmd; -import com.github.dockerjava.api.command.RestartContainerCmd; -import com.github.dockerjava.api.command.SaveImageCmd; -import com.github.dockerjava.api.command.SearchImagesCmd; -import com.github.dockerjava.api.command.StartContainerCmd; -import com.github.dockerjava.api.command.StatsCmd; -import com.github.dockerjava.api.command.StopContainerCmd; -import com.github.dockerjava.api.command.TagImageCmd; -import com.github.dockerjava.api.command.TopContainerCmd; -import com.github.dockerjava.api.command.UnpauseContainerCmd; -import com.github.dockerjava.api.command.UpdateContainerCmd; -import com.github.dockerjava.api.command.UpdateServiceCmd; -import com.github.dockerjava.api.command.UpdateSwarmCmd; -import com.github.dockerjava.api.command.UpdateSwarmNodeCmd; -import com.github.dockerjava.api.command.VersionCmd; -import com.github.dockerjava.api.command.WaitContainerCmd; +import com.github.dockerjava.api.command.*; import com.github.dockerjava.api.exception.DockerClientException; import com.github.dockerjava.core.DockerClientConfig; import com.github.dockerjava.core.SSLConfig; @@ -658,6 +591,11 @@ public ListTasksCmd.Exec listTasksCmdExec() { return new ListTasksCmdExec(getBaseResource(), getDockerClientConfig()); } + @Override + public PruneCmd.Exec pruneCmdExec() { + return new PruneCmdExec(getBaseResource(), getDockerClientConfig()); + } + @Override public void close() throws IOException { checkNotNull(client, "Factory not initialized. You probably forgot to call init()!"); diff --git a/src/main/java/com/github/dockerjava/jaxrs/PruneCmdExec.java b/src/main/java/com/github/dockerjava/jaxrs/PruneCmdExec.java new file mode 100644 index 000000000..0ef9c77a9 --- /dev/null +++ b/src/main/java/com/github/dockerjava/jaxrs/PruneCmdExec.java @@ -0,0 +1,39 @@ +package com.github.dockerjava.jaxrs; + +import com.github.dockerjava.api.command.PruneCmd; +import com.github.dockerjava.api.model.PruneResponse; +import com.github.dockerjava.core.DockerClientConfig; +import com.github.dockerjava.core.util.FiltersEncoder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.GenericType; +import javax.ws.rs.core.MediaType; + +public class PruneCmdExec extends AbstrSyncDockerCmdExec implements PruneCmd.Exec { + + private static final Logger LOGGER = LoggerFactory.getLogger(PruneCmdExec.class); + + public PruneCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) { + super(baseResource, dockerClientConfig); + } + + @Override + protected PruneResponse execute(PruneCmd command) { + WebTarget webTarget = getBaseResource().path(command.getApiPath()); + + if (command.getFilters() != null && !command.getFilters().isEmpty()) { + webTarget = webTarget.queryParam("filters", FiltersEncoder.jsonEncode(command.getFilters())); + } + + LOGGER.trace("POST: {}", webTarget); + + PruneResponse response = webTarget.request().accept(MediaType.APPLICATION_JSON) + .post(null, new GenericType() {}); + LOGGER.trace("Response: {}", response); + + return response; + } + +} diff --git a/src/test/java/com/github/dockerjava/core/TestDockerCmdExecFactory.java b/src/test/java/com/github/dockerjava/core/TestDockerCmdExecFactory.java index e2986ef69..dea7ead9f 100644 --- a/src/test/java/com/github/dockerjava/core/TestDockerCmdExecFactory.java +++ b/src/test/java/com/github/dockerjava/core/TestDockerCmdExecFactory.java @@ -1,78 +1,8 @@ package com.github.dockerjava.core; import com.github.dockerjava.api.async.ResultCallback; -import com.github.dockerjava.api.command.AttachContainerCmd; +import com.github.dockerjava.api.command.*; import com.github.dockerjava.api.command.AuthCmd.Exec; -import com.github.dockerjava.api.command.BuildImageCmd; -import com.github.dockerjava.api.command.CommitCmd; -import com.github.dockerjava.api.command.ConnectToNetworkCmd; -import com.github.dockerjava.api.command.ContainerDiffCmd; -import com.github.dockerjava.api.command.CopyArchiveFromContainerCmd; -import com.github.dockerjava.api.command.CopyArchiveToContainerCmd; -import com.github.dockerjava.api.command.CopyFileFromContainerCmd; -import com.github.dockerjava.api.command.CreateContainerCmd; -import com.github.dockerjava.api.command.CreateContainerResponse; -import com.github.dockerjava.api.command.CreateImageCmd; -import com.github.dockerjava.api.command.CreateImageResponse; -import com.github.dockerjava.api.command.CreateNetworkCmd; -import com.github.dockerjava.api.command.CreateNetworkResponse; -import com.github.dockerjava.api.command.CreateServiceCmd; -import com.github.dockerjava.api.command.CreateVolumeCmd; -import com.github.dockerjava.api.command.CreateVolumeResponse; -import com.github.dockerjava.api.command.DisconnectFromNetworkCmd; -import com.github.dockerjava.api.command.DockerCmdExecFactory; -import com.github.dockerjava.api.command.EventsCmd; -import com.github.dockerjava.api.command.ExecCreateCmd; -import com.github.dockerjava.api.command.ExecStartCmd; -import com.github.dockerjava.api.command.InfoCmd; -import com.github.dockerjava.api.command.InitializeSwarmCmd; -import com.github.dockerjava.api.command.InspectContainerCmd; -import com.github.dockerjava.api.command.InspectExecCmd; -import com.github.dockerjava.api.command.InspectImageCmd; -import com.github.dockerjava.api.command.InspectNetworkCmd; -import com.github.dockerjava.api.command.InspectServiceCmd; -import com.github.dockerjava.api.command.InspectSwarmCmd; -import com.github.dockerjava.api.command.InspectSwarmNodeCmd; -import com.github.dockerjava.api.command.InspectVolumeCmd; -import com.github.dockerjava.api.command.JoinSwarmCmd; -import com.github.dockerjava.api.command.KillContainerCmd; -import com.github.dockerjava.api.command.LeaveSwarmCmd; -import com.github.dockerjava.api.command.ListContainersCmd; -import com.github.dockerjava.api.command.ListImagesCmd; -import com.github.dockerjava.api.command.ListNetworksCmd; -import com.github.dockerjava.api.command.ListServicesCmd; -import com.github.dockerjava.api.command.ListSwarmNodesCmd; -import com.github.dockerjava.api.command.ListTasksCmd; -import com.github.dockerjava.api.command.ListVolumesCmd; -import com.github.dockerjava.api.command.LoadImageCmd; -import com.github.dockerjava.api.command.LogContainerCmd; -import com.github.dockerjava.api.command.LogSwarmObjectCmd; -import com.github.dockerjava.api.command.PauseContainerCmd; -import com.github.dockerjava.api.command.PingCmd; -import com.github.dockerjava.api.command.PullImageCmd; -import com.github.dockerjava.api.command.PushImageCmd; -import com.github.dockerjava.api.command.RemoveContainerCmd; -import com.github.dockerjava.api.command.RemoveImageCmd; -import com.github.dockerjava.api.command.RemoveNetworkCmd; -import com.github.dockerjava.api.command.RemoveServiceCmd; -import com.github.dockerjava.api.command.RemoveSwarmNodeCmd; -import com.github.dockerjava.api.command.RemoveVolumeCmd; -import com.github.dockerjava.api.command.RenameContainerCmd; -import com.github.dockerjava.api.command.RestartContainerCmd; -import com.github.dockerjava.api.command.SaveImageCmd; -import com.github.dockerjava.api.command.SearchImagesCmd; -import com.github.dockerjava.api.command.StartContainerCmd; -import com.github.dockerjava.api.command.StatsCmd; -import com.github.dockerjava.api.command.StopContainerCmd; -import com.github.dockerjava.api.command.TagImageCmd; -import com.github.dockerjava.api.command.TopContainerCmd; -import com.github.dockerjava.api.command.UnpauseContainerCmd; -import com.github.dockerjava.api.command.UpdateContainerCmd; -import com.github.dockerjava.api.command.UpdateServiceCmd; -import com.github.dockerjava.api.command.UpdateSwarmCmd; -import com.github.dockerjava.api.command.UpdateSwarmNodeCmd; -import com.github.dockerjava.api.command.VersionCmd; -import com.github.dockerjava.api.command.WaitContainerCmd; import com.github.dockerjava.api.model.BuildResponseItem; import java.io.IOException; @@ -526,6 +456,11 @@ public ListTasksCmd.Exec listTasksCmdExec() { return delegate.listTasksCmdExec(); } + @Override + public PruneCmd.Exec pruneCmdExec() { + return delegate.pruneCmdExec(); + } + public List getContainerNames() { return new ArrayList(containerNames); } From 9492fbff1c73d9e2a35948ca8e51be0438453195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Kov=C3=A1=C5=99?= Date: Mon, 18 Feb 2019 13:31:29 +0100 Subject: [PATCH 2/5] repair method name in DockerClient --- src/main/java/com/github/dockerjava/api/DockerClient.java | 2 +- src/main/java/com/github/dockerjava/core/DockerClientImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/dockerjava/api/DockerClient.java b/src/main/java/com/github/dockerjava/api/DockerClient.java index 2e810da95..13a4607f8 100644 --- a/src/main/java/com/github/dockerjava/api/DockerClient.java +++ b/src/main/java/com/github/dockerjava/api/DockerClient.java @@ -329,7 +329,7 @@ public interface DockerClient extends Closeable { * * @since {@link RemoteApiVersion#VERSION_1_25} */ - PruneCmd createPruneContainersCmd(PruneType pruneType); + PruneCmd pruneContainersCmd(PruneType pruneType); @Override void close() throws IOException; diff --git a/src/main/java/com/github/dockerjava/core/DockerClientImpl.java b/src/main/java/com/github/dockerjava/core/DockerClientImpl.java index efe617b64..39d2d8f95 100644 --- a/src/main/java/com/github/dockerjava/core/DockerClientImpl.java +++ b/src/main/java/com/github/dockerjava/core/DockerClientImpl.java @@ -448,7 +448,7 @@ public LogSwarmObjectCmd logTaskCmd(String taskId) { } @Override - public PruneCmd createPruneContainersCmd(PruneType pruneType) { + public PruneCmd pruneContainersCmd(PruneType pruneType) { return new PruneCmdImpl(getDockerCmdExecFactory().pruneCmdExec(), pruneType); } From cf6e176b10a888b015751bccd5a0cad0264157e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Kov=C3=A1=C5=99?= Date: Mon, 18 Feb 2019 13:53:48 +0100 Subject: [PATCH 3/5] make source code Checkstyle compliant --- .../github/dockerjava/api/DockerClient.java | 73 ++++++++- .../dockerjava/api/command/PruneCmd.java | 3 +- .../dockerjava/api/model/PruneResponse.java | 3 +- .../core/AbstractDockerCmdExecFactory.java | 139 ++++++++++++++++- .../dockerjava/core/DockerClientImpl.java | 141 +++++++++++++++++- .../dockerjava/core/exec/PruneCmdExec.java | 2 +- .../dockerjava/core/util/FiltersBuilder.java | 3 +- .../jaxrs/JerseyDockerCmdExecFactory.java | 70 ++++++++- .../github/dockerjava/jaxrs/PruneCmdExec.java | 2 +- 9 files changed, 423 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/github/dockerjava/api/DockerClient.java b/src/main/java/com/github/dockerjava/api/DockerClient.java index 13a4607f8..4dd139ca6 100644 --- a/src/main/java/com/github/dockerjava/api/DockerClient.java +++ b/src/main/java/com/github/dockerjava/api/DockerClient.java @@ -1,8 +1,77 @@ package com.github.dockerjava.api; -import com.github.dockerjava.api.command.*; +import com.github.dockerjava.api.command.AttachContainerCmd; +import com.github.dockerjava.api.command.AuthCmd; +import com.github.dockerjava.api.command.BuildImageCmd; +import com.github.dockerjava.api.command.CommitCmd; +import com.github.dockerjava.api.command.ConnectToNetworkCmd; +import com.github.dockerjava.api.command.ContainerDiffCmd; +import com.github.dockerjava.api.command.CopyArchiveFromContainerCmd; +import com.github.dockerjava.api.command.CopyArchiveToContainerCmd; +import com.github.dockerjava.api.command.CopyFileFromContainerCmd; +import com.github.dockerjava.api.command.CreateContainerCmd; +import com.github.dockerjava.api.command.CreateImageCmd; +import com.github.dockerjava.api.command.CreateNetworkCmd; +import com.github.dockerjava.api.command.CreateServiceCmd; +import com.github.dockerjava.api.command.CreateVolumeCmd; +import com.github.dockerjava.api.command.DisconnectFromNetworkCmd; +import com.github.dockerjava.api.command.EventsCmd; +import com.github.dockerjava.api.command.ExecCreateCmd; +import com.github.dockerjava.api.command.ExecStartCmd; +import com.github.dockerjava.api.command.InfoCmd; +import com.github.dockerjava.api.command.InitializeSwarmCmd; +import com.github.dockerjava.api.command.InspectContainerCmd; +import com.github.dockerjava.api.command.InspectExecCmd; +import com.github.dockerjava.api.command.InspectImageCmd; +import com.github.dockerjava.api.command.InspectNetworkCmd; +import com.github.dockerjava.api.command.InspectServiceCmd; +import com.github.dockerjava.api.command.InspectSwarmCmd; +import com.github.dockerjava.api.command.InspectVolumeCmd; +import com.github.dockerjava.api.command.JoinSwarmCmd; +import com.github.dockerjava.api.command.KillContainerCmd; +import com.github.dockerjava.api.command.LeaveSwarmCmd; +import com.github.dockerjava.api.command.ListContainersCmd; +import com.github.dockerjava.api.command.ListImagesCmd; +import com.github.dockerjava.api.command.ListNetworksCmd; +import com.github.dockerjava.api.command.ListServicesCmd; +import com.github.dockerjava.api.command.ListSwarmNodesCmd; +import com.github.dockerjava.api.command.ListTasksCmd; +import com.github.dockerjava.api.command.ListVolumesCmd; +import com.github.dockerjava.api.command.LoadImageCmd; +import com.github.dockerjava.api.command.LogContainerCmd; +import com.github.dockerjava.api.command.LogSwarmObjectCmd; +import com.github.dockerjava.api.command.PauseContainerCmd; +import com.github.dockerjava.api.command.PingCmd; +import com.github.dockerjava.api.command.PruneCmd; +import com.github.dockerjava.api.command.PullImageCmd; +import com.github.dockerjava.api.command.PushImageCmd; +import com.github.dockerjava.api.command.RemoveContainerCmd; +import com.github.dockerjava.api.command.RemoveImageCmd; +import com.github.dockerjava.api.command.RemoveNetworkCmd; +import com.github.dockerjava.api.command.RemoveServiceCmd; +import com.github.dockerjava.api.command.RemoveVolumeCmd; +import com.github.dockerjava.api.command.RenameContainerCmd; +import com.github.dockerjava.api.command.RestartContainerCmd; +import com.github.dockerjava.api.command.SaveImageCmd; +import com.github.dockerjava.api.command.SearchImagesCmd; +import com.github.dockerjava.api.command.StartContainerCmd; +import com.github.dockerjava.api.command.StatsCmd; +import com.github.dockerjava.api.command.StopContainerCmd; +import com.github.dockerjava.api.command.TagImageCmd; +import com.github.dockerjava.api.command.TopContainerCmd; +import com.github.dockerjava.api.command.UnpauseContainerCmd; +import com.github.dockerjava.api.command.UpdateContainerCmd; +import com.github.dockerjava.api.command.UpdateServiceCmd; +import com.github.dockerjava.api.command.UpdateSwarmCmd; +import com.github.dockerjava.api.command.UpdateSwarmNodeCmd; +import com.github.dockerjava.api.command.VersionCmd; +import com.github.dockerjava.api.command.WaitContainerCmd; import com.github.dockerjava.api.exception.DockerException; -import com.github.dockerjava.api.model.*; +import com.github.dockerjava.api.model.AuthConfig; +import com.github.dockerjava.api.model.Identifier; +import com.github.dockerjava.api.model.PruneType; +import com.github.dockerjava.api.model.ServiceSpec; +import com.github.dockerjava.api.model.SwarmSpec; import com.github.dockerjava.core.RemoteApiVersion; import javax.annotation.Nonnull; diff --git a/src/main/java/com/github/dockerjava/api/command/PruneCmd.java b/src/main/java/com/github/dockerjava/api/command/PruneCmd.java index 23bca4879..7a86434aa 100644 --- a/src/main/java/com/github/dockerjava/api/command/PruneCmd.java +++ b/src/main/java/com/github/dockerjava/api/command/PruneCmd.java @@ -29,7 +29,8 @@ public interface PruneCmd extends SyncDockerCmd { /** * Prune containers created before this timestamp * Meaningful only for CONTAINERS and IMAGES prune type - * @param until Can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. 10m, 1h30m) computed relative to the daemon machine’s time. + * @param until Can be Unix timestamps, date formatted timestamps, + * or Go duration strings (e.g. 10m, 1h30m) computed relative to the daemon machine’s time. */ PruneCmd withUntilFilter(String until); diff --git a/src/main/java/com/github/dockerjava/api/model/PruneResponse.java b/src/main/java/com/github/dockerjava/api/model/PruneResponse.java index ceee08d8a..d6653cdc6 100644 --- a/src/main/java/com/github/dockerjava/api/model/PruneResponse.java +++ b/src/main/java/com/github/dockerjava/api/model/PruneResponse.java @@ -53,8 +53,9 @@ public boolean equals(Object o) { if (o instanceof Ulimit) { Ulimit other = (Ulimit) o; return new EqualsBuilder().append(spaceReclaimed, other.getName()).isEquals(); - } else + } else { return super.equals(o); + } } @Override diff --git a/src/main/java/com/github/dockerjava/core/AbstractDockerCmdExecFactory.java b/src/main/java/com/github/dockerjava/core/AbstractDockerCmdExecFactory.java index be493c623..c822b4cc2 100644 --- a/src/main/java/com/github/dockerjava/core/AbstractDockerCmdExecFactory.java +++ b/src/main/java/com/github/dockerjava/core/AbstractDockerCmdExecFactory.java @@ -1,7 +1,142 @@ package com.github.dockerjava.core; -import com.github.dockerjava.api.command.*; -import com.github.dockerjava.core.exec.*; +import com.github.dockerjava.api.command.AttachContainerCmd; +import com.github.dockerjava.api.command.AuthCmd; +import com.github.dockerjava.api.command.BuildImageCmd; +import com.github.dockerjava.api.command.CommitCmd; +import com.github.dockerjava.api.command.ConnectToNetworkCmd; +import com.github.dockerjava.api.command.ContainerDiffCmd; +import com.github.dockerjava.api.command.CopyArchiveFromContainerCmd; +import com.github.dockerjava.api.command.CopyArchiveToContainerCmd; +import com.github.dockerjava.api.command.CopyFileFromContainerCmd; +import com.github.dockerjava.api.command.CreateContainerCmd; +import com.github.dockerjava.api.command.CreateImageCmd; +import com.github.dockerjava.api.command.CreateNetworkCmd; +import com.github.dockerjava.api.command.CreateServiceCmd; +import com.github.dockerjava.api.command.CreateVolumeCmd; +import com.github.dockerjava.api.command.DisconnectFromNetworkCmd; +import com.github.dockerjava.api.command.DockerCmdExecFactory; +import com.github.dockerjava.api.command.EventsCmd; +import com.github.dockerjava.api.command.ExecCreateCmd; +import com.github.dockerjava.api.command.ExecStartCmd; +import com.github.dockerjava.api.command.InfoCmd; +import com.github.dockerjava.api.command.InitializeSwarmCmd; +import com.github.dockerjava.api.command.InspectContainerCmd; +import com.github.dockerjava.api.command.InspectExecCmd; +import com.github.dockerjava.api.command.InspectImageCmd; +import com.github.dockerjava.api.command.InspectNetworkCmd; +import com.github.dockerjava.api.command.InspectServiceCmd; +import com.github.dockerjava.api.command.InspectSwarmCmd; +import com.github.dockerjava.api.command.InspectSwarmNodeCmd; +import com.github.dockerjava.api.command.InspectVolumeCmd; +import com.github.dockerjava.api.command.JoinSwarmCmd; +import com.github.dockerjava.api.command.KillContainerCmd; +import com.github.dockerjava.api.command.LeaveSwarmCmd; +import com.github.dockerjava.api.command.ListContainersCmd; +import com.github.dockerjava.api.command.ListImagesCmd; +import com.github.dockerjava.api.command.ListNetworksCmd; +import com.github.dockerjava.api.command.ListServicesCmd; +import com.github.dockerjava.api.command.ListSwarmNodesCmd; +import com.github.dockerjava.api.command.ListTasksCmd; +import com.github.dockerjava.api.command.ListVolumesCmd; +import com.github.dockerjava.api.command.LoadImageCmd; +import com.github.dockerjava.api.command.LogContainerCmd; +import com.github.dockerjava.api.command.LogSwarmObjectCmd; +import com.github.dockerjava.api.command.PauseContainerCmd; +import com.github.dockerjava.api.command.PingCmd; +import com.github.dockerjava.api.command.PruneCmd; +import com.github.dockerjava.api.command.PullImageCmd; +import com.github.dockerjava.api.command.PushImageCmd; +import com.github.dockerjava.api.command.RemoveContainerCmd; +import com.github.dockerjava.api.command.RemoveImageCmd; +import com.github.dockerjava.api.command.RemoveNetworkCmd; +import com.github.dockerjava.api.command.RemoveServiceCmd; +import com.github.dockerjava.api.command.RemoveSwarmNodeCmd; +import com.github.dockerjava.api.command.RemoveVolumeCmd; +import com.github.dockerjava.api.command.RenameContainerCmd; +import com.github.dockerjava.api.command.RestartContainerCmd; +import com.github.dockerjava.api.command.SaveImageCmd; +import com.github.dockerjava.api.command.SearchImagesCmd; +import com.github.dockerjava.api.command.StartContainerCmd; +import com.github.dockerjava.api.command.StatsCmd; +import com.github.dockerjava.api.command.StopContainerCmd; +import com.github.dockerjava.api.command.TagImageCmd; +import com.github.dockerjava.api.command.TopContainerCmd; +import com.github.dockerjava.api.command.UnpauseContainerCmd; +import com.github.dockerjava.api.command.UpdateContainerCmd; +import com.github.dockerjava.api.command.UpdateServiceCmd; +import com.github.dockerjava.api.command.UpdateSwarmCmd; +import com.github.dockerjava.api.command.UpdateSwarmNodeCmd; +import com.github.dockerjava.api.command.VersionCmd; +import com.github.dockerjava.api.command.WaitContainerCmd; +import com.github.dockerjava.core.exec.AttachContainerCmdExec; +import com.github.dockerjava.core.exec.AuthCmdExec; +import com.github.dockerjava.core.exec.BuildImageCmdExec; +import com.github.dockerjava.core.exec.CommitCmdExec; +import com.github.dockerjava.core.exec.ConnectToNetworkCmdExec; +import com.github.dockerjava.core.exec.ContainerDiffCmdExec; +import com.github.dockerjava.core.exec.CopyArchiveFromContainerCmdExec; +import com.github.dockerjava.core.exec.CopyArchiveToContainerCmdExec; +import com.github.dockerjava.core.exec.CopyFileFromContainerCmdExec; +import com.github.dockerjava.core.exec.CreateContainerCmdExec; +import com.github.dockerjava.core.exec.CreateImageCmdExec; +import com.github.dockerjava.core.exec.CreateNetworkCmdExec; +import com.github.dockerjava.core.exec.CreateServiceCmdExec; +import com.github.dockerjava.core.exec.CreateVolumeCmdExec; +import com.github.dockerjava.core.exec.DisconnectFromNetworkCmdExec; +import com.github.dockerjava.core.exec.EventsCmdExec; +import com.github.dockerjava.core.exec.ExecCreateCmdExec; +import com.github.dockerjava.core.exec.ExecStartCmdExec; +import com.github.dockerjava.core.exec.InfoCmdExec; +import com.github.dockerjava.core.exec.InitializeSwarmCmdExec; +import com.github.dockerjava.core.exec.InspectContainerCmdExec; +import com.github.dockerjava.core.exec.InspectExecCmdExec; +import com.github.dockerjava.core.exec.InspectImageCmdExec; +import com.github.dockerjava.core.exec.InspectNetworkCmdExec; +import com.github.dockerjava.core.exec.InspectServiceCmdExec; +import com.github.dockerjava.core.exec.InspectSwarmCmdExec; +import com.github.dockerjava.core.exec.InspectSwarmNodeCmdExec; +import com.github.dockerjava.core.exec.InspectVolumeCmdExec; +import com.github.dockerjava.core.exec.JoinSwarmCmdExec; +import com.github.dockerjava.core.exec.KillContainerCmdExec; +import com.github.dockerjava.core.exec.LeaveSwarmCmdExec; +import com.github.dockerjava.core.exec.ListContainersCmdExec; +import com.github.dockerjava.core.exec.ListImagesCmdExec; +import com.github.dockerjava.core.exec.ListNetworksCmdExec; +import com.github.dockerjava.core.exec.ListServicesCmdExec; +import com.github.dockerjava.core.exec.ListSwarmNodesCmdExec; +import com.github.dockerjava.core.exec.ListTasksCmdExec; +import com.github.dockerjava.core.exec.ListVolumesCmdExec; +import com.github.dockerjava.core.exec.LoadImageCmdExec; +import com.github.dockerjava.core.exec.LogContainerCmdExec; +import com.github.dockerjava.core.exec.PauseContainerCmdExec; +import com.github.dockerjava.core.exec.PingCmdExec; +import com.github.dockerjava.core.exec.PruneCmdExec; +import com.github.dockerjava.core.exec.PullImageCmdExec; +import com.github.dockerjava.core.exec.PushImageCmdExec; +import com.github.dockerjava.core.exec.RemoveContainerCmdExec; +import com.github.dockerjava.core.exec.RemoveImageCmdExec; +import com.github.dockerjava.core.exec.RemoveNetworkCmdExec; +import com.github.dockerjava.core.exec.RemoveServiceCmdExec; +import com.github.dockerjava.core.exec.RemoveSwarmNodeCmdExec; +import com.github.dockerjava.core.exec.RemoveVolumeCmdExec; +import com.github.dockerjava.core.exec.RenameContainerCmdExec; +import com.github.dockerjava.core.exec.RestartContainerCmdExec; +import com.github.dockerjava.core.exec.SaveImageCmdExec; +import com.github.dockerjava.core.exec.SearchImagesCmdExec; +import com.github.dockerjava.core.exec.StartContainerCmdExec; +import com.github.dockerjava.core.exec.StatsCmdExec; +import com.github.dockerjava.core.exec.StopContainerCmdExec; +import com.github.dockerjava.core.exec.TagImageCmdExec; +import com.github.dockerjava.core.exec.TopContainerCmdExec; +import com.github.dockerjava.core.exec.UnpauseContainerCmdExec; +import com.github.dockerjava.core.exec.UpdateContainerCmdExec; +import com.github.dockerjava.core.exec.UpdateServiceCmdExec; +import com.github.dockerjava.core.exec.UpdateSwarmCmdExec; +import com.github.dockerjava.core.exec.UpdateSwarmNodeCmdExec; +import com.github.dockerjava.core.exec.VersionCmdExec; +import com.github.dockerjava.core.exec.WaitContainerCmdExec; +import com.github.dockerjava.core.exec.LogSwarmObjectExec; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/src/main/java/com/github/dockerjava/core/DockerClientImpl.java b/src/main/java/com/github/dockerjava/core/DockerClientImpl.java index 39d2d8f95..4bac1162d 100644 --- a/src/main/java/com/github/dockerjava/core/DockerClientImpl.java +++ b/src/main/java/com/github/dockerjava/core/DockerClientImpl.java @@ -1,9 +1,144 @@ package com.github.dockerjava.core; import com.github.dockerjava.api.DockerClient; -import com.github.dockerjava.api.command.*; -import com.github.dockerjava.api.model.*; -import com.github.dockerjava.core.command.*; +import com.github.dockerjava.api.command.AttachContainerCmd; +import com.github.dockerjava.api.command.AuthCmd; +import com.github.dockerjava.api.command.BuildImageCmd; +import com.github.dockerjava.api.command.CommitCmd; +import com.github.dockerjava.api.command.ConnectToNetworkCmd; +import com.github.dockerjava.api.command.ContainerDiffCmd; +import com.github.dockerjava.api.command.CopyArchiveFromContainerCmd; +import com.github.dockerjava.api.command.CopyArchiveToContainerCmd; +import com.github.dockerjava.api.command.CopyFileFromContainerCmd; +import com.github.dockerjava.api.command.CreateContainerCmd; +import com.github.dockerjava.api.command.CreateImageCmd; +import com.github.dockerjava.api.command.CreateNetworkCmd; +import com.github.dockerjava.api.command.CreateServiceCmd; +import com.github.dockerjava.api.command.CreateVolumeCmd; +import com.github.dockerjava.api.command.DisconnectFromNetworkCmd; +import com.github.dockerjava.api.command.DockerCmdExecFactory; +import com.github.dockerjava.api.command.EventsCmd; +import com.github.dockerjava.api.command.ExecCreateCmd; +import com.github.dockerjava.api.command.ExecStartCmd; +import com.github.dockerjava.api.command.InfoCmd; +import com.github.dockerjava.api.command.InitializeSwarmCmd; +import com.github.dockerjava.api.command.InspectContainerCmd; +import com.github.dockerjava.api.command.InspectExecCmd; +import com.github.dockerjava.api.command.InspectImageCmd; +import com.github.dockerjava.api.command.InspectNetworkCmd; +import com.github.dockerjava.api.command.InspectServiceCmd; +import com.github.dockerjava.api.command.InspectSwarmCmd; +import com.github.dockerjava.api.command.InspectVolumeCmd; +import com.github.dockerjava.api.command.JoinSwarmCmd; +import com.github.dockerjava.api.command.KillContainerCmd; +import com.github.dockerjava.api.command.LeaveSwarmCmd; +import com.github.dockerjava.api.command.ListContainersCmd; +import com.github.dockerjava.api.command.ListImagesCmd; +import com.github.dockerjava.api.command.ListNetworksCmd; +import com.github.dockerjava.api.command.ListServicesCmd; +import com.github.dockerjava.api.command.ListSwarmNodesCmd; +import com.github.dockerjava.api.command.ListTasksCmd; +import com.github.dockerjava.api.command.ListVolumesCmd; +import com.github.dockerjava.api.command.LoadImageCmd; +import com.github.dockerjava.api.command.LogContainerCmd; +import com.github.dockerjava.api.command.LogSwarmObjectCmd; +import com.github.dockerjava.api.command.PauseContainerCmd; +import com.github.dockerjava.api.command.PingCmd; +import com.github.dockerjava.api.command.PruneCmd; +import com.github.dockerjava.api.command.PullImageCmd; +import com.github.dockerjava.api.command.PushImageCmd; +import com.github.dockerjava.api.command.RemoveContainerCmd; +import com.github.dockerjava.api.command.RemoveImageCmd; +import com.github.dockerjava.api.command.RemoveNetworkCmd; +import com.github.dockerjava.api.command.RemoveServiceCmd; +import com.github.dockerjava.api.command.RemoveVolumeCmd; +import com.github.dockerjava.api.command.RenameContainerCmd; +import com.github.dockerjava.api.command.RestartContainerCmd; +import com.github.dockerjava.api.command.SaveImageCmd; +import com.github.dockerjava.api.command.SearchImagesCmd; +import com.github.dockerjava.api.command.StartContainerCmd; +import com.github.dockerjava.api.command.StatsCmd; +import com.github.dockerjava.api.command.StopContainerCmd; +import com.github.dockerjava.api.command.TagImageCmd; +import com.github.dockerjava.api.command.TopContainerCmd; +import com.github.dockerjava.api.command.UnpauseContainerCmd; +import com.github.dockerjava.api.command.UpdateContainerCmd; +import com.github.dockerjava.api.command.UpdateServiceCmd; +import com.github.dockerjava.api.command.UpdateSwarmCmd; +import com.github.dockerjava.api.command.UpdateSwarmNodeCmd; +import com.github.dockerjava.api.command.VersionCmd; +import com.github.dockerjava.api.command.WaitContainerCmd; +import com.github.dockerjava.api.model.AuthConfig; +import com.github.dockerjava.api.model.Identifier; +import com.github.dockerjava.api.model.PruneType; +import com.github.dockerjava.api.model.ServiceSpec; +import com.github.dockerjava.api.model.SwarmSpec; +import com.github.dockerjava.core.command.AttachContainerCmdImpl; +import com.github.dockerjava.core.command.AuthCmdImpl; +import com.github.dockerjava.core.command.BuildImageCmdImpl; +import com.github.dockerjava.core.command.CommitCmdImpl; +import com.github.dockerjava.core.command.ConnectToNetworkCmdImpl; +import com.github.dockerjava.core.command.ContainerDiffCmdImpl; +import com.github.dockerjava.core.command.CopyArchiveFromContainerCmdImpl; +import com.github.dockerjava.core.command.CopyArchiveToContainerCmdImpl; +import com.github.dockerjava.core.command.CopyFileFromContainerCmdImpl; +import com.github.dockerjava.core.command.CreateContainerCmdImpl; +import com.github.dockerjava.core.command.CreateImageCmdImpl; +import com.github.dockerjava.core.command.CreateNetworkCmdImpl; +import com.github.dockerjava.core.command.CreateServiceCmdImpl; +import com.github.dockerjava.core.command.CreateVolumeCmdImpl; +import com.github.dockerjava.core.command.DisconnectFromNetworkCmdImpl; +import com.github.dockerjava.core.command.EventsCmdImpl; +import com.github.dockerjava.core.command.ExecCreateCmdImpl; +import com.github.dockerjava.core.command.ExecStartCmdImpl; +import com.github.dockerjava.core.command.InfoCmdImpl; +import com.github.dockerjava.core.command.InitializeSwarmCmdImpl; +import com.github.dockerjava.core.command.InpectNetworkCmdImpl; +import com.github.dockerjava.core.command.InspectContainerCmdImpl; +import com.github.dockerjava.core.command.InspectExecCmdImpl; +import com.github.dockerjava.core.command.InspectImageCmdImpl; +import com.github.dockerjava.core.command.InspectServiceCmdImpl; +import com.github.dockerjava.core.command.InspectSwarmCmdImpl; +import com.github.dockerjava.core.command.InspectVolumeCmdImpl; +import com.github.dockerjava.core.command.JoinSwarmCmdImpl; +import com.github.dockerjava.core.command.KillContainerCmdImpl; +import com.github.dockerjava.core.command.LeaveSwarmCmdImpl; +import com.github.dockerjava.core.command.ListContainersCmdImpl; +import com.github.dockerjava.core.command.ListImagesCmdImpl; +import com.github.dockerjava.core.command.ListNetworksCmdImpl; +import com.github.dockerjava.core.command.ListServicesCmdImpl; +import com.github.dockerjava.core.command.ListSwarmNodesCmdImpl; +import com.github.dockerjava.core.command.ListTasksCmdImpl; +import com.github.dockerjava.core.command.ListVolumesCmdImpl; +import com.github.dockerjava.core.command.LoadImageCmdImpl; +import com.github.dockerjava.core.command.LogContainerCmdImpl; +import com.github.dockerjava.core.command.LogSwarmObjectImpl; +import com.github.dockerjava.core.command.PauseContainerCmdImpl; +import com.github.dockerjava.core.command.PingCmdImpl; +import com.github.dockerjava.core.command.PruneCmdImpl; +import com.github.dockerjava.core.command.PullImageCmdImpl; +import com.github.dockerjava.core.command.PushImageCmdImpl; +import com.github.dockerjava.core.command.RemoveContainerCmdImpl; +import com.github.dockerjava.core.command.RemoveImageCmdImpl; +import com.github.dockerjava.core.command.RemoveNetworkCmdImpl; +import com.github.dockerjava.core.command.RemoveServiceCmdImpl; +import com.github.dockerjava.core.command.RemoveVolumeCmdImpl; +import com.github.dockerjava.core.command.RenameContainerCmdImpl; +import com.github.dockerjava.core.command.RestartContainerCmdImpl; +import com.github.dockerjava.core.command.SaveImageCmdImpl; +import com.github.dockerjava.core.command.SearchImagesCmdImpl; +import com.github.dockerjava.core.command.StartContainerCmdImpl; +import com.github.dockerjava.core.command.StatsCmdImpl; +import com.github.dockerjava.core.command.StopContainerCmdImpl; +import com.github.dockerjava.core.command.TagImageCmdImpl; +import com.github.dockerjava.core.command.TopContainerCmdImpl; +import com.github.dockerjava.core.command.UnpauseContainerCmdImpl; +import com.github.dockerjava.core.command.UpdateContainerCmdImpl; +import com.github.dockerjava.core.command.UpdateServiceCmdImpl; +import com.github.dockerjava.core.command.UpdateSwarmCmdImpl; +import com.github.dockerjava.core.command.UpdateSwarmNodeCmdImpl; +import com.github.dockerjava.core.command.VersionCmdImpl; +import com.github.dockerjava.core.command.WaitContainerCmdImpl; import javax.annotation.Nonnull; import java.io.Closeable; diff --git a/src/main/java/com/github/dockerjava/core/exec/PruneCmdExec.java b/src/main/java/com/github/dockerjava/core/exec/PruneCmdExec.java index ef28e5586..0b8832bcb 100644 --- a/src/main/java/com/github/dockerjava/core/exec/PruneCmdExec.java +++ b/src/main/java/com/github/dockerjava/core/exec/PruneCmdExec.java @@ -30,7 +30,7 @@ protected PruneResponse execute(PruneCmd command) { LOGGER.trace("POST: {}", webTarget); PruneResponse response = webTarget.request().accept(MediaType.APPLICATION_JSON) - .post(null, new TypeReference() {}); + .post(null, new TypeReference() { }); LOGGER.trace("Response: {}", response); diff --git a/src/main/java/com/github/dockerjava/core/util/FiltersBuilder.java b/src/main/java/com/github/dockerjava/core/util/FiltersBuilder.java index 8ec85dee2..d942e59e0 100644 --- a/src/main/java/com/github/dockerjava/core/util/FiltersBuilder.java +++ b/src/main/java/com/github/dockerjava/core/util/FiltersBuilder.java @@ -22,7 +22,8 @@ public class FiltersBuilder { private static final Pattern UNTIL_TIMESTAMP_PATTERN = Pattern.compile("^\\d{1,10}$"); private static final Pattern UNTIL_DATETIME_PATTERN = - Pattern.compile("^([0-9]+)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])([Tt]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\\.[0-9]+)?)?(([Zz])|([\\+|\\-]([01][0-9]|2[0-3]):[0-5][0-9]))?$"); + Pattern.compile("^([0-9]+)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])([Tt]([01][0-9]|2[0-3]):([0-5][0-9]):" + + "([0-5][0-9]|60)(\\.[0-9]+)?)?(([Zz])|([\\+|\\-]([01][0-9]|2[0-3]):[0-5][0-9]))?$"); private static final Pattern UNTIL_GO_PATTERN = Pattern.compile("^([1-9][0-9]*h)?([1-9][0-9]*m)?([1-9][0-9]*s)?$"); diff --git a/src/main/java/com/github/dockerjava/jaxrs/JerseyDockerCmdExecFactory.java b/src/main/java/com/github/dockerjava/jaxrs/JerseyDockerCmdExecFactory.java index 12c60090e..1582d5313 100644 --- a/src/main/java/com/github/dockerjava/jaxrs/JerseyDockerCmdExecFactory.java +++ b/src/main/java/com/github/dockerjava/jaxrs/JerseyDockerCmdExecFactory.java @@ -3,7 +3,75 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; -import com.github.dockerjava.api.command.*; +import com.github.dockerjava.api.command.AttachContainerCmd; +import com.github.dockerjava.api.command.AuthCmd; +import com.github.dockerjava.api.command.BuildImageCmd; +import com.github.dockerjava.api.command.CommitCmd; +import com.github.dockerjava.api.command.ConnectToNetworkCmd; +import com.github.dockerjava.api.command.ContainerDiffCmd; +import com.github.dockerjava.api.command.CopyArchiveFromContainerCmd; +import com.github.dockerjava.api.command.CopyArchiveToContainerCmd; +import com.github.dockerjava.api.command.CopyFileFromContainerCmd; +import com.github.dockerjava.api.command.CreateContainerCmd; +import com.github.dockerjava.api.command.CreateImageCmd; +import com.github.dockerjava.api.command.CreateNetworkCmd; +import com.github.dockerjava.api.command.CreateServiceCmd; +import com.github.dockerjava.api.command.CreateVolumeCmd; +import com.github.dockerjava.api.command.DisconnectFromNetworkCmd; +import com.github.dockerjava.api.command.DockerCmdExecFactory; +import com.github.dockerjava.api.command.EventsCmd; +import com.github.dockerjava.api.command.ExecCreateCmd; +import com.github.dockerjava.api.command.ExecStartCmd; +import com.github.dockerjava.api.command.InfoCmd; +import com.github.dockerjava.api.command.InitializeSwarmCmd; +import com.github.dockerjava.api.command.InspectContainerCmd; +import com.github.dockerjava.api.command.InspectExecCmd; +import com.github.dockerjava.api.command.InspectImageCmd; +import com.github.dockerjava.api.command.InspectNetworkCmd; +import com.github.dockerjava.api.command.InspectServiceCmd; +import com.github.dockerjava.api.command.InspectSwarmCmd; +import com.github.dockerjava.api.command.InspectSwarmNodeCmd; +import com.github.dockerjava.api.command.InspectVolumeCmd; +import com.github.dockerjava.api.command.JoinSwarmCmd; +import com.github.dockerjava.api.command.KillContainerCmd; +import com.github.dockerjava.api.command.LeaveSwarmCmd; +import com.github.dockerjava.api.command.ListContainersCmd; +import com.github.dockerjava.api.command.ListImagesCmd; +import com.github.dockerjava.api.command.ListNetworksCmd; +import com.github.dockerjava.api.command.ListServicesCmd; +import com.github.dockerjava.api.command.ListSwarmNodesCmd; +import com.github.dockerjava.api.command.ListTasksCmd; +import com.github.dockerjava.api.command.ListVolumesCmd; +import com.github.dockerjava.api.command.LoadImageCmd; +import com.github.dockerjava.api.command.LogContainerCmd; +import com.github.dockerjava.api.command.LogSwarmObjectCmd; +import com.github.dockerjava.api.command.PauseContainerCmd; +import com.github.dockerjava.api.command.PingCmd; +import com.github.dockerjava.api.command.PruneCmd; +import com.github.dockerjava.api.command.PullImageCmd; +import com.github.dockerjava.api.command.PushImageCmd; +import com.github.dockerjava.api.command.RemoveContainerCmd; +import com.github.dockerjava.api.command.RemoveImageCmd; +import com.github.dockerjava.api.command.RemoveNetworkCmd; +import com.github.dockerjava.api.command.RemoveServiceCmd; +import com.github.dockerjava.api.command.RemoveSwarmNodeCmd; +import com.github.dockerjava.api.command.RemoveVolumeCmd; +import com.github.dockerjava.api.command.RenameContainerCmd; +import com.github.dockerjava.api.command.RestartContainerCmd; +import com.github.dockerjava.api.command.SaveImageCmd; +import com.github.dockerjava.api.command.SearchImagesCmd; +import com.github.dockerjava.api.command.StartContainerCmd; +import com.github.dockerjava.api.command.StatsCmd; +import com.github.dockerjava.api.command.StopContainerCmd; +import com.github.dockerjava.api.command.TagImageCmd; +import com.github.dockerjava.api.command.TopContainerCmd; +import com.github.dockerjava.api.command.UnpauseContainerCmd; +import com.github.dockerjava.api.command.UpdateContainerCmd; +import com.github.dockerjava.api.command.UpdateServiceCmd; +import com.github.dockerjava.api.command.UpdateSwarmCmd; +import com.github.dockerjava.api.command.UpdateSwarmNodeCmd; +import com.github.dockerjava.api.command.VersionCmd; +import com.github.dockerjava.api.command.WaitContainerCmd; import com.github.dockerjava.api.exception.DockerClientException; import com.github.dockerjava.core.DockerClientConfig; import com.github.dockerjava.core.SSLConfig; diff --git a/src/main/java/com/github/dockerjava/jaxrs/PruneCmdExec.java b/src/main/java/com/github/dockerjava/jaxrs/PruneCmdExec.java index 0ef9c77a9..983f5e012 100644 --- a/src/main/java/com/github/dockerjava/jaxrs/PruneCmdExec.java +++ b/src/main/java/com/github/dockerjava/jaxrs/PruneCmdExec.java @@ -30,7 +30,7 @@ protected PruneResponse execute(PruneCmd command) { LOGGER.trace("POST: {}", webTarget); PruneResponse response = webTarget.request().accept(MediaType.APPLICATION_JSON) - .post(null, new GenericType() {}); + .post(null, new GenericType() { }); LOGGER.trace("Response: {}", response); return response; From 97c69c32b35b9d685568c6f5c0f249b275af8c8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Kov=C3=A1=C5=99?= Date: Mon, 18 Feb 2019 13:53:48 +0100 Subject: [PATCH 4/5] make source code Checkstyle compliant --- .../core/TestDockerCmdExecFactory.java | 73 ++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/github/dockerjava/core/TestDockerCmdExecFactory.java b/src/test/java/com/github/dockerjava/core/TestDockerCmdExecFactory.java index dea7ead9f..a3c96e54d 100644 --- a/src/test/java/com/github/dockerjava/core/TestDockerCmdExecFactory.java +++ b/src/test/java/com/github/dockerjava/core/TestDockerCmdExecFactory.java @@ -1,8 +1,79 @@ package com.github.dockerjava.core; import com.github.dockerjava.api.async.ResultCallback; -import com.github.dockerjava.api.command.*; +import com.github.dockerjava.api.command.AttachContainerCmd; import com.github.dockerjava.api.command.AuthCmd.Exec; +import com.github.dockerjava.api.command.BuildImageCmd; +import com.github.dockerjava.api.command.CommitCmd; +import com.github.dockerjava.api.command.ConnectToNetworkCmd; +import com.github.dockerjava.api.command.ContainerDiffCmd; +import com.github.dockerjava.api.command.CopyArchiveFromContainerCmd; +import com.github.dockerjava.api.command.CopyArchiveToContainerCmd; +import com.github.dockerjava.api.command.CopyFileFromContainerCmd; +import com.github.dockerjava.api.command.CreateContainerCmd; +import com.github.dockerjava.api.command.CreateContainerResponse; +import com.github.dockerjava.api.command.CreateImageCmd; +import com.github.dockerjava.api.command.CreateImageResponse; +import com.github.dockerjava.api.command.CreateNetworkCmd; +import com.github.dockerjava.api.command.CreateNetworkResponse; +import com.github.dockerjava.api.command.CreateServiceCmd; +import com.github.dockerjava.api.command.CreateVolumeCmd; +import com.github.dockerjava.api.command.CreateVolumeResponse; +import com.github.dockerjava.api.command.DisconnectFromNetworkCmd; +import com.github.dockerjava.api.command.DockerCmdExecFactory; +import com.github.dockerjava.api.command.EventsCmd; +import com.github.dockerjava.api.command.ExecCreateCmd; +import com.github.dockerjava.api.command.ExecStartCmd; +import com.github.dockerjava.api.command.InfoCmd; +import com.github.dockerjava.api.command.InitializeSwarmCmd; +import com.github.dockerjava.api.command.InspectContainerCmd; +import com.github.dockerjava.api.command.InspectExecCmd; +import com.github.dockerjava.api.command.InspectImageCmd; +import com.github.dockerjava.api.command.InspectNetworkCmd; +import com.github.dockerjava.api.command.InspectServiceCmd; +import com.github.dockerjava.api.command.InspectSwarmCmd; +import com.github.dockerjava.api.command.InspectSwarmNodeCmd; +import com.github.dockerjava.api.command.InspectVolumeCmd; +import com.github.dockerjava.api.command.JoinSwarmCmd; +import com.github.dockerjava.api.command.KillContainerCmd; +import com.github.dockerjava.api.command.LeaveSwarmCmd; +import com.github.dockerjava.api.command.ListContainersCmd; +import com.github.dockerjava.api.command.ListImagesCmd; +import com.github.dockerjava.api.command.ListNetworksCmd; +import com.github.dockerjava.api.command.ListServicesCmd; +import com.github.dockerjava.api.command.ListSwarmNodesCmd; +import com.github.dockerjava.api.command.ListTasksCmd; +import com.github.dockerjava.api.command.ListVolumesCmd; +import com.github.dockerjava.api.command.LoadImageCmd; +import com.github.dockerjava.api.command.LogContainerCmd; +import com.github.dockerjava.api.command.LogSwarmObjectCmd; +import com.github.dockerjava.api.command.PauseContainerCmd; +import com.github.dockerjava.api.command.PingCmd; +import com.github.dockerjava.api.command.PruneCmd; +import com.github.dockerjava.api.command.PullImageCmd; +import com.github.dockerjava.api.command.PushImageCmd; +import com.github.dockerjava.api.command.RemoveContainerCmd; +import com.github.dockerjava.api.command.RemoveImageCmd; +import com.github.dockerjava.api.command.RemoveNetworkCmd; +import com.github.dockerjava.api.command.RemoveServiceCmd; +import com.github.dockerjava.api.command.RemoveSwarmNodeCmd; +import com.github.dockerjava.api.command.RemoveVolumeCmd; +import com.github.dockerjava.api.command.RenameContainerCmd; +import com.github.dockerjava.api.command.RestartContainerCmd; +import com.github.dockerjava.api.command.SaveImageCmd; +import com.github.dockerjava.api.command.SearchImagesCmd; +import com.github.dockerjava.api.command.StartContainerCmd; +import com.github.dockerjava.api.command.StatsCmd; +import com.github.dockerjava.api.command.StopContainerCmd; +import com.github.dockerjava.api.command.TagImageCmd; +import com.github.dockerjava.api.command.TopContainerCmd; +import com.github.dockerjava.api.command.UnpauseContainerCmd; +import com.github.dockerjava.api.command.UpdateContainerCmd; +import com.github.dockerjava.api.command.UpdateServiceCmd; +import com.github.dockerjava.api.command.UpdateSwarmCmd; +import com.github.dockerjava.api.command.UpdateSwarmNodeCmd; +import com.github.dockerjava.api.command.VersionCmd; +import com.github.dockerjava.api.command.WaitContainerCmd; import com.github.dockerjava.api.model.BuildResponseItem; import java.io.IOException; From 93c0c471a3eaf938e54af7ed1d586f02bec0d781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Kov=C3=A1=C5=99?= Date: Mon, 18 Feb 2019 16:08:57 +0100 Subject: [PATCH 5/5] add URL escape to filters parameter --- src/main/java/com/github/dockerjava/api/DockerClient.java | 4 ++-- .../java/com/github/dockerjava/core/DockerClientImpl.java | 2 +- src/main/java/com/github/dockerjava/jaxrs/PruneCmdExec.java | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/github/dockerjava/api/DockerClient.java b/src/main/java/com/github/dockerjava/api/DockerClient.java index 4dd139ca6..ddc23dca8 100644 --- a/src/main/java/com/github/dockerjava/api/DockerClient.java +++ b/src/main/java/com/github/dockerjava/api/DockerClient.java @@ -394,11 +394,11 @@ public interface DockerClient extends Closeable { LogSwarmObjectCmd logTaskCmd(String taskId); /** - * Command to delete unused containers + * Command to delete unused containers/images/networks/volumes * * @since {@link RemoteApiVersion#VERSION_1_25} */ - PruneCmd pruneContainersCmd(PruneType pruneType); + PruneCmd pruneCmd(PruneType pruneType); @Override void close() throws IOException; diff --git a/src/main/java/com/github/dockerjava/core/DockerClientImpl.java b/src/main/java/com/github/dockerjava/core/DockerClientImpl.java index 4bac1162d..edf3bfc29 100644 --- a/src/main/java/com/github/dockerjava/core/DockerClientImpl.java +++ b/src/main/java/com/github/dockerjava/core/DockerClientImpl.java @@ -583,7 +583,7 @@ public LogSwarmObjectCmd logTaskCmd(String taskId) { } @Override - public PruneCmd pruneContainersCmd(PruneType pruneType) { + public PruneCmd pruneCmd(PruneType pruneType) { return new PruneCmdImpl(getDockerCmdExecFactory().pruneCmdExec(), pruneType); } diff --git a/src/main/java/com/github/dockerjava/jaxrs/PruneCmdExec.java b/src/main/java/com/github/dockerjava/jaxrs/PruneCmdExec.java index 983f5e012..324bc8201 100644 --- a/src/main/java/com/github/dockerjava/jaxrs/PruneCmdExec.java +++ b/src/main/java/com/github/dockerjava/jaxrs/PruneCmdExec.java @@ -11,6 +11,8 @@ import javax.ws.rs.core.GenericType; import javax.ws.rs.core.MediaType; +import static com.google.common.net.UrlEscapers.urlPathSegmentEscaper; + public class PruneCmdExec extends AbstrSyncDockerCmdExec implements PruneCmd.Exec { private static final Logger LOGGER = LoggerFactory.getLogger(PruneCmdExec.class); @@ -24,7 +26,7 @@ protected PruneResponse execute(PruneCmd command) { WebTarget webTarget = getBaseResource().path(command.getApiPath()); if (command.getFilters() != null && !command.getFilters().isEmpty()) { - webTarget = webTarget.queryParam("filters", FiltersEncoder.jsonEncode(command.getFilters())); + webTarget = webTarget.queryParam("filters", urlPathSegmentEscaper().escape(FiltersEncoder.jsonEncode(command.getFilters()))); } LOGGER.trace("POST: {}", webTarget);