dockerapi 0.10.0 → 0.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aeb3c1971c26c62d0737576e5ec79f2abcf536b1148be5272be8f501dfcae852
4
- data.tar.gz: 1392073ca52d6fecfc12e642368713c2fa44a9ebbcd7629de5fb54faf9ac7209
3
+ metadata.gz: '09aa5bf2a46df8ad42f1c4833fe7577610af14dde350730787b703e1080fa4c7'
4
+ data.tar.gz: 0be7a47781bbc7f75824f65b8fea5d7bcbd11deb98451f2b030856391a68d5c1
5
5
  SHA512:
6
- metadata.gz: 3b03b8e5ce6d95f19c8dd6d357277a102fcc170b35ac989cd080db27c66efcad63125aaedab1c971a8ed435bed7c7447979d332a1b7f43686a2217907bf21fe8
7
- data.tar.gz: 62cd2888ad859834cf949a6189f6e863e1b2f23ce9849fce4a39a1248cfa74efeaff5e0e6220a165d6b7980445a7773dc4bc3f8d4a678fc364a06b205fc07630
6
+ metadata.gz: f0573e091c6cbbc6c2fa3411ca6336a328e4677a656f22bd7d4a036064f8c813523c6a686c2e3ec03df2ec194f65c1b69c6d5be5782c1a1fca80460f3c383db9
7
+ data.tar.gz: 5fa96ad226aad3faa2e3a2836948687adf29079b0495e88ceb42424bbe14d2664cab4a8f59a2a795e2f73c9fe59318504a9c454b4964d1b16a04165023c7e8f8
@@ -1,3 +1,27 @@
1
+ # 0.11.0
2
+
3
+ Add `Docker::API::Task` methods:
4
+ * list
5
+ * details
6
+ * logs
7
+
8
+ Add `Docker::API::Secret` methods:
9
+ * create
10
+ * update
11
+ * list
12
+ * details
13
+ * delete
14
+
15
+ Add `Docker::API::Config` methods:
16
+ * create
17
+ * update
18
+ * list
19
+ * details
20
+ * delete
21
+
22
+ Add `Docker::API::Image` methods:
23
+ * distribution
24
+
1
25
  # 0.10.0
2
26
 
3
27
  Add `Docker::API::Service` methods:
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dockerapi (0.10.0)
4
+ dockerapi (0.11.0)
5
5
  excon (~> 0.74.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -44,6 +44,9 @@ image.list
44
44
  # Inspect image
45
45
  image.details("image")
46
46
 
47
+ # Return image digest and platform information by contacting the registry.
48
+ image.distribution("image")
49
+
47
50
  # History
48
51
  image.history("image")
49
52
 
@@ -325,7 +328,67 @@ service.details("nginx-service")
325
328
 
326
329
  # Delete service
327
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==" }))
328
389
 
390
+ # Delete config
391
+ config.delete("config-name")
329
392
  ```
330
393
 
331
394
  ### Connection
@@ -410,11 +473,11 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
410
473
  | Exec | Ok | Ok | 8/21 |
411
474
  | Swarm | Ok | Ok | 8/28 |
412
475
  | Node | Ok | Ok | 8/28 |
413
- | Service | 7/17 | 7/17 | 8/28 |
414
- | Task | 7/17 | 7/17 | 9/4 |
415
- | Secret | 7/17 | 7/17 | 9/4 |
416
- | Config | 7/17 | 7/17 | 9/4 |
417
- | Distribution | 7/17 | 7/17 | 9/4 |
476
+ | Service | Ok | Ok | 8/28 |
477
+ | Task | Ok | Ok | 9/4 |
478
+ | Secret | Ok | Ok | 9/4 |
479
+ | Config | Ok | Ok | 9/4 |
480
+ | Distribution | Ok | Ok | 9/4 |
418
481
  | Plugin | 7/24 | 7/24 | 9/4 |
419
482
 
420
483
  ## Contributing
@@ -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
@@ -11,6 +11,10 @@ module Docker
11
11
  @connection.get(build_path([name, "json"]))
12
12
  end
13
13
 
14
+ def distribution name
15
+ @connection.get("/distribution/#{name}/json")
16
+ end
17
+
14
18
  def history name
15
19
  @connection.get(build_path([name, "history"]))
16
20
  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
@@ -1,42 +1,98 @@
1
- module Docker
2
- module API
3
- class Service < Docker::API::Base
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
4
7
 
5
- def list params = {}
6
- validate Docker::API::InvalidParameter, [:filters], params
7
- @connection.get(build_path("/services", params))
8
- end
9
-
10
- def create body = {}, authentication = {}
11
- validate Docker::API::InvalidRequestBody, [:Name, :Labels, :TaskTemplate, :Mode, :UpdateConfig, :RollbackConfig, :Networks, :EndpointSpec], body
12
- headers = {"Content-Type": "application/json"}
13
- headers.merge!({"X-Registry-Auth" => Base64.urlsafe_encode64(authentication.to_json.to_s)}) if authentication.keys.size > 0
14
- @connection.request(method: :post, path: "/services/create", headers: headers, body: body.to_json)
15
- end
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
16
19
 
17
- def update name, params = {}, body = {}, authentication = {}
18
- # view https://github.com/docker/swarmkit/issues/1394#issuecomment-240850719
19
- validate Docker::API::InvalidParameter, [:version, :registryAuthFrom, :rollback], params
20
- validate Docker::API::InvalidRequestBody, [:Name, :Labels, :TaskTemplate, :Mode, :UpdateConfig, :RollbackConfig, :Networks, :EndpointSpec], body
21
- headers = {"Content-Type": "application/json"}
22
- headers.merge!({"X-Registry-Auth" => Base64.urlsafe_encode64(authentication.to_json.to_s)}) if authentication.keys.size > 0
23
- @connection.request(method: :post, path: build_path("/services/#{name}/update", params), headers: headers, body: body.to_json)
24
- end
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
25
35
 
26
- def details name, params = {}
27
- validate Docker::API::InvalidParameter, [:insertDefaults], params
28
- @connection.get(build_path("/services/#{name}", params))
29
- end
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
30
57
 
31
- def logs name, params = {}
32
- validate Docker::API::InvalidParameter, [:details, :follow, :stdout, :stderr, :since, :timestamps, :tail], params
33
- @connection.get(build_path("/services/#{name}/logs", params))
34
- end
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
35
71
 
36
- def delete name
37
- @connection.delete("/services/#{name}")
38
- end
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
39
87
 
40
- end
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}")
41
97
  end
42
- end
98
+ 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
@@ -1,6 +1,6 @@
1
1
  module Docker
2
2
  module API
3
- GEM_VERSION = "0.10.0"
3
+ GEM_VERSION = "0.11.0"
4
4
 
5
5
  API_VERSION = "1.40"
6
6
 
@@ -15,6 +15,9 @@ require "docker/api/system"
15
15
  require "docker/api/swarm"
16
16
  require "docker/api/node"
17
17
  require "docker/api/service"
18
+ require "docker/api/task"
19
+ require "docker/api/secret"
20
+ require "docker/api/config"
18
21
 
19
22
  module Docker
20
23
  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.10.0
4
+ version: 0.11.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-14 00:00:00.000000000 Z
11
+ date: 2020-07-17 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
@@ -52,9 +53,11 @@ files:
52
53
  - lib/docker/api/network.rb
53
54
  - lib/docker/api/node.rb
54
55
  - lib/docker/api/response.rb
56
+ - lib/docker/api/secret.rb
55
57
  - lib/docker/api/service.rb
56
58
  - lib/docker/api/swarm.rb
57
59
  - lib/docker/api/system.rb
60
+ - lib/docker/api/task.rb
58
61
  - lib/docker/api/version.rb
59
62
  - lib/docker/api/volume.rb
60
63
  - lib/dockerapi.rb