Class: Docker::API::Plugin
Overview
This class represents the Docker API endpoints regarding plugins.
Instance Method Summary collapse
-
#configure(name, config) ⇒ Object
Configure a plugin.
-
#create(name, path) ⇒ Object
Create a plugin.
-
#details(name) ⇒ Object
Inspect a plugin.
-
#disable(name) ⇒ Object
Disable a plugin.
-
#enable(name, params = {}) ⇒ Object
Enable a plugin.
-
#install(params = {}, privileges = [], authentication = {}) ⇒ Object
Install a plugin.
-
#list(params = {}) ⇒ Object
List plugins.
-
#privileges(params = {}) ⇒ Object
Get plugin privileges.
-
#push(name, authentication = {}) ⇒ Object
Push a plugin to the registry.
-
#remove(name, params = {}) ⇒ Object
Remove a plugin.
-
#upgrade(name, params = {}, privileges = [], authentication = {}) ⇒ Object
Upgrade a plugin.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Docker::API::Base
Instance Method Details
#configure(name, config) ⇒ Object
Configure a plugin
Docker API: POST /plugins/name/set
156 157 158 |
# File 'lib/docker/api/plugin.rb', line 156 def configure name, config @connection.request(method: :post, path: "/plugins/#{name}/set", headers: {"Content-Type": "application/json"}, body:config.to_json) end |
#create(name, path) ⇒ Object
Create a plugin
Docker API: POST /plugins/create
123 124 125 126 127 128 |
# File 'lib/docker/api/plugin.rb', line 123 def create name, path file = File.open( File.( path ) , "r") response = @connection.request(method: :post, path: "/plugins/create?name=#{name}", body: file.read.to_s ) file.close response end |
#details(name) ⇒ Object
Inspect a plugin
Docker API: GET /plugins/name/json
54 55 56 |
# File 'lib/docker/api/plugin.rb', line 54 def details name @connection.get("/plugins/#{name}/json") end |
#disable(name) ⇒ Object
Disable a plugin
Docker API: POST /plugins/name/disable
91 92 93 |
# File 'lib/docker/api/plugin.rb', line 91 def disable name @connection.post("/plugins/#{name}/disable") end |
#enable(name, params = {}) ⇒ Object
Enable a plugin
Docker API: POST /plugins/name/enable
80 81 82 |
# File 'lib/docker/api/plugin.rb', line 80 def enable name, params = {} @connection.post(build_path("/plugins/#{name}/enable", params)) end |
#install(params = {}, privileges = [], authentication = {}) ⇒ Object
Install a plugin
Pulls and installs a plugin. After the plugin is installed, it can be enabled using the POST /plugins/name/enable endpoint.
Docker API: POST /plugins/pull
41 42 43 44 45 |
# File 'lib/docker/api/plugin.rb', line 41 def install params = {}, privileges = [], authentication = {} headers = {"Content-Type": "application/json"} headers.merge!({"X-Registry-Auth" => Base64.urlsafe_encode64(authentication.to_json.to_s)}) if authentication.keys.size > 0 @connection.request(method: :post, path: build_path("/plugins/pull", params), headers: headers, body: privileges.to_json ) end |
#list(params = {}) ⇒ Object
List plugins
Docker API: GET /plugins
13 14 15 |
# File 'lib/docker/api/plugin.rb', line 13 def list params = {} @connection.get(build_path("/plugins", params)) end |
#privileges(params = {}) ⇒ Object
Get plugin privileges
Docker API: GET /plugins/privileges
24 25 26 |
# File 'lib/docker/api/plugin.rb', line 24 def privileges params = {} @connection.get(build_path("/plugins/privileges", params)) end |
#push(name, authentication = {}) ⇒ Object
Push a plugin to the registry.
Docker API: POST /plugins/name/push
139 140 141 142 143 144 145 |
# File 'lib/docker/api/plugin.rb', line 139 def push name, authentication = {} if authentication.keys.size > 0 @connection.request(method: :post, path: "/plugins/#{name}/push", headers: {"X-Registry-Auth" => Base64.urlsafe_encode64(authentication.to_json.to_s)}) else @connection.post("/plugins/#{name}/push") end end |
#remove(name, params = {}) ⇒ Object
Remove a plugin
Docker API: DELETE /plugins/name
67 68 69 |
# File 'lib/docker/api/plugin.rb', line 67 def remove name, params = {} @connection.delete(build_path("/plugins/#{name}",params)) end |
#upgrade(name, params = {}, privileges = [], authentication = {}) ⇒ Object
Upgrade a plugin
Docker API: POST /plugins/name/upgrade
108 109 110 111 112 |
# File 'lib/docker/api/plugin.rb', line 108 def upgrade name, params = {}, privileges = [], authentication = {} headers = {"Content-Type": "application/json"} headers.merge!({"X-Registry-Auth" => Base64.urlsafe_encode64(authentication.to_json.to_s)}) if authentication.keys.size > 0 @connection.request(method: :post, path: build_path("/plugins/#{name}/upgrade", params), headers: headers, body: privileges.to_json ) end |