dockerapi 0.20.0 → 0.21.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.
@@ -21,7 +21,7 @@ class Docker::API::Secret < Docker::API::Base
21
21
  #
22
22
  # @param body [Hash]: Request body to be sent as json.
23
23
  def create body = {}
24
- @connection.request(method: :post, path: "/secrets/create", headers: {"Content-Type": "application/json"}, body: body.to_json)
24
+ @connection.request(method: :post, path: build_path("/secrets/create"), headers: {"Content-Type" => "application/json"}, body: body.to_json)
25
25
  end
26
26
 
27
27
  # Inspect a secret
@@ -31,7 +31,7 @@ class Docker::API::Secret < Docker::API::Base
31
31
  #
32
32
  # @param name [String]: The ID or name of the secret.
33
33
  def details name
34
- @connection.get("/secrets/#{name}")
34
+ @connection.get(build_path("/secrets/#{name}"))
35
35
  end
36
36
 
37
37
  # Update a secret
@@ -43,7 +43,7 @@ class Docker::API::Secret < Docker::API::Base
43
43
  # @param params [Hash]: Parameters that are appended to the URL.
44
44
  # @param body [Hash]: Request body to be sent as json.
45
45
  def update name, params = {}, body = {}
46
- @connection.request(method: :post, path: build_path("/secrets/#{name}/update",params), headers: {"Content-Type": "application/json"}, body: body.to_json)
46
+ @connection.request(method: :post, path: build_path("/secrets/#{name}/update",params), headers: {"Content-Type" => "application/json"}, body: body.to_json)
47
47
  end
48
48
 
49
49
  # Delete a secret
@@ -53,6 +53,6 @@ class Docker::API::Secret < Docker::API::Base
53
53
  #
54
54
  # @param name [String]: The ID or name of the secret.
55
55
  def delete name
56
- @connection.delete("/secrets/#{name}")
56
+ @connection.delete(build_path("/secrets/#{name}"))
57
57
  end
58
58
  end
@@ -22,9 +22,9 @@ class Docker::API::Service < Docker::API::Base
22
22
  # @param body [Hash]: Request body to be sent as json.
23
23
  # @param authentication [Hash]: Authentication parameters.
24
24
  def create body = {}, authentication = {}
25
- headers = {"Content-Type": "application/json"}
25
+ headers = {"Content-Type" => "application/json"}
26
26
  headers.merge!({"X-Registry-Auth" => auth_encoder(authentication) }) if authentication.keys.size > 0
27
- @connection.request(method: :post, path: "/services/create", headers: headers, body: body.to_json)
27
+ @connection.request(method: :post, path: build_path("/services/create"), headers: headers, body: body.to_json)
28
28
  end
29
29
 
30
30
  # Update a service
@@ -38,7 +38,7 @@ class Docker::API::Service < Docker::API::Base
38
38
  # @param authentication [Hash]: Authentication parameters.
39
39
  def update name, params = {}, body = {}, authentication = {}
40
40
  # view https://github.com/docker/swarmkit/issues/1394#issuecomment-240850719
41
- headers = {"Content-Type": "application/json"}
41
+ headers = {"Content-Type" => "application/json"}
42
42
  headers.merge!({"X-Registry-Auth" => auth_encoder(authentication) }) if authentication.keys.size > 0
43
43
  @connection.request(method: :post, path: build_path("/services/#{name}/update", params), headers: headers, body: body.to_json)
44
44
  end
@@ -72,6 +72,6 @@ class Docker::API::Service < Docker::API::Base
72
72
  #
73
73
  # @param name [String]: The ID or name of the service.
74
74
  def delete name
75
- @connection.delete("/services/#{name}")
75
+ @connection.delete(build_path("/services/#{name}"))
76
76
  end
77
77
  end
@@ -11,7 +11,7 @@ class Docker::API::Swarm < Docker::API::Base
11
11
  #
12
12
  # @param body [Hash]: Request body to be sent as json.
13
13
  def init body = {}
14
- @connection.request(method: :post, path: build_path("/swarm/init"), headers: {"Content-Type": "application/json"}, body: body.to_json)
14
+ @connection.request(method: :post, path: build_path("/swarm/init"), headers: {"Content-Type" => "application/json"}, body: body.to_json)
15
15
  end
16
16
 
17
17
  ##
@@ -23,7 +23,7 @@ class Docker::API::Swarm < Docker::API::Base
23
23
  # @param params [Hash]: Parameters that are appended to the URL.
24
24
  # @param body [Hash]: Request body to be sent as json.
25
25
  def update params = {}, body = {}
26
- @connection.request(method: :post, path: build_path("/swarm/update", params), headers: {"Content-Type": "application/json"}, body: body.to_json)
26
+ @connection.request(method: :post, path: build_path("/swarm/update", params), headers: {"Content-Type" => "application/json"}, body: body.to_json)
27
27
  end
28
28
 
29
29
  ##
@@ -32,7 +32,7 @@ class Docker::API::Swarm < Docker::API::Base
32
32
  # Docker API: GET /swarm
33
33
  # @see https://docs.docker.com/engine/api/v1.40/#operation/SwarmInspect
34
34
  def details
35
- @connection.get("/swarm")
35
+ @connection.get(build_path("/swarm"))
36
36
  end
37
37
 
38
38
  ##
@@ -41,7 +41,7 @@ class Docker::API::Swarm < Docker::API::Base
41
41
  # Docker API: GET /swarm/unlockkey
42
42
  # @see https://docs.docker.com/engine/api/v1.40/#operation/SwarmUnlockkey
43
43
  def unlock_key
44
- @connection.get("/swarm/unlockkey")
44
+ @connection.get(build_path("/swarm/unlockkey"))
45
45
  end
46
46
 
47
47
  ##
@@ -52,7 +52,7 @@ class Docker::API::Swarm < Docker::API::Base
52
52
  #
53
53
  # @param body [Hash]: Request body to be sent as json.
54
54
  def unlock body = {}
55
- @connection.request(method: :post, path: "/swarm/unlock", headers: {"Content-Type": "application/json"}, body: body.to_json)
55
+ @connection.request(method: :post, path: build_path("/swarm/unlock"), headers: {"Content-Type" => "application/json"}, body: body.to_json)
56
56
  end
57
57
 
58
58
  ##
@@ -63,7 +63,7 @@ class Docker::API::Swarm < Docker::API::Base
63
63
  #
64
64
  # @param body [Hash]: Request body to be sent as json.
65
65
  def join body = {}
66
- @connection.request(method: :post, path: "/swarm/join", headers: {"Content-Type": "application/json"}, body: body.to_json)
66
+ @connection.request(method: :post, path: build_path("/swarm/join"), headers: {"Content-Type" => "application/json"}, body: body.to_json)
67
67
  end
68
68
 
69
69
  ##
@@ -11,7 +11,7 @@ class Docker::API::System < Docker::API::Base
11
11
  #
12
12
  # @param body [Hash]: Request body to be sent as json.
13
13
  def auth body = {}
14
- @connection.request(method: :post, path: "/auth", headers: { "Content-Type" => "application/json" }, body: body.to_json)
14
+ @connection.request(method: :post, path: build_path("/auth"), headers: { "Content-Type" => "application/json" }, body: body.to_json)
15
15
  end
16
16
 
17
17
  ##
@@ -32,7 +32,7 @@ class Docker::API::System < Docker::API::Base
32
32
  # Docker API: GET /_ping
33
33
  # @see https://docs.docker.com/engine/api/v1.40/#operation/SystemPing
34
34
  def ping
35
- @connection.get("/_ping")
35
+ @connection.get(build_path("/_ping"))
36
36
  end
37
37
 
38
38
  ##
@@ -41,7 +41,7 @@ class Docker::API::System < Docker::API::Base
41
41
  # Docker API: GET /info
42
42
  # @see https://docs.docker.com/engine/api/v1.40/#operation/SystemInfo
43
43
  def info
44
- @connection.get("/info")
44
+ @connection.get(build_path("/info"))
45
45
  end
46
46
 
47
47
  ##
@@ -50,7 +50,7 @@ class Docker::API::System < Docker::API::Base
50
50
  # Docker API: GET /version
51
51
  # @see https://docs.docker.com/engine/api/v1.40/#operation/SystemVersion
52
52
  def version
53
- @connection.get("/version")
53
+ @connection.get(build_path("/version"))
54
54
  end
55
55
 
56
56
  ##
@@ -21,7 +21,7 @@ class Docker::API::Task < Docker::API::Base
21
21
  #
22
22
  # @param name [String]: The ID or name of the task.
23
23
  def details name
24
- @connection.get("/tasks/#{name}")
24
+ @connection.get(build_path("/tasks/#{name}"))
25
25
  end
26
26
 
27
27
  # Get stdout and stderr logs from a task.
@@ -1,6 +1,6 @@
1
1
  module Docker
2
2
  module API
3
- GEM_VERSION = "0.20.0"
3
+ GEM_VERSION = "0.21.0"
4
4
 
5
5
  API_VERSION = "1.43"
6
6
 
@@ -22,7 +22,7 @@ class Docker::API::Volume < Docker::API::Base
22
22
  #
23
23
  # @param name [String]: The ID or name of the volume.
24
24
  def details name
25
- @connection.get("/volumes/#{name}")
25
+ @connection.get(build_path("/volumes/#{name}"))
26
26
  end
27
27
 
28
28
  ##
@@ -33,7 +33,7 @@ class Docker::API::Volume < Docker::API::Base
33
33
  #
34
34
  # @param body [Hash]: Request body to be sent as json.
35
35
  def create body = {}
36
- @connection.request(method: :post, path: "/volumes/create", headers: {"Content-Type": "application/json"}, body: body.to_json)
36
+ @connection.request(method: :post, path: build_path("/volumes/create"), headers: {"Content-Type" => "application/json"}, body: body.to_json)
37
37
  end
38
38
 
39
39
  ##
data/lib/dockerapi.rb CHANGED
@@ -4,7 +4,6 @@ require "base64"
4
4
  require "fileutils"
5
5
 
6
6
  require "docker/api/version"
7
- require "docker/api/error"
8
7
  require "docker/api/connection"
9
8
  require "docker/api/response"
10
9
  require "docker/api/base"
@@ -27,149 +26,23 @@ module Docker
27
26
 
28
27
  ##
29
28
  # This variable controls output verbosity.
30
- PRINT_TO_STDOUT = true
29
+ def self.print_to_stdout
30
+ @@print_to_stdout
31
+ end
32
+ def self.print_to_stdout=(bool)
33
+ @@print_to_stdout = bool
34
+ end
35
+ self.print_to_stdout = true
31
36
 
32
37
  ##
33
38
  # This variable controls output verbosity.
34
- PRINT_RESPONSE_TO_STDOUT = false
35
-
36
- ##
37
- # Valid values for parameter validations.
38
- VALID_PARAMS = {
39
- "Docker::API::Image" => {
40
- "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],
41
- "prune" => [:filters],
42
- "list" => [:all, :filters, "shared-size", :digests],
43
- "search" => [:term, :limit, :filters],
44
- "tag" => [:repo, :tag],
45
- "remove" => [:force, :noprune],
46
- "import" => [:quiet],
47
- "push" => [:tag],
48
- "commit" => [:container, :repo, :tag, :comment, :author, :pause, :changes],
49
- "create" => [:fromImage, :fromSrc, :repo, :tag, :message, :changes, :platform],
50
- "delete_cache" => [:all, "keep-storage", :filters]
51
- },
52
- "Docker::API::Container" => {
53
- "list" => [:all, :limit, :size, :filters],
54
- "details" => [:size],
55
- "top" => [:ps_args],
56
- "start" => [:detachKeys],
57
- "stop" => [:signal, :t],
58
- "restart" => [:signal, :t],
59
- "kill" => [:signal],
60
- "wait" => [:condition],
61
- "rename" => [:name],
62
- "resize" => [:w, :h],
63
- "prune" => [:filters],
64
- "remove" => [:v, :force, :link],
65
- "logs" => [:follow, :stdout, :stderr, :since, :until, :timestamps, :tail],
66
- "attach" => [:detachKeys, :logs, :stream, :stdin, :stdout, :stderr],
67
- "stats" => [:stream, "one-shot"],
68
- "get_archive" => [:path],
69
- "put_archive" => [:path, :noOverwriteDirNonDir, :copyUIDGID],
70
- "create" => [:name, :platform]
71
- },
72
- "Docker::API::Volume" => {
73
- "list" => [:filters],
74
- "remove" => [:force],
75
- "prune" => [:filters]
76
- },
77
- "Docker::API::Network" => {
78
- "list" => [:filters],
79
- "details" => [:verbose, :scope],
80
- "prune" => [:filters]
81
- },
82
- "Docker::API::System" => {
83
- "events" => [:since, :until, :filters],
84
- "df" => [:type]
85
- },
86
- "Docker::API::Exec" => {
87
- "resize" => [:w, :h]
88
- },
89
- "Docker::API::Swarm" => {
90
- "leave" => [:force],
91
- "update" => [:version, :rotateWorkerToken, :rotateManagerToken, :rotateManagerUnlockKey]
92
- },
93
- "Docker::API::Node" => {
94
- "list" => [:filters],
95
- "update" => [:version],
96
- "delete" => [:force]
97
- },
98
- "Docker::API::Service" => {
99
- "list" => [:filters, :status],
100
- "update" => [:version, :registryAuthFrom, :rollback],
101
- "details" => [:insertDefaults],
102
- "logs" => [:details, :follow, :stdout, :stderr, :since, :timestamps, :tail]
103
- },
104
- "Docker::API::Secret" => {
105
- "list" => [:filters],
106
- "update" => [:version]
107
- },
108
- "Docker::API::Task" => {
109
- "list" => [:filters],
110
- "logs" => [:details, :follow, :stdout, :stderr, :since, :timestamps, :tail]
111
- },
112
- "Docker::API::Plugin" => {
113
- "list" => [:filters],
114
- "privileges" => [:remote],
115
- "install" => [:remote, :name],
116
- "remove" => [:force],
117
- "enable" => [:timeout],
118
- "upgrade" => [:remote]
119
- },
120
- "Docker::API::Config" => {
121
- "list" => [:filters],
122
- "update" => [:version]
123
- }
124
- }
125
-
126
- ##
127
- # Valid values for request body validations.
128
- VALID_BODY = {
129
- "Docker::API::Image" => {
130
- "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]
131
- },
132
- "Docker::API::Container" => {
133
- "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],
134
- "update" => [:CpuShares, :Memory, :CgroupParent, :BlkioWeight, :BlkioWeightDevice, :BlkioDeviceReadBps, :BlkioDeviceWriteBps, :BlkioDeviceReadIOps, :BlkioDeviceWriteIOps, :CpuPeriod, :CpuQuota, :CpuRealtimePeriod, :CpuRealtimeRuntime, :CpusetCpus, :CpusetMems, :Devices, :DeviceCgroupRules, :DeviceRequest, :Memory, :KernelMemoryTCP, :MemoryReservation, :MemorySwap, :MemorySwappiness, :NanoCPUs, :OomKillDisable, :Init, :PidsLimit, :ULimits, :CpuCount, :CpuPercent, :IOMaximumIOps, :IOMaximumBandwidth, :RestartPolicy]
135
- },
136
- "Docker::API::Volume" => {
137
- "create" => [:Name, :Driver, :DriverOpts, :Labels, :ClusterVolumeSpec]
138
- },
139
- "Docker::API::Network" => {
140
- "create" => [:Name, :CheckDuplicate, :Driver, :Internal, :Attachable, :Ingress, :IPAM, :EnableIPv6, :Options, :Labels],
141
- "connect" => [:Container, :EndpointConfig],
142
- "disconnect" => [:Container, :Force]
143
- },
144
- "Docker::API::System" => {
145
- "auth" => [:username, :password, :email, :serveraddress, :identitytoken]
146
- },
147
- "Docker::API::Exec" => {
148
- "create" => [:AttachStdin, :AttachStdout, :AttachStderr, :ConsoleSize, :DetachKeys, :Tty, :Env, :Cmd, :Privileged, :User, :WorkingDir],
149
- "start" => [:Detach, :Tty, :ConsoleSize]
150
- },
151
- "Docker::API::Swarm" => {
152
- "init" => [:ListenAddr, :AdvertiseAddr, :DataPathAddr, :DataPathPort, :DefaultAddrPool, :ForceNewCluster, :SubnetSize, :Spec],
153
- "update" => [:Name, :Labels, :Orchestration, :Raft, :Dispatcher, :CAConfig, :EncryptionConfig, :TaskDefaults],
154
- "unlock" => [:UnlockKey],
155
- "join" => [:ListenAddr, :AdvertiseAddr, :DataPathAddr, :RemoteAddrs, :JoinToken]
156
- },
157
- "Docker::API::Node" => {
158
- "update" => [:Name, :Labels, :Role, :Availability]
159
- },
160
- "Docker::API::Service" => {
161
- "create" => [:Name, :Labels, :TaskTemplate, :Mode, :UpdateConfig, :RollbackConfig, :Networks, :EndpointSpec],
162
- "update" => [:Name, :Labels, :TaskTemplate, :Mode, :UpdateConfig, :RollbackConfig, :Networks, :EndpointSpec]
163
- },
164
- "Docker::API::Secret" => {
165
- "create" => [:Name, :Labels, :Data, :Driver, :Templating],
166
- "update" => [:Name, :Labels, :Data, :Driver, :Templating]
167
- },
168
- "Docker::API::Config" => {
169
- "create" => [:Name, :Labels, :Data, :Templating],
170
- "update" => [:Name, :Labels, :Data, :Templating]
171
- }
172
- }
39
+ def self.print_response_to_stdout
40
+ @@print_response_to_stdout
41
+ end
42
+ def self.print_response_to_stdout=(bool)
43
+ @@print_response_to_stdout = bool
44
+ end
45
+ self.print_response_to_stdout = false
173
46
 
174
47
  end
175
48
  end
data/mise.toml ADDED
@@ -0,0 +1,2 @@
1
+ [tools]
2
+ ruby = "3.2"
metadata CHANGED
@@ -1,29 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dockerapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alysson A. Costa
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-12 00:00:00.000000000 Z
11
+ date: 2025-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: base64
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: excon
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
- - - "~>"
31
+ - - ">="
18
32
  - !ruby/object:Gem::Version
19
- version: '0.79'
33
+ version: '0.97'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '2'
20
37
  type: :runtime
21
38
  prerelease: false
22
39
  version_requirements: !ruby/object:Gem::Requirement
23
40
  requirements:
24
- - - "~>"
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0.97'
44
+ - - "<"
25
45
  - !ruby/object:Gem::Version
26
- version: '0.79'
46
+ version: '2'
27
47
  description: Interact with Docker API directly from Ruby code. Comprehensive implementation
28
48
  (all available endpoints), no local Docker installation required, easily manipulated
29
49
  http responses.
@@ -37,20 +57,17 @@ files:
37
57
  - ".github/workflows/ci.yml"
38
58
  - ".gitignore"
39
59
  - ".rspec"
40
- - CHANGELOG.md
41
60
  - Gemfile
42
61
  - Gemfile.lock
43
62
  - LICENSE.txt
44
63
  - README.md
45
64
  - Rakefile
46
65
  - bin/console
47
- - bin/setup
48
66
  - dockerapi.gemspec
49
67
  - lib/docker/api/base.rb
50
68
  - lib/docker/api/config.rb
51
69
  - lib/docker/api/connection.rb
52
70
  - lib/docker/api/container.rb
53
- - lib/docker/api/error.rb
54
71
  - lib/docker/api/exec.rb
55
72
  - lib/docker/api/image.rb
56
73
  - lib/docker/api/network.rb
@@ -65,15 +82,15 @@ files:
65
82
  - lib/docker/api/version.rb
66
83
  - lib/docker/api/volume.rb
67
84
  - lib/dockerapi.rb
85
+ - mise.toml
68
86
  homepage: https://github.com/nu12/dockerapi
69
87
  licenses:
70
88
  - MIT
71
89
  metadata:
72
90
  homepage_uri: https://github.com/nu12/dockerapi
73
91
  source_code_uri: https://github.com/nu12/dockerapi.git
74
- changelog_uri: https://github.com/nu12/dockerapi/blob/master/CHANGELOG.md
75
92
  documentation_uri: https://www.rubydoc.info/gems/dockerapi
76
- post_install_message:
93
+ post_install_message:
77
94
  rdoc_options: []
78
95
  require_paths:
79
96
  - lib
@@ -81,15 +98,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
98
  requirements:
82
99
  - - ">="
83
100
  - !ruby/object:Gem::Version
84
- version: 2.3.0
101
+ version: '3.2'
85
102
  required_rubygems_version: !ruby/object:Gem::Requirement
86
103
  requirements:
87
104
  - - ">="
88
105
  - !ruby/object:Gem::Version
89
106
  version: '0'
90
107
  requirements: []
91
- rubygems_version: 3.2.3
92
- signing_key:
108
+ rubygems_version: 3.5.11
109
+ signing_key:
93
110
  specification_version: 4
94
111
  summary: Interact with Docker API from Ruby code.
95
112
  test_files: []