dockerapi 0.14.0 → 0.15.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac123f7f5ed500758fd1bb2a9f214495e71c6848517662eae15b92dfa00387aa
4
- data.tar.gz: 270f7a7e14d43f73c402191f11ebf9233aa8b7e2c2e314ac3eeb2875487c5120
3
+ metadata.gz: a07cc3ef52a91afb13ab99c130cb6cbed118055aba264df3e0fb0a1ec701ef6d
4
+ data.tar.gz: d9e6e03672a7a47de2cb0fb840569c45582075be679d21995192247633d58d70
5
5
  SHA512:
6
- metadata.gz: 878a7c0a146bc6657909151ff0e866c1b9cc93f1dc57ed6c7d0e91b87063e41496af294d1f1e7318b11b0ba3eaf03823e5e081b664b4c3bdd326d4298aed6c65
7
- data.tar.gz: fee3d36fd9de8619fc27c588c1285c9acd6ca20a3a6ce1f9fd2ea67c807c74d90ae1a0b531ec233a227ccfd4655056e0c33e6605fa9a31040f6984ca2e3a6798
6
+ metadata.gz: 46bbd5e8c6cbb41e13b3830aab5ca8825d37a1c85401dedc33aeba3352657f8410e99c8c321bc5e5d10e9eeac6435769f9b7d7570a8910b7f0d0779a3308381a
7
+ data.tar.gz: 672a71377c73a0c0a09796d84afebf2cfe03f3a6182626119c3370ab41112249d881152f1dadbe24ba31775475b4463df5d8c42ca2e9f7d6915c080149fab7ab
@@ -1,3 +1,9 @@
1
+ # 0.15.0
2
+
3
+ `Docker::API::System#events` and `Docker::API::Exec#start` methods that can now receive a block to replace standard output to stdout behavior.
4
+
5
+ General refactoring and API documentation.
6
+
1
7
  # 0.14.0
2
8
 
3
9
  Method `Docker::API::Container#archive` is splitted in `#get_archive` and `#put_archive` as per Docker API documentation.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dockerapi (0.14.0)
4
+ dockerapi (0.15.0)
5
5
  excon (~> 0.76.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -543,18 +543,18 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
543
543
  |---|---|---|---|
544
544
  | Image | Ok | Ok | Ok |
545
545
  | Container | Ok | Ok | Ok |
546
- | Volume | Ok | Ok | 8/14 |
547
- | Network | Ok | Ok | 8/14 |
548
- | System | Ok | Ok | 8/14 |
549
- | Exec | Ok | Ok | 8/14 |
550
- | Swarm | Ok | Ok | 8/21 |
551
- | Node | Ok | Ok | 8/21 |
552
- | Service | Ok | Ok | 8/21 |
553
- | Task | Ok | Ok | 8/28 |
554
- | Secret | Ok | Ok | 8/28 |
555
- | Config | Ok | Ok | 8/28 |
556
- | Distribution | Ok | Ok | 8/28 |
557
- | Plugin | Ok | Ok | 8/28 |
546
+ | Volume | Ok | Ok | Ok |
547
+ | Network | Ok | Ok | Ok |
548
+ | System | Ok | Ok | Ok |
549
+ | Exec | Ok | Ok | Ok |
550
+ | Swarm | Ok | Ok | 8/11 |
551
+ | Node | Ok | Ok | 8/11 |
552
+ | Service | Ok | Ok | 8/11 |
553
+ | Task | Ok | Ok | 8/11 |
554
+ | Secret | Ok | Ok | 8/11 |
555
+ | Config | Ok | Ok | 8/14 |
556
+ | Distribution | Ok | Ok | 8/14 |
557
+ | Plugin | Ok | Ok | 8/14 |
558
558
 
559
559
  Add doc in these files: `base`, `connection`, `error`, `response`, `dockerapi`
560
560
 
@@ -1,42 +1,55 @@
1
- module Docker
2
- module API
3
- class Exec < Docker::API::Base
1
+ ##
2
+ # This class represents the Docker API exec related endpoints.
3
+ # @see https://docs.docker.com/engine/api/v1.40/#tag/Exec
4
+ class Docker::API::Exec < Docker::API::Base
4
5
 
5
- def create name, body = {}
6
- @connection.request(method: :post, path: "/containers/#{name}/exec", headers: {"Content-Type": "application/json"}, body: body.to_json )
7
- end
8
-
9
- def start name, body = {}
10
- stream = ""
11
- response = @connection.request(method: :post,
12
- path: "/exec/#{name}/start",
13
- headers: {"Content-Type": "application/json"},
14
- body: body.to_json,
15
- response_block: lambda { |chunk, remaining_bytes, total_bytes| stream += chunk.to_s.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?') }
16
- )
17
- response.data.merge!({stream: stream})
18
- response
19
- end
6
+ ##
7
+ # Run a command inside a running container.
8
+ #
9
+ # Docker API: POST /containers/{id}/exec
10
+ # @see https://docs.docker.com/engine/api/v1.40/#operation/ContainerExec
11
+ #
12
+ # @param name [String]: The ID or name of the container.
13
+ # @param body [Hash]: Request body to be sent as json.
14
+ def create name, body = {}
15
+ @connection.request(method: :post, path: "/containers/#{name}/exec", headers: {"Content-Type": "application/json"}, body: body.to_json )
16
+ end
20
17
 
21
- def resize name, params = {}
22
- @connection.post(build_path("/exec/#{name}/resize", params))
23
- end
18
+ ##
19
+ # Starts a previously set up exec instance.
20
+ #
21
+ # Docker API: POST /exec/{id}/start
22
+ # @see https://docs.docker.com/engine/api/v1.40/#operation/ExecStart
23
+ #
24
+ # @param name [String]: Exec instance ID.
25
+ # @param body [Hash]: Request body to be sent as json.
26
+ # @param &block: Replace the default output to stdout behavior.
27
+ def start name, body = {}, &block
28
+ @connection.request(method: :post, path: "/exec/#{name}/start", headers: {"Content-Type": "application/json"}, body: body.to_json,
29
+ response_block: block_given? ? block.call : default_streamer )
30
+ end
24
31
 
25
- def details name
26
- @connection.get("/exec/#{name}/json")
27
- end
28
-
29
- #################################################
30
- # Items in this area to be removed before 1.0.0 #
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
- details(name)
37
- end
38
- #################################################
32
+ ##
33
+ # Resize the TTY session used by an exec instance.
34
+ #
35
+ # Docker API: POST /exec/{id}/resize
36
+ # @see https://docs.docker.com/engine/api/v1.40/#operation/ExecResize
37
+ #
38
+ # @param name [String]: Exec instance ID.
39
+ # @param body [Hash]: Request body to be sent as json.
40
+ def resize name, params = {}
41
+ @connection.post(build_path("/exec/#{name}/resize", params))
42
+ end
39
43
 
40
- end
44
+ ##
45
+ # Return low-level information about an exec instance.
46
+ #
47
+ # Docker API: GET /exec/{id}/json
48
+ # @see https://docs.docker.com/engine/api/v1.40/#operation/ExecInspect
49
+ #
50
+ # @param name [String]: Exec instance ID.
51
+ def details name
52
+ @connection.get("/exec/#{name}/json")
41
53
  end
54
+
42
55
  end
@@ -1,50 +1,86 @@
1
- module Docker
2
- module API
3
- class Network < Docker::API::Base
4
-
5
- def list params = {}
6
- @connection.get(build_path("/networks", params))
7
- end
8
-
9
- def details name, params = {}
10
- @connection.get(build_path([name], params))
11
- end
12
-
13
- def create body = {}
14
- @connection.request(method: :post, path: build_path(["create"]), headers: {"Content-Type": "application/json"}, body: body.to_json)
15
- end
16
-
17
- def remove name
18
- @connection.delete(build_path([name]))
19
- end
20
-
21
- def prune params = {}
22
- @connection.post(build_path(["prune"], params))
23
- end
24
-
25
- def connect name, body = {}
26
- @connection.request(method: :post, path: build_path([name, "connect"]), headers: {"Content-Type": "application/json"}, body: body.to_json)
27
- end
28
-
29
- def disconnect name, body = {}
30
- @connection.request(method: :post, path: build_path([name, "disconnect"]), headers: {"Content-Type": "application/json"}, body: body.to_json)
31
- end
32
-
33
- #################################################
34
- # Items in this area to be removed before 1.0.0 #
35
- #################################################
36
- def base_path
37
- "/networks"
38
- end
39
-
40
- def inspect *args
41
- return super.inspect if args.size == 0
42
- warn "WARNING: #inspect is deprecated and will be removed in the future, please use #details instead."
43
- name, params = args[0], args[1] || {}
44
- details(name, params)
45
- end
46
- #################################################
47
-
48
- end
1
+ ##
2
+ # This class represents the Docker API endpoints regarding networks.
3
+ # @see https://docs.docker.com/engine/api/v1.40/#tag/Network
4
+ class Docker::API::Network < Docker::API::Base
5
+
6
+ ##
7
+ # List networks.
8
+ #
9
+ # Docker API: GET /networks
10
+ # @see https://docs.docker.com/engine/api/v1.40/#operation/NetworkList
11
+ #
12
+ # @param params [Hash]: Parameters that are appended to the URL.
13
+ def list params = {}
14
+ @connection.get(build_path("/networks", params))
15
+ end
16
+
17
+ ##
18
+ # Inspect a network.
19
+ #
20
+ # Docker API: GET /networks/{id}
21
+ # @see https://docs.docker.com/engine/api/v1.40/#operation/NetworkInspect
22
+ #
23
+ # @param name [String]: The ID or name of the network.
24
+ # @param params [Hash]: Parameters that are appended to the URL.
25
+ def details name, params = {}
26
+ @connection.get(build_path("/networks/#{name}", params))
27
+ end
28
+
29
+ ##
30
+ # Create a network.
31
+ #
32
+ # Docker API: POST /networks/create
33
+ # @see https://docs.docker.com/engine/api/v1.40/#operation/NetworkCreate
34
+ #
35
+ # @param body [Hash]: Request body to be sent as json.
36
+ def create body = {}
37
+ @connection.request(method: :post, path: "/networks/create", headers: {"Content-Type": "application/json"}, body: body.to_json)
38
+ end
39
+
40
+ ##
41
+ # Remove a network.
42
+ #
43
+ # Docker API: DELETE /networks/{id}
44
+ # @see https://docs.docker.com/engine/api/v1.40/#operation/NetworkDelete
45
+ #
46
+ # @param name [String]: The ID or name of the network.
47
+ def remove name
48
+ @connection.delete("/networks/#{name}")
49
49
  end
50
+
51
+ ##
52
+ # Delete unused networks.
53
+ #
54
+ # Docker API: POST /networks/prune
55
+ # @see https://docs.docker.com/engine/api/v1.40/#operation/NetworkPrune
56
+ #
57
+ # @param params [Hash]: Parameters that are appended to the URL.
58
+ def prune params = {}
59
+ @connection.post(build_path("/networks/prune", params))
60
+ end
61
+
62
+ ##
63
+ # Connect a container to a network.
64
+ #
65
+ # Docker API: POST /networks/{id}/connect
66
+ # @see https://docs.docker.com/engine/api/v1.40/#operation/NetworkConnect
67
+ #
68
+ # @param name [String]: The ID or name of the network.
69
+ # @param body [Hash]: Request body to be sent as json.
70
+ def connect name, body = {}
71
+ @connection.request(method: :post, path: "/networks/#{name}/connect", headers: {"Content-Type": "application/json"}, body: body.to_json)
72
+ end
73
+
74
+ ##
75
+ # Disconnect a container from a network.
76
+ #
77
+ # Docker API: POST /networks/{id}/disconnect
78
+ # @see https://docs.docker.com/engine/api/v1.40/#operation/NetworkDisconnect
79
+ #
80
+ # @param name [String]: The ID or name of the network.
81
+ # @param body [Hash]: Request body to be sent as json.
82
+ def disconnect name, body = {}
83
+ @connection.request(method: :post, path: "/networks/#{name}/disconnect", headers: {"Content-Type": "application/json"}, body: body.to_json)
84
+ end
85
+
50
86
  end
@@ -1,32 +1,65 @@
1
- require "json"
2
- module Docker
3
- module API
4
- class System < Docker::API::Base
1
+ ##
2
+ # This class represents the Docker API system related endpoints.
3
+ # @see https://docs.docker.com/engine/api/v1.40/#tag/System
4
+ class Docker::API::System < Docker::API::Base
5
5
 
6
- def auth body = {}
7
- @connection.request(method: :post, path: "/auth", headers: { "Content-Type" => "application/json" }, body: body.to_json)
8
- end
6
+ ##
7
+ # Validate credentials for a registry and, if available, get an identity token for accessing the registry without password.
8
+ #
9
+ # Docker API: POST /auth
10
+ # @see https://docs.docker.com/engine/api/v1.40/#operation/SystemAuth
11
+ #
12
+ # @param body [Hash]: Request body to be sent as json.
13
+ def auth body = {}
14
+ @connection.request(method: :post, path: "/auth", headers: { "Content-Type" => "application/json" }, body: body.to_json)
15
+ end
9
16
 
10
- def events params = {}
11
- @connection.request(method: :get, path: build_path("/events", params), response_block: lambda { |chunk, remaining_bytes, total_bytes| puts chunk.inspect } )
12
- end
17
+ ##
18
+ # Stream real-time events from the server.
19
+ #
20
+ # Docker API: GET /events
21
+ # @see https://docs.docker.com/engine/api/v1.40/#operation/SystemEvents
22
+ #
23
+ # @param params [Hash]: Parameters that are appended to the URL.
24
+ # @param &block: Replace the default output to stdout behavior.
25
+ def events params = {}, &block
26
+ @connection.request(method: :get, path: build_path("/events", params), response_block: block_given? ? block.call : default_streamer )
27
+ end
13
28
 
14
- def ping
15
- @connection.get("/_ping")
16
- end
29
+ ##
30
+ # This is a dummy endpoint you can use to test if the server is accessible.
31
+ #
32
+ # Docker API: GET /_ping
33
+ # @see https://docs.docker.com/engine/api/v1.40/#operation/SystemPing
34
+ def ping
35
+ @connection.get("/_ping")
36
+ end
17
37
 
18
- def info
19
- @connection.get("/info")
20
- end
38
+ ##
39
+ # Get system information.
40
+ #
41
+ # Docker API: GET /info
42
+ # @see https://docs.docker.com/engine/api/v1.40/#operation/SystemInfo
43
+ def info
44
+ @connection.get("/info")
45
+ end
21
46
 
22
- def version
23
- @connection.get("/version")
24
- end
47
+ ##
48
+ # Returns the version of Docker that is running and various information about the system that Docker is running on.
49
+ #
50
+ # Docker API: GET /version
51
+ # @see https://docs.docker.com/engine/api/v1.40/#operation/SystemVersion
52
+ def version
53
+ @connection.get("/version")
54
+ end
25
55
 
26
- def df
27
- @connection.get("/system/df")
28
- end
29
-
30
- end
56
+ ##
57
+ # Get data usage information.
58
+ #
59
+ # Docker API: GET /system/df
60
+ # @see https://docs.docker.com/engine/api/v1.40/#operation/SystemDataUsage
61
+ def df
62
+ @connection.get("/system/df")
31
63
  end
64
+
32
65
  end
@@ -1,6 +1,6 @@
1
1
  module Docker
2
2
  module API
3
- GEM_VERSION = "0.14.0"
3
+ GEM_VERSION = "0.15.0"
4
4
 
5
5
  API_VERSION = "1.40"
6
6
 
@@ -1,42 +1,61 @@
1
- module Docker
2
- module API
3
- class Volume < Docker::API::Base
4
-
5
- def list params = {}
6
- @connection.get(build_path("/volumes", params))
7
- end
8
-
9
- def details name
10
- @connection.get(build_path([name]))
11
- end
12
-
13
- def create body = {}
14
- @connection.request(method: :post, path: build_path(["create"]), headers: {"Content-Type": "application/json"}, body: body.to_json)
15
- end
16
-
17
- def remove name, params = {}
18
- @connection.delete(build_path([name]))
19
- end
1
+ ##
2
+ # This class represents the Docker API endpoints regarding volumes.
3
+ # @see https://docs.docker.com/engine/api/v1.40/#tag/Volume
4
+ class Docker::API::Volume < Docker::API::Base
5
+
6
+ ##
7
+ # List volumes.
8
+ #
9
+ # Docker API: GET
10
+ # @see https://docs.docker.com/engine/api/v1.40/#operation/VolumeList
11
+ #
12
+ # @param params [Hash]: Parameters that are appended to the URL.
13
+ def list params = {}
14
+ @connection.get(build_path("/volumes", params))
15
+ end
20
16
 
21
- def prune params = {}
22
- @connection.post(build_path(["prune"], params))
23
- end
17
+ ##
18
+ # Inspect a volume.
19
+ #
20
+ # Docker API: GET /volumes/{name}
21
+ # @see https://docs.docker.com/engine/api/v1.40/#operation/VolumeInspect
22
+ #
23
+ # @param name [String]: The ID or name of the volume.
24
+ def details name
25
+ @connection.get("/volumes/#{name}")
26
+ end
24
27
 
25
- #################################################
26
- # Items in this area to be removed before 1.0.0 #
27
- #################################################
28
- def base_path
29
- "/volumes"
30
- end
28
+ ##
29
+ # Create a volume.
30
+ #
31
+ # Docker API: POST /volumes/create
32
+ # @see https://docs.docker.com/engine/api/v1.40/#operation/VolumeCreate
33
+ #
34
+ # @param body [Hash]: Request body to be sent as json.
35
+ def create body = {}
36
+ @connection.request(method: :post, path: "/volumes/create", headers: {"Content-Type": "application/json"}, body: body.to_json)
37
+ end
31
38
 
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
+ ##
40
+ # Remove a volume.
41
+ #
42
+ # Docker API: DELETE /volumes/{name}
43
+ # @see https://docs.docker.com/engine/api/v1.40/#operation/VolumeDelete
44
+ #
45
+ # @param name [String]: The ID or name of the volume.
46
+ # @param params [Hash]: Parameters that are appended to the URL.
47
+ def remove name, params = {}
48
+ @connection.delete(build_path("/volumes/#{name}",params))
49
+ end
39
50
 
40
- end
51
+ ##
52
+ # Delete unused volumes.
53
+ #
54
+ # Docker API: POST /volumes/prune
55
+ # @see https://docs.docker.com/engine/api/v1.40/#operation/VolumePrune
56
+ #
57
+ # @param params [Hash]: Parameters that are appended to the URL.
58
+ def prune params = {}
59
+ @connection.post(build_path("/volumes/prune", params))
41
60
  end
42
- end
61
+ 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.14.0
4
+ version: 0.15.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-08-05 00:00:00.000000000 Z
11
+ date: 2020-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon