Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1ec98f1c3ec12cd946ae95a56f35d380142ca5cc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/*******************************************************************************
 * Copyright (c) 2014 Red Hat.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Red Hat - Initial Contribution
 *******************************************************************************/
package org.eclipse.linuxtools.docker.core;

import java.io.OutputStream;
import java.util.Collections;
import java.util.List;

import org.eclipse.core.runtime.IPath;
import org.eclipse.linuxtools.internal.docker.core.DockerContainerRefreshManager;

public interface IDockerConnection {

	public void addContainerListener(IDockerContainerListener listener);

	public void removeContainerListener(IDockerContainerListener listener);

	/**
	 * Get the list of {@link IDockerContainer} of the remote Docker daemon.
	 * 
	 * @return an unmodifiable list of {@link IDockerContainer} or
	 *         {@link Collections#emptyList()} if no container exists yet. see
	 *         {@link IDockerConnection#getContainers(boolean)}
	 */
	public List<IDockerContainer> getContainers();

	/**
	 * Get the list of {@link IDockerContainer} of the remote Docker daemon.
	 * 
	 * @param force
	 *            {@code true} to force a new retrieval of the list of
	 *            {@link IDockerContainer}, {@code false} to use the cached
	 *            list.
	 * @return an unmodifiable list of {@link IDockerContainer} or
	 *         {@link Collections#emptyList()} if no container exists yet.
	 */
	public List<IDockerContainer> getContainers(final boolean force);
	
	/**
	 * @return Boolean flag to indicate if the list of {@link IDockerContainer}
	 *         has already been loaded ({@code true}) or not ({@code false}).
	 */
	public boolean isContainersLoaded();

	/**
	 * @return the {@link IDockerContainer} identified by the given {@code id} or <code>null</code> if none was found.
	 * @param id the {@link IDockerContainer} id
	 */
	public IDockerContainer getContainer(final String id);

	/**
	 * @return the {@link IDockerContainerInfo} for the {@link IDockerContainer} identified by the given {@code id} or <code>null</code> if none was found.
	 * @param id the {@link IDockerContainer} id
	 */
	public IDockerContainerInfo getContainerInfo(final String id);

	/**
	 * @return the {@link IDockerImageInfo} for the {@link IDockerImage}
	 *         identified by the given {@code id} or <code>null</code> if none
	 *         was found.
	 * @param id
	 *            the {@link IDockerImage} id
	 */
	public IDockerImageInfo getImageInfo(final String id);

	public void addImageListener(IDockerImageListener listener);

	public void removeImageListener(IDockerImageListener listener);

	/**
	 * Get the list of {@link IDockerImage} of the remote Docker daemon.
	 * 
	 * @return an unmodifiable list of {@link IDockerImage} or
	 *         {@link Collections#emptyList()} if no container exists yet.
	 * @see IDockerConnection#getImages(boolean)
	 */
	public List<IDockerImage> getImages();

	/**
	 * Get the list of {@link IDockerImage} of the remote Docker daemon.
	 * 
	 * @param force
	 *            {@code true} to force a new retrieval of the list of
	 *            {@link IDockerImage}, {@code false} to use the cached
	 *            list.
	 * @return an unmodifiable list of {@link IDockerImage} or
	 *         {@link Collections#emptyList()} if no container exists yet.
	 */
	public List<IDockerImage> getImages(final boolean force);
	
	/**
	 * @return Boolean flag to indicate if the list of {@link IDockerImage}
	 *         has already been loaded ({@code true}) or not ({@code false}).
	 */
	public boolean isImagesLoaded();

	public String getName();

	public String getUri();

	public String getUsername();

	public String getTcpCertPath();

	/**
	 * Checks if the connection is open
	 * @return {@code true} if connection is open, {@code false} otherwise.
	 */
	public boolean isOpen();

	/**
	 * Opens the connection to the Docker daemon.
	 * 
	 * @param registerContainerRefreshManager
	 *            {@code true} if the {@link DockerContainerRefreshManager}
	 *            should be associated with the Docker client to auto-refresh
	 *            the list of containers, {@code false} otherwise (eg: wheh the
	 *            connection should just be tested with a call to
	 *            {@link IDockerConnection#ping()}
	 * @throws DockerException
	 *             generic exception
	 */
	public void open(boolean registerContainerRefreshManager) throws DockerException;

	/**
	 * Send a ping message to the Docker daemon to check if the connection
	 * works.
	 * 
	 * @throws DockerException
	 *             generic exception
	 */
	public void ping() throws DockerException;

	/**
	 * Closes the connection.
	 */
	public void close();

	/**
	 * @return the {@link IDockerConnectionInfo} associated with this {@link IDockerConnection}
	 * @throws DockerException if info retrieval failed
	 */
	public IDockerConnectionInfo getInfo() throws DockerException;

	void pullImage(String id, IDockerProgressHandler handler) throws DockerException, InterruptedException;

	void pushImage(String name, IDockerProgressHandler handler) throws DockerException, InterruptedException;

	void tagImage(String name, String newTag) throws DockerException, InterruptedException;

	String buildImage(IPath path, String name, IDockerProgressHandler handler)
			throws DockerException, InterruptedException;

	String createContainer(IDockerContainerConfig c) throws DockerException, InterruptedException;

	void stopContainer(String id) throws DockerException, InterruptedException;

	void killContainer(String id) throws DockerException, InterruptedException;

	void pauseContainer(String id) throws DockerException, InterruptedException;

	void unpauseContainer(String id, OutputStream stream) throws DockerException, InterruptedException;

	void removeContainer(String id) throws DockerException, InterruptedException;

	void startContainer(String id, OutputStream stream) throws DockerException, InterruptedException;

	void startContainer(String id, IDockerHostConfig config, OutputStream stream)
			throws DockerException, InterruptedException;

	void startContainer(String id, String loggingId, IDockerHostConfig config, OutputStream stream)
			throws DockerException, InterruptedException;

	void commitContainer(String id, String repo, String tag, String comment, String author) throws DockerException;

	void stopLoggingThread(String id);

	void logContainer(String id, OutputStream stream) throws DockerException, InterruptedException;

	void removeImage(String name) throws DockerException, InterruptedException;

	void removeTag(String tag) throws DockerException, InterruptedException;

}

Back to the top