dockerapi 0.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09aa5bf2a46df8ad42f1c4833fe7577610af14dde350730787b703e1080fa4c7'
4
- data.tar.gz: 0be7a47781bbc7f75824f65b8fea5d7bcbd11deb98451f2b030856391a68d5c1
3
+ metadata.gz: a32e488d06a0afd653bb04ab0ad5131fa8e898973128d7a6661f3d3fa4eae53d
4
+ data.tar.gz: 641ffcc096f798fbfff057fb1eecc7ce97ad9191c2acf49f5e97c90bf5ceddc5
5
5
  SHA512:
6
- metadata.gz: f0573e091c6cbbc6c2fa3411ca6336a328e4677a656f22bd7d4a036064f8c813523c6a686c2e3ec03df2ec194f65c1b69c6d5be5782c1a1fca80460f3c383db9
7
- data.tar.gz: 5fa96ad226aad3faa2e3a2836948687adf29079b0495e88ceb42424bbe14d2664cab4a8f59a2a795e2f73c9fe59318504a9c454b4964d1b16a04165023c7e8f8
6
+ metadata.gz: 6cda72170483e133b467a399d77fbcc7668793726b8f67beb4235c5eaf74e2d91977c9544f93ee7d3f3c4b681004d9415f939d2d521aa70151d3a580fc15fc86
7
+ data.tar.gz: d45997041c9d706d2c2d0e2c5e3f5ccaedad51d71cb27ba8538898565e6259e30d7ff11ffa60a5dee9ffca3611ed51ddc96ca68af2a5aff490715b4645297c0d
@@ -1,3 +1,18 @@
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
+
1
16
  # 0.11.0
2
17
 
3
18
  Add `Docker::API::Task` methods:
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dockerapi (0.11.0)
4
+ dockerapi (0.12.0)
5
5
  excon (~> 0.74.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -391,9 +391,50 @@ config.update("config-name", {version: version}, spec.merge!({ Data: "VEhJUyBJUy
391
391
  config.delete("config-name")
392
392
  ```
393
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
+
394
435
  ### Connection
395
436
 
396
- 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.
397
438
 
398
439
  ```ruby
399
440
  # Setting different connections
@@ -478,7 +519,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
478
519
  | Secret | Ok | Ok | 9/4 |
479
520
  | Config | Ok | Ok | 9/4 |
480
521
  | Distribution | Ok | Ok | 9/4 |
481
- | Plugin | 7/24 | 7/24 | 9/4 |
522
+ | Plugin | Ok | 7/24 | 9/4 |
482
523
 
483
524
  ## Contributing
484
525
 
@@ -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
@@ -1,6 +1,6 @@
1
1
  module Docker
2
2
  module API
3
- GEM_VERSION = "0.11.0"
3
+ GEM_VERSION = "0.12.0"
4
4
 
5
5
  API_VERSION = "1.40"
6
6
 
@@ -18,6 +18,7 @@ require "docker/api/service"
18
18
  require "docker/api/task"
19
19
  require "docker/api/secret"
20
20
  require "docker/api/config"
21
+ require "docker/api/plugin"
21
22
 
22
23
  module Docker
23
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.11.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-17 00:00:00.000000000 Z
11
+ date: 2020-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -52,6 +52,7 @@ files:
52
52
  - lib/docker/api/image.rb
53
53
  - lib/docker/api/network.rb
54
54
  - lib/docker/api/node.rb
55
+ - lib/docker/api/plugin.rb
55
56
  - lib/docker/api/response.rb
56
57
  - lib/docker/api/secret.rb
57
58
  - lib/docker/api/service.rb