UNPKG

13.1 kBTypeScriptView Raw
1/// <reference types="node" />
2import Modem = require('docker-modem');
3import { Image } from './image';
4import fs = require('fs');
5/**
6 * Class representing container execution
7 */
8export declare class Exec {
9 modem: Modem;
10 container: Container;
11 id: String;
12 data: Object;
13 /**
14 * Create an execution
15 * @param {Modem} modem Modem to connect to the remote service
16 * @param {Container} container Container that owns the execution (optional)
17 * @param {string} id Id of the execution
18 */
19 constructor(modem: Modem, container: Container, id: String);
20 /**
21 * Create an exec instance in a container
22 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/create-a-container
23 * @param {Object} opts Query params in the request (optional)
24 * @return {Promise} Promise return the new exec instance
25 */
26 create(opts?: Object): Promise<Exec>;
27 /**
28 * Start an exec instance
29 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/exec-start
30 * @param {Object} opts Query params in the request (optional)
31 * @return {Promise} Promise return the stream to the execution
32 */
33 start(opts?: any): Promise<Object>;
34 /**
35 * Resize an exec instance
36 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/exec-resize
37 * @param {Object} opts Query params in the request (optional)
38 * @return {Promise} Promise return the result
39 */
40 resize(opts?: Object): Promise<{}>;
41 /**
42 * Get status of an exec instance
43 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/exec-inspect
44 * The reason why this module isn't called inspect is because that interferes with the inspect utility of node.
45 * @param {Object} opts Query params in the request (optional)
46 * @return {Promise} Promise return the exec instance
47 */
48 status(opts?: Object): Promise<Exec>;
49}
50/**
51 * Class representing container execution management
52 */
53export declare class ExecManager {
54 modem: Modem;
55 container: Container;
56 /**
57 * Create an execution
58 * @param {Modem} modem Modem to connect to the remote service
59 * @param {Container} container Container that owns the execution (optional)
60 * @param {string} id Id of the execution
61 */
62 constructor(modem: Modem, container: Container);
63 /**
64 * Get a Exec object
65 * @param {id} string ID of the exec
66 * @return {Exec}
67 */
68 get(id: String): Exec;
69 /**
70 * Create an exec instance in a container
71 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/create-a-container
72 * @param {Object} opts Query params in the request (optional)
73 * @return {Promise} Promise return the new exec instance
74 */
75 create(opts?: Object): Promise<Exec>;
76}
77/**
78 * Class representing container filesystem
79 */
80export declare class ContainerFs {
81 modem: Modem;
82 container: Container;
83 /**
84 * Create an container filesystem object
85 * @param {Modem} modem Modem to connect to the remote service
86 * @param {Container} container Container that owns the filesystem (optional)
87 */
88 constructor(modem: Modem, container: Container);
89 /**
90 * Get the info about the filesystem of the container
91 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/retrieving-information-about-files-and-folders-in-a-container
92 * @param {Object} opts Query params in the request (optional)
93 * @return {Promise} Promise returning the info about the filesystem
94 */
95 info(opts?: Object): Promise<String>;
96 /**
97 * Get a tar archive of a resource in the filesystem of a container
98 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/get-an-archive-of-a-filesystem-resource-in-a-container
99 * @param {Object} opts Query params in the request (optional)
100 * @return {Promise} Promise returning the result as a stream to the tar file
101 */
102 get(opts?: any): Promise<Object>;
103 /**
104 * Put an extracted tar archive in the filesystem of a container
105 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/extract-an-archive-of-files-or-folders-to-a-directory-in-a-container
106 * @param {Object} opts Query params in the request (optional)
107 * @return {Promise} Promise returning the result
108 */
109 put(file: fs.ReadStream, opts?: Object): Promise<Object>;
110}
111/**
112 * Class representing a container
113 */
114export declare class Container {
115 modem: Modem;
116 id: String;
117 fs: ContainerFs;
118 exec: ExecManager;
119 Warnings: Array<String>;
120 data: Object;
121 /**
122 * Create an container object
123 * @param {Modem} modem Modem to connect to the remote service
124 * @param {string} id Container id
125 */
126 constructor(modem: Modem, id: String);
127 /**
128 * Get low-level information on a container
129 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/inspect-a-container
130 * The reason why this module isn't called inspect is because that interferes with the inspect utility of node.
131 * @param {Object} opts Query params in the request (optional)
132 * @return {Promise} Promise return the container
133 */
134 status(opts?: Object): Promise<Container>;
135 /**
136 * Get list of processes (ps) inside a container. Not supported in Windows.
137 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/list-processes-running-inside-a-container
138 * @param {Object} opts Query params in the request (optional)
139 * @return {Promise} Promise return the list of processes
140 */
141 top(opts?: Object): Promise<Array<Object>>;
142 /**
143 * Get stdout and stderr logs from a container
144 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/get-container-logs
145 * @param {Object} opts Query params in the request (optional)
146 * @return {Promise} Promise returning the concatenated logs
147 */
148 logs(opts?: Object): Promise<Object>;
149 /**
150 * Get changes on a container's filesystem
151 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/inspect-changes-on-a-container-s-filesystem
152 * @return {Promise} Promise returning the changes
153 */
154 changes(): Promise<Array<Object>>;
155 /**
156 * Export the content of a container
157 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/export-a-container
158 * @param {Object} opts Query params in the request (optional)
159 * @return {Promise} Promise returning the content of the tar file as a stream or as a string
160 */
161 export(opts?: any): Promise<Object>;
162 /**
163 * Get the stats of a container, either by a live stream or the current state
164 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/export-a-container
165 * @param {Object} opts Query params in the request (optional)
166 * @return {Promise} Promise returning the stats, in a stream or string
167 */
168 stats(opts?: Object): Promise<Object>;
169 /**
170 * Resize the TTY for a container. You must restart the container to make the resize take effect.
171 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/resize-a-container-tty
172 * @param {Object} opts Query params in the request (optional)
173 * @return {Promise} Promise returning the response
174 */
175 resize(opts?: Object): Promise<Object>;
176 /**
177 * Start a container
178 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/start-a-container
179 * @param {Object} opts Query params in the request (optional)
180 * @return {Promise} Promise returning the container
181 */
182 start(opts?: Object): Promise<Container>;
183 /**
184 * Stop a container
185 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/stop-a-container
186 * @param {Object} opts Query params in the request (optional)
187 * @return {Promise} Promise returning the container
188 */
189 stop(opts?: Object): Promise<Container>;
190 /**
191 * Restart a container
192 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/restart-a-container
193 * @param {Object} opts Query params in the request (optional)
194 * @return {Promise} Promise returning the container
195 */
196 restart(opts?: Object): Promise<Container>;
197 /**
198 * Kill a container
199 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/kill-a-container
200 * @param {Object} opts Query params in the request (optional)
201 * @return {Promise} Promise returning the container
202 */
203 kill(opts?: Object): Promise<Container>;
204 /**
205 * Update configuration a container.
206 * Docs says you can do it for more than one, but doesn't exaplin how, so let's leave it in only one
207 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/update-a-container
208 * @param {Object} opts Query params in the request (optional)
209 * @return {Promise} Promise returning the container
210 */
211 update(opts?: Object): Promise<Container>;
212 /**
213 * Rename a container.
214 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/rename-a-container
215 * @param {Object} opts Query params in the request (optional)
216 * @return {Promise} Promise returning the container
217 */
218 rename(opts: Object): Promise<Container>;
219 /**
220 * Pause a container.
221 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/pause-a-container
222 * @return {Promise} Promise returning the container
223 */
224 pause(): Promise<Container>;
225 /**
226 * Unpause a container.
227 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/unpause-a-container
228 * @return {Promise} Promise returning the container
229 */
230 unpause(): Promise<Container>;
231 /**
232 * Attach to a container.
233 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/attach-to-a-container
234 * @param {Object} opts Query params in the request (optional)
235 * @return {Promise} Promise returning the container
236 */
237 attach(opts?: any): Promise<Array<Object>>;
238 /**
239 * Attach to a container using websocket.
240 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/attach-to-a-container-websocket
241 * @param {Object} opts Query params in the request (optional)
242 * @return {Promise} Promise returning the stream and the container
243 */
244 wsattach(opts?: Object): Promise<Array<Object>>;
245 /**
246 * Block until a container stops, returning exit code
247 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/wait-a-container
248 * @return {Promise} Promise returning the exit code
249 */
250 wait(): Promise<Number>;
251 /**
252 * Remove a container.
253 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/remove-a-container
254 * @param {Object} opts Query params in the request (optional)
255 * @return {Promise} Promise returning nothing
256 */
257 delete(opts?: Object): Promise<{}>;
258 /**
259 * Commit container into an image
260 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/create-a-new-image-from-a-container-s-changes
261 * @param {Object} opts Query params in the request (optional)
262 * @return {Promise} Promise returning the new image
263 */
264 commit(opts?: any): Promise<Image>;
265}
266export default class {
267 modem: Modem;
268 constructor(modem: Modem);
269 /**
270 * Get a Container object
271 * @param {id} string ID of the container
272 * @return {Container}
273 */
274 get(id: String): Container;
275 /**
276 * Get the list of containers
277 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/list-containers
278 * @param {Object} opts Query params in the request (optional)
279 * @return {Promise} Promise returning the result as a list of containers
280 */
281 list(opts?: Object): Promise<Array<Container>>;
282 /**
283 * Create a container
284 * https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/create-a-container
285 * @param {Object} opts Query params in the request (optional)
286 * @return {Promise} Promise return the new container
287 */
288 create(opts?: Object): Promise<Container>;
289 /**
290 * Prune a container
291 * https://docs.docker.com/engine/api/v1.25/#operation/ContainerPrune
292 * @param {Object} opts Query params in the request (optional)
293 * @return {Promise} Promise returning the container
294 */
295 prune(opts?: Object): Promise<Object>;
296}