dockerapi 0.10.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.
@@ -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
@@ -1,6 +1,6 @@
1
1
  module Docker
2
2
  module API
3
- GEM_VERSION = "0.10.0"
3
+ GEM_VERSION = "0.15.0"
4
4
 
5
5
  API_VERSION = "1.40"
6
6
 
@@ -1,46 +1,61 @@
1
- module Docker
2
- module API
3
- class Volume < Docker::API::Base
4
-
5
- def list params = {}
6
- validate Docker::API::InvalidParameter, [:filters], params
7
- @connection.get(build_path("/volumes", params))
8
- end
9
-
10
- def details name
11
- @connection.get(build_path([name]))
12
- end
13
-
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)
17
- end
18
-
19
- def remove name, params = {}
20
- validate Docker::API::InvalidParameter, [:force], params
21
- @connection.delete(build_path([name]))
22
- 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
23
16
 
24
- def prune params = {}
25
- validate Docker::API::InvalidParameter, [:filters], params
26
- @connection.post(build_path(["prune"], params))
27
- 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
28
27
 
29
- #################################################
30
- # Items in this area to be removed before 1.0.0 #
31
- #################################################
32
- def base_path
33
- "/volumes"
34
- 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
35
38
 
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]))
41
- end
42
- #################################################
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
43
50
 
44
- 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))
45
60
  end
46
- end
61
+ end
@@ -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"
@@ -15,9 +17,148 @@ require "docker/api/system"
15
17
  require "docker/api/swarm"
16
18
  require "docker/api/node"
17
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"
18
24
 
19
25
  module Docker
20
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
+ "get_archive" => [:path],
61
+ "put_archive" => [:path, :noOverwriteDirNonDir, :copyUIDGID],
62
+ "create" => [:name]
63
+ },
64
+ "Docker::API::Volume" => {
65
+ "list" => [:filters],
66
+ "remove" => [:force],
67
+ "prune" => [:filters]
68
+ },
69
+ "Docker::API::Network" => {
70
+ "list" => [:filters],
71
+ "details" => [:verbose, :scope],
72
+ "prune" => [:filters]
73
+ },
74
+ "Docker::API::System" => {
75
+ "events" => [:since, :until, :filters]
76
+ },
77
+ "Docker::API::Exec" => {
78
+ "resize" => [:w, :h]
79
+ },
80
+ "Docker::API::Swarm" => {
81
+ "leave" => [:force],
82
+ "update" => [:version, :rotateWorkerToken, :rotateManagerToken, :rotateManagerUnlockKey]
83
+ },
84
+ "Docker::API::Node" => {
85
+ "list" => [:filters],
86
+ "update" => [:version],
87
+ "delete" => [:force]
88
+ },
89
+ "Docker::API::Service" => {
90
+ "list" => [:filters],
91
+ "update" => [:version, :registryAuthFrom, :rollback],
92
+ "details" => [:insertDefaults],
93
+ "logs" => [:details, :follow, :stdout, :stderr, :since, :timestamps, :tail]
94
+ },
95
+ "Docker::API::Secret" => {
96
+ "list" => [:filters],
97
+ "update" => [:version]
98
+ },
99
+ "Docker::API::Task" => {
100
+ "list" => [:filters],
101
+ "logs" => [:details, :follow, :stdout, :stderr, :since, :timestamps, :tail]
102
+ },
103
+ "Docker::API::Plugin" => {
104
+ "list" => [:filters],
105
+ "privileges" => [:remote],
106
+ "install" => [:remote, :name],
107
+ "remove" => [:force],
108
+ "enable" => [:timeout],
109
+ "upgrade" => [:remote]
110
+ },
111
+ "Docker::API::Config" => {
112
+ "list" => [:filters],
113
+ "update" => [:version]
114
+ }
115
+ }
116
+
117
+ VALID_BODY = {
118
+ "Docker::API::Image" => {
119
+ "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]
120
+ },
121
+ "Docker::API::Container" => {
122
+ "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],
123
+ "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]
124
+ },
125
+ "Docker::API::Volume" => {
126
+ "create" => [:Name, :Driver, :DriverOpts, :Labels]
127
+ },
128
+ "Docker::API::Network" => {
129
+ "create" => [:Name, :CheckDuplicate, :Driver, :Internal, :Attachable, :Ingress, :IPAM, :EnableIPv6, :Options, :Labels],
130
+ "connect" => [:Container, :EndpointConfig],
131
+ "disconnect" => [:Container, :Force]
132
+ },
133
+ "Docker::API::System" => {
134
+ "auth" => [:username, :password, :email, :serveraddress, :identitytoken]
135
+ },
136
+ "Docker::API::Exec" => {
137
+ "create" => [:AttachStdin, :AttachStdout, :AttachStderr, :DetachKeys, :Tty, :Env, :Cmd, :Privileged, :User, :WorkingDir],
138
+ "start" => [:Detach, :Tty]
139
+ },
140
+ "Docker::API::Swarm" => {
141
+ "init" => [:ListenAddr, :AdvertiseAddr, :DataPathAddr, :DataPathPort, :DefaultAddrPool, :ForceNewCluster, :SubnetSize, :Spec],
142
+ "update" => [:Name, :Labels, :Orchestration, :Raft, :Dispatcher, :CAConfig, :EncryptionConfig, :TaskDefaults],
143
+ "unlock" => [:UnlockKey],
144
+ "join" => [:ListenAddr, :AdvertiseAddr, :DataPathAddr, :RemoteAddrs, :JoinToken]
145
+ },
146
+ "Docker::API::Node" => {
147
+ "update" => [:Name, :Labels, :Role, :Availability]
148
+ },
149
+ "Docker::API::Service" => {
150
+ "create" => [:Name, :Labels, :TaskTemplate, :Mode, :UpdateConfig, :RollbackConfig, :Networks, :EndpointSpec],
151
+ "update" => [:Name, :Labels, :TaskTemplate, :Mode, :UpdateConfig, :RollbackConfig, :Networks, :EndpointSpec]
152
+ },
153
+ "Docker::API::Secret" => {
154
+ "create" => [:Name, :Labels, :Data, :Driver, :Templating],
155
+ "update" => [:Name, :Labels, :Data, :Driver, :Templating]
156
+ },
157
+ "Docker::API::Config" => {
158
+ "create" => [:Name, :Labels, :Data, :Templating],
159
+ "update" => [:Name, :Labels, :Data, :Driver, :Templating]
160
+ }
161
+ }
21
162
 
22
163
  end
23
164
  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.10.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-07-14 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
@@ -16,15 +16,17 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.74.0
19
+ version: 0.76.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.74.0
27
- description: Interact directly with Docker API from Ruby code.
26
+ version: 0.76.0
27
+ description: Interact with Docker API directly from Ruby code. Comprehensive implementation
28
+ (all available endpoints), no local Docker installation required, easily manipulated
29
+ http responses.
28
30
  email:
29
31
  - alysson.avila.costa@gmail.com
30
32
  executables: []
@@ -44,6 +46,7 @@ files:
44
46
  - bin/setup
45
47
  - dockerapi.gemspec
46
48
  - lib/docker/api/base.rb
49
+ - lib/docker/api/config.rb
47
50
  - lib/docker/api/connection.rb
48
51
  - lib/docker/api/container.rb
49
52
  - lib/docker/api/error.rb
@@ -51,10 +54,13 @@ files:
51
54
  - lib/docker/api/image.rb
52
55
  - lib/docker/api/network.rb
53
56
  - lib/docker/api/node.rb
57
+ - lib/docker/api/plugin.rb
54
58
  - lib/docker/api/response.rb
59
+ - lib/docker/api/secret.rb
55
60
  - lib/docker/api/service.rb
56
61
  - lib/docker/api/swarm.rb
57
62
  - lib/docker/api/system.rb
63
+ - lib/docker/api/task.rb
58
64
  - lib/docker/api/version.rb
59
65
  - lib/docker/api/volume.rb
60
66
  - lib/dockerapi.rb
@@ -65,6 +71,7 @@ metadata:
65
71
  homepage_uri: https://github.com/nu12/dockerapi
66
72
  source_code_uri: https://github.com/nu12/dockerapi.git
67
73
  changelog_uri: https://github.com/nu12/dockerapi/blob/master/CHANGELOG.md
74
+ documentation_uri: https://www.rubydoc.info/gems/dockerapi
68
75
  post_install_message:
69
76
  rdoc_options: []
70
77
  require_paths:
@@ -83,5 +90,5 @@ requirements: []
83
90
  rubygems_version: 3.1.2
84
91
  signing_key:
85
92
  specification_version: 4
86
- summary: Interact directly with Docker API from Ruby code.
93
+ summary: Interact with Docker API from Ruby code.
87
94
  test_files: []