class Docker::API::Plugin

This class represents the Docker API endpoints regarding plugins.

@see docs.docker.com/engine/api/v1.40/#tag/Plugin

Public Instance Methods

configure(name, config) click to toggle source

Configure a plugin

Docker API: POST /plugins/{name}/set

@see docs.docker.com/engine/api/v1.40/#operation/PluginSet

@param name [String]: The ID or name of the plugin.

@param config [Array]: Plugin configuration to be sent as json in request body.

# 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) click to toggle source

Create a plugin

Docker API: POST /plugins/create

@see docs.docker.com/engine/api/v1.40/#operation/PluginCreate

@param name [String]: The ID or name of the plugin.

@param path [String]: Path to tar file that contains rootfs folder and config.json file.

# File lib/docker/api/plugin.rb, line 123
def create name, path
    file = File.open( File.expand_path( path ) , "r")
    response = @connection.request(method: :post, path: "/plugins/create?name=#{name}", body: file.read.to_s )
    file.close        
    response
end
details(name) click to toggle source

Inspect a plugin

Docker API: GET /plugins/{name}/json

@see docs.docker.com/engine/api/v1.40/#operation/PluginInspect

@param name [String]: The ID or name of the plugin.

# File lib/docker/api/plugin.rb, line 54
def details name 
    @connection.get("/plugins/#{name}/json")
end
disable(name) click to toggle source

Disable a plugin

Docker API: POST /plugins/{name}/disable

@see docs.docker.com/engine/api/v1.40/#operation/PluginDisable

@param name [String]: The ID or name of the plugin.

# File lib/docker/api/plugin.rb, line 91
def disable name
    @connection.post("/plugins/#{name}/disable")
end
enable(name, params = {}) click to toggle source

Enable a plugin

Docker API: POST /plugins/{name}/enable

@see docs.docker.com/engine/api/v1.40/#operation/PluginEnable

@param name [String]: The ID or name of the plugin.

@param params [Hash]: Parameters that are appended to the URL.

# File lib/docker/api/plugin.rb, line 80
def enable name, params = {}
    @connection.post(build_path("/plugins/#{name}/enable", params))
end
install(params = {}) click to toggle source

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

@see docs.docker.com/engine/api/v1.40/#operation/PluginPull

@param params [Hash]: Parameters that are appended to the URL.

@param privileges [Array]: Plugin privileges to be sent as json in request body.

@param authentication [Hash]: Authentication parameters.

# 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 = {}) click to toggle source

List plugins

Docker API: GET /plugins

@see docs.docker.com/engine/api/v1.40/#operation/PluginList

@param params [Hash]: Parameters that are appended to the URL.

# File lib/docker/api/plugin.rb, line 13
def list params = {}
    @connection.get(build_path("/plugins", params))
end
privileges(params = {}) click to toggle source

Get plugin privileges

Docker API: GET /plugins/privileges

@see docs.docker.com/engine/api/v1.40/#operation/GetPluginPrivileges

@param params [Hash]: Parameters that are appended to the URL.

# File lib/docker/api/plugin.rb, line 24
def privileges params = {}
    @connection.get(build_path("/plugins/privileges", params))
end
push(name, authentication = {}) click to toggle source

Push a plugin to the registry.

Docker API: POST /plugins/{name}/push

@see docs.docker.com/engine/api/v1.40/#operation/PluginPush

@param name [String]: The ID or name of the plugin.

@param authentication [Hash]: Authentication parameters.

# 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 = {}) click to toggle source

Remove a plugin

Docker API: DELETE /plugins/{name}

@see docs.docker.com/engine/api/v1.40/#operation/PluginDelete

@param name [String]: The ID or name of the plugin.

@param params [Hash]: Parameters that are appended to the URL.

# File lib/docker/api/plugin.rb, line 67
def remove name, params = {}
    @connection.delete(build_path("/plugins/#{name}",params))
end
upgrade(name, params = {}) click to toggle source

Upgrade a plugin

Docker API: POST /plugins/{name}/upgrade

@see docs.docker.com/engine/api/v1.40/#operation/PluginUpgrade

@param name [String]: The ID or name of the plugin.

@param params [Hash]: Parameters that are appended to the URL.

@param privileges [Array]: Plugin privileges to be sent as json in request body.

@param authentication [Hash]: Authentication parameters.

# 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