dockerapi 0.8.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +86 -18
- data/Gemfile.lock +1 -1
- data/README.md +158 -22
- data/lib/docker/api/config.rb +70 -0
- data/lib/docker/api/container.rb +17 -6
- data/lib/docker/api/exec.rb +14 -7
- data/lib/docker/api/image.rb +20 -6
- data/lib/docker/api/network.rb +16 -5
- data/lib/docker/api/node.rb +17 -5
- data/lib/docker/api/plugin.rb +166 -0
- data/lib/docker/api/secret.rb +70 -0
- data/lib/docker/api/service.rb +98 -0
- data/lib/docker/api/swarm.rb +12 -1
- data/lib/docker/api/task.rb +46 -0
- data/lib/docker/api/version.rb +1 -1
- data/lib/docker/api/volume.rb +19 -7
- data/lib/dockerapi.rb +5 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a32e488d06a0afd653bb04ab0ad5131fa8e898973128d7a6661f3d3fa4eae53d
|
4
|
+
data.tar.gz: 641ffcc096f798fbfff057fb1eecc7ce97ad9191c2acf49f5e97c90bf5ceddc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cda72170483e133b467a399d77fbcc7668793726b8f67beb4235c5eaf74e2d91977c9544f93ee7d3f3c4b681004d9415f939d2d521aa70151d3a580fc15fc86
|
7
|
+
data.tar.gz: d45997041c9d706d2c2d0e2c5e3f5ccaedad51d71cb27ba8538898565e6259e30d7ff11ffa60a5dee9ffca3611ed51ddc96ca68af2a5aff490715b4645297c0d
|
data/CHANGELOG.md
CHANGED
@@ -1,17 +1,85 @@
|
|
1
|
+
# 0.12.0
|
2
|
+
|
3
|
+
Add `Docker::API::Plugin` methods:
|
4
|
+
* list
|
5
|
+
* privileges
|
6
|
+
* install
|
7
|
+
* details
|
8
|
+
* remove
|
9
|
+
* enable
|
10
|
+
* disable
|
11
|
+
* upgrade
|
12
|
+
* create
|
13
|
+
* push
|
14
|
+
* configure
|
15
|
+
|
16
|
+
# 0.11.0
|
17
|
+
|
18
|
+
Add `Docker::API::Task` methods:
|
19
|
+
* list
|
20
|
+
* details
|
21
|
+
* logs
|
22
|
+
|
23
|
+
Add `Docker::API::Secret` methods:
|
24
|
+
* create
|
25
|
+
* update
|
26
|
+
* list
|
27
|
+
* details
|
28
|
+
* delete
|
29
|
+
|
30
|
+
Add `Docker::API::Config` methods:
|
31
|
+
* create
|
32
|
+
* update
|
33
|
+
* list
|
34
|
+
* details
|
35
|
+
* delete
|
36
|
+
|
37
|
+
Add `Docker::API::Image` methods:
|
38
|
+
* distribution
|
39
|
+
|
40
|
+
# 0.10.0
|
41
|
+
|
42
|
+
Add `Docker::API::Service` methods:
|
43
|
+
* create
|
44
|
+
* update
|
45
|
+
* list
|
46
|
+
* details
|
47
|
+
* logs
|
48
|
+
* delete
|
49
|
+
|
50
|
+
# 0.9.0
|
51
|
+
|
52
|
+
Significant change: `#inspect` is now deprecated and replaced by `#details` in the following classes:
|
53
|
+
* `Docker::API::Container`
|
54
|
+
* `Docker::API::Image`
|
55
|
+
* `Docker::API::Network`
|
56
|
+
* `Docker::API::Volume`
|
57
|
+
* `Docker::API::Exec`
|
58
|
+
* `Docker::API::Swarm`
|
59
|
+
* `Docker::API::Node`
|
60
|
+
|
61
|
+
The method will be removed in the refactoring phase.
|
62
|
+
|
63
|
+
# 0.8.1
|
64
|
+
|
65
|
+
Restore the default `#inspect` output for `Docker::API` classes.
|
66
|
+
|
67
|
+
Most of the overriding methods take an argument, therefore calling using the expect arguments will return a `Docker::API::Response` object, while calling without arguments will return `Kernel#inspect`. To avoid this confusing schema, next release will rename `#inspect` within `Docker::API` to something else.
|
68
|
+
|
1
69
|
# 0.8.0
|
2
70
|
|
3
|
-
Add Docker::API::Swarm methods:
|
71
|
+
Add `Docker::API::Swarm` methods:
|
4
72
|
* init
|
5
73
|
* update
|
6
|
-
* inspect
|
74
|
+
* ~~inspect~~ details
|
7
75
|
* unlock_key
|
8
76
|
* unlock
|
9
77
|
* join
|
10
78
|
* leave
|
11
79
|
|
12
|
-
Add Docker::API::Node methods:
|
80
|
+
Add `Docker::API::Node` methods:
|
13
81
|
* list
|
14
|
-
* inspect
|
82
|
+
* ~~inspect~~ details
|
15
83
|
* update
|
16
84
|
* delete
|
17
85
|
|
@@ -19,7 +87,7 @@ Query parameters and request body json can now skip the validation step with `:s
|
|
19
87
|
|
20
88
|
# 0.7.0
|
21
89
|
|
22
|
-
|
90
|
+
Significant changes: `Docker::API::Connection` is now a regular class intead of a Singleton, allowing multiple connections to be stablished within the same program (replacing the connect_to implementation). To leverage this feature, API-related classes must be initialized and may or may not receive a `Docker::API::Connection` as parameter, or it'll connect to `/var/run/docker.sock` by default. For this reason, class methods were replaced with instance methods. Documentation will reflect this changes of implementation.
|
23
91
|
|
24
92
|
Bug fix: Image push returns a 20X status even when the push is unsucessful. To prevent false positives, it now requires the authentication parameters to be provided, generating a 403 status for invalid credentials or an error if they are absent.
|
25
93
|
|
@@ -27,15 +95,15 @@ Bug fix: Image push returns a 20X status even when the push is unsucessful. To p
|
|
27
95
|
|
28
96
|
Add connection parameters specifications with connect_to in Docker::API::Connection.
|
29
97
|
|
30
|
-
Add Docker::API::Exec methods:
|
98
|
+
Add `Docker::API::Exec` methods:
|
31
99
|
* create
|
32
100
|
* start
|
33
101
|
* resize
|
34
|
-
* inspect
|
102
|
+
* ~~inspect~~ details
|
35
103
|
|
36
104
|
# 0.5.0
|
37
105
|
|
38
|
-
Add Docker::API::System methods:
|
106
|
+
Add `Docker::API::System` methods:
|
39
107
|
* auth
|
40
108
|
* ping
|
41
109
|
* info
|
@@ -43,7 +111,7 @@ Add Docker::API::System methods:
|
|
43
111
|
* events
|
44
112
|
* df
|
45
113
|
|
46
|
-
Add new response class Docker::API::Response with the following methods:
|
114
|
+
Add new response class `Docker::API::Response` with the following methods:
|
47
115
|
* json
|
48
116
|
* path
|
49
117
|
* success?
|
@@ -52,9 +120,9 @@ Error classes output better error messages.
|
|
52
120
|
|
53
121
|
# 0.4.0
|
54
122
|
|
55
|
-
Add Docker::API::Network methods:
|
123
|
+
Add `Docker::API::Network` methods:
|
56
124
|
* list
|
57
|
-
* inspect
|
125
|
+
* ~~inspect~~ details
|
58
126
|
* create
|
59
127
|
* remove
|
60
128
|
* prune
|
@@ -63,9 +131,9 @@ Add Docker::API::Network methods:
|
|
63
131
|
|
64
132
|
# 0.3.0
|
65
133
|
|
66
|
-
Add Docker::API::Volume methods:
|
134
|
+
Add `Docker::API::Volume` methods:
|
67
135
|
* list
|
68
|
-
* inspect
|
136
|
+
* ~~inspect~~ details
|
69
137
|
* create
|
70
138
|
* remove
|
71
139
|
* prune
|
@@ -73,8 +141,8 @@ Add Docker::API::Volume methods:
|
|
73
141
|
|
74
142
|
# 0.2.0
|
75
143
|
|
76
|
-
Add Docker::API::Image methods:
|
77
|
-
* inspect
|
144
|
+
Add `Docker::API::Image` methods:
|
145
|
+
* ~~inspect~~ details
|
78
146
|
* history
|
79
147
|
* list
|
80
148
|
* search
|
@@ -89,13 +157,13 @@ Add Docker::API::Image methods:
|
|
89
157
|
* build
|
90
158
|
* delete_cache
|
91
159
|
|
92
|
-
Add Docker::API::System.auth (untested) for basic authentication
|
160
|
+
Add `Docker::API::System.auth` (untested) for basic authentication
|
93
161
|
|
94
162
|
# 0.1.0
|
95
163
|
|
96
|
-
Add Docker::API::Container methods:
|
164
|
+
Add `Docker::API::Container` methods:
|
97
165
|
* list
|
98
|
-
* inspect
|
166
|
+
* ~~inspect~~ details
|
99
167
|
* top
|
100
168
|
* changes
|
101
169
|
* start
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -20,8 +20,6 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
New implementation details as of v0.7.0.
|
24
|
-
|
25
23
|
### Images
|
26
24
|
|
27
25
|
```ruby
|
@@ -44,7 +42,10 @@ image.create( fromSrc: "https://url.to/file.tar", repo: "repo:tag" )
|
|
44
42
|
image.list
|
45
43
|
|
46
44
|
# Inspect image
|
47
|
-
image.
|
45
|
+
image.details("image")
|
46
|
+
|
47
|
+
# Return image digest and platform information by contacting the registry.
|
48
|
+
image.distribution("image")
|
48
49
|
|
49
50
|
# History
|
50
51
|
image.history("image")
|
@@ -125,7 +126,7 @@ container.list
|
|
125
126
|
container.list(all: true)
|
126
127
|
|
127
128
|
# Inspect container
|
128
|
-
container.
|
129
|
+
container.details("nginx")
|
129
130
|
|
130
131
|
# View container's processes
|
131
132
|
container.top("nginx")
|
@@ -136,7 +137,7 @@ container.top("nginx").json
|
|
136
137
|
# View filesystem changes
|
137
138
|
container.changes("nginx")
|
138
139
|
|
139
|
-
# View
|
140
|
+
# View container logs
|
140
141
|
container.logs("nginx", stdout: true)
|
141
142
|
container.logs("nginx", stdout: true, follow: true)
|
142
143
|
|
@@ -172,7 +173,7 @@ volume.create( Name:"my-volume" )
|
|
172
173
|
volume.list
|
173
174
|
|
174
175
|
# Inspect volume
|
175
|
-
volume.
|
176
|
+
volume.details("my-volume")
|
176
177
|
|
177
178
|
# Remove volume
|
178
179
|
volume.remove("my-volume")
|
@@ -191,7 +192,7 @@ network = Docker::API::Network.new
|
|
191
192
|
network.list
|
192
193
|
|
193
194
|
# Inspect network
|
194
|
-
network.
|
195
|
+
network.details("bridge")
|
195
196
|
|
196
197
|
# Create network
|
197
198
|
network.create( Name:"my-network" )
|
@@ -246,7 +247,7 @@ response = exe.start(id)
|
|
246
247
|
print response.data[:stream]
|
247
248
|
|
248
249
|
# Inspect exec instance
|
249
|
-
exe.
|
250
|
+
exe.details(id)
|
250
251
|
```
|
251
252
|
|
252
253
|
### Swarm
|
@@ -258,7 +259,7 @@ swarm = Docker::API::Swarm.new
|
|
258
259
|
swarm.init({AdvertiseAddr: "local-ip-address:2377", ListenAddr: "0.0.0.0:4567"})
|
259
260
|
|
260
261
|
# Inspect swarm
|
261
|
-
swarm.
|
262
|
+
swarm.details
|
262
263
|
|
263
264
|
# Update swarm
|
264
265
|
swarm.update(version, {rotateWorkerToken: true})
|
@@ -288,7 +289,7 @@ node = Docker::API::Node.new
|
|
288
289
|
node.list
|
289
290
|
|
290
291
|
# Inspect node
|
291
|
-
node.
|
292
|
+
node.details("node-id")
|
292
293
|
|
293
294
|
# Update node (version, Role and Availability must be present)
|
294
295
|
node.update("node-id", {version: "version"}, {Role: "worker", Availability: "pause" })
|
@@ -299,9 +300,141 @@ node.update("node-id", {version: "version"}, {Role: "manager", Availability: "ac
|
|
299
300
|
node.delete("node-id")
|
300
301
|
```
|
301
302
|
|
303
|
+
### Service
|
304
|
+
```ruby
|
305
|
+
# Connect to local service endpoints
|
306
|
+
service = Docker::API::Service.new
|
307
|
+
|
308
|
+
# List services
|
309
|
+
service.list
|
310
|
+
|
311
|
+
# Create a service
|
312
|
+
service.create({Name: "nginx-service",
|
313
|
+
TaskTemplate: {ContainerSpec: { Image: "nginx:alpine" }},
|
314
|
+
Mode: { Replicated: { Replicas: 2 } },
|
315
|
+
EndpointSpec: { Ports: [ {Protocol: "tcp", PublishedPort: 80, TargetPort: 80} ] }
|
316
|
+
})
|
317
|
+
|
318
|
+
# Update a service (needs version and current Spec)
|
319
|
+
version = service.details( service ).json["Version"]["Index"]
|
320
|
+
spec = service.details(service).json["Spec"]
|
321
|
+
service.update("nginx-service", {version: version}, spec.merge!({ Mode: { Replicated: { Replicas: 1 } } }))
|
322
|
+
|
323
|
+
# View service logs
|
324
|
+
service.logs("nginx-service", stdout: true)
|
325
|
+
|
326
|
+
# Inspect service
|
327
|
+
service.details("nginx-service")
|
328
|
+
|
329
|
+
# Delete service
|
330
|
+
service.delete("nginx-service")
|
331
|
+
```
|
332
|
+
|
333
|
+
### Task
|
334
|
+
```ruby
|
335
|
+
# Connect to local task endpoints
|
336
|
+
task = Docker::API::Task.new
|
337
|
+
|
338
|
+
# List tasks
|
339
|
+
task.list
|
340
|
+
|
341
|
+
# View task logs
|
342
|
+
task.logs("task-id", stdout: true)
|
343
|
+
|
344
|
+
# Inspect service
|
345
|
+
task.details("task-id")
|
346
|
+
```
|
347
|
+
|
348
|
+
### Secret
|
349
|
+
```ruby
|
350
|
+
# Connect to local secret endpoints
|
351
|
+
secret = Docker::API::Secret.new
|
352
|
+
|
353
|
+
# List secrets
|
354
|
+
secret.list
|
355
|
+
|
356
|
+
# Create a secret
|
357
|
+
secret.create({Name: "secret-name", Data: "VEhJUyBJUyBOT1QgQSBSRUFMIENFUlRJRklDQVRFCg=="})
|
358
|
+
|
359
|
+
# Inspect secrets
|
360
|
+
secret.details("secret-name")
|
361
|
+
|
362
|
+
# Update a secret (needs version and current Spec)
|
363
|
+
version = secret.details( "secret-name" ).json["Version"]["Index"]
|
364
|
+
spec = secret.details("secret-name").json["Spec"]
|
365
|
+
secret.update("secret-name", {version: version}, spec.merge!({ Data: "VEhJUyBJUyBOT1QgQSBSRUFMIENFUlRJRklDQVRFCg==" }))
|
366
|
+
|
367
|
+
# Delete secret
|
368
|
+
secret.delete("secret-name")
|
369
|
+
```
|
370
|
+
|
371
|
+
### Config
|
372
|
+
```ruby
|
373
|
+
# Connect to local config endpoints
|
374
|
+
config = Docker::API::Config.new
|
375
|
+
|
376
|
+
# List configs
|
377
|
+
config.list
|
378
|
+
|
379
|
+
# Create a config
|
380
|
+
config.create({Name: "config-name", Data: "VEhJUyBJUyBOT1QgQSBSRUFMIENFUlRJRklDQVRFCg=="})
|
381
|
+
|
382
|
+
# Inspect configs
|
383
|
+
config.details("config-name")
|
384
|
+
|
385
|
+
# Update a configs (needs version and current Spec)
|
386
|
+
version = config.details( "config-name" ).json["Version"]["Index"]
|
387
|
+
spec = config.details("config-name").json["Spec"]
|
388
|
+
config.update("config-name", {version: version}, spec.merge!({ Data: "VEhJUyBJUyBOT1QgQSBSRUFMIENFUlRJRklDQVRFCg==" }))
|
389
|
+
|
390
|
+
# Delete config
|
391
|
+
config.delete("config-name")
|
392
|
+
```
|
393
|
+
|
394
|
+
### Plugin
|
395
|
+
```ruby
|
396
|
+
# Connect to local plugin endpoints
|
397
|
+
plugin = Docker::API::Plugin.new
|
398
|
+
|
399
|
+
# List plugins
|
400
|
+
plugin.list
|
401
|
+
|
402
|
+
# List plugin's privileges
|
403
|
+
plugin.privileges(remote: "plugin-name")
|
404
|
+
|
405
|
+
# Install plugin (using defined privileges)
|
406
|
+
privileges = plugin.privileges(remote: "plugin-name")
|
407
|
+
plugin.install({remote: "plugin-name"}, privileges)
|
408
|
+
|
409
|
+
# Upgrade plugin (using defined privileges)
|
410
|
+
privileges = plugin.privileges(remote: "plugin-name2")
|
411
|
+
plugin.upgrade("plugin-name", {remote: "plugin-name2"}, privileges)
|
412
|
+
|
413
|
+
# Enable plugin
|
414
|
+
plugin.enable("plugin-name", timeout: 0)
|
415
|
+
|
416
|
+
# Disable plugin
|
417
|
+
plugin.disable("plugin-name")
|
418
|
+
|
419
|
+
# Configure plugin
|
420
|
+
plugin.configure("plugin-name", ["DEBUG=1"])
|
421
|
+
|
422
|
+
# Inspect plugin
|
423
|
+
plugin.details("plugin-name")
|
424
|
+
|
425
|
+
# Remove plugin
|
426
|
+
plugin.remove("plugin-name")
|
427
|
+
|
428
|
+
# Create plugin (tar file must contain rootfs folder and config.json file)
|
429
|
+
plugin.create("name", "/path/to/file.tar")
|
430
|
+
|
431
|
+
# Push plugin
|
432
|
+
plugin.push("name")
|
433
|
+
```
|
434
|
+
|
302
435
|
### Connection
|
303
436
|
|
304
|
-
By default Docker::API::Connection will connect to local Docker socket at `/var/run/docker.sock`. See examples below to use a different path or connect to a remote address.
|
437
|
+
By default `Docker::API::Connection` will connect to local Docker socket at `/var/run/docker.sock`. See examples below to use a different path or connect to a remote address.
|
305
438
|
|
306
439
|
```ruby
|
307
440
|
# Setting different connections
|
@@ -373,17 +506,20 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
373
506
|
|
374
507
|
| Class | Tests | Implementation | Refactoring |
|
375
508
|
|---|---|---|---|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
| Volume | Ok | Ok | 8/
|
379
|
-
| Network | Ok | Ok | 8/
|
380
|
-
| System | Ok | Ok | 8/
|
381
|
-
| Exec | Ok | Ok | 8/
|
382
|
-
| Swarm | Ok | Ok | 8/
|
383
|
-
| Node | Ok | Ok | 8/
|
384
|
-
| Service |
|
385
|
-
| Task |
|
386
|
-
| Secret |
|
509
|
+
| Image | Ok | Ok | 8/7 |
|
510
|
+
| Container | Ok | Ok | 8/14 |
|
511
|
+
| Volume | Ok | Ok | 8/21 |
|
512
|
+
| Network | Ok | Ok | 8/21 |
|
513
|
+
| System | Ok | Ok | 8/21 |
|
514
|
+
| Exec | Ok | Ok | 8/21 |
|
515
|
+
| Swarm | Ok | Ok | 8/28 |
|
516
|
+
| Node | Ok | Ok | 8/28 |
|
517
|
+
| Service | Ok | Ok | 8/28 |
|
518
|
+
| Task | Ok | Ok | 9/4 |
|
519
|
+
| Secret | Ok | Ok | 9/4 |
|
520
|
+
| Config | Ok | Ok | 9/4 |
|
521
|
+
| Distribution | Ok | Ok | 9/4 |
|
522
|
+
| Plugin | Ok | 7/24 | 9/4 |
|
387
523
|
|
388
524
|
## Contributing
|
389
525
|
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# This class represents the Docker API endpoints regarding configs.
|
2
|
+
#
|
3
|
+
# @see https://docs.docker.com/engine/api/v1.40/#tag/Config
|
4
|
+
#
|
5
|
+
# Configs are application configurations that can be used by services. Swarm mode must be enabled for these endpoints to work.
|
6
|
+
class Docker::API::Config < Docker::API::Base
|
7
|
+
|
8
|
+
# List configs
|
9
|
+
#
|
10
|
+
# Docker API: GET /configs
|
11
|
+
#
|
12
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ConfigList
|
13
|
+
#
|
14
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
15
|
+
def list params = {}
|
16
|
+
validate Docker::API::InvalidParameter, [:filters], params
|
17
|
+
@connection.get(build_path("/configs",params))
|
18
|
+
end
|
19
|
+
|
20
|
+
# Create a config
|
21
|
+
#
|
22
|
+
# Docker API: POST /configs/create
|
23
|
+
#
|
24
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ConfigCreate
|
25
|
+
#
|
26
|
+
# @param body [Hash]: Request body to be sent as json.
|
27
|
+
def create body = {}
|
28
|
+
validate Docker::API::InvalidRequestBody, [:Name, :Labels, :Data, :Templating], body
|
29
|
+
@connection.request(method: :post, path: "/configs/create", headers: {"Content-Type": "application/json"}, body: body.to_json)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Inspect a config
|
33
|
+
#
|
34
|
+
# Docker API: GET /configs/{id}
|
35
|
+
#
|
36
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ConfigInspect
|
37
|
+
#
|
38
|
+
# @param name [String]: The ID or name of the config.
|
39
|
+
def details name
|
40
|
+
@connection.get("/configs/#{name}")
|
41
|
+
end
|
42
|
+
|
43
|
+
# Update a config
|
44
|
+
#
|
45
|
+
# Docker API: POST /configs/{id}/update
|
46
|
+
#
|
47
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ConfigUpdate
|
48
|
+
#
|
49
|
+
# @param name [String]: The ID or name of the config.
|
50
|
+
#
|
51
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
52
|
+
#
|
53
|
+
# @param body [Hash]: Request body to be sent as json.
|
54
|
+
def update name, params = {}, body = {}
|
55
|
+
validate Docker::API::InvalidParameter, [:version], params
|
56
|
+
validate Docker::API::InvalidRequestBody, [:Name, :Labels, :Data, :Driver, :Templating], body
|
57
|
+
@connection.request(method: :post, path: build_path("/configs/#{name}/update",params), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Delete a config
|
61
|
+
#
|
62
|
+
# Docker API: DELETE /configs/{id}
|
63
|
+
#
|
64
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ConfigDelete
|
65
|
+
#
|
66
|
+
# @param name [String]: The ID or name of the config.
|
67
|
+
def delete name
|
68
|
+
@connection.delete("/configs/#{name}")
|
69
|
+
end
|
70
|
+
end
|
data/lib/docker/api/container.rb
CHANGED
@@ -5,16 +5,12 @@ module Docker
|
|
5
5
|
|
6
6
|
class Container < Docker::API::Base
|
7
7
|
|
8
|
-
def base_path
|
9
|
-
"/containers"
|
10
|
-
end
|
11
|
-
|
12
8
|
def list params = {}
|
13
9
|
validate Docker::API::InvalidParameter, [:all, :limit, :size, :filters], params
|
14
10
|
@connection.get(build_path(["json"], params))
|
15
11
|
end
|
16
12
|
|
17
|
-
def
|
13
|
+
def details name, params = {}
|
18
14
|
validate Docker::API::InvalidParameter, [:size], params
|
19
15
|
@connection.get(build_path([name, "json"], params))
|
20
16
|
end
|
@@ -124,7 +120,7 @@ module Docker
|
|
124
120
|
end
|
125
121
|
|
126
122
|
def export name, path = "exported_container"
|
127
|
-
response = self.
|
123
|
+
response = self.details(name)
|
128
124
|
if response.status == 200
|
129
125
|
file = File.open(File.expand_path(path), "wb")
|
130
126
|
streamer = lambda do |chunk, remaining_bytes, total_bytes|
|
@@ -154,6 +150,21 @@ module Docker
|
|
154
150
|
response
|
155
151
|
end
|
156
152
|
|
153
|
+
#################################################
|
154
|
+
# Items in this area to be removed before 1.0.0 #
|
155
|
+
#################################################
|
156
|
+
def base_path
|
157
|
+
"/containers"
|
158
|
+
end
|
159
|
+
|
160
|
+
def inspect *args
|
161
|
+
return super.inspect if args.size == 0
|
162
|
+
warn "WARNING: #inspect is deprecated and will be removed in the future, please use #details instead."
|
163
|
+
name, params = args[0], args[1] || {}
|
164
|
+
details(name, params)
|
165
|
+
end
|
166
|
+
#################################################
|
167
|
+
|
157
168
|
end
|
158
169
|
end
|
159
170
|
end
|
data/lib/docker/api/exec.rb
CHANGED
@@ -2,10 +2,6 @@ module Docker
|
|
2
2
|
module API
|
3
3
|
class Exec < Docker::API::Base
|
4
4
|
|
5
|
-
def base_path
|
6
|
-
"/exec"
|
7
|
-
end
|
8
|
-
|
9
5
|
def create name, body = {}
|
10
6
|
validate Docker::API::InvalidRequestBody, [:AttachStdin, :AttachStdout, :AttachStderr, :DetachKeys, :Tty, :Env, :Cmd, :Privileged, :User, :WorkingDir], body
|
11
7
|
@connection.request(method: :post, path: "/containers/#{name}/exec", headers: {"Content-Type": "application/json"}, body: body.to_json )
|
@@ -27,12 +23,23 @@ module Docker
|
|
27
23
|
|
28
24
|
def resize name, params = {}
|
29
25
|
validate Docker::API::InvalidParameter, [:w, :h], params
|
30
|
-
@connection.post(build_path(
|
26
|
+
@connection.post(build_path("/exec/#{name}/resize", params))
|
31
27
|
end
|
32
28
|
|
33
|
-
def
|
34
|
-
@connection.get(
|
29
|
+
def details name
|
30
|
+
@connection.get("/exec/#{name}/json")
|
31
|
+
end
|
32
|
+
|
33
|
+
#################################################
|
34
|
+
# Items in this area to be removed before 1.0.0 #
|
35
|
+
#################################################
|
36
|
+
def inspect *args
|
37
|
+
return super.inspect if args.size == 0
|
38
|
+
warn "WARNING: #inspect is deprecated and will be removed in the future, please use #details instead."
|
39
|
+
name = args[0]
|
40
|
+
details(name)
|
35
41
|
end
|
42
|
+
#################################################
|
36
43
|
|
37
44
|
end
|
38
45
|
end
|
data/lib/docker/api/image.rb
CHANGED
@@ -7,12 +7,12 @@ module Docker
|
|
7
7
|
BuildParams = [:dockerfile, :t, :extrahosts, :remote, :q, :nocache, :cachefrom, :pull, :rm, :forcerm, :memory, :memswap, :cpushares, :cpusetcpus, :cpuperiod, :cpuquota, :buildargs, :shmsize, :squash, :labels, :networkmode, :platform, :target, :outputs]
|
8
8
|
class Image < Docker::API::Base
|
9
9
|
|
10
|
-
def
|
11
|
-
"
|
10
|
+
def details name
|
11
|
+
@connection.get(build_path([name, "json"]))
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
@connection.get(
|
14
|
+
def distribution name
|
15
|
+
@connection.get("/distribution/#{name}/json")
|
16
16
|
end
|
17
17
|
|
18
18
|
def history name
|
@@ -76,7 +76,7 @@ module Docker
|
|
76
76
|
def commit params = {}, body = {}
|
77
77
|
validate Docker::API::InvalidParameter, [:container, :repo, :tag, :comment, :author, :pause, :changes], params
|
78
78
|
validate Docker::API::InvalidRequestBody, Docker::API::CommitBody, body
|
79
|
-
container = Docker::API::Container.new.
|
79
|
+
container = Docker::API::Container.new.details(params[:container])
|
80
80
|
return container if [404, 301].include? container.status
|
81
81
|
body = JSON.parse(container.body)["Config"].merge(body)
|
82
82
|
@connection.request(method: :post, path: build_path("/commit", params), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
@@ -132,7 +132,21 @@ module Docker
|
|
132
132
|
@connection.post(build_path("/build/prune", params))
|
133
133
|
end
|
134
134
|
|
135
|
-
|
135
|
+
#################################################
|
136
|
+
# Items in this area to be removed before 1.0.0 #
|
137
|
+
#################################################
|
138
|
+
def base_path
|
139
|
+
"/images"
|
140
|
+
end
|
136
141
|
|
142
|
+
def inspect *args
|
143
|
+
return super.inspect if args.size == 0
|
144
|
+
warn "WARNING: #inspect is deprecated and will be removed in the future, please use #details instead."
|
145
|
+
name = args[0]
|
146
|
+
details(name)
|
147
|
+
end
|
148
|
+
#################################################
|
149
|
+
|
150
|
+
end
|
137
151
|
end
|
138
152
|
end
|
data/lib/docker/api/network.rb
CHANGED
@@ -2,16 +2,12 @@ module Docker
|
|
2
2
|
module API
|
3
3
|
class Network < Docker::API::Base
|
4
4
|
|
5
|
-
def base_path
|
6
|
-
"/networks"
|
7
|
-
end
|
8
|
-
|
9
5
|
def list params = {}
|
10
6
|
validate Docker::API::InvalidParameter, [:filters], params
|
11
7
|
@connection.get(build_path("/networks", params))
|
12
8
|
end
|
13
9
|
|
14
|
-
def
|
10
|
+
def details name, params = {}
|
15
11
|
validate Docker::API::InvalidParameter, [:verbose, :scope], params
|
16
12
|
@connection.get(build_path([name], params))
|
17
13
|
end
|
@@ -40,6 +36,21 @@ module Docker
|
|
40
36
|
@connection.request(method: :post, path: build_path([name, "disconnect"]), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
41
37
|
end
|
42
38
|
|
39
|
+
#################################################
|
40
|
+
# Items in this area to be removed before 1.0.0 #
|
41
|
+
#################################################
|
42
|
+
def base_path
|
43
|
+
"/networks"
|
44
|
+
end
|
45
|
+
|
46
|
+
def inspect *args
|
47
|
+
return super.inspect if args.size == 0
|
48
|
+
warn "WARNING: #inspect is deprecated and will be removed in the future, please use #details instead."
|
49
|
+
name, params = args[0], args[1] || {}
|
50
|
+
details(name, params)
|
51
|
+
end
|
52
|
+
#################################################
|
53
|
+
|
43
54
|
end
|
44
55
|
end
|
45
56
|
end
|
data/lib/docker/api/node.rb
CHANGED
@@ -1,16 +1,12 @@
|
|
1
1
|
module Docker
|
2
2
|
module API
|
3
3
|
class Node < Docker::API::Base
|
4
|
-
|
4
|
+
|
5
5
|
def list params = {}
|
6
6
|
validate Docker::API::InvalidParameter, [:filters], params
|
7
7
|
@connection.get(build_path("/nodes", params))
|
8
8
|
end
|
9
9
|
|
10
|
-
def inspect name
|
11
|
-
@connection.get("/nodes/#{name}")
|
12
|
-
end
|
13
|
-
|
14
10
|
def update name, params = {}, body = {}
|
15
11
|
validate Docker::API::InvalidParameter, [:version], params
|
16
12
|
validate Docker::API::InvalidRequestBody, [:Name, :Labels, :Role, :Availability], body
|
@@ -21,6 +17,22 @@ module Docker
|
|
21
17
|
validate Docker::API::InvalidParameter, [:force], params
|
22
18
|
@connection.delete(build_path("/nodes/#{name}", params))
|
23
19
|
end
|
20
|
+
|
21
|
+
def details name
|
22
|
+
@connection.get("/nodes/#{name}")
|
23
|
+
end
|
24
|
+
|
25
|
+
#################################################
|
26
|
+
# Items in this area to be removed before 1.0.0 #
|
27
|
+
#################################################
|
28
|
+
def inspect *args
|
29
|
+
return super.inspect if args.size == 0
|
30
|
+
warn "WARNING: #inspect is deprecated and will be removed in the future, please use #details instead."
|
31
|
+
name = args[0]
|
32
|
+
details(name)
|
33
|
+
end
|
34
|
+
#################################################
|
35
|
+
|
24
36
|
end
|
25
37
|
end
|
26
38
|
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
# This class represents the Docker API endpoints regarding plugins.
|
2
|
+
#
|
3
|
+
# @see https://docs.docker.com/engine/api/v1.40/#tag/Plugin
|
4
|
+
class Docker::API::Plugin < Docker::API::Base
|
5
|
+
|
6
|
+
# List plugins
|
7
|
+
#
|
8
|
+
# Docker API: GET /plugins
|
9
|
+
#
|
10
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginList
|
11
|
+
#
|
12
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
13
|
+
def list params = {}
|
14
|
+
validate Docker::API::InvalidParameter, [:filters], params
|
15
|
+
@connection.get(build_path("/plugins", params))
|
16
|
+
end
|
17
|
+
|
18
|
+
# Get plugin privileges
|
19
|
+
#
|
20
|
+
# Docker API: GET /plugins/privileges
|
21
|
+
#
|
22
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/GetPluginPrivileges
|
23
|
+
#
|
24
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
25
|
+
def privileges params = {}
|
26
|
+
validate Docker::API::InvalidParameter, [:remote], params
|
27
|
+
@connection.get(build_path("/plugins/privileges", params))
|
28
|
+
end
|
29
|
+
|
30
|
+
# Install a plugin
|
31
|
+
#
|
32
|
+
# Pulls and installs a plugin. After the plugin is installed, it can be enabled using the POST /plugins/{name}/enable endpoint.
|
33
|
+
#
|
34
|
+
# Docker API: POST /plugins/pull
|
35
|
+
#
|
36
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginPull
|
37
|
+
#
|
38
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
39
|
+
#
|
40
|
+
# @param privileges [Array]: Plugin privileges to be sent as json in request body.
|
41
|
+
#
|
42
|
+
# @param authentication [Hash]: Authentication parameters.
|
43
|
+
def install params = {}, privileges = [], authentication = {}
|
44
|
+
validate Docker::API::InvalidParameter, [:remote, :name], params
|
45
|
+
headers = {"Content-Type": "application/json"}
|
46
|
+
headers.merge!({"X-Registry-Auth" => Base64.urlsafe_encode64(authentication.to_json.to_s)}) if authentication.keys.size > 0
|
47
|
+
@connection.request(method: :post, path: build_path("/plugins/pull", params), headers: headers, body: privileges.to_json )
|
48
|
+
end
|
49
|
+
|
50
|
+
# Inspect a plugin
|
51
|
+
#
|
52
|
+
# Docker API: GET /plugins/{name}/json
|
53
|
+
#
|
54
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginInspect
|
55
|
+
#
|
56
|
+
# @param name [String]: The ID or name of the plugin.
|
57
|
+
def details name
|
58
|
+
@connection.get("/plugins/#{name}/json")
|
59
|
+
end
|
60
|
+
|
61
|
+
# Remove a plugin
|
62
|
+
#
|
63
|
+
# Docker API: DELETE /plugins/{name}
|
64
|
+
#
|
65
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginDelete
|
66
|
+
#
|
67
|
+
# @param name [String]: The ID or name of the plugin.
|
68
|
+
#
|
69
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
70
|
+
def remove name, params = {}
|
71
|
+
validate Docker::API::InvalidParameter, [:force], params
|
72
|
+
@connection.delete(build_path("/plugins/#{name}",params))
|
73
|
+
end
|
74
|
+
|
75
|
+
# Enable a plugin
|
76
|
+
#
|
77
|
+
# Docker API: POST /plugins/{name}/enable
|
78
|
+
#
|
79
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginEnable
|
80
|
+
#
|
81
|
+
# @param name [String]: The ID or name of the plugin.
|
82
|
+
#
|
83
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
84
|
+
def enable name, params = {}
|
85
|
+
validate Docker::API::InvalidParameter, [:timeout], params
|
86
|
+
@connection.post(build_path("/plugins/#{name}/enable", params))
|
87
|
+
end
|
88
|
+
|
89
|
+
# Disable a plugin
|
90
|
+
#
|
91
|
+
# Docker API: POST /plugins/{name}/disable
|
92
|
+
#
|
93
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginDisable
|
94
|
+
#
|
95
|
+
# @param name [String]: The ID or name of the plugin.
|
96
|
+
def disable name
|
97
|
+
@connection.post("/plugins/#{name}/disable")
|
98
|
+
end
|
99
|
+
|
100
|
+
# Upgrade a plugin
|
101
|
+
#
|
102
|
+
# Docker API: POST /plugins/{name}/upgrade
|
103
|
+
#
|
104
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginUpgrade
|
105
|
+
#
|
106
|
+
# @param name [String]: The ID or name of the plugin.
|
107
|
+
#
|
108
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
109
|
+
#
|
110
|
+
# @param privileges [Array]: Plugin privileges to be sent as json in request body.
|
111
|
+
#
|
112
|
+
# @param authentication [Hash]: Authentication parameters.
|
113
|
+
def upgrade name, params = {}, privileges = [], authentication = {}
|
114
|
+
validate Docker::API::InvalidParameter, [:remote], params
|
115
|
+
headers = {"Content-Type": "application/json"}
|
116
|
+
headers.merge!({"X-Registry-Auth" => Base64.urlsafe_encode64(authentication.to_json.to_s)}) if authentication.keys.size > 0
|
117
|
+
@connection.request(method: :post, path: build_path("/plugins/#{name}/upgrade", params), headers: headers, body: privileges.to_json )
|
118
|
+
end
|
119
|
+
|
120
|
+
# Create a plugin
|
121
|
+
#
|
122
|
+
# Docker API: POST /plugins/create
|
123
|
+
#
|
124
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginCreate
|
125
|
+
#
|
126
|
+
# @param name [String]: The ID or name of the plugin.
|
127
|
+
#
|
128
|
+
# @param path [String]: Path to tar file that contains rootfs folder and config.json file.
|
129
|
+
def create name, path
|
130
|
+
file = File.open( File.expand_path( path ) , "r")
|
131
|
+
response = @connection.request(method: :post, path: "/plugins/create?name=#{name}", body: file.read.to_s )
|
132
|
+
file.close
|
133
|
+
response
|
134
|
+
end
|
135
|
+
|
136
|
+
# Push a plugin to the registry.
|
137
|
+
#
|
138
|
+
# Docker API: POST /plugins/{name}/push
|
139
|
+
#
|
140
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginPush
|
141
|
+
#
|
142
|
+
# @param name [String]: The ID or name of the plugin.
|
143
|
+
#
|
144
|
+
# @param authentication [Hash]: Authentication parameters.
|
145
|
+
def push name, authentication = {}
|
146
|
+
if authentication.keys.size > 0
|
147
|
+
@connection.request(method: :post, path: "/plugins/#{name}/push", headers: {"X-Registry-Auth" => Base64.urlsafe_encode64(authentication.to_json.to_s)})
|
148
|
+
else
|
149
|
+
@connection.post("/plugins/#{name}/push")
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
# Configure a plugin
|
154
|
+
#
|
155
|
+
# Docker API: POST /plugins/{name}/set
|
156
|
+
#
|
157
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginSet
|
158
|
+
#
|
159
|
+
# @param name [String]: The ID or name of the plugin.
|
160
|
+
#
|
161
|
+
# @param config [Array]: Plugin configuration to be sent as json in request body.
|
162
|
+
def configure name, config
|
163
|
+
@connection.request(method: :post, path: "/plugins/#{name}/set", headers: {"Content-Type": "application/json"}, body:config.to_json)
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# This class represents the Docker API endpoints regarding secrets.
|
2
|
+
#
|
3
|
+
# @see https://docs.docker.com/engine/api/v1.40/#tag/Secret
|
4
|
+
#
|
5
|
+
# Secrets are sensitive data that can be used by services. Swarm mode must be enabled for these endpoints to work.
|
6
|
+
class Docker::API::Secret < Docker::API::Base
|
7
|
+
|
8
|
+
# List secrets
|
9
|
+
#
|
10
|
+
# Docker API: GET /secrets
|
11
|
+
#
|
12
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/SecretList
|
13
|
+
#
|
14
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
15
|
+
def list params = {}
|
16
|
+
validate Docker::API::InvalidParameter, [:filters], params
|
17
|
+
@connection.get(build_path("/secrets",params))
|
18
|
+
end
|
19
|
+
|
20
|
+
# Create a secret
|
21
|
+
#
|
22
|
+
# Docker API: POST /secrets/create
|
23
|
+
#
|
24
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/SecretCreate
|
25
|
+
#
|
26
|
+
# @param body [Hash]: Request body to be sent as json.
|
27
|
+
def create body = {}
|
28
|
+
validate Docker::API::InvalidRequestBody, [:Name, :Labels, :Data, :Driver, :Templating], body
|
29
|
+
@connection.request(method: :post, path: "/secrets/create", headers: {"Content-Type": "application/json"}, body: body.to_json)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Inspect a secret
|
33
|
+
#
|
34
|
+
# Docker API: GET /secrets/{id}
|
35
|
+
#
|
36
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/SecretInspect
|
37
|
+
#
|
38
|
+
# @param name [String]: The ID or name of the secret.
|
39
|
+
def details name
|
40
|
+
@connection.get("/secrets/#{name}")
|
41
|
+
end
|
42
|
+
|
43
|
+
# Update a secret
|
44
|
+
#
|
45
|
+
# Docker API: POST /secrets/{id}/update
|
46
|
+
#
|
47
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/SecretUpdate
|
48
|
+
#
|
49
|
+
# @param name [String]: The ID or name of the secret.
|
50
|
+
#
|
51
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
52
|
+
#
|
53
|
+
# @param body [Hash]: Request body to be sent as json.
|
54
|
+
def update name, params = {}, body = {}
|
55
|
+
validate Docker::API::InvalidParameter, [:version], params
|
56
|
+
validate Docker::API::InvalidRequestBody, [:Name, :Labels, :Data, :Driver, :Templating], body
|
57
|
+
@connection.request(method: :post, path: build_path("/secrets/#{name}/update",params), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Delete a secret
|
61
|
+
#
|
62
|
+
# Docker API: DELETE /secrets/{id}
|
63
|
+
#
|
64
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/SecretDelete
|
65
|
+
#
|
66
|
+
# @param name [String]: The ID or name of the secret.
|
67
|
+
def delete name
|
68
|
+
@connection.delete("/secrets/#{name}")
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# This class represents the Docker API endpoints regarding services.
|
2
|
+
#
|
3
|
+
# @see https://docs.docker.com/engine/api/v1.40/#tag/Service
|
4
|
+
#
|
5
|
+
# Services are the definitions of tasks to run on a swarm. Swarm mode must be enabled for these endpoints to work.
|
6
|
+
class Docker::API::Service < Docker::API::Base
|
7
|
+
|
8
|
+
# List services
|
9
|
+
#
|
10
|
+
# Docker API: GET /services
|
11
|
+
#
|
12
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ServiceList
|
13
|
+
#
|
14
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
15
|
+
def list params = {}
|
16
|
+
validate Docker::API::InvalidParameter, [:filters], params
|
17
|
+
@connection.get(build_path("/services", params))
|
18
|
+
end
|
19
|
+
|
20
|
+
# Create a service
|
21
|
+
#
|
22
|
+
# Docker API: POST /services/create
|
23
|
+
#
|
24
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ServiceCreate
|
25
|
+
#
|
26
|
+
# @param body [Hash]: Request body to be sent as json.
|
27
|
+
#
|
28
|
+
# @param authentication [Hash]: Authentication parameters.
|
29
|
+
def create body = {}, authentication = {}
|
30
|
+
validate Docker::API::InvalidRequestBody, [:Name, :Labels, :TaskTemplate, :Mode, :UpdateConfig, :RollbackConfig, :Networks, :EndpointSpec], body
|
31
|
+
headers = {"Content-Type": "application/json"}
|
32
|
+
headers.merge!({"X-Registry-Auth" => Base64.urlsafe_encode64(authentication.to_json.to_s)}) if authentication.keys.size > 0
|
33
|
+
@connection.request(method: :post, path: "/services/create", headers: headers, body: body.to_json)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Update a service
|
37
|
+
#
|
38
|
+
# Docker API: POST /services/{id}/update
|
39
|
+
#
|
40
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ServiceUpdate
|
41
|
+
#
|
42
|
+
# @param name [String]: The ID or name of the service.
|
43
|
+
#
|
44
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
45
|
+
#
|
46
|
+
# @param body [Hash]: Request body to be sent as json.
|
47
|
+
#
|
48
|
+
# @param authentication [Hash]: Authentication parameters.
|
49
|
+
def update name, params = {}, body = {}, authentication = {}
|
50
|
+
# view https://github.com/docker/swarmkit/issues/1394#issuecomment-240850719
|
51
|
+
validate Docker::API::InvalidParameter, [:version, :registryAuthFrom, :rollback], params
|
52
|
+
validate Docker::API::InvalidRequestBody, [:Name, :Labels, :TaskTemplate, :Mode, :UpdateConfig, :RollbackConfig, :Networks, :EndpointSpec], body
|
53
|
+
headers = {"Content-Type": "application/json"}
|
54
|
+
headers.merge!({"X-Registry-Auth" => Base64.urlsafe_encode64(authentication.to_json.to_s)}) if authentication.keys.size > 0
|
55
|
+
@connection.request(method: :post, path: build_path("/services/#{name}/update", params), headers: headers, body: body.to_json)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Inspect a service
|
59
|
+
#
|
60
|
+
# Docker API: GET /services/{id}
|
61
|
+
#
|
62
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ServiceInspect
|
63
|
+
#
|
64
|
+
# @param name [String]: The ID or name of the service.
|
65
|
+
#
|
66
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
67
|
+
def details name, params = {}
|
68
|
+
validate Docker::API::InvalidParameter, [:insertDefaults], params
|
69
|
+
@connection.get(build_path("/services/#{name}", params))
|
70
|
+
end
|
71
|
+
|
72
|
+
# Get stdout and stderr logs from a service.
|
73
|
+
#
|
74
|
+
# Note: This endpoint works only for services with the local, json-file or journald logging drivers.
|
75
|
+
#
|
76
|
+
# Docker API: GET /services/{id}/logs
|
77
|
+
#
|
78
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ServiceLogs
|
79
|
+
#
|
80
|
+
# @param name [String]: The ID or name of the service.
|
81
|
+
#
|
82
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
83
|
+
def logs name, params = {}
|
84
|
+
validate Docker::API::InvalidParameter, [:details, :follow, :stdout, :stderr, :since, :timestamps, :tail], params
|
85
|
+
@connection.get(build_path("/services/#{name}/logs", params))
|
86
|
+
end
|
87
|
+
|
88
|
+
# Delete a service
|
89
|
+
#
|
90
|
+
# Docker API: DELETE /services/{id}
|
91
|
+
#
|
92
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ServiceDelete
|
93
|
+
#
|
94
|
+
# @param name [String]: The ID or name of the service.
|
95
|
+
def delete name
|
96
|
+
@connection.delete("/services/#{name}")
|
97
|
+
end
|
98
|
+
end
|
data/lib/docker/api/swarm.rb
CHANGED
@@ -13,7 +13,7 @@ module Docker
|
|
13
13
|
@connection.request(method: :post, path: build_path("/swarm/update", params), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def details
|
17
17
|
@connection.get("/swarm")
|
18
18
|
end
|
19
19
|
|
@@ -35,6 +35,17 @@ module Docker
|
|
35
35
|
validate Docker::API::InvalidParameter, [:force], params
|
36
36
|
@connection.post(build_path("/swarm/leave", params))
|
37
37
|
end
|
38
|
+
|
39
|
+
#################################################
|
40
|
+
# Items in this area to be removed before 1.0.0 #
|
41
|
+
#################################################
|
42
|
+
def inspect
|
43
|
+
caller.each { | el | return super.inspect if el.match(/inspector/) }
|
44
|
+
warn "WARNING: #inspect is deprecated and will be removed in the future, please use #details instead."
|
45
|
+
details
|
46
|
+
end
|
47
|
+
#################################################
|
48
|
+
|
38
49
|
end
|
39
50
|
end
|
40
51
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# This class represents the Docker API endpoints regarding tasks.
|
2
|
+
#
|
3
|
+
# @see https://docs.docker.com/engine/api/v1.40/#tag/Task
|
4
|
+
#
|
5
|
+
# A task is a container running on a swarm. It is the atomic scheduling unit of swarm. Swarm mode must be enabled for these endpoints to work.
|
6
|
+
class Docker::API::Task < Docker::API::Base
|
7
|
+
|
8
|
+
# List tasks
|
9
|
+
#
|
10
|
+
# Docker API: GET /tasks
|
11
|
+
#
|
12
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/TaskList
|
13
|
+
#
|
14
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
15
|
+
def list params = {}
|
16
|
+
validate Docker::API::InvalidParameter, [:filters], params
|
17
|
+
@connection.get(build_path("/tasks",params))
|
18
|
+
end
|
19
|
+
|
20
|
+
# Inspect a task
|
21
|
+
#
|
22
|
+
# Docker API: GET /tasks/{id}
|
23
|
+
#
|
24
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/TaskInspect
|
25
|
+
#
|
26
|
+
# @param name [String]: The ID or name of the task.
|
27
|
+
def details name
|
28
|
+
@connection.get("/tasks/#{name}")
|
29
|
+
end
|
30
|
+
|
31
|
+
# Get stdout and stderr logs from a task.
|
32
|
+
#
|
33
|
+
# Note: This endpoint works only for services with the local, json-file or journald logging drivers.
|
34
|
+
#
|
35
|
+
# Docker API: GET /tasks/{id}/logs
|
36
|
+
#
|
37
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/TaskLogs
|
38
|
+
#
|
39
|
+
# @param name (String) : The ID or name of the task.
|
40
|
+
#
|
41
|
+
# @param params (Hash) : Parameters that are appended to the URL.
|
42
|
+
def logs name, params = {}
|
43
|
+
validate Docker::API::InvalidParameter, [:details, :follow, :stdout, :stderr, :since, :timestamps, :tail], params
|
44
|
+
@connection.get(build_path("/tasks/#{name}/logs", params))
|
45
|
+
end
|
46
|
+
end
|
data/lib/docker/api/version.rb
CHANGED
data/lib/docker/api/volume.rb
CHANGED
@@ -1,24 +1,21 @@
|
|
1
1
|
module Docker
|
2
2
|
module API
|
3
3
|
class Volume < Docker::API::Base
|
4
|
-
def base_path
|
5
|
-
"/volumes"
|
6
|
-
end
|
7
4
|
|
8
5
|
def list params = {}
|
9
6
|
validate Docker::API::InvalidParameter, [:filters], params
|
10
7
|
@connection.get(build_path("/volumes", params))
|
11
8
|
end
|
12
9
|
|
10
|
+
def details name
|
11
|
+
@connection.get(build_path([name]))
|
12
|
+
end
|
13
|
+
|
13
14
|
def create body = {}
|
14
15
|
validate Docker::API::InvalidRequestBody, [:Name, :Driver, :DriverOpts, :Labels], body
|
15
16
|
@connection.request(method: :post, path: build_path(["create"]), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
16
17
|
end
|
17
18
|
|
18
|
-
def inspect name
|
19
|
-
@connection.get(build_path([name]))
|
20
|
-
end
|
21
|
-
|
22
19
|
def remove name, params = {}
|
23
20
|
validate Docker::API::InvalidParameter, [:force], params
|
24
21
|
@connection.delete(build_path([name]))
|
@@ -29,6 +26,21 @@ module Docker
|
|
29
26
|
@connection.post(build_path(["prune"], params))
|
30
27
|
end
|
31
28
|
|
29
|
+
#################################################
|
30
|
+
# Items in this area to be removed before 1.0.0 #
|
31
|
+
#################################################
|
32
|
+
def base_path
|
33
|
+
"/volumes"
|
34
|
+
end
|
35
|
+
|
36
|
+
def inspect *args
|
37
|
+
return super.inspect if args.size == 0
|
38
|
+
warn "WARNING: #inspect is deprecated and will be removed in the future, please use #details instead."
|
39
|
+
name = args[0]
|
40
|
+
@connection.get(build_path([name]))
|
41
|
+
end
|
42
|
+
#################################################
|
43
|
+
|
32
44
|
end
|
33
45
|
end
|
34
46
|
end
|
data/lib/dockerapi.rb
CHANGED
@@ -14,6 +14,11 @@ require "docker/api/exec"
|
|
14
14
|
require "docker/api/system"
|
15
15
|
require "docker/api/swarm"
|
16
16
|
require "docker/api/node"
|
17
|
+
require "docker/api/service"
|
18
|
+
require "docker/api/task"
|
19
|
+
require "docker/api/secret"
|
20
|
+
require "docker/api/config"
|
21
|
+
require "docker/api/plugin"
|
17
22
|
|
18
23
|
module Docker
|
19
24
|
module API
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dockerapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alysson A. Costa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|
@@ -44,6 +44,7 @@ files:
|
|
44
44
|
- bin/setup
|
45
45
|
- dockerapi.gemspec
|
46
46
|
- lib/docker/api/base.rb
|
47
|
+
- lib/docker/api/config.rb
|
47
48
|
- lib/docker/api/connection.rb
|
48
49
|
- lib/docker/api/container.rb
|
49
50
|
- lib/docker/api/error.rb
|
@@ -51,9 +52,13 @@ files:
|
|
51
52
|
- lib/docker/api/image.rb
|
52
53
|
- lib/docker/api/network.rb
|
53
54
|
- lib/docker/api/node.rb
|
55
|
+
- lib/docker/api/plugin.rb
|
54
56
|
- lib/docker/api/response.rb
|
57
|
+
- lib/docker/api/secret.rb
|
58
|
+
- lib/docker/api/service.rb
|
55
59
|
- lib/docker/api/swarm.rb
|
56
60
|
- lib/docker/api/system.rb
|
61
|
+
- lib/docker/api/task.rb
|
57
62
|
- lib/docker/api/version.rb
|
58
63
|
- lib/docker/api/volume.rb
|
59
64
|
- lib/dockerapi.rb
|