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
6 changes: 6 additions & 0 deletions src/main/java/com/github/dockerjava/api/DockerClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
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.ResizeContainerCmd;
import com.github.dockerjava.api.command.ResizeExecCmd;
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 @@ -157,6 +159,8 @@ public interface DockerClient extends Closeable {
*/
StartContainerCmd startContainerCmd(@Nonnull String containerId);

ResizeContainerCmd resizeContainerCmd(@Nonnull String containerId);

ExecCreateCmd execCreateCmd(@Nonnull String containerId);

InspectContainerCmd inspectContainerCmd(@Nonnull String containerId);
Expand All @@ -169,6 +173,8 @@ public interface DockerClient extends Closeable {

ExecStartCmd execStartCmd(@Nonnull String execId);

ResizeExecCmd resizeExecCmd(@Nonnull String execId);

InspectExecCmd inspectExecCmd(@Nonnull String execId);

LogContainerCmd logContainerCmd(@Nonnull String containerId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ public interface DockerCmdExecFactory extends Closeable {

AttachContainerCmd.Exec createAttachContainerCmdExec();

ResizeContainerCmd.Exec createResizeContainerCmdExec();

ExecStartCmd.Exec createExecStartCmdExec();

ResizeExecCmd.Exec createResizeExecCmdExec();

InspectExecCmd.Exec createInspectExecCmdExec();

LogContainerCmd.Exec createLogContainerCmdExec();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.github.dockerjava.api.command;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

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

public interface ResizeContainerCmd extends SyncDockerCmd<Void> {

@CheckForNull
String getContainerId();

Integer getHeight();

Integer getWidth();

ResizeContainerCmd withContainerId(@Nonnull String execId);

ResizeContainerCmd withSize(int height, int width);

/**
*
* @throws NotFoundException
* No such container instance
*/
@Override
Void exec() throws NotFoundException;

interface Exec extends DockerCmdSyncExec<ResizeContainerCmd, Void> {
}

}
32 changes: 32 additions & 0 deletions src/main/java/com/github/dockerjava/api/command/ResizeExecCmd.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.github.dockerjava.api.command;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

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

public interface ResizeExecCmd extends SyncDockerCmd<Void> {

@CheckForNull
String getExecId();

Integer getHeight();

Integer getWidth();

ResizeExecCmd withExecId(@Nonnull String execId);

ResizeExecCmd withSize(int height, int width);

/**
*
* @throws NotFoundException
* No such exec instance
*/
@Override
Void exec() throws NotFoundException;

interface Exec extends DockerCmdSyncExec<ResizeExecCmd, Void> {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
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.ResizeContainerCmd;
import com.github.dockerjava.api.command.ResizeExecCmd;
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 @@ -128,6 +130,8 @@
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.ResizeContainerCmdExec;
import com.github.dockerjava.core.exec.ResizeExecCmdExec;
import com.github.dockerjava.core.exec.RestartContainerCmdExec;
import com.github.dockerjava.core.exec.SaveImageCmdExec;
import com.github.dockerjava.core.exec.SearchImagesCmdExec;
Expand Down Expand Up @@ -282,6 +286,16 @@ public ExecStartCmd.Exec createExecStartCmdExec() {
return new ExecStartCmdExec(getBaseResource(), getDockerClientConfig());
}

@Override
public ResizeContainerCmd.Exec createResizeContainerCmdExec() {
return new ResizeContainerCmdExec(getBaseResource(), getDockerClientConfig());
}

@Override
public ResizeExecCmd.Exec createResizeExecCmdExec() {
return new ResizeExecCmdExec(getBaseResource(), getDockerClientConfig());
}

@Override
public InspectExecCmd.Exec createInspectExecCmdExec() {
return new InspectExecCmdExec(getBaseResource(), getDockerClientConfig());
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/github/dockerjava/core/DockerClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
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.ResizeContainerCmd;
import com.github.dockerjava.api.command.ResizeExecCmd;
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 @@ -131,6 +133,8 @@
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.ResizeContainerCmdImpl;
import com.github.dockerjava.core.command.ResizeExecCmdImpl;
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 @@ -356,11 +360,21 @@ public AttachContainerCmd attachContainerCmd(String containerId) {
return new AttachContainerCmdImpl(getDockerCmdExecFactory().createAttachContainerCmdExec(), containerId);
}

@Override
public ResizeContainerCmd resizeContainerCmd(String containerId) {
return new ResizeContainerCmdImpl(getDockerCmdExecFactory().createResizeContainerCmdExec(), containerId);
}

@Override
public ExecStartCmd execStartCmd(String execId) {
return new ExecStartCmdImpl(getDockerCmdExecFactory().createExecStartCmdExec(), execId);
}

@Override
public ResizeExecCmd resizeExecCmd(String execId) {
return new ResizeExecCmdImpl(getDockerCmdExecFactory().createResizeExecCmdExec(), execId);
}

@Override
public InspectExecCmd inspectExecCmd(String execId) {
return new InspectExecCmdImpl(getDockerCmdExecFactory().createInspectExecCmdExec(), execId);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.github.dockerjava.core.command;

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

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.github.dockerjava.api.command.ResizeContainerCmd;
import com.github.dockerjava.api.exception.NotFoundException;

@JsonInclude(Include.NON_NULL)
public class ResizeContainerCmdImpl extends AbstrDockerCmd<ResizeContainerCmd, Void> implements ResizeContainerCmd {

private String containerId;

private Integer height;

private Integer width;

public ResizeContainerCmdImpl(ResizeContainerCmd.Exec exec, String execId) {
super(exec);
withContainerId(execId);
}

@Override
public String getContainerId() {
return containerId;
}

@Override
public Integer getHeight() {
return height;
}

@Override
public Integer getWidth() {
return width;
}

@Override
public ResizeContainerCmd withContainerId(String containerId) {
checkNotNull(containerId, "containerId was not specified");
this.containerId = containerId;
return this;
}

@Override
public ResizeContainerCmd withSize(int height, int width) {
this.height = height;
this.width = width;
return this;
}

/**
* @throws NotFoundException
* No such exec instance
*/
@Override
public Void exec() throws NotFoundException {
return super.exec();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.github.dockerjava.core.command;

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

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.github.dockerjava.api.command.ResizeExecCmd;
import com.github.dockerjava.api.exception.NotFoundException;

@JsonInclude(Include.NON_NULL)
public class ResizeExecCmdImpl extends AbstrDockerCmd<ResizeExecCmd, Void> implements ResizeExecCmd {

private String execId;

private Integer height;

private Integer width;

public ResizeExecCmdImpl(ResizeExecCmd.Exec exec, String execId) {
super(exec);
withExecId(execId);
}

@Override
public String getExecId() {
return execId;
}

@Override
public Integer getHeight() {
return height;
}

@Override
public Integer getWidth() {
return width;
}

@Override
public ResizeExecCmd withExecId(String execId) {
checkNotNull(execId, "execId was not specified");
this.execId = execId;
return this;
}

@Override
public ResizeExecCmd withSize(int height, int width) {
this.height = height;
this.width = width;
return this;
}

/**
* @throws NotFoundException
* No such exec instance
*/
@Override
public Void exec() throws NotFoundException {
return super.exec();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ public CommitCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConf

@Override
protected String execute(CommitCmd command) {
WebTarget webTarget = getBaseResource().path("/commit").queryParam("container", command.getContainerId())
.queryParam("repo", command.getRepository()).queryParam("tag", command.getTag())
.queryParam("m", command.getMessage()).queryParam("author", command.getAuthor());
WebTarget webTarget = getBaseResource().path("/commit")
.queryParam("container", command.getContainerId())
.queryParam("repo", command.getRepository())
.queryParam("tag", command.getTag())
.queryParam("m", command.getMessage())
.queryParam("author", command.getAuthor());

webTarget = booleanQueryParam(webTarget, "pause", command.hasPauseEnabled());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
import com.github.dockerjava.core.MediaType;
import com.github.dockerjava.core.WebTarget;

public class ExecCreateCmdExec extends AbstrSyncDockerCmdExec<ExecCreateCmd, ExecCreateCmdResponse> implements
ExecCreateCmd.Exec {
public class ExecCreateCmdExec extends AbstrSyncDockerCmdExec<ExecCreateCmd, ExecCreateCmdResponse> implements ExecCreateCmd.Exec {

private static final Logger LOGGER = LoggerFactory.getLogger(ExecCreateCmdExec.class);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.github.dockerjava.core.exec;

import com.github.dockerjava.api.command.ResizeContainerCmd;
import com.github.dockerjava.core.DockerClientConfig;
import com.github.dockerjava.core.MediaType;
import com.github.dockerjava.core.WebTarget;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ResizeContainerCmdExec extends AbstrSyncDockerCmdExec<ResizeContainerCmd, Void> implements ResizeContainerCmd.Exec {

private static final Logger LOGGER = LoggerFactory.getLogger(ResizeContainerCmdExec.class);

public ResizeContainerCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) {
super(baseResource, dockerClientConfig);
}

@Override
protected Void execute(ResizeContainerCmd command) {
WebTarget webResource = getBaseResource().path("/containers/{id}/resize")
.resolveTemplate("id", command.getContainerId())
.queryParam("h", command.getHeight())
.queryParam("w", command.getWidth());

LOGGER.trace("POST: {}", webResource);
webResource.request().accept(MediaType.APPLICATION_JSON).post(command);

return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.github.dockerjava.core.exec;

import com.github.dockerjava.core.MediaType;
import com.github.dockerjava.core.WebTarget;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.github.dockerjava.api.command.ResizeExecCmd;
import com.github.dockerjava.core.DockerClientConfig;

public class ResizeExecCmdExec extends AbstrSyncDockerCmdExec<ResizeExecCmd, Void> implements ResizeExecCmd.Exec {

private static final Logger LOGGER = LoggerFactory.getLogger(ResizeExecCmdExec.class);

public ResizeExecCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) {
super(baseResource, dockerClientConfig);
}

@Override
protected Void execute(ResizeExecCmd command) {
WebTarget webResource = getBaseResource().path("/exec/{id}/resize")
.resolveTemplate("id", command.getExecId())
.queryParam("h", command.getHeight())
.queryParam("w", command.getWidth());

LOGGER.trace("POST: {}", webResource);
webResource.request().accept(MediaType.APPLICATION_JSON).post(command);

return null;
}
}
Loading