dockerapi 0.8.1 → 0.13.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 +93 -18
- data/Gemfile.lock +1 -1
- data/README.md +166 -25
- data/dockerapi.gemspec +1 -1
- data/lib/docker/api/base.rb +57 -29
- data/lib/docker/api/config.rb +66 -0
- data/lib/docker/api/container.rb +19 -32
- data/lib/docker/api/exec.rb +15 -10
- data/lib/docker/api/image.rb +185 -135
- data/lib/docker/api/network.rb +18 -15
- data/lib/docker/api/node.rb +16 -10
- 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 +12 -8
- 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 +19 -13
- data/lib/dockerapi.rb +141 -0
- metadata +7 -2
data/lib/docker/api/system.rb
CHANGED
@@ -4,12 +4,10 @@ module Docker
|
|
4
4
|
class System < Docker::API::Base
|
5
5
|
|
6
6
|
def auth body = {}
|
7
|
-
validate Docker::API::InvalidRequestBody, [:username, :password, :email, :serveraddress, :identitytoken], body
|
8
7
|
@connection.request(method: :post, path: "/auth", headers: { "Content-Type" => "application/json" }, body: body.to_json)
|
9
8
|
end
|
10
9
|
|
11
10
|
def events params = {}
|
12
|
-
validate Docker::API::InvalidParameter, [:since, :until, :filters], params
|
13
11
|
@connection.request(method: :get, path: build_path("/events", params), response_block: lambda { |chunk, remaining_bytes, total_bytes| puts chunk.inspect } )
|
14
12
|
end
|
15
13
|
|
@@ -0,0 +1,44 @@
|
|
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
|
+
@connection.get(build_path("/tasks",params))
|
17
|
+
end
|
18
|
+
|
19
|
+
# Inspect a task
|
20
|
+
#
|
21
|
+
# Docker API: GET /tasks/{id}
|
22
|
+
#
|
23
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/TaskInspect
|
24
|
+
#
|
25
|
+
# @param name [String]: The ID or name of the task.
|
26
|
+
def details name
|
27
|
+
@connection.get("/tasks/#{name}")
|
28
|
+
end
|
29
|
+
|
30
|
+
# Get stdout and stderr logs from a task.
|
31
|
+
#
|
32
|
+
# Note: This endpoint works only for services with the local, json-file or journald logging drivers.
|
33
|
+
#
|
34
|
+
# Docker API: GET /tasks/{id}/logs
|
35
|
+
#
|
36
|
+
# @see https://docs.docker.com/engine/api/v1.40/#operation/TaskLogs
|
37
|
+
#
|
38
|
+
# @param name (String) : The ID or name of the task.
|
39
|
+
#
|
40
|
+
# @param params (Hash) : Parameters that are appended to the URL.
|
41
|
+
def logs name, params = {}
|
42
|
+
@connection.get(build_path("/tasks/#{name}/logs", params))
|
43
|
+
end
|
44
|
+
end
|
data/lib/docker/api/version.rb
CHANGED
data/lib/docker/api/volume.rb
CHANGED
@@ -1,36 +1,42 @@
|
|
1
1
|
module Docker
|
2
2
|
module API
|
3
3
|
class Volume < Docker::API::Base
|
4
|
-
def base_path
|
5
|
-
"/volumes"
|
6
|
-
end
|
7
|
-
|
8
|
-
def inspect *args
|
9
|
-
return super.inspect if args.size == 0
|
10
|
-
name = args[0]
|
11
|
-
@connection.get(build_path([name]))
|
12
|
-
end
|
13
4
|
|
14
5
|
def list params = {}
|
15
|
-
validate Docker::API::InvalidParameter, [:filters], params
|
16
6
|
@connection.get(build_path("/volumes", params))
|
17
7
|
end
|
18
8
|
|
9
|
+
def details name
|
10
|
+
@connection.get(build_path([name]))
|
11
|
+
end
|
12
|
+
|
19
13
|
def create body = {}
|
20
|
-
validate Docker::API::InvalidRequestBody, [:Name, :Driver, :DriverOpts, :Labels], body
|
21
14
|
@connection.request(method: :post, path: build_path(["create"]), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
22
15
|
end
|
23
16
|
|
24
17
|
def remove name, params = {}
|
25
|
-
validate Docker::API::InvalidParameter, [:force], params
|
26
18
|
@connection.delete(build_path([name]))
|
27
19
|
end
|
28
20
|
|
29
21
|
def prune params = {}
|
30
|
-
validate Docker::API::InvalidParameter, [:filters], params
|
31
22
|
@connection.post(build_path(["prune"], params))
|
32
23
|
end
|
33
24
|
|
25
|
+
#################################################
|
26
|
+
# Items in this area to be removed before 1.0.0 #
|
27
|
+
#################################################
|
28
|
+
def base_path
|
29
|
+
"/volumes"
|
30
|
+
end
|
31
|
+
|
32
|
+
def inspect *args
|
33
|
+
return super.inspect if args.size == 0
|
34
|
+
warn "WARNING: #inspect is deprecated and will be removed in the future, please use #details instead."
|
35
|
+
name = args[0]
|
36
|
+
@connection.get(build_path([name]))
|
37
|
+
end
|
38
|
+
#################################################
|
39
|
+
|
34
40
|
end
|
35
41
|
end
|
36
42
|
end
|
data/lib/dockerapi.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require "excon"
|
2
2
|
require "json"
|
3
|
+
require "base64"
|
4
|
+
require "fileutils"
|
3
5
|
|
4
6
|
require "docker/api/version"
|
5
7
|
require "docker/api/error"
|
@@ -14,9 +16,148 @@ require "docker/api/exec"
|
|
14
16
|
require "docker/api/system"
|
15
17
|
require "docker/api/swarm"
|
16
18
|
require "docker/api/node"
|
19
|
+
require "docker/api/service"
|
20
|
+
require "docker/api/task"
|
21
|
+
require "docker/api/secret"
|
22
|
+
require "docker/api/config"
|
23
|
+
require "docker/api/plugin"
|
17
24
|
|
18
25
|
module Docker
|
19
26
|
module API
|
27
|
+
|
28
|
+
PRINT_TO_STDOUT = true
|
29
|
+
|
30
|
+
VALID_PARAMS = {
|
31
|
+
"Docker::API::Image" => {
|
32
|
+
"build" => [:dockerfile, :t, :extrahosts, :remote, :q, :nocache, :cachefrom, :pull, :rm, :forcerm, :memory, :memswap, :cpushares, :cpusetcpus, :cpuperiod, :cpuquota, :buildargs, :shmsize, :squash, :labels, :networkmode, :platform, :target, :outputs],
|
33
|
+
"prune" => [:filters],
|
34
|
+
"list" => [:all, :filters, :digests],
|
35
|
+
"search" => [:term, :limit, :filters],
|
36
|
+
"tag" => [:repo, :tag],
|
37
|
+
"remove" => [:force, :noprune],
|
38
|
+
"import" => [:quiet],
|
39
|
+
"push" => [:tag],
|
40
|
+
"commit" => [:container, :repo, :tag, :comment, :author, :pause, :changes],
|
41
|
+
"create" => [:fromImage, :fromSrc, :repo, :tag, :message, :platform],
|
42
|
+
"delete_cache" => [:all, "keep-storage", :filters]
|
43
|
+
},
|
44
|
+
"Docker::API::Container" => {
|
45
|
+
"list" => [:all, :limit, :size, :filters],
|
46
|
+
"details" => [:size],
|
47
|
+
"top" => [:ps_args],
|
48
|
+
"start" => [:detachKeys],
|
49
|
+
"stop" => [:t],
|
50
|
+
"restart" => [:t],
|
51
|
+
"kill" => [:signal],
|
52
|
+
"wait" => [:condition],
|
53
|
+
"rename" => [:name],
|
54
|
+
"resize" => [:w, :h],
|
55
|
+
"prune" => [:filters],
|
56
|
+
"remove" => [:v, :force, :link],
|
57
|
+
"logs" => [:follow, :stdout, :stderr, :since, :until, :timestamps, :tail],
|
58
|
+
"attach" => [:detachKeys, :logs, :stream, :stdin, :stdout, :stderr],
|
59
|
+
"stats" => [:stream],
|
60
|
+
"archive" => [:path, :noOverwriteDirNonDir, :copyUIDGID],
|
61
|
+
"create" => [:name]
|
62
|
+
},
|
63
|
+
"Docker::API::Volume" => {
|
64
|
+
"list" => [:filters],
|
65
|
+
"remove" => [:force],
|
66
|
+
"prune" => [:filters]
|
67
|
+
},
|
68
|
+
"Docker::API::Network" => {
|
69
|
+
"list" => [:filters],
|
70
|
+
"details" => [:verbose, :scope],
|
71
|
+
"prune" => [:filters]
|
72
|
+
},
|
73
|
+
"Docker::API::System" => {
|
74
|
+
"events" => [:since, :until, :filters]
|
75
|
+
},
|
76
|
+
"Docker::API::Exec" => {
|
77
|
+
"resize" => [:w, :h]
|
78
|
+
},
|
79
|
+
"Docker::API::Swarm" => {
|
80
|
+
"leave" => [:force],
|
81
|
+
"update" => [:version, :rotateWorkerToken, :rotateManagerToken, :rotateManagerUnlockKey]
|
82
|
+
},
|
83
|
+
"Docker::API::Node" => {
|
84
|
+
"list" => [:filters],
|
85
|
+
"update" => [:version],
|
86
|
+
"delete" => [:force]
|
87
|
+
},
|
88
|
+
"Docker::API::Service" => {
|
89
|
+
"list" => [:filters],
|
90
|
+
"update" => [:version, :registryAuthFrom, :rollback],
|
91
|
+
"details" => [:insertDefaults],
|
92
|
+
"logs" => [:details, :follow, :stdout, :stderr, :since, :timestamps, :tail]
|
93
|
+
},
|
94
|
+
"Docker::API::Secret" => {
|
95
|
+
"list" => [:filters],
|
96
|
+
"update" => [:version]
|
97
|
+
},
|
98
|
+
"Docker::API::Task" => {
|
99
|
+
"list" => [:filters],
|
100
|
+
"logs" => [:details, :follow, :stdout, :stderr, :since, :timestamps, :tail]
|
101
|
+
},
|
102
|
+
"Docker::API::Plugin" => {
|
103
|
+
"list" => [:filters],
|
104
|
+
"privileges" => [:remote],
|
105
|
+
"install" => [:remote, :name],
|
106
|
+
"remove" => [:force],
|
107
|
+
"enable" => [:timeout],
|
108
|
+
"upgrade" => [:remote]
|
109
|
+
},
|
110
|
+
"Docker::API::Config" => {
|
111
|
+
"list" => [:filters],
|
112
|
+
"update" => [:version]
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
VALID_BODY = {
|
117
|
+
"Docker::API::Image" => {
|
118
|
+
"commit" => [:Hostname, :Domainname, :User, :AttachStdin, :AttachStdout, :AttachStderr, :ExposedPorts, :Tty, :OpenStdin, :StdinOnce, :Env, :Cmd, :HealthCheck, :ArgsEscaped, :Image, :Volumes, :WorkingDir, :Entrypoint, :NetworkDisabled, :MacAddress, :OnBuild, :Labels, :StopSignal, :StopTimeout, :Shell]
|
119
|
+
},
|
120
|
+
"Docker::API::Container" => {
|
121
|
+
"create" => [:Hostname,:Domainname,:User,:AttachStdin,:AttachStdout,:AttachStderr,:ExposedPorts,:Tty,:OpenStdin,:StdinOnce,:Env,:Cmd,:HealthCheck,:ArgsEscaped,:Image,:Volumes,:WorkingDir,:Entrypoint,:NetworkDisabled,:MacAddress,:OnBuild,:Labels,:StopSignal,:StopTimeout,:Shell,:HostConfig,:NetworkingConfig],
|
122
|
+
"update" => [:CpuShares, :Memory, :CgroupParent, :BlkioWeight, :BlkioWeightDevice, :BlkioWeightReadBps, :BlkioWeightWriteBps, :BlkioWeightReadOps, :BlkioWeightWriteOps, :CpuPeriod, :CpuQuota, :CpuRealtimePeriod, :CpuRealtimeRuntime, :CpusetCpus, :CpusetMems, :Devices, :DeviceCgroupRules, :DeviceRequest, :Kernel, :Memory, :KernelMemoryTCP, :MemoryReservation, :MemorySwap, :MemorySwappiness, :NanoCPUs, :OomKillDisable, :Init, :PidsLimit, :ULimits, :CpuCount, :CpuPercent, :IOMaximumIOps, :IOMaximumBandwidth, :RestartPolicy]
|
123
|
+
},
|
124
|
+
"Docker::API::Volume" => {
|
125
|
+
"create" => [:Name, :Driver, :DriverOpts, :Labels]
|
126
|
+
},
|
127
|
+
"Docker::API::Network" => {
|
128
|
+
"create" => [:Name, :CheckDuplicate, :Driver, :Internal, :Attachable, :Ingress, :IPAM, :EnableIPv6, :Options, :Labels],
|
129
|
+
"connect" => [:Container, :EndpointConfig],
|
130
|
+
"disconnect" => [:Container, :Force]
|
131
|
+
},
|
132
|
+
"Docker::API::System" => {
|
133
|
+
"auth" => [:username, :password, :email, :serveraddress, :identitytoken]
|
134
|
+
},
|
135
|
+
"Docker::API::Exec" => {
|
136
|
+
"create" => [:AttachStdin, :AttachStdout, :AttachStderr, :DetachKeys, :Tty, :Env, :Cmd, :Privileged, :User, :WorkingDir],
|
137
|
+
"start" => [:Detach, :Tty]
|
138
|
+
},
|
139
|
+
"Docker::API::Swarm" => {
|
140
|
+
"init" => [:ListenAddr, :AdvertiseAddr, :DataPathAddr, :DataPathPort, :DefaultAddrPool, :ForceNewCluster, :SubnetSize, :Spec],
|
141
|
+
"update" => [:Name, :Labels, :Orchestration, :Raft, :Dispatcher, :CAConfig, :EncryptionConfig, :TaskDefaults],
|
142
|
+
"unlock" => [:UnlockKey],
|
143
|
+
"join" => [:ListenAddr, :AdvertiseAddr, :DataPathAddr, :RemoteAddrs, :JoinToken]
|
144
|
+
},
|
145
|
+
"Docker::API::Node" => {
|
146
|
+
"update" => [:Name, :Labels, :Role, :Availability]
|
147
|
+
},
|
148
|
+
"Docker::API::Service" => {
|
149
|
+
"create" => [:Name, :Labels, :TaskTemplate, :Mode, :UpdateConfig, :RollbackConfig, :Networks, :EndpointSpec],
|
150
|
+
"update" => [:Name, :Labels, :TaskTemplate, :Mode, :UpdateConfig, :RollbackConfig, :Networks, :EndpointSpec]
|
151
|
+
},
|
152
|
+
"Docker::API::Secret" => {
|
153
|
+
"create" => [:Name, :Labels, :Data, :Driver, :Templating],
|
154
|
+
"update" => [:Name, :Labels, :Data, :Driver, :Templating]
|
155
|
+
},
|
156
|
+
"Docker::API::Config" => {
|
157
|
+
"create" => [:Name, :Labels, :Data, :Templating],
|
158
|
+
"update" => [:Name, :Labels, :Data, :Driver, :Templating]
|
159
|
+
}
|
160
|
+
}
|
20
161
|
|
21
162
|
end
|
22
163
|
end
|
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.
|
4
|
+
version: 0.13.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-
|
11
|
+
date: 2020-07-31 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
|
@@ -51,9 +52,13 @@ files:
|
|
51
52
|
- lib/docker/api/image.rb
|
52
53
|
- lib/docker/api/network.rb
|
53
54
|
- lib/docker/api/node.rb
|
55
|
+
- lib/docker/api/plugin.rb
|
54
56
|
- lib/docker/api/response.rb
|
57
|
+
- lib/docker/api/secret.rb
|
58
|
+
- lib/docker/api/service.rb
|
55
59
|
- lib/docker/api/swarm.rb
|
56
60
|
- lib/docker/api/system.rb
|
61
|
+
- lib/docker/api/task.rb
|
57
62
|
- lib/docker/api/version.rb
|
58
63
|
- lib/docker/api/volume.rb
|
59
64
|
- lib/dockerapi.rb
|