rabbitmq_http_api_client 1.9.1 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/ChangeLog.md +66 -1
- data/LICENSE.txt +1 -1
- data/README.md +7 -8
- data/lib/rabbitmq/http/client.rb +103 -87
- data/lib/rabbitmq/http/client/version.rb +1 -1
- metadata +30 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: afd16eec1e7511b4c5fecd268f414036ecf0874fcf6babc31ab421bfc2fb48c2
|
4
|
+
data.tar.gz: c5883f195ac79adf0ecfe381461b211440482c1f0ba4d2b94f3b2c13840b0bb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f25b0386053eb50530c92dafa20c42dc50d706c502d049068cffa9fc0e1884fffd50f88793d00bcadba3dd8b612b0abf3d22a4c498cb7e3ec1d568e39e83c9d
|
7
|
+
data.tar.gz: b16d32b2a285fd6c350d380a40f94ba39051260afd877f2556aee85f0a8bbf0ba9af3fbfae52b96db68259189381321831cbc668ec26a3ad00c6152f7f2e384d
|
data/ChangeLog.md
CHANGED
@@ -1,7 +1,72 @@
|
|
1
|
-
## Changes Between 1.
|
1
|
+
## Changes Between 1.14.0 and 1.15.0 (unreleased)
|
2
2
|
|
3
3
|
No changes yet.
|
4
4
|
|
5
|
+
## Changes Between 1.13.0 and 1.14.0 (July 8th, 2020)
|
6
|
+
|
7
|
+
### URI.escape is No Longer Used
|
8
|
+
|
9
|
+
Deprecated `URI.escape` has been replaced with `Addressable::URI.escape_component`.
|
10
|
+
This introduces `addressable` as a new dependency.
|
11
|
+
|
12
|
+
### Dependency Bump
|
13
|
+
|
14
|
+
Note: Faraday will now raise a `Faraday::ResourceNotFound` instead of `Faraday::Error::ResourceNotFound`.
|
15
|
+
|
16
|
+
GitHub issue: [#45](https://github.com/ruby-amqp/rabbitmq_http_api_client/pull/45)
|
17
|
+
|
18
|
+
Contributed by Niels Jansen.
|
19
|
+
|
20
|
+
## Changes Between 1.12.0 and 1.13.0 (March 5th, 2020)
|
21
|
+
|
22
|
+
### Pagination Support
|
23
|
+
|
24
|
+
GitHub issue: [#43](https://github.com/ruby-amqp/rabbitmq_http_api_client/pull/43)
|
25
|
+
|
26
|
+
Contributed by Rustam Sharshenov.
|
27
|
+
|
28
|
+
### Dependency Updates
|
29
|
+
|
30
|
+
GitHub issue: [#42](https://github.com/ruby-amqp/rabbitmq_http_api_client/pull/42)
|
31
|
+
|
32
|
+
Contributed by @hatch-carl.
|
33
|
+
|
34
|
+
|
35
|
+
## Changes Between 1.11.0 and 1.12.0 (March 12th, 2019)
|
36
|
+
|
37
|
+
### Dependency Updates
|
38
|
+
|
39
|
+
GitHub issue: [#38](https://github.com/ruby-amqp/rabbitmq_http_api_client/pull/38)
|
40
|
+
|
41
|
+
Contributed by Jon Homan.
|
42
|
+
|
43
|
+
|
44
|
+
## Changes Between 1.10.0 and 1.11.0 (Dec 25th, 2018)
|
45
|
+
|
46
|
+
### effin_utf8 Dependency Dropped
|
47
|
+
|
48
|
+
This library no longer supports Ruby 1.8 and thus
|
49
|
+
doesn't need to depend on the `effin_utf8` gem.
|
50
|
+
|
51
|
+
Contributed by Luciano Sousa.
|
52
|
+
|
53
|
+
|
54
|
+
## Changes Between 1.9.0 and 1.10.0 (Nov 27th, 2018)
|
55
|
+
|
56
|
+
### Improved Resource Deserialisation
|
57
|
+
|
58
|
+
Bodies of responses with content length of 0 will no longer
|
59
|
+
be deserialised.
|
60
|
+
|
61
|
+
This improves compatibility with future versions of RabbitMQ
|
62
|
+
that will use Cowboy 2.7.0 or later, which doesn't include
|
63
|
+
the content-type header for blank responses (e.g. PUTs).
|
64
|
+
|
65
|
+
|
66
|
+
## Changes Between 1.9.0 and 1.9.1 (Oct 19th, 2017)
|
67
|
+
|
68
|
+
Spec files and development/CI scripts are no longer included into the gem.
|
69
|
+
|
5
70
|
|
6
71
|
## Changes Between 1.8.0 and 1.9.0 (July 30th, 2017)
|
7
72
|
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -18,9 +18,9 @@ and will support more HTTP API features in the future
|
|
18
18
|
|
19
19
|
## Supported Ruby Versions
|
20
20
|
|
21
|
-
* CRuby 2.
|
21
|
+
* CRuby 2.2 through 2.7.x
|
22
22
|
* JRuby 9K
|
23
|
-
|
23
|
+
|
24
24
|
## Supported RabbitMQ Versions
|
25
25
|
|
26
26
|
* RabbitMQ 3.x
|
@@ -32,7 +32,7 @@ All versions require [RabbitMQ Management UI plugin](http://www.rabbitmq.com/man
|
|
32
32
|
Add this line to your application's Gemfile:
|
33
33
|
|
34
34
|
``` ruby
|
35
|
-
gem 'rabbitmq_http_api_client', '>= 1.
|
35
|
+
gem 'rabbitmq_http_api_client', '>= 1.13.0'
|
36
36
|
```
|
37
37
|
|
38
38
|
And then execute:
|
@@ -59,7 +59,7 @@ Use `RabbitMQ::HTTP::Client#connect` to specify RabbitMQ HTTP API endpoint (e.g.
|
|
59
59
|
require "rabbitmq/http/client"
|
60
60
|
|
61
61
|
endpoint = "http://127.0.0.1:15672"
|
62
|
-
client = RabbitMQ::HTTP::Client.new(endpoint, :
|
62
|
+
client = RabbitMQ::HTTP::Client.new(endpoint, username: "guest", password: "guest")
|
63
63
|
```
|
64
64
|
|
65
65
|
Alternatively, credentials can be specified in the endpoint URI:
|
@@ -127,7 +127,7 @@ puts n.proc_used
|
|
127
127
|
puts n.fd_total
|
128
128
|
|
129
129
|
# Get Management Plugin extension list
|
130
|
-
xs = client.list_extensions
|
130
|
+
xs = client.list_extensions
|
131
131
|
|
132
132
|
# List all the entities (vhosts, queues, exchanges, bindings, users, etc)
|
133
133
|
defs = client.list_definitions
|
@@ -259,7 +259,7 @@ puts b.vhost
|
|
259
259
|
# List all bindings in a vhost
|
260
260
|
bs = client.list_bindings("/")
|
261
261
|
|
262
|
-
# List all
|
262
|
+
# List all bindings between an exchange and a queue
|
263
263
|
bs = client.list_bindings_between_queue_and_exchange("/", "collector1.megacorp.local", "log.events")
|
264
264
|
```
|
265
265
|
|
@@ -371,5 +371,4 @@ and rabbitmq-management plugin enabled.
|
|
371
371
|
|
372
372
|
Double-licensed under the MIT and Mozilla Public License (same as RabbitMQ).
|
373
373
|
|
374
|
-
(c) Michael S. Klishin, 2012-
|
375
|
-
|
374
|
+
(c) Michael S. Klishin, 2012-2020.
|
data/lib/rabbitmq/http/client.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "addressable/uri"
|
1
2
|
require "hashie"
|
2
3
|
require "faraday"
|
3
4
|
require "faraday_middleware"
|
@@ -57,16 +58,16 @@ module RabbitMQ
|
|
57
58
|
reduce(Hash.new) { |acc, lnr| acc[lnr.protocol] = lnr.port; acc }
|
58
59
|
end
|
59
60
|
|
60
|
-
def list_nodes
|
61
|
-
decode_resource_collection(@connection.get("nodes"))
|
61
|
+
def list_nodes(query = {})
|
62
|
+
decode_resource_collection(@connection.get("nodes", query))
|
62
63
|
end
|
63
64
|
|
64
65
|
def node_info(name)
|
65
|
-
decode_resource(@connection.get("nodes/#{
|
66
|
+
decode_resource(@connection.get("nodes/#{encode_uri_path_segment(name)}"))
|
66
67
|
end
|
67
68
|
|
68
|
-
def list_extensions
|
69
|
-
decode_resource_collection(@connection.get("extensions"))
|
69
|
+
def list_extensions(query = {})
|
70
|
+
decode_resource_collection(@connection.get("extensions", query))
|
70
71
|
end
|
71
72
|
|
72
73
|
def list_definitions
|
@@ -81,34 +82,34 @@ module RabbitMQ
|
|
81
82
|
response.success?
|
82
83
|
end
|
83
84
|
|
84
|
-
def list_connections
|
85
|
-
decode_resource_collection(@connection.get("connections"))
|
85
|
+
def list_connections(query = {})
|
86
|
+
decode_resource_collection(@connection.get("connections", query))
|
86
87
|
end
|
87
88
|
|
88
89
|
def connection_info(name)
|
89
|
-
decode_resource(@connection.get("connections/#{
|
90
|
+
decode_resource(@connection.get("connections/#{encode_uri_path_segment(name)}"))
|
90
91
|
end
|
91
92
|
|
92
93
|
def close_connection(name)
|
93
|
-
decode_resource(@connection.delete("connections/#{
|
94
|
+
decode_resource(@connection.delete("connections/#{encode_uri_path_segment(name)}"))
|
94
95
|
end
|
95
96
|
|
96
|
-
def list_channels
|
97
|
-
decode_resource_collection(@connection.get("channels"))
|
97
|
+
def list_channels(query = {})
|
98
|
+
decode_resource_collection(@connection.get("channels", query))
|
98
99
|
end
|
99
100
|
|
100
101
|
def channel_info(name)
|
101
|
-
decode_resource(@connection.get("channels/#{
|
102
|
+
decode_resource(@connection.get("channels/#{encode_uri_path_segment(name)}"))
|
102
103
|
end
|
103
104
|
|
104
|
-
def list_exchanges(vhost = nil)
|
105
|
+
def list_exchanges(vhost = nil, query = {})
|
105
106
|
path = if vhost.nil?
|
106
107
|
"exchanges"
|
107
108
|
else
|
108
|
-
"exchanges/#{
|
109
|
+
"exchanges/#{encode_uri_path_segment(vhost)}"
|
109
110
|
end
|
110
111
|
|
111
|
-
decode_resource_collection(@connection.get(path))
|
112
|
+
decode_resource_collection(@connection.get(path, query))
|
112
113
|
end
|
113
114
|
|
114
115
|
def declare_exchange(vhost, name, attributes = {})
|
@@ -119,7 +120,7 @@ module RabbitMQ
|
|
119
120
|
:arguments => {}
|
120
121
|
}.merge(attributes)
|
121
122
|
|
122
|
-
response = @connection.put("exchanges/#{
|
123
|
+
response = @connection.put("exchanges/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}") do |req|
|
123
124
|
req.headers['Content-Type'] = 'application/json'
|
124
125
|
req.body = MultiJson.dump(opts)
|
125
126
|
end
|
@@ -127,40 +128,40 @@ module RabbitMQ
|
|
127
128
|
end
|
128
129
|
|
129
130
|
def delete_exchange(vhost, name, if_unused = false)
|
130
|
-
response = @connection.delete("exchanges/#{
|
131
|
+
response = @connection.delete("exchanges/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}") do |req|
|
131
132
|
req.params["if-unused"] = true if if_unused
|
132
133
|
end
|
133
134
|
decode_resource(response)
|
134
135
|
end
|
135
136
|
|
136
137
|
def exchange_info(vhost, name)
|
137
|
-
decode_resource(@connection.get("exchanges/#{
|
138
|
+
decode_resource(@connection.get("exchanges/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}"))
|
138
139
|
end
|
139
140
|
|
140
|
-
def list_bindings_by_source(vhost, exchange)
|
141
|
-
decode_resource_collection(@connection.get("exchanges/#{
|
141
|
+
def list_bindings_by_source(vhost, exchange, query = {})
|
142
|
+
decode_resource_collection(@connection.get("exchanges/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(exchange)}/bindings/source", query))
|
142
143
|
end
|
143
144
|
|
144
|
-
def list_bindings_by_destination(vhost, exchange)
|
145
|
-
decode_resource_collection(@connection.get("exchanges/#{
|
145
|
+
def list_bindings_by_destination(vhost, exchange, query = {})
|
146
|
+
decode_resource_collection(@connection.get("exchanges/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(exchange)}/bindings/destination", query))
|
146
147
|
end
|
147
148
|
|
148
|
-
def list_queues(vhost = nil)
|
149
|
+
def list_queues(vhost = nil, query = {})
|
149
150
|
path = if vhost.nil?
|
150
151
|
"queues"
|
151
152
|
else
|
152
|
-
"queues/#{
|
153
|
+
"queues/#{encode_uri_path_segment(vhost)}"
|
153
154
|
end
|
154
155
|
|
155
|
-
decode_resource_collection(@connection.get(path))
|
156
|
+
decode_resource_collection(@connection.get(path, query))
|
156
157
|
end
|
157
158
|
|
158
159
|
def queue_info(vhost, name)
|
159
|
-
decode_resource(@connection.get("queues/#{
|
160
|
+
decode_resource(@connection.get("queues/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}"))
|
160
161
|
end
|
161
162
|
|
162
163
|
def declare_queue(vhost, name, attributes)
|
163
|
-
response = @connection.put("queues/#{
|
164
|
+
response = @connection.put("queues/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}") do |req|
|
164
165
|
req.headers['Content-Type'] = "application/json"
|
165
166
|
req.body = MultiJson.dump(attributes)
|
166
167
|
end
|
@@ -168,46 +169,46 @@ module RabbitMQ
|
|
168
169
|
end
|
169
170
|
|
170
171
|
def delete_queue(vhost, name)
|
171
|
-
decode_resource(@connection.delete("queues/#{
|
172
|
+
decode_resource(@connection.delete("queues/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}"))
|
172
173
|
end
|
173
174
|
|
174
|
-
def list_queue_bindings(vhost, queue)
|
175
|
-
decode_resource_collection(@connection.get("queues/#{
|
175
|
+
def list_queue_bindings(vhost, queue, query = {})
|
176
|
+
decode_resource_collection(@connection.get("queues/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(queue)}/bindings", query))
|
176
177
|
end
|
177
178
|
|
178
179
|
def purge_queue(vhost, name)
|
179
|
-
@connection.delete("queues/#{
|
180
|
+
@connection.delete("queues/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}/contents")
|
180
181
|
Hashie::Mash.new
|
181
182
|
end
|
182
183
|
|
183
184
|
def get_messages(vhost, name, options)
|
184
|
-
response = @connection.post("queues/#{
|
185
|
+
response = @connection.post("queues/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}/get") do |req|
|
185
186
|
req.headers['Content-Type'] = "application/json"
|
186
187
|
req.body = MultiJson.dump(options)
|
187
188
|
end
|
188
189
|
decode_resource_collection(response)
|
189
190
|
end
|
190
191
|
|
191
|
-
def list_bindings(vhost = nil)
|
192
|
+
def list_bindings(vhost = nil, query = {})
|
192
193
|
path = if vhost.nil?
|
193
194
|
"bindings"
|
194
195
|
else
|
195
|
-
"bindings/#{
|
196
|
+
"bindings/#{encode_uri_path_segment(vhost)}"
|
196
197
|
end
|
197
198
|
|
198
|
-
decode_resource_collection(@connection.get(path))
|
199
|
+
decode_resource_collection(@connection.get(path, query))
|
199
200
|
end
|
200
201
|
|
201
|
-
def list_bindings_between_queue_and_exchange(vhost, queue, exchange)
|
202
|
-
decode_resource_collection(@connection.get("bindings/#{
|
202
|
+
def list_bindings_between_queue_and_exchange(vhost, queue, exchange, query = {})
|
203
|
+
decode_resource_collection(@connection.get("bindings/#{encode_uri_path_segment(vhost)}/e/#{encode_uri_path_segment(exchange)}/q/#{encode_uri_path_segment(queue)}", query))
|
203
204
|
end
|
204
205
|
|
205
206
|
def queue_binding_info(vhost, queue, exchange, properties_key)
|
206
|
-
decode_resource(@connection.get("bindings/#{
|
207
|
+
decode_resource(@connection.get("bindings/#{encode_uri_path_segment(vhost)}/e/#{encode_uri_path_segment(exchange)}/q/#{encode_uri_path_segment(queue)}/#{encode_uri_path_segment(properties_key)}"))
|
207
208
|
end
|
208
209
|
|
209
210
|
def bind_queue(vhost, queue, exchange, routing_key, arguments = [])
|
210
|
-
resp = @connection.post("bindings/#{
|
211
|
+
resp = @connection.post("bindings/#{encode_uri_path_segment(vhost)}/e/#{encode_uri_path_segment(exchange)}/q/#{encode_uri_path_segment(queue)}") do |req|
|
211
212
|
req.headers['Content-Type'] = 'application/json'
|
212
213
|
req.body = MultiJson.dump({:routing_key => routing_key, :arguments => arguments})
|
213
214
|
end
|
@@ -215,21 +216,21 @@ module RabbitMQ
|
|
215
216
|
end
|
216
217
|
|
217
218
|
def delete_queue_binding(vhost, queue, exchange, properties_key)
|
218
|
-
resp = @connection.delete("bindings/#{
|
219
|
+
resp = @connection.delete("bindings/#{encode_uri_path_segment(vhost)}/e/#{encode_uri_path_segment(exchange)}/q/#{encode_uri_path_segment(queue)}/#{encode_uri_path_segment(properties_key)}")
|
219
220
|
resp.success?
|
220
221
|
end
|
221
222
|
|
222
|
-
def list_bindings_between_exchanges(vhost, destination_exchange, source_exchange)
|
223
|
-
decode_resource_collection(@connection.get("bindings/#{
|
223
|
+
def list_bindings_between_exchanges(vhost, destination_exchange, source_exchange, query = {})
|
224
|
+
decode_resource_collection(@connection.get("bindings/#{encode_uri_path_segment(vhost)}/e/#{encode_uri_path_segment(source_exchange)}/e/#{encode_uri_path_segment(destination_exchange)}", query))
|
224
225
|
end
|
225
226
|
|
226
227
|
def exchange_binding_info(vhost, destination_exchange, source_exchange, properties_key)
|
227
|
-
decode_resource(@connection.get("bindings/#{
|
228
|
+
decode_resource(@connection.get("bindings/#{encode_uri_path_segment(vhost)}/e/#{encode_uri_path_segment(source_exchange)}/e/#{encode_uri_path_segment(destination_exchange)}/#{encode_uri_path_segment(properties_key)}"))
|
228
229
|
end
|
229
230
|
|
230
231
|
|
231
232
|
def bind_exchange(vhost, destination_exchange, source_exchange, routing_key, arguments = [])
|
232
|
-
resp = @connection.post("bindings/#{
|
233
|
+
resp = @connection.post("bindings/#{encode_uri_path_segment(vhost)}/e/#{encode_uri_path_segment(source_exchange)}/e/#{encode_uri_path_segment(destination_exchange)}") do |req|
|
233
234
|
req.headers['Content-Type'] = 'application/json'
|
234
235
|
req.body = MultiJson.dump({:routing_key => routing_key, :arguments => arguments})
|
235
236
|
end
|
@@ -237,48 +238,48 @@ module RabbitMQ
|
|
237
238
|
end
|
238
239
|
|
239
240
|
def delete_exchange_binding(vhost, destination_exchange, source_exchange, properties_key)
|
240
|
-
resp = @connection.delete("bindings/#{
|
241
|
+
resp = @connection.delete("bindings/#{encode_uri_path_segment(vhost)}/e/#{encode_uri_path_segment(source_exchange)}/e/#{encode_uri_path_segment(destination_exchange)}/#{encode_uri_path_segment(properties_key)}")
|
241
242
|
resp.success?
|
242
243
|
end
|
243
244
|
|
244
245
|
|
245
|
-
def list_vhosts
|
246
|
-
decode_resource_collection(@connection.get("vhosts"))
|
246
|
+
def list_vhosts(query = {})
|
247
|
+
decode_resource_collection(@connection.get("vhosts", query))
|
247
248
|
end
|
248
249
|
|
249
250
|
def vhost_info(name)
|
250
|
-
decode_resource(@connection.get("vhosts/#{
|
251
|
+
decode_resource(@connection.get("vhosts/#{encode_uri_path_segment(name)}"))
|
251
252
|
end
|
252
253
|
|
253
254
|
def create_vhost(name)
|
254
|
-
response = @connection.put("vhosts/#{
|
255
|
+
response = @connection.put("vhosts/#{encode_uri_path_segment(name)}") do |req|
|
255
256
|
req.headers['Content-Type'] = "application/json"
|
256
257
|
end
|
257
258
|
decode_resource(response)
|
258
259
|
end
|
259
260
|
|
260
261
|
def delete_vhost(name)
|
261
|
-
decode_resource(@connection.delete("vhosts/#{
|
262
|
+
decode_resource(@connection.delete("vhosts/#{encode_uri_path_segment(name)}"))
|
262
263
|
end
|
263
264
|
|
264
265
|
|
265
266
|
|
266
|
-
def list_permissions(vhost = nil)
|
267
|
+
def list_permissions(vhost = nil, query = {})
|
267
268
|
path = if vhost
|
268
|
-
"vhosts/#{
|
269
|
+
"vhosts/#{encode_uri_path_segment(vhost)}/permissions"
|
269
270
|
else
|
270
271
|
"permissions"
|
271
272
|
end
|
272
273
|
|
273
|
-
decode_resource_collection(@connection.get(path))
|
274
|
+
decode_resource_collection(@connection.get(path, query))
|
274
275
|
end
|
275
276
|
|
276
277
|
def list_permissions_of(vhost, user)
|
277
|
-
decode_resource(@connection.get("permissions/#{
|
278
|
+
decode_resource(@connection.get("permissions/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(user)}"))
|
278
279
|
end
|
279
280
|
|
280
281
|
def update_permissions_of(vhost, user, attributes)
|
281
|
-
response = @connection.put("permissions/#{
|
282
|
+
response = @connection.put("permissions/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(user)}") do |req|
|
282
283
|
req.headers['Content-Type'] = "application/json"
|
283
284
|
req.body = MultiJson.dump(attributes)
|
284
285
|
end
|
@@ -286,23 +287,23 @@ module RabbitMQ
|
|
286
287
|
end
|
287
288
|
|
288
289
|
def clear_permissions_of(vhost, user)
|
289
|
-
decode_resource(@connection.delete("permissions/#{
|
290
|
+
decode_resource(@connection.delete("permissions/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(user)}"))
|
290
291
|
end
|
291
292
|
|
292
293
|
|
293
294
|
|
294
|
-
def list_users
|
295
|
-
decode_resource_collection(@connection.get("users"))
|
295
|
+
def list_users(query = {})
|
296
|
+
decode_resource_collection(@connection.get("users", query))
|
296
297
|
end
|
297
298
|
|
298
299
|
def user_info(name)
|
299
|
-
decode_resource(@connection.get("users/#{
|
300
|
+
decode_resource(@connection.get("users/#{encode_uri_path_segment(name)}"))
|
300
301
|
end
|
301
302
|
|
302
303
|
def update_user(name, attributes)
|
303
304
|
attributes[:tags] ||= ""
|
304
305
|
|
305
|
-
response = @connection.put("users/#{
|
306
|
+
response = @connection.put("users/#{encode_uri_path_segment(name)}") do |req|
|
306
307
|
req.headers['Content-Type'] = "application/json"
|
307
308
|
req.body = MultiJson.dump(attributes)
|
308
309
|
end
|
@@ -311,11 +312,11 @@ module RabbitMQ
|
|
311
312
|
alias create_user update_user
|
312
313
|
|
313
314
|
def delete_user(name)
|
314
|
-
decode_resource(@connection.delete("users/#{
|
315
|
+
decode_resource(@connection.delete("users/#{encode_uri_path_segment(name)}"))
|
315
316
|
end
|
316
317
|
|
317
|
-
def user_permissions(name)
|
318
|
-
decode_resource_collection(@connection.get("users/#{
|
318
|
+
def user_permissions(name, query = {})
|
319
|
+
decode_resource_collection(@connection.get("users/#{encode_uri_path_segment(name)}/permissions", query))
|
319
320
|
end
|
320
321
|
|
321
322
|
def whoami
|
@@ -324,27 +325,27 @@ module RabbitMQ
|
|
324
325
|
|
325
326
|
|
326
327
|
|
327
|
-
def list_policies(vhost = nil)
|
328
|
+
def list_policies(vhost = nil, query = {})
|
328
329
|
path = if vhost
|
329
|
-
"policies/#{
|
330
|
+
"policies/#{encode_uri_path_segment(vhost)}"
|
330
331
|
else
|
331
332
|
"policies"
|
332
333
|
end
|
333
334
|
|
334
|
-
decode_resource_collection(@connection.get(path))
|
335
|
+
decode_resource_collection(@connection.get(path, query))
|
335
336
|
end
|
336
337
|
|
337
|
-
def list_policies_of(vhost, name = nil)
|
338
|
+
def list_policies_of(vhost, name = nil, query = {})
|
338
339
|
path = if name
|
339
|
-
"policies/#{
|
340
|
+
"policies/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}"
|
340
341
|
else
|
341
|
-
"policies/#{
|
342
|
+
"policies/#{encode_uri_path_segment(vhost)}"
|
342
343
|
end
|
343
|
-
decode_resource_collection(@connection.get(path))
|
344
|
+
decode_resource_collection(@connection.get(path, query))
|
344
345
|
end
|
345
346
|
|
346
347
|
def update_policies_of(vhost, name, attributes)
|
347
|
-
response = @connection.put("policies/#{
|
348
|
+
response = @connection.put("policies/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}") do |req|
|
348
349
|
req.headers['Content-Type'] = "application/json"
|
349
350
|
req.body = MultiJson.dump(attributes)
|
350
351
|
end
|
@@ -352,32 +353,32 @@ module RabbitMQ
|
|
352
353
|
end
|
353
354
|
|
354
355
|
def clear_policies_of(vhost, name)
|
355
|
-
decode_resource(@connection.delete("policies/#{
|
356
|
+
decode_resource(@connection.delete("policies/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}"))
|
356
357
|
end
|
357
358
|
|
358
359
|
|
359
360
|
|
360
361
|
|
361
|
-
def list_parameters(component = nil)
|
362
|
+
def list_parameters(component = nil, query = {})
|
362
363
|
path = if component
|
363
|
-
"parameters/#{
|
364
|
+
"parameters/#{encode_uri_path_segment(component)}"
|
364
365
|
else
|
365
366
|
"parameters"
|
366
367
|
end
|
367
|
-
decode_resource_collection(@connection.get(path))
|
368
|
+
decode_resource_collection(@connection.get(path, query))
|
368
369
|
end
|
369
370
|
|
370
|
-
def list_parameters_of(component, vhost, name = nil)
|
371
|
+
def list_parameters_of(component, vhost, name = nil, query = {})
|
371
372
|
path = if name
|
372
|
-
"parameters/#{
|
373
|
+
"parameters/#{encode_uri_path_segment(component)}/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}"
|
373
374
|
else
|
374
|
-
"parameters/#{
|
375
|
+
"parameters/#{encode_uri_path_segment(component)}/#{encode_uri_path_segment(vhost)}"
|
375
376
|
end
|
376
|
-
decode_resource_collection(@connection.get(path))
|
377
|
+
decode_resource_collection(@connection.get(path, query))
|
377
378
|
end
|
378
379
|
|
379
380
|
def update_parameters_of(component, vhost, name, attributes)
|
380
|
-
response = @connection.put("parameters/#{
|
381
|
+
response = @connection.put("parameters/#{encode_uri_path_segment(component)}/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}") do |req|
|
381
382
|
req.headers['Content-Type'] = "application/json"
|
382
383
|
req.body = MultiJson.dump(attributes)
|
383
384
|
end
|
@@ -385,13 +386,13 @@ module RabbitMQ
|
|
385
386
|
end
|
386
387
|
|
387
388
|
def clear_parameters_of(component, vhost, name)
|
388
|
-
decode_resource(@connection.delete("parameters/#{
|
389
|
+
decode_resource(@connection.delete("parameters/#{encode_uri_path_segment(component)}/#{encode_uri_path_segment(vhost)}/#{encode_uri_path_segment(name)}"))
|
389
390
|
end
|
390
391
|
|
391
392
|
|
392
393
|
|
393
394
|
def aliveness_test(vhost)
|
394
|
-
r = @connection.get("aliveness-test/#{
|
395
|
+
r = @connection.get("aliveness-test/#{encode_uri_path_segment(vhost)}")
|
395
396
|
r.body["status"] == "ok"
|
396
397
|
end
|
397
398
|
|
@@ -416,17 +417,32 @@ module RabbitMQ
|
|
416
417
|
end
|
417
418
|
end
|
418
419
|
|
419
|
-
def
|
420
|
-
#
|
421
|
-
|
420
|
+
def encode_uri_path_segment(segment)
|
421
|
+
# Correctly escapes spaces, see ruby-amqp/rabbitmq_http_api_client#28.
|
422
|
+
#
|
423
|
+
# Note that slashes also must be escaped since this is a single URI path segment,
|
424
|
+
# not an entire path.
|
425
|
+
Addressable::URI.encode_component(segment, Addressable::URI::CharacterClasses::UNRESERVED)
|
422
426
|
end
|
423
427
|
|
424
428
|
def decode_resource(response)
|
425
|
-
|
429
|
+
case response.headers["content-length"]
|
430
|
+
when nil then Hashie::Mash.new
|
431
|
+
when 0 then Hashie::Mash.new
|
432
|
+
when "0" then Hashie::Mash.new
|
433
|
+
else
|
434
|
+
if response.body.empty?
|
435
|
+
Hashie::Mash.new
|
436
|
+
else
|
437
|
+
Hashie::Mash.new(response.body)
|
438
|
+
end
|
439
|
+
end
|
426
440
|
end
|
427
441
|
|
428
442
|
def decode_resource_collection(response)
|
429
|
-
response.body.
|
443
|
+
collection = response.body.is_a?(Array) ? response.body : response.body.fetch('items')
|
444
|
+
|
445
|
+
collection.map { |i| Hashie::Mash.new(i) }
|
430
446
|
end
|
431
447
|
end # Client
|
432
448
|
end # HTTP
|
metadata
CHANGED
@@ -1,85 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rabbitmq_http_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Klishin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: addressable
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.7'
|
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: '
|
26
|
+
version: '2.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: hashie
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1
|
33
|
+
version: '4.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1
|
40
|
+
version: '4.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: multi_json
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '1.14'
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 1.14.1
|
48
51
|
type: :runtime
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
55
|
- - "~>"
|
53
56
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
57
|
+
version: '1.14'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 1.14.1
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
62
|
+
name: faraday
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
65
|
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
67
|
+
version: '1.0'
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.0.1
|
62
71
|
type: :runtime
|
63
72
|
prerelease: false
|
64
73
|
version_requirements: !ruby/object:Gem::Requirement
|
65
74
|
requirements:
|
66
75
|
- - "~>"
|
67
76
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
77
|
+
version: '1.0'
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 1.0.1
|
69
81
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
82
|
+
name: faraday_middleware
|
71
83
|
requirement: !ruby/object:Gem::Requirement
|
72
84
|
requirements:
|
73
85
|
- - "~>"
|
74
86
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.0
|
87
|
+
version: '1.0'
|
76
88
|
type: :runtime
|
77
89
|
prerelease: false
|
78
90
|
version_requirements: !ruby/object:Gem::Requirement
|
79
91
|
requirements:
|
80
92
|
- - "~>"
|
81
93
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.0
|
94
|
+
version: '1.0'
|
83
95
|
description: RabbitMQ HTTP API client for Ruby
|
84
96
|
email:
|
85
97
|
- michael@clojurewerkz.org
|
@@ -112,8 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
124
|
- !ruby/object:Gem::Version
|
113
125
|
version: '0'
|
114
126
|
requirements: []
|
115
|
-
|
116
|
-
rubygems_version: 2.6.11
|
127
|
+
rubygems_version: 3.1.2
|
117
128
|
signing_key:
|
118
129
|
specification_version: 4
|
119
130
|
summary: RabbitMQ HTTP API client for Ruby
|