Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main/java/com/github/dockerjava/api/DockerClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,27 @@
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.CreateVolumeCmd;
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.InspectContainerCmd;
import com.github.dockerjava.api.command.InspectExecCmd;
import com.github.dockerjava.api.command.InspectImageCmd;
import com.github.dockerjava.api.command.InspectVolumeCmd;
import com.github.dockerjava.api.command.KillContainerCmd;
import com.github.dockerjava.api.command.ListContainersCmd;
import com.github.dockerjava.api.command.ListImagesCmd;
import com.github.dockerjava.api.command.ListVolumesCmd;
import com.github.dockerjava.api.command.LogContainerCmd;
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.RemoveVolumeCmd;
import com.github.dockerjava.api.command.RestartContainerCmd;
import com.github.dockerjava.api.command.SaveImageCmd;
import com.github.dockerjava.api.command.SearchImagesCmd;
Expand Down Expand Up @@ -188,6 +192,14 @@ public interface DockerClient extends Closeable {

public StatsCmd statsCmd(String containerId);

public CreateVolumeCmd createVolumeCmd();

public InspectVolumeCmd inspectVolumeCmd(String name);

public RemoveVolumeCmd removeVolumeCmd(String name);

public ListVolumesCmd listVolumesCmd();

@Override
public void close() throws IOException;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.github.dockerjava.api.command;

import java.util.Map;

import javax.annotation.CheckForNull;

public interface CreateVolumeCmd extends SyncDockerCmd<CreateVolumeResponse> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add javadoc when apparead? 1.21?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do myself later.


@CheckForNull
public String getName();

@CheckForNull
public String getDriver();

@CheckForNull
public Map<String, String> getDriverOpts();

/**
* @param name
* - The new volume’s name. If not specified, Docker generates a name.
*/
public CreateVolumeCmd withName(String name);

/**
* @param driver
* - Name of the volume driver to use. Defaults to local for the name.
*/
public CreateVolumeCmd withDriver(String driver);

/**
* @param driverOpts
* - A mapping of driver options and values. These options are passed directly to the driver and are
* driver specific.
*/
public CreateVolumeCmd withDriverOpts(Map<String, String> driverOpts);

public static interface Exec extends DockerCmdSyncExec<CreateVolumeCmd, CreateVolumeResponse> {
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.github.dockerjava.api.command;

import org.apache.commons.lang.builder.ToStringBuilder;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
*
* @author Marcus Linke
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class CreateVolumeResponse {

@JsonProperty("Name")
private String name;

@JsonProperty("Driver")
private String driver;

@JsonProperty("Mountpoint")
private String mountpoint;

public String getName() {
return name;
}

public String getDriver() {
return driver;
}

public String getMountpoint() {
return mountpoint;
}

@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ public interface DockerCmdExecFactory extends Closeable {

public StatsCmd.Exec createStatsCmdExec();

public CreateVolumeCmd.Exec createCreateVolumeCmdExec();

public InspectVolumeCmd.Exec createInspectVolumeCmdExec();

public RemoveVolumeCmd.Exec createRemoveVolumeCmdExec();

public ListVolumesCmd.Exec createListVolumesCmdExec();

@Override
public void close() throws IOException;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.github.dockerjava.api.command;

import javax.annotation.Nonnull;

/**
* Inspect the details of a volume.
*
* @author Marcus Linke
*
*/
public interface InspectVolumeCmd extends SyncDockerCmd<InspectVolumeResponse> {

public String getName();

/**
* @param name
* - The volume’s name.
*/
public InspectVolumeCmd withName(@Nonnull String name);

public static interface Exec extends DockerCmdSyncExec<InspectVolumeCmd, InspectVolumeResponse> {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.github.dockerjava.api.command;

import org.apache.commons.lang.builder.ToStringBuilder;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
*
* @author Marcus Linke
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class InspectVolumeResponse {

@JsonProperty("Name")
private String name;

@JsonProperty("Driver")
private String driver;

@JsonProperty("Mountpoint")
private String mountpoint;

public String getName() {
return name;
}

public String getDriver() {
return driver;
}

public String getMountpoint() {
return mountpoint;
}

@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.github.dockerjava.api.command;

import javax.annotation.CheckForNull;

/**
* List volumes.
*
*
* @author Marcus Linke
*/
public interface ListVolumesCmd extends SyncDockerCmd<ListVolumesResponse> {

@CheckForNull
public String getFilters();

/**
* @param filters
* - JSON encoded value of the filters (a map[string][]string) to process on the volumes list. There is
* one available filter: dangling=true
*/
public ListVolumesCmd withFilters(String filters);

public static interface Exec extends DockerCmdSyncExec<ListVolumesCmd, ListVolumesResponse> {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.github.dockerjava.api.command;

import java.util.List;

import org.apache.commons.lang.builder.ToStringBuilder;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
*
* @author Marcus Linke
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class ListVolumesResponse {

@JsonProperty("Volumes")
private List<InspectVolumeResponse> volumes;

public List<InspectVolumeResponse> getVolumes() {
return volumes;
}

@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.github.dockerjava.api.command;

import javax.annotation.Nonnull;

import com.github.dockerjava.api.exception.ConflictException;
import com.github.dockerjava.api.exception.NotFoundException;

/**
* Remove a volume.
*
* @author Marcus Linke
*/
public interface RemoveVolumeCmd extends SyncDockerCmd<Void> {

public String getName();

public RemoveVolumeCmd withName(@Nonnull String name);

/**
* @throws NotFoundException
* No such volume
* @throws ConflictException
* Volume is in use and cannot be removed
*/
@Override
public Void exec() throws NotFoundException;

public static interface Exec extends DockerCmdSyncExec<RemoveVolumeCmd, Void> {
}
}
28 changes: 28 additions & 0 deletions src/main/java/com/github/dockerjava/core/DockerClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
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.CreateVolumeCmd;
import com.github.dockerjava.api.command.DockerCmdExecFactory;
import com.github.dockerjava.api.command.EventsCmd;
import com.github.dockerjava.api.command.ExecCreateCmd;
Expand All @@ -26,16 +27,19 @@
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.InspectVolumeCmd;
import com.github.dockerjava.api.command.KillContainerCmd;
import com.github.dockerjava.api.command.ListContainersCmd;
import com.github.dockerjava.api.command.ListImagesCmd;
import com.github.dockerjava.api.command.ListVolumesCmd;
import com.github.dockerjava.api.command.LogContainerCmd;
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.RemoveVolumeCmd;
import com.github.dockerjava.api.command.RestartContainerCmd;
import com.github.dockerjava.api.command.SaveImageCmd;
import com.github.dockerjava.api.command.SearchImagesCmd;
Expand All @@ -59,23 +63,27 @@
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.CreateVolumeCmdImpl;
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.InspectContainerCmdImpl;
import com.github.dockerjava.core.command.InspectExecCmdImpl;
import com.github.dockerjava.core.command.InspectImageCmdImpl;
import com.github.dockerjava.core.command.InspectVolumeCmdImpl;
import com.github.dockerjava.core.command.KillContainerCmdImpl;
import com.github.dockerjava.core.command.ListContainersCmdImpl;
import com.github.dockerjava.core.command.ListImagesCmdImpl;
import com.github.dockerjava.core.command.ListVolumesCmdImpl;
import com.github.dockerjava.core.command.LogContainerCmdImpl;
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.RemoveVolumeCmdImpl;
import com.github.dockerjava.core.command.RestartContainerCmdImpl;
import com.github.dockerjava.core.command.SaveImageCmdImpl;
import com.github.dockerjava.core.command.SearchImagesCmdImpl;
Expand Down Expand Up @@ -389,6 +397,26 @@ public StatsCmd statsCmd(String containerId) {
return new StatsCmdImpl(getDockerCmdExecFactory().createStatsCmdExec(), containerId);
}

@Override
public CreateVolumeCmd createVolumeCmd() {
return new CreateVolumeCmdImpl(getDockerCmdExecFactory().createCreateVolumeCmdExec());
}

@Override
public InspectVolumeCmd inspectVolumeCmd(String name) {
return new InspectVolumeCmdImpl(getDockerCmdExecFactory().createInspectVolumeCmdExec(), name);
}

@Override
public RemoveVolumeCmd removeVolumeCmd(String name) {
return new RemoveVolumeCmdImpl(getDockerCmdExecFactory().createRemoveVolumeCmdExec(), name);
}

@Override
public ListVolumesCmd listVolumesCmd() {
return new ListVolumesCmdImpl(getDockerCmdExecFactory().createListVolumesCmdExec());
}

@Override
public void close() throws IOException {
getDockerCmdExecFactory().close();
Expand Down
Loading