Skip to content

Commit 0619214

Browse files
author
Marcus Linke
committed
Extracted command interfaces
1 parent 31662d5 commit 0619214

File tree

97 files changed

+2144
-878
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+2144
-878
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
package com.github.dockerjava.api;
2+
3+
import java.io.*;
4+
5+
import com.github.dockerjava.api.command.AttachContainerCmd;
6+
import com.github.dockerjava.api.command.AuthCmd;
7+
import com.github.dockerjava.api.command.BuildImageCmd;
8+
import com.github.dockerjava.api.command.CommitCmd;
9+
import com.github.dockerjava.api.command.ContainerDiffCmd;
10+
import com.github.dockerjava.api.command.CopyFileFromContainerCmd;
11+
import com.github.dockerjava.api.command.CreateContainerCmd;
12+
import com.github.dockerjava.api.command.CreateImageCmd;
13+
import com.github.dockerjava.api.command.InfoCmd;
14+
import com.github.dockerjava.api.command.InspectContainerCmd;
15+
import com.github.dockerjava.api.command.InspectImageCmd;
16+
import com.github.dockerjava.api.command.KillContainerCmd;
17+
import com.github.dockerjava.api.command.ListContainersCmd;
18+
import com.github.dockerjava.api.command.ListImagesCmd;
19+
import com.github.dockerjava.api.command.LogContainerCmd;
20+
import com.github.dockerjava.api.command.PauseContainerCmd;
21+
import com.github.dockerjava.api.command.PingCmd;
22+
import com.github.dockerjava.api.command.PullImageCmd;
23+
import com.github.dockerjava.api.command.PushImageCmd;
24+
import com.github.dockerjava.api.command.RemoveContainerCmd;
25+
import com.github.dockerjava.api.command.RemoveImageCmd;
26+
import com.github.dockerjava.api.command.RestartContainerCmd;
27+
import com.github.dockerjava.api.command.SearchImagesCmd;
28+
import com.github.dockerjava.api.command.StartContainerCmd;
29+
import com.github.dockerjava.api.command.StopContainerCmd;
30+
import com.github.dockerjava.api.command.TagImageCmd;
31+
import com.github.dockerjava.api.command.TopContainerCmd;
32+
import com.github.dockerjava.api.command.UnpauseContainerCmd;
33+
import com.github.dockerjava.api.command.VersionCmd;
34+
import com.github.dockerjava.api.command.WaitContainerCmd;
35+
import com.github.dockerjava.client.model.AuthConfig;
36+
37+
public interface DockerClient extends Closeable {
38+
39+
public AuthConfig authConfig() throws DockerException;
40+
41+
/**
42+
* Authenticate with the server, useful for checking authentication.
43+
*/
44+
public AuthCmd authCmd();
45+
46+
public InfoCmd infoCmd() throws DockerException;
47+
48+
public PingCmd pingCmd();
49+
50+
public VersionCmd versionCmd() throws DockerException;
51+
52+
/**
53+
* * IMAGE API *
54+
*/
55+
56+
public PullImageCmd pullImageCmd(String repository);
57+
58+
public PushImageCmd pushImageCmd(String name);
59+
60+
public CreateImageCmd createImageCmd(String repository,
61+
InputStream imageStream);
62+
63+
public SearchImagesCmd searchImagesCmd(String term);
64+
65+
public RemoveImageCmd removeImageCmd(String imageId);
66+
67+
public ListImagesCmd listImagesCmd();
68+
69+
public InspectImageCmd inspectImageCmd(String imageId);
70+
71+
/**
72+
* * CONTAINER API *
73+
*/
74+
75+
public ListContainersCmd listContainersCmd();
76+
77+
public CreateContainerCmd createContainerCmd(String image);
78+
79+
public StartContainerCmd startContainerCmd(String containerId);
80+
81+
public InspectContainerCmd inspectContainerCmd(String containerId);
82+
83+
public RemoveContainerCmd removeContainerCmd(String containerId);
84+
85+
public WaitContainerCmd waitContainerCmd(String containerId);
86+
87+
public AttachContainerCmd attachContainerCmd(String containerId);
88+
89+
public LogContainerCmd logContainerCmd(String containerId);
90+
91+
public CopyFileFromContainerCmd copyFileFromContainerCmd(
92+
String containerId, String resource);
93+
94+
public ContainerDiffCmd containerDiffCmd(String containerId);
95+
96+
public StopContainerCmd stopContainerCmd(String containerId);
97+
98+
public KillContainerCmd killContainerCmd(String containerId);
99+
100+
public RestartContainerCmd restartContainerCmd(String containerId);
101+
102+
public CommitCmd commitCmd(String containerId);
103+
104+
public BuildImageCmd buildImageCmd(File dockerFolder);
105+
106+
public BuildImageCmd buildImageCmd(InputStream tarInputStream);
107+
108+
public TopContainerCmd topContainerCmd(String containerId);
109+
110+
public TagImageCmd tagImageCmd(String imageId, String repository, String tag);
111+
112+
public PauseContainerCmd pauseContainerCmd(String containerId);
113+
114+
public UnpauseContainerCmd unpauseContainerCmd(String containerId);
115+
116+
public void close() throws IOException;
117+
118+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.github.dockerjava.api.command;
2+
3+
import java.io.InputStream;
4+
5+
import com.github.dockerjava.api.NotFoundException;
6+
7+
/**
8+
* Attach to container
9+
*
10+
* @param logs
11+
* - true or false, includes logs. Defaults to false.
12+
*
13+
* @param followStream
14+
* - true or false, return stream. Defaults to false.
15+
* @param stdout
16+
* - true or false, includes stdout log. Defaults to false.
17+
* @param stderr
18+
* - true or false, includes stderr log. Defaults to false.
19+
* @param timestamps
20+
* - true or false, if true, print timestamps for every log line.
21+
* Defaults to false.
22+
*/
23+
public interface AttachContainerCmd extends DockerCmd<InputStream>{
24+
25+
public String getContainerId();
26+
27+
public boolean hasLogsEnabled();
28+
29+
public boolean hasFollowStreamEnabled();
30+
31+
public boolean hasTimestampsEnabled();
32+
33+
public boolean hasStdoutEnabled();
34+
35+
public boolean hasStderrEnabled();
36+
37+
public AttachContainerCmd withContainerId(String containerId);
38+
39+
public AttachContainerCmd withFollowStream();
40+
41+
public AttachContainerCmd withFollowStream(boolean followStream);
42+
43+
public AttachContainerCmd withTimestamps(boolean timestamps);
44+
45+
public AttachContainerCmd withStdOut();
46+
47+
public AttachContainerCmd withStdOut(boolean stdout);
48+
49+
public AttachContainerCmd withStdErr();
50+
51+
public AttachContainerCmd withStdErr(boolean stderr);
52+
53+
public AttachContainerCmd withLogs(boolean logs);
54+
55+
/**
56+
* @throws NotFoundException No such container
57+
*/
58+
@Override
59+
public InputStream exec() throws NotFoundException;
60+
61+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.github.dockerjava.api.command;
2+
3+
/**
4+
*
5+
* Authenticate with the server, useful for checking authentication.
6+
*
7+
*/
8+
public interface AuthCmd extends DockerCmd<Void>{
9+
10+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.github.dockerjava.api.command;
2+
3+
import java.io.File;
4+
import java.io.InputStream;
5+
6+
/**
7+
*
8+
* Build an image from Dockerfile.
9+
*
10+
* TODO: http://docs.docker.com/reference/builder/#dockerignore
11+
*
12+
*/
13+
public interface BuildImageCmd extends DockerCmd<InputStream>{
14+
15+
public BuildImageCmd withTag(String tag);
16+
17+
public File getDockerFolder();
18+
19+
public String getTag();
20+
21+
public boolean hasNoCacheEnabled();
22+
23+
public boolean hasRemoveEnabled();
24+
25+
public boolean isQuiet();
26+
27+
public BuildImageCmd withNoCache();
28+
29+
public BuildImageCmd withNoCache(boolean noCache);
30+
31+
public BuildImageCmd withRemove(boolean rm);
32+
33+
public BuildImageCmd withQuiet(boolean quiet);
34+
35+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
package com.github.dockerjava.api.command;
2+
3+
import com.github.dockerjava.api.NotFoundException;
4+
import com.github.dockerjava.client.model.ExposedPorts;
5+
import com.github.dockerjava.client.model.Volumes;
6+
import com.github.dockerjava.jaxrs1.command.CommitCommand;
7+
8+
/**
9+
*
10+
* Create a new image from a container's changes. Returns the new image ID.
11+
*
12+
*/
13+
public interface CommitCmd extends DockerCmd<String>{
14+
15+
public String getContainerId();
16+
17+
public CommitCommand withContainerId(String containerId);
18+
19+
public String getRepository();
20+
21+
public String getTag();
22+
23+
public String getMessage();
24+
25+
public String getAuthor();
26+
27+
public boolean hasPauseEnabled();
28+
29+
public CommitCmd withAttachStderr(boolean attachStderr);
30+
31+
public CommitCmd withAttachStderr();
32+
33+
public CommitCmd withAttachStdin(boolean attachStdin);
34+
35+
public CommitCmd withAttachStdin();
36+
37+
public CommitCmd withAttachStdout(boolean attachStdout);
38+
39+
public CommitCmd withAttachStdout();
40+
41+
public CommitCmd withCmd(String... cmd);
42+
43+
public CommitCmd withDisableNetwork(boolean disableNetwork);
44+
45+
public CommitCmd withAuthor(String author);
46+
47+
public CommitCmd withMessage(String message);
48+
49+
public CommitCmd withTag(String tag);
50+
51+
public CommitCmd withRepository(String repository);
52+
53+
public CommitCmd withPause(boolean pause);
54+
55+
public String[] getEnv();
56+
57+
public CommitCmd withEnv(String... env);
58+
59+
public ExposedPorts getExposedPorts();
60+
61+
public CommitCmd withExposedPorts(ExposedPorts exposedPorts);
62+
63+
public String getHostname();
64+
65+
public CommitCmd withHostname(String hostname);
66+
67+
public Integer getMemory();
68+
69+
public CommitCmd withMemory(Integer memory);
70+
71+
public Integer getMemorySwap();
72+
73+
public CommitCmd withMemorySwap(Integer memorySwap);
74+
75+
public boolean isOpenStdin();
76+
77+
public CommitCmd withOpenStdin(boolean openStdin);
78+
79+
public String[] getPortSpecs();
80+
81+
public CommitCmd withPortSpecs(String... portSpecs);
82+
83+
public boolean isStdinOnce();
84+
85+
public CommitCmd withStdinOnce(boolean stdinOnce);
86+
87+
public CommitCmd withStdinOnce();
88+
89+
public boolean isTty();
90+
91+
public CommitCmd withTty(boolean tty);
92+
93+
public CommitCmd withTty();
94+
95+
public String getUser();
96+
97+
public CommitCmd withUser(String user);
98+
99+
public Volumes getVolumes();
100+
101+
public CommitCmd withVolumes(Volumes volumes);
102+
103+
public String getWorkingDir();
104+
105+
public CommitCmd withWorkingDir(String workingDir);
106+
107+
/**
108+
* @throws NotFoundException No such container
109+
*/
110+
public String exec() throws NotFoundException;
111+
112+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.github.dockerjava.api.command;
2+
3+
import java.util.List;
4+
5+
import com.github.dockerjava.api.DockerException;
6+
import com.github.dockerjava.api.InternalServerErrorException;
7+
import com.github.dockerjava.api.NotFoundException;
8+
import com.github.dockerjava.client.model.ChangeLog;
9+
10+
public interface ContainerDiffCmd extends DockerCmd<List<ChangeLog>> {
11+
12+
public String getContainerId();
13+
14+
public ContainerDiffCmd withContainerId(String containerId);
15+
16+
public String toString();
17+
18+
/**
19+
* @throws NotFoundException No such container
20+
* @throws InternalServerErrorException server error
21+
* @throws DockerException unexpected http status code
22+
*/
23+
public List<ChangeLog> exec() throws NotFoundException;
24+
25+
}

0 commit comments

Comments
 (0)