dockerapi 0.9.0 → 0.14.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 +73 -0
- data/Gemfile.lock +3 -3
- data/README.md +193 -21
- data/dockerapi.gemspec +4 -3
- data/lib/docker/api/base.rb +57 -29
- data/lib/docker/api/config.rb +66 -0
- data/lib/docker/api/container.rb +306 -166
- data/lib/docker/api/exec.rb +0 -4
- data/lib/docker/api/image.rb +201 -144
- data/lib/docker/api/network.rb +0 -6
- data/lib/docker/api/node.rb +0 -4
- data/lib/docker/api/plugin.rb +160 -0
- data/lib/docker/api/secret.rb +66 -0
- data/lib/docker/api/service.rb +92 -0
- data/lib/docker/api/swarm.rb +0 -6
- data/lib/docker/api/system.rb +0 -2
- data/lib/docker/api/task.rb +44 -0
- data/lib/docker/api/version.rb +1 -1
- data/lib/docker/api/volume.rb +0 -4
- data/lib/dockerapi.rb +142 -0
- metadata +14 -6
data/lib/docker/api/exec.rb
CHANGED
|
@@ -3,13 +3,10 @@ module Docker
|
|
|
3
3
|
class Exec < Docker::API::Base
|
|
4
4
|
|
|
5
5
|
def create name, body = {}
|
|
6
|
-
validate Docker::API::InvalidRequestBody, [:AttachStdin, :AttachStdout, :AttachStderr, :DetachKeys, :Tty, :Env, :Cmd, :Privileged, :User, :WorkingDir], body
|
|
7
6
|
@connection.request(method: :post, path: "/containers/#{name}/exec", headers: {"Content-Type": "application/json"}, body: body.to_json )
|
|
8
7
|
end
|
|
9
8
|
|
|
10
9
|
def start name, body = {}
|
|
11
|
-
validate Docker::API::InvalidRequestBody, [:Detach, :Tty], body
|
|
12
|
-
|
|
13
10
|
stream = ""
|
|
14
11
|
response = @connection.request(method: :post,
|
|
15
12
|
path: "/exec/#{name}/start",
|
|
@@ -22,7 +19,6 @@ module Docker
|
|
|
22
19
|
end
|
|
23
20
|
|
|
24
21
|
def resize name, params = {}
|
|
25
|
-
validate Docker::API::InvalidParameter, [:w, :h], params
|
|
26
22
|
@connection.post(build_path("/exec/#{name}/resize", params))
|
|
27
23
|
end
|
|
28
24
|
|
data/lib/docker/api/image.rb
CHANGED
|
@@ -1,148 +1,205 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
def inspect *args
|
|
139
|
-
return super.inspect if args.size == 0
|
|
140
|
-
warn "WARNING: #inspect is deprecated and will be removed in the future, please use #details instead."
|
|
141
|
-
name = args[0]
|
|
142
|
-
details(name)
|
|
143
|
-
end
|
|
144
|
-
#################################################
|
|
1
|
+
##
|
|
2
|
+
# This class represents the Docker API endpoints regarding images.
|
|
3
|
+
# @see https://docs.docker.com/engine/api/v1.40/#tag/Image
|
|
4
|
+
class Docker::API::Image < Docker::API::Base
|
|
5
|
+
|
|
6
|
+
##
|
|
7
|
+
# Return low-level information about an image.
|
|
8
|
+
#
|
|
9
|
+
# Docker API: GET /images/{name}/json
|
|
10
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ImageInspect
|
|
11
|
+
#
|
|
12
|
+
# @param name [String]: The ID or name of the image.
|
|
13
|
+
def details name
|
|
14
|
+
@connection.get("/images/#{name}/json")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
##
|
|
18
|
+
# Return image digest and platform information by contacting the registry.
|
|
19
|
+
#
|
|
20
|
+
# Docker API: GET /distribution/{name}/json
|
|
21
|
+
# @see https://docs.docker.com/engine/api/v1.40/#tag/Distribution
|
|
22
|
+
#
|
|
23
|
+
# @param name [String]: The ID or name of the image.
|
|
24
|
+
def distribution name
|
|
25
|
+
@connection.get("/distribution/#{name}/json")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
##
|
|
29
|
+
# Return parent layers of an image.
|
|
30
|
+
#
|
|
31
|
+
# Docker API: GET /images/{name}/history
|
|
32
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ImageHistory
|
|
33
|
+
#
|
|
34
|
+
# @param name [String]: The ID or name of the image.
|
|
35
|
+
def history name
|
|
36
|
+
@connection.get("/images/#{name}/history")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
##
|
|
40
|
+
# Returns a list of images on the server. Note that it uses a different, smaller representation of an image than inspecting a single image.
|
|
41
|
+
#
|
|
42
|
+
# Docker API: GET /images/json
|
|
43
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ImageList
|
|
44
|
+
#
|
|
45
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
|
46
|
+
def list params = {}
|
|
47
|
+
@connection.get(build_path("/images/json", params))
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
##
|
|
51
|
+
# Search for an image on Docker Hub.
|
|
52
|
+
#
|
|
53
|
+
# Docker API: GET /images/search
|
|
54
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ImageSearch
|
|
55
|
+
#
|
|
56
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
|
57
|
+
def search params = {}
|
|
58
|
+
@connection.get(build_path("/images/search", params))
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
##
|
|
62
|
+
# Tag an image so that it becomes part of a repository.
|
|
63
|
+
#
|
|
64
|
+
# Docker API: POST /images/{name}/tag
|
|
65
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ImageTag
|
|
66
|
+
#
|
|
67
|
+
# @param name [String]: The ID or name of the image.
|
|
68
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
|
69
|
+
def tag name, params = {}
|
|
70
|
+
@connection.post(build_path("/images/#{name}/tag", params))
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
##
|
|
74
|
+
# Delete unused images.
|
|
75
|
+
#
|
|
76
|
+
# Docker API: POST /images/prune
|
|
77
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ImagePrune
|
|
78
|
+
#
|
|
79
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
|
80
|
+
def prune params = {}
|
|
81
|
+
@connection.post(build_path("/images/prune", params))
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
##
|
|
85
|
+
# Remove an image, along with any untagged parent images that were referenced by that image.
|
|
86
|
+
#
|
|
87
|
+
# Images can't be removed if they have descendant images, are being used by a running container or are being used by a build.
|
|
88
|
+
#
|
|
89
|
+
# Docker API: DELETE /images/{name}
|
|
90
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ImageDelete
|
|
91
|
+
#
|
|
92
|
+
# @param name [String]: The ID or name of the image.
|
|
93
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
|
94
|
+
def remove name, params = {}
|
|
95
|
+
@connection.delete(build_path("/images/#{name}", params))
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
##
|
|
99
|
+
# Export an image.
|
|
100
|
+
#
|
|
101
|
+
# Docker API: GET /images/{name}/get
|
|
102
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ImageGet
|
|
103
|
+
#
|
|
104
|
+
# @param name [String]: The ID or name of the image.
|
|
105
|
+
# @param path [String]: Path to the exported file.
|
|
106
|
+
# @param &block: Replace the default file writing behavior.
|
|
107
|
+
def export name, path, &block
|
|
108
|
+
@connection.request(method: :get, path: build_path("/images/#{name}/get") , response_block: block_given? ? block.call : default_writer(path))
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
##
|
|
112
|
+
# Import images.
|
|
113
|
+
#
|
|
114
|
+
# Docker API: POST /images/load
|
|
115
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ImageLoad
|
|
116
|
+
#
|
|
117
|
+
# @param name [String]: The ID or name of the image.
|
|
118
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
|
119
|
+
def import path, params = {}
|
|
120
|
+
default_reader(path, build_path("/images/load", params))
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
##
|
|
124
|
+
# Push an image to a registry.
|
|
125
|
+
#
|
|
126
|
+
# Docker API: POST /images/{name}/push
|
|
127
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ImagePush
|
|
128
|
+
#
|
|
129
|
+
# @param name [String]: The ID or name of the image.
|
|
130
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
|
131
|
+
# @param authentication [Hash]: Authentication parameters.
|
|
132
|
+
def push name, params = {}, authentication = {}
|
|
133
|
+
raise Docker::API::Error.new("Provide authentication parameters to push an image") unless authentication.keys.size > 0
|
|
134
|
+
@connection.request(method: :post, path: build_path("/images/#{name}/push", params), headers: { "X-Registry-Auth" => Base64.urlsafe_encode64(authentication.to_json.to_s).chomp } )
|
|
135
|
+
end
|
|
145
136
|
|
|
137
|
+
##
|
|
138
|
+
# Create a new image from a container.
|
|
139
|
+
#
|
|
140
|
+
# Docker API: POST /commit
|
|
141
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ImageCommit
|
|
142
|
+
#
|
|
143
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
|
144
|
+
# @param body [Hash]: Request body to be sent as json.
|
|
145
|
+
def commit params = {}, body = {}
|
|
146
|
+
container = Docker::API::Container.new.details(params[:container])
|
|
147
|
+
return container if [404, 301].include? container.status
|
|
148
|
+
@connection.request(method: :post, path: build_path("/commit", params), headers: {"Content-Type": "application/json"}, body: container.json["Config"].merge(body).to_json)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
##
|
|
152
|
+
# Create an image by either pulling it from a registry or importing it.
|
|
153
|
+
#
|
|
154
|
+
# Docker API: POST /images/create
|
|
155
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ImageCreate
|
|
156
|
+
#
|
|
157
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
|
158
|
+
# @param authentication [Hash]: Authentication parameters.
|
|
159
|
+
# @param &block: Replace the default output to stdout behavior.
|
|
160
|
+
def create params = {}, authentication = {}, &block
|
|
161
|
+
request = {method: :post, path: build_path("/images/create", params), response_block: block_given? ? block.call : default_streamer }
|
|
162
|
+
if params.has_key? :fromSrc and !params[:fromSrc].match(/^(http|https)/) # then it's using a tar file
|
|
163
|
+
path = params[:fromSrc]
|
|
164
|
+
params[:fromSrc] = "-"
|
|
165
|
+
default_reader(path, build_path("/images/create", params))
|
|
166
|
+
else
|
|
167
|
+
request[:headers] = { "X-Registry-Auth" => Base64.encode64(authentication.to_json.to_s).chomp } if authentication.keys.size > 0
|
|
168
|
+
@connection.request(request)
|
|
146
169
|
end
|
|
147
170
|
end
|
|
171
|
+
|
|
172
|
+
##
|
|
173
|
+
# Build an image from a tar archive with a Dockerfile in it.
|
|
174
|
+
#
|
|
175
|
+
# Docker API: POST /build
|
|
176
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/ImageBuild
|
|
177
|
+
#
|
|
178
|
+
# @param path [String]: Path to the tar file.
|
|
179
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
|
180
|
+
# @param authentication [Hash]: Authentication parameters.
|
|
181
|
+
# @param &block: Replace the default output to stdout behavior.
|
|
182
|
+
def build path, params = {}, authentication = {}, &block
|
|
183
|
+
raise Docker::API::Error.new("Expected path or params[:remote]") unless path || params[:remote]
|
|
184
|
+
|
|
185
|
+
headers = {"Content-type": "application/x-tar"}
|
|
186
|
+
headers.merge!({"X-Registry-Config": Base64.urlsafe_encode64(authentication.to_json.to_s).chomp}) if authentication.keys.size > 0
|
|
187
|
+
|
|
188
|
+
if path == nil and params.has_key? :remote
|
|
189
|
+
response = @connection.request(method: :post, path: build_path("/build", params), headers: headers, response_block: block_given? ? block.call : default_streamer)
|
|
190
|
+
else
|
|
191
|
+
default_reader(path, build_path("/build", params), headers)
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
##
|
|
196
|
+
# Delete builder cache.
|
|
197
|
+
#
|
|
198
|
+
# Docker API: POST /build/prune
|
|
199
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/BuildPrune
|
|
200
|
+
#
|
|
201
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
|
202
|
+
def delete_cache params = {}
|
|
203
|
+
@connection.post(build_path("/build/prune", params))
|
|
204
|
+
end
|
|
148
205
|
end
|
data/lib/docker/api/network.rb
CHANGED
|
@@ -3,17 +3,14 @@ module Docker
|
|
|
3
3
|
class Network < Docker::API::Base
|
|
4
4
|
|
|
5
5
|
def list params = {}
|
|
6
|
-
validate Docker::API::InvalidParameter, [:filters], params
|
|
7
6
|
@connection.get(build_path("/networks", params))
|
|
8
7
|
end
|
|
9
8
|
|
|
10
9
|
def details name, params = {}
|
|
11
|
-
validate Docker::API::InvalidParameter, [:verbose, :scope], params
|
|
12
10
|
@connection.get(build_path([name], params))
|
|
13
11
|
end
|
|
14
12
|
|
|
15
13
|
def create body = {}
|
|
16
|
-
validate Docker::API::InvalidRequestBody, [:Name, :CheckDuplicate, :Driver, :Internal, :Attachable, :Ingress, :IPAM, :EnableIPv6, :Options, :Labels], body
|
|
17
14
|
@connection.request(method: :post, path: build_path(["create"]), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
|
18
15
|
end
|
|
19
16
|
|
|
@@ -22,17 +19,14 @@ module Docker
|
|
|
22
19
|
end
|
|
23
20
|
|
|
24
21
|
def prune params = {}
|
|
25
|
-
validate Docker::API::InvalidParameter, [:filters], params
|
|
26
22
|
@connection.post(build_path(["prune"], params))
|
|
27
23
|
end
|
|
28
24
|
|
|
29
25
|
def connect name, body = {}
|
|
30
|
-
validate Docker::API::InvalidRequestBody, [:Container, :EndpointConfig], body
|
|
31
26
|
@connection.request(method: :post, path: build_path([name, "connect"]), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
|
32
27
|
end
|
|
33
28
|
|
|
34
29
|
def disconnect name, body = {}
|
|
35
|
-
validate Docker::API::InvalidRequestBody, [:Container, :Force], body
|
|
36
30
|
@connection.request(method: :post, path: build_path([name, "disconnect"]), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
|
37
31
|
end
|
|
38
32
|
|
data/lib/docker/api/node.rb
CHANGED
|
@@ -3,18 +3,14 @@ module Docker
|
|
|
3
3
|
class Node < Docker::API::Base
|
|
4
4
|
|
|
5
5
|
def list params = {}
|
|
6
|
-
validate Docker::API::InvalidParameter, [:filters], params
|
|
7
6
|
@connection.get(build_path("/nodes", params))
|
|
8
7
|
end
|
|
9
8
|
|
|
10
9
|
def update name, params = {}, body = {}
|
|
11
|
-
validate Docker::API::InvalidParameter, [:version], params
|
|
12
|
-
validate Docker::API::InvalidRequestBody, [:Name, :Labels, :Role, :Availability], body
|
|
13
10
|
@connection.request(method: :post, path: build_path("nodes/#{name}/update", params), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
|
14
11
|
end
|
|
15
12
|
|
|
16
13
|
def delete name, params = {}
|
|
17
|
-
validate Docker::API::InvalidParameter, [:force], params
|
|
18
14
|
@connection.delete(build_path("/nodes/#{name}", params))
|
|
19
15
|
end
|
|
20
16
|
|
|
@@ -0,0 +1,160 @@
|
|
|
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
|
+
@connection.get(build_path("/plugins", params))
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Get plugin privileges
|
|
18
|
+
#
|
|
19
|
+
# Docker API: GET /plugins/privileges
|
|
20
|
+
#
|
|
21
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/GetPluginPrivileges
|
|
22
|
+
#
|
|
23
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
|
24
|
+
def privileges params = {}
|
|
25
|
+
@connection.get(build_path("/plugins/privileges", params))
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Install a plugin
|
|
29
|
+
#
|
|
30
|
+
# Pulls and installs a plugin. After the plugin is installed, it can be enabled using the POST /plugins/{name}/enable endpoint.
|
|
31
|
+
#
|
|
32
|
+
# Docker API: POST /plugins/pull
|
|
33
|
+
#
|
|
34
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginPull
|
|
35
|
+
#
|
|
36
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
|
37
|
+
#
|
|
38
|
+
# @param privileges [Array]: Plugin privileges to be sent as json in request body.
|
|
39
|
+
#
|
|
40
|
+
# @param authentication [Hash]: Authentication parameters.
|
|
41
|
+
def install params = {}, privileges = [], authentication = {}
|
|
42
|
+
headers = {"Content-Type": "application/json"}
|
|
43
|
+
headers.merge!({"X-Registry-Auth" => Base64.urlsafe_encode64(authentication.to_json.to_s)}) if authentication.keys.size > 0
|
|
44
|
+
@connection.request(method: :post, path: build_path("/plugins/pull", params), headers: headers, body: privileges.to_json )
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Inspect a plugin
|
|
48
|
+
#
|
|
49
|
+
# Docker API: GET /plugins/{name}/json
|
|
50
|
+
#
|
|
51
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginInspect
|
|
52
|
+
#
|
|
53
|
+
# @param name [String]: The ID or name of the plugin.
|
|
54
|
+
def details name
|
|
55
|
+
@connection.get("/plugins/#{name}/json")
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Remove a plugin
|
|
59
|
+
#
|
|
60
|
+
# Docker API: DELETE /plugins/{name}
|
|
61
|
+
#
|
|
62
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginDelete
|
|
63
|
+
#
|
|
64
|
+
# @param name [String]: The ID or name of the plugin.
|
|
65
|
+
#
|
|
66
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
|
67
|
+
def remove name, params = {}
|
|
68
|
+
@connection.delete(build_path("/plugins/#{name}",params))
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Enable a plugin
|
|
72
|
+
#
|
|
73
|
+
# Docker API: POST /plugins/{name}/enable
|
|
74
|
+
#
|
|
75
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginEnable
|
|
76
|
+
#
|
|
77
|
+
# @param name [String]: The ID or name of the plugin.
|
|
78
|
+
#
|
|
79
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
|
80
|
+
def enable name, params = {}
|
|
81
|
+
@connection.post(build_path("/plugins/#{name}/enable", params))
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Disable a plugin
|
|
85
|
+
#
|
|
86
|
+
# Docker API: POST /plugins/{name}/disable
|
|
87
|
+
#
|
|
88
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginDisable
|
|
89
|
+
#
|
|
90
|
+
# @param name [String]: The ID or name of the plugin.
|
|
91
|
+
def disable name
|
|
92
|
+
@connection.post("/plugins/#{name}/disable")
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Upgrade a plugin
|
|
96
|
+
#
|
|
97
|
+
# Docker API: POST /plugins/{name}/upgrade
|
|
98
|
+
#
|
|
99
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginUpgrade
|
|
100
|
+
#
|
|
101
|
+
# @param name [String]: The ID or name of the plugin.
|
|
102
|
+
#
|
|
103
|
+
# @param params [Hash]: Parameters that are appended to the URL.
|
|
104
|
+
#
|
|
105
|
+
# @param privileges [Array]: Plugin privileges to be sent as json in request body.
|
|
106
|
+
#
|
|
107
|
+
# @param authentication [Hash]: Authentication parameters.
|
|
108
|
+
def upgrade name, params = {}, privileges = [], authentication = {}
|
|
109
|
+
headers = {"Content-Type": "application/json"}
|
|
110
|
+
headers.merge!({"X-Registry-Auth" => Base64.urlsafe_encode64(authentication.to_json.to_s)}) if authentication.keys.size > 0
|
|
111
|
+
@connection.request(method: :post, path: build_path("/plugins/#{name}/upgrade", params), headers: headers, body: privileges.to_json )
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Create a plugin
|
|
115
|
+
#
|
|
116
|
+
# Docker API: POST /plugins/create
|
|
117
|
+
#
|
|
118
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginCreate
|
|
119
|
+
#
|
|
120
|
+
# @param name [String]: The ID or name of the plugin.
|
|
121
|
+
#
|
|
122
|
+
# @param path [String]: Path to tar file that contains rootfs folder and config.json file.
|
|
123
|
+
def create name, path
|
|
124
|
+
file = File.open( File.expand_path( path ) , "r")
|
|
125
|
+
response = @connection.request(method: :post, path: "/plugins/create?name=#{name}", body: file.read.to_s )
|
|
126
|
+
file.close
|
|
127
|
+
response
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Push a plugin to the registry.
|
|
131
|
+
#
|
|
132
|
+
# Docker API: POST /plugins/{name}/push
|
|
133
|
+
#
|
|
134
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginPush
|
|
135
|
+
#
|
|
136
|
+
# @param name [String]: The ID or name of the plugin.
|
|
137
|
+
#
|
|
138
|
+
# @param authentication [Hash]: Authentication parameters.
|
|
139
|
+
def push name, authentication = {}
|
|
140
|
+
if authentication.keys.size > 0
|
|
141
|
+
@connection.request(method: :post, path: "/plugins/#{name}/push", headers: {"X-Registry-Auth" => Base64.urlsafe_encode64(authentication.to_json.to_s)})
|
|
142
|
+
else
|
|
143
|
+
@connection.post("/plugins/#{name}/push")
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# Configure a plugin
|
|
148
|
+
#
|
|
149
|
+
# Docker API: POST /plugins/{name}/set
|
|
150
|
+
#
|
|
151
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/PluginSet
|
|
152
|
+
#
|
|
153
|
+
# @param name [String]: The ID or name of the plugin.
|
|
154
|
+
#
|
|
155
|
+
# @param config [Array]: Plugin configuration to be sent as json in request body.
|
|
156
|
+
def configure name, config
|
|
157
|
+
@connection.request(method: :post, path: "/plugins/#{name}/set", headers: {"Content-Type": "application/json"}, body:config.to_json)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
end
|