dockerapi 0.5.0 → 0.9.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 +65 -11
- data/Gemfile.lock +1 -1
- data/README.md +186 -86
- data/bin/setup +17 -3
- data/lib/docker/api/base.rb +12 -10
- data/lib/docker/api/connection.rb +4 -10
- data/lib/docker/api/container.rb +64 -53
- data/lib/docker/api/exec.rb +46 -0
- data/lib/docker/api/image.rb +51 -43
- data/lib/docker/api/network.rb +29 -18
- data/lib/docker/api/node.rb +38 -0
- data/lib/docker/api/swarm.rb +51 -0
- data/lib/docker/api/system.rb +14 -13
- data/lib/docker/api/version.rb +1 -1
- data/lib/docker/api/volume.rb +26 -14
- data/lib/dockerapi.rb +3 -0
- metadata +5 -2
data/lib/docker/api/network.rb
CHANGED
@@ -2,43 +2,54 @@ module Docker
|
|
2
2
|
module API
|
3
3
|
class Network < Docker::API::Base
|
4
4
|
|
5
|
-
def
|
6
|
-
"/networks"
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.list params = {}
|
5
|
+
def list params = {}
|
10
6
|
validate Docker::API::InvalidParameter, [:filters], params
|
11
|
-
connection.get(build_path("/networks", params))
|
7
|
+
@connection.get(build_path("/networks", params))
|
12
8
|
end
|
13
9
|
|
14
|
-
def
|
10
|
+
def details name, params = {}
|
15
11
|
validate Docker::API::InvalidParameter, [:verbose, :scope], params
|
16
|
-
connection.get(build_path([name], params))
|
12
|
+
@connection.get(build_path([name], params))
|
17
13
|
end
|
18
14
|
|
19
|
-
def
|
15
|
+
def create body = {}
|
20
16
|
validate Docker::API::InvalidRequestBody, [:Name, :CheckDuplicate, :Driver, :Internal, :Attachable, :Ingress, :IPAM, :EnableIPv6, :Options, :Labels], body
|
21
|
-
connection.request(method: :post, path: build_path(["create"]), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
17
|
+
@connection.request(method: :post, path: build_path(["create"]), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
22
18
|
end
|
23
19
|
|
24
|
-
def
|
25
|
-
connection.delete(build_path([name]))
|
20
|
+
def remove name
|
21
|
+
@connection.delete(build_path([name]))
|
26
22
|
end
|
27
23
|
|
28
|
-
def
|
24
|
+
def prune params = {}
|
29
25
|
validate Docker::API::InvalidParameter, [:filters], params
|
30
|
-
connection.post(build_path(["prune"], params))
|
26
|
+
@connection.post(build_path(["prune"], params))
|
31
27
|
end
|
32
28
|
|
33
|
-
def
|
29
|
+
def connect name, body = {}
|
34
30
|
validate Docker::API::InvalidRequestBody, [:Container, :EndpointConfig], body
|
35
|
-
connection.request(method: :post, path: build_path([name, "connect"]), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
31
|
+
@connection.request(method: :post, path: build_path([name, "connect"]), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
36
32
|
end
|
37
33
|
|
38
|
-
def
|
34
|
+
def disconnect name, body = {}
|
39
35
|
validate Docker::API::InvalidRequestBody, [:Container, :Force], body
|
40
|
-
connection.request(method: :post, path: build_path([name, "disconnect"]), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
36
|
+
@connection.request(method: :post, path: build_path([name, "disconnect"]), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
37
|
+
end
|
38
|
+
|
39
|
+
#################################################
|
40
|
+
# Items in this area to be removed before 1.0.0 #
|
41
|
+
#################################################
|
42
|
+
def base_path
|
43
|
+
"/networks"
|
44
|
+
end
|
45
|
+
|
46
|
+
def inspect *args
|
47
|
+
return super.inspect if args.size == 0
|
48
|
+
warn "WARNING: #inspect is deprecated and will be removed in the future, please use #details instead."
|
49
|
+
name, params = args[0], args[1] || {}
|
50
|
+
details(name, params)
|
41
51
|
end
|
52
|
+
#################################################
|
42
53
|
|
43
54
|
end
|
44
55
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Docker
|
2
|
+
module API
|
3
|
+
class Node < Docker::API::Base
|
4
|
+
|
5
|
+
def list params = {}
|
6
|
+
validate Docker::API::InvalidParameter, [:filters], params
|
7
|
+
@connection.get(build_path("/nodes", params))
|
8
|
+
end
|
9
|
+
|
10
|
+
def update name, params = {}, body = {}
|
11
|
+
validate Docker::API::InvalidParameter, [:version], params
|
12
|
+
validate Docker::API::InvalidRequestBody, [:Name, :Labels, :Role, :Availability], body
|
13
|
+
@connection.request(method: :post, path: build_path("nodes/#{name}/update", params), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
14
|
+
end
|
15
|
+
|
16
|
+
def delete name, params = {}
|
17
|
+
validate Docker::API::InvalidParameter, [:force], params
|
18
|
+
@connection.delete(build_path("/nodes/#{name}", params))
|
19
|
+
end
|
20
|
+
|
21
|
+
def details name
|
22
|
+
@connection.get("/nodes/#{name}")
|
23
|
+
end
|
24
|
+
|
25
|
+
#################################################
|
26
|
+
# Items in this area to be removed before 1.0.0 #
|
27
|
+
#################################################
|
28
|
+
def inspect *args
|
29
|
+
return super.inspect if args.size == 0
|
30
|
+
warn "WARNING: #inspect is deprecated and will be removed in the future, please use #details instead."
|
31
|
+
name = args[0]
|
32
|
+
details(name)
|
33
|
+
end
|
34
|
+
#################################################
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Docker
|
2
|
+
module API
|
3
|
+
class Swarm < Docker::API::Base
|
4
|
+
|
5
|
+
def init body = {}
|
6
|
+
validate Docker::API::InvalidRequestBody, [:ListenAddr, :AdvertiseAddr, :DataPathAddr, :DataPathPort, :DefaultAddrPool, :ForceNewCluster, :SubnetSize, :Spec], body
|
7
|
+
@connection.request(method: :post, path: build_path("/swarm/init"), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
8
|
+
end
|
9
|
+
|
10
|
+
def update params = {}, body = {}
|
11
|
+
validate Docker::API::InvalidParameter, [:version, :rotateWorkerToken, :rotateManagerToken, :rotateManagerUnlockKey], params
|
12
|
+
validate Docker::API::InvalidRequestBody, [:Name, :Labels, :Orchestration, :Raft, :Dispatcher, :CAConfig, :EncryptionConfig, :TaskDefaults], body
|
13
|
+
@connection.request(method: :post, path: build_path("/swarm/update", params), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
14
|
+
end
|
15
|
+
|
16
|
+
def details
|
17
|
+
@connection.get("/swarm")
|
18
|
+
end
|
19
|
+
|
20
|
+
def unlock_key
|
21
|
+
@connection.get(build_path("/swarm/unlockkey"))
|
22
|
+
end
|
23
|
+
|
24
|
+
def unlock body = {}
|
25
|
+
validate Docker::API::InvalidRequestBody, [:UnlockKey], body
|
26
|
+
@connection.request(method: :post, path: build_path("/swarm/unlock"), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
27
|
+
end
|
28
|
+
|
29
|
+
def join body = {}
|
30
|
+
validate Docker::API::InvalidRequestBody, [:ListenAddr, :AdvertiseAddr, :DataPathAddr, :RemoteAddrs, :JoinToken], body
|
31
|
+
@connection.request(method: :post, path: build_path("/swarm/join"), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
32
|
+
end
|
33
|
+
|
34
|
+
def leave params = {}
|
35
|
+
validate Docker::API::InvalidParameter, [:force], params
|
36
|
+
@connection.post(build_path("/swarm/leave", params))
|
37
|
+
end
|
38
|
+
|
39
|
+
#################################################
|
40
|
+
# Items in this area to be removed before 1.0.0 #
|
41
|
+
#################################################
|
42
|
+
def inspect
|
43
|
+
caller.each { | el | return super.inspect if el.match(/inspector/) }
|
44
|
+
warn "WARNING: #inspect is deprecated and will be removed in the future, please use #details instead."
|
45
|
+
details
|
46
|
+
end
|
47
|
+
#################################################
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/docker/api/system.rb
CHANGED
@@ -2,32 +2,33 @@ require "json"
|
|
2
2
|
module Docker
|
3
3
|
module API
|
4
4
|
class System < Docker::API::Base
|
5
|
-
|
6
|
-
def
|
5
|
+
|
6
|
+
def auth body = {}
|
7
7
|
validate Docker::API::InvalidRequestBody, [:username, :password, :email, :serveraddress, :identitytoken], body
|
8
|
-
connection.request(method: :post, path: "/auth", headers: { "Content-Type" => "application/json" }, body: body.to_json)
|
8
|
+
@connection.request(method: :post, path: "/auth", headers: { "Content-Type" => "application/json" }, body: body.to_json)
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
11
|
+
def events params = {}
|
12
12
|
validate Docker::API::InvalidParameter, [:since, :until, :filters], params
|
13
|
-
connection.request(method: :get, path: build_path("/events", params), response_block: lambda { |chunk, remaining_bytes, total_bytes| puts chunk.inspect } )
|
13
|
+
@connection.request(method: :get, path: build_path("/events", params), response_block: lambda { |chunk, remaining_bytes, total_bytes| puts chunk.inspect } )
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
connection.get("/_ping")
|
16
|
+
def ping
|
17
|
+
@connection.get("/_ping")
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
21
|
-
connection.get("/info")
|
20
|
+
def info
|
21
|
+
@connection.get("/info")
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
connection.get("/version")
|
24
|
+
def version
|
25
|
+
@connection.get("/version")
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
29
|
-
connection.get("/system/df")
|
28
|
+
def df
|
29
|
+
@connection.get("/system/df")
|
30
30
|
end
|
31
|
+
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
data/lib/docker/api/version.rb
CHANGED
data/lib/docker/api/volume.rb
CHANGED
@@ -1,33 +1,45 @@
|
|
1
1
|
module Docker
|
2
2
|
module API
|
3
3
|
class Volume < Docker::API::Base
|
4
|
-
def self.base_path
|
5
|
-
"/volumes"
|
6
|
-
end
|
7
4
|
|
8
|
-
def
|
5
|
+
def list params = {}
|
9
6
|
validate Docker::API::InvalidParameter, [:filters], params
|
10
|
-
connection.get(build_path("/volumes", params))
|
7
|
+
@connection.get(build_path("/volumes", params))
|
11
8
|
end
|
12
9
|
|
13
|
-
def
|
14
|
-
|
15
|
-
connection.request(method: :post, path: build_path(["create"]), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
10
|
+
def details name
|
11
|
+
@connection.get(build_path([name]))
|
16
12
|
end
|
17
13
|
|
18
|
-
def
|
19
|
-
|
14
|
+
def create body = {}
|
15
|
+
validate Docker::API::InvalidRequestBody, [:Name, :Driver, :DriverOpts, :Labels], body
|
16
|
+
@connection.request(method: :post, path: build_path(["create"]), headers: {"Content-Type": "application/json"}, body: body.to_json)
|
20
17
|
end
|
21
18
|
|
22
|
-
def
|
19
|
+
def remove name, params = {}
|
23
20
|
validate Docker::API::InvalidParameter, [:force], params
|
24
|
-
connection.delete(build_path([name]))
|
21
|
+
@connection.delete(build_path([name]))
|
25
22
|
end
|
26
23
|
|
27
|
-
def
|
24
|
+
def prune params = {}
|
28
25
|
validate Docker::API::InvalidParameter, [:filters], params
|
29
|
-
connection.post(build_path(["prune"], params))
|
26
|
+
@connection.post(build_path(["prune"], params))
|
27
|
+
end
|
28
|
+
|
29
|
+
#################################################
|
30
|
+
# Items in this area to be removed before 1.0.0 #
|
31
|
+
#################################################
|
32
|
+
def base_path
|
33
|
+
"/volumes"
|
34
|
+
end
|
35
|
+
|
36
|
+
def inspect *args
|
37
|
+
return super.inspect if args.size == 0
|
38
|
+
warn "WARNING: #inspect is deprecated and will be removed in the future, please use #details instead."
|
39
|
+
name = args[0]
|
40
|
+
@connection.get(build_path([name]))
|
30
41
|
end
|
42
|
+
#################################################
|
31
43
|
|
32
44
|
end
|
33
45
|
end
|
data/lib/dockerapi.rb
CHANGED
@@ -10,7 +10,10 @@ require "docker/api/container"
|
|
10
10
|
require "docker/api/image"
|
11
11
|
require "docker/api/volume"
|
12
12
|
require "docker/api/network"
|
13
|
+
require "docker/api/exec"
|
13
14
|
require "docker/api/system"
|
15
|
+
require "docker/api/swarm"
|
16
|
+
require "docker/api/node"
|
14
17
|
|
15
18
|
module Docker
|
16
19
|
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.
|
4
|
+
version: 0.9.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-
|
11
|
+
date: 2020-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|
@@ -47,9 +47,12 @@ files:
|
|
47
47
|
- lib/docker/api/connection.rb
|
48
48
|
- lib/docker/api/container.rb
|
49
49
|
- lib/docker/api/error.rb
|
50
|
+
- lib/docker/api/exec.rb
|
50
51
|
- lib/docker/api/image.rb
|
51
52
|
- lib/docker/api/network.rb
|
53
|
+
- lib/docker/api/node.rb
|
52
54
|
- lib/docker/api/response.rb
|
55
|
+
- lib/docker/api/swarm.rb
|
53
56
|
- lib/docker/api/system.rb
|
54
57
|
- lib/docker/api/version.rb
|
55
58
|
- lib/docker/api/volume.rb
|