rabbitmq_http_api_client 0.2.0.pre1

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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/ChangeLog.md ADDED
@@ -0,0 +1,13 @@
1
+ ## Changes Between 0.1.0 and 0.2.0
2
+
3
+ No changes yet.
4
+
5
+
6
+ ## Original Release: 0.1.0
7
+
8
+ ### Support for many HTTP API operations
9
+
10
+ * Status overview
11
+ * Cluster nodes information
12
+ * Operations on exchanges, queues, bindings
13
+ * Operations on connections
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development, :test do
4
+ gem "rspec"
5
+ gem "json"
6
+ gem "bunny", ">= 0.9.0.pre3"
7
+ end
8
+
9
+ # Specify your gem's dependencies in superintendent.gemspec
10
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Michael Klishin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # RabbitMQ HTTP API Client for Ruby
2
+
3
+ This gem is a RabbitMQ HTTP API Client for Ruby. It supports
4
+
5
+ * Getting cluster overview information
6
+ * Getting cluster nodes status (# file descriptors used, RAM consumption and so on)
7
+ * Getting information about exchanges, queues, bindings
8
+ * Closing client connections
9
+ * Getting information about vhosts, users, permissions
10
+
11
+ and will support more HTTP API features in the future
12
+
13
+ * Publishing messages via HTTP
14
+ * Operations on components/extensions
15
+ * Operations on federation policies
16
+
17
+ ## Supported Ruby Versions
18
+
19
+ * MRI 1.9.3
20
+ * JRuby 1.7+
21
+ * Rubinius 2.0+
22
+ * MRI 1.9.2
23
+ * MRI 1.8.7
24
+
25
+ ## Supported RabbitMQ Versions
26
+
27
+ * RabbitMQ 3.x
28
+ * RabbitMQ 2.x
29
+
30
+ All versions require [RabbitMQ Management UI plugin](http://www.rabbitmq.com/management.html) to be installed and enabled.
31
+
32
+ ## Installation
33
+
34
+ Add this line to your application's Gemfile:
35
+
36
+ gem 'veterinarian'
37
+
38
+ And then execute:
39
+
40
+ $ bundle
41
+
42
+ Or install it yourself as:
43
+
44
+ $ gem install veterinarian
45
+
46
+ ## Usage
47
+
48
+ TODO: Write usage instructions here
49
+
50
+ ## Contributing
51
+
52
+ 1. Fork it
53
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
54
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
55
+ 4. Push to the branch (`git push origin my-new-feature`)
56
+ 5. Create new Pull Request
57
+
58
+
59
+ ## License & Copyright
60
+
61
+ Double-licensed under the MIT and Mozilla Public License (same as RabbitMQ).
62
+
63
+ (c) Michael S. Klishin, 2012-2013.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,189 @@
1
+ require "hashie"
2
+ require "faraday"
3
+ require "faraday_middleware"
4
+ require "multi_json"
5
+
6
+ # for URI encoding
7
+ require "cgi"
8
+
9
+ module RabbitMQ
10
+ module HTTP
11
+ class Client
12
+
13
+ #
14
+ # API
15
+ #
16
+
17
+ def self.connect(endpoint, options = {})
18
+ new(endpoint, options)
19
+ end
20
+
21
+ def initialize(endpoint, options = {})
22
+ @endpoint = endpoint
23
+ @options = options
24
+
25
+ initialize_connection(endpoint, options)
26
+ end
27
+
28
+ def overview
29
+ decode_resource(@connection.get("/api/overview"))
30
+ end
31
+
32
+ def list_nodes
33
+ decode_resource_collection(@connection.get("/api/nodes"))
34
+ end
35
+
36
+ def node_info(name)
37
+ decode_resource(@connection.get("/api/nodes/#{uri_encode(name)}"))
38
+ end
39
+
40
+ def list_extensions
41
+ decode_resource_collection(@connection.get("/api/extensions"))
42
+ end
43
+
44
+ def list_definitions
45
+ decode_resource_collection(@connection.get("/api/definitions"))
46
+ end
47
+
48
+ def upload_definitions(defs)
49
+ raise NotImplementedError.new
50
+ end
51
+
52
+ def list_connections
53
+ decode_resource_collection(@connection.get("/api/connections"))
54
+ end
55
+
56
+ def connection_info(name)
57
+ decode_resource(@connection.get("/api/connections/#{uri_encode(name)}"))
58
+ end
59
+
60
+ def close_connection(name)
61
+ decode_resource(@connection.delete("/api/connections/#{uri_encode(name)}"))
62
+ end
63
+
64
+ def list_channels
65
+ decode_resource_collection(@connection.get("/api/channels"))
66
+ end
67
+
68
+ def channel_info(name)
69
+ decode_resource(@connection.get("/api/channels/#{uri_encode(name)}"))
70
+ end
71
+
72
+ def list_exchanges(vhost = nil)
73
+ path = if vhost.nil?
74
+ "/api/exchanges"
75
+ else
76
+ "/api/exchanges/#{uri_encode(vhost)}"
77
+ end
78
+
79
+ decode_resource_collection(@connection.get(path))
80
+ end
81
+
82
+ def exchange_info(vhost, name)
83
+ decode_resource(@connection.get("/api/exchanges/#{uri_encode(vhost)}/#{uri_encode(name)}"))
84
+ end
85
+
86
+ def list_bindings_by_source(vhost, exchange)
87
+ decode_resource_collection(@connection.get("/api/exchanges/#{uri_encode(vhost)}/#{uri_encode(exchange)}/bindings/source"))
88
+ end
89
+
90
+ def list_bindings_by_destination(vhost, exchange)
91
+ decode_resource_collection(@connection.get("/api/exchanges/#{uri_encode(vhost)}/#{uri_encode(exchange)}/bindings/destination"))
92
+ end
93
+
94
+ def list_queues(vhost = nil)
95
+ path = if vhost.nil?
96
+ "/api/queues"
97
+ else
98
+ "/api/queues/#{uri_encode(vhost)}"
99
+ end
100
+
101
+ decode_resource_collection(@connection.get(path))
102
+ end
103
+
104
+ def queue_info(vhost, name)
105
+ decode_resource(@connection.get("/api/queues/#{uri_encode(vhost)}/#{uri_encode(name)}"))
106
+ end
107
+
108
+ def declare_queue(vhost, name, attributes)
109
+ raise NotImplementedError.new
110
+ end
111
+
112
+ def delete_queue(vhost, name)
113
+ raise NotImplementedError.new
114
+ end
115
+
116
+ def purge_queue(vhost, name)
117
+ raise NotImplementedError.new
118
+ end
119
+
120
+
121
+ def list_bindings(vhost = nil)
122
+ path = if vhost.nil?
123
+ "/api/bindings"
124
+ else
125
+ "/api/bindings/#{uri_encode(vhost)}"
126
+ end
127
+
128
+ decode_resource_collection(@connection.get(path))
129
+ end
130
+
131
+ def list_vhosts
132
+ decode_resource_collection(@connection.get("/api/vhosts"))
133
+ end
134
+
135
+ def vhost_info(name)
136
+ decode_resource(@connection.get("/api/vhosts/#{uri_encode(name)}"))
137
+ end
138
+
139
+
140
+
141
+ def list_users
142
+ decode_resource_collection(@connection.get("/api/users"))
143
+ end
144
+
145
+
146
+
147
+ def list_policies
148
+ decode_resource_collection(@connection.get("/api/policies"))
149
+ end
150
+
151
+
152
+ def list_parameters
153
+ decode_resource_collection(@connection.get("/api/parameters"))
154
+ end
155
+
156
+
157
+
158
+ def aliveness_test(vhost)
159
+ r = @connection.get("/api/aliveness-test/#{uri_encode(vhost)}")
160
+ r.body["status"] == "ok"
161
+ end
162
+
163
+
164
+ protected
165
+
166
+ def initialize_connection(endpoint, options = {})
167
+ @connection = Faraday.new(:url => endpoint) do |conn|
168
+ conn.basic_auth options.fetch(:username, "guest"), options.fetch(:password, "guest")
169
+ conn.use FaradayMiddleware::FollowRedirects, :limit => 3
170
+ conn.response :json, :content_type => /\bjson$/
171
+
172
+ conn.adapter options.fetch(:adapter, Faraday.default_adapter)
173
+ end
174
+ end
175
+
176
+ def uri_encode(s)
177
+ CGI.escape(s)
178
+ end
179
+
180
+ def decode_resource(response)
181
+ Hashie::Mash.new(response.body)
182
+ end
183
+
184
+ def decode_resource_collection(response)
185
+ response.body.map { |i| Hashie::Mash.new(i) }
186
+ end
187
+ end # Client
188
+ end # HTTP
189
+ end # RabbitMQ
@@ -0,0 +1,7 @@
1
+ module RabbitMQ
2
+ module HTTP
3
+ class Client
4
+ VERSION = "0.2.0.pre1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rabbitmq/http/client/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "rabbitmq_http_api_client"
8
+ gem.version = RabbitMQ::HTTP::Client::VERSION
9
+ gem.authors = ["Michael Klishin"]
10
+ gem.email = ["michael@defprotocol.org"]
11
+ gem.description = %q{RabbitMQ HTTP API client for Ruby}
12
+ gem.summary = %q{RabbitMQ HTTP API client for Ruby}
13
+ gem.homepage = "http://github.com/ruby-amqp/rabbitmq_http_api_client"
14
+ gem.licenses = ["MIT", "Mozilla Public License"]
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.add_dependency "hashie", "~> 1.2.0"
22
+ gem.add_dependency "multi_json", "~> 1.4.0"
23
+ gem.add_dependency "faraday", "~> 0.8.4"
24
+ gem.add_dependency "faraday_middleware", "~> 0.9.0"
25
+ gem.add_dependency "effin_utf8", "~> 1.0.0"
26
+ end
@@ -0,0 +1,593 @@
1
+ require "spec_helper"
2
+
3
+ describe RabbitMQ::HTTP::Client do
4
+ let(:endpoint) { "http://127.0.0.1:55672" }
5
+
6
+ subject do
7
+ described_class.connect(endpoint, :username => "guest", :password => "guest")
8
+ end
9
+
10
+
11
+ #
12
+ # Overview
13
+ #
14
+
15
+ describe "GET /api/overview" do
16
+ it "returns an overview" do
17
+ r = subject.overview
18
+
19
+ r.exchange_types.map { |h| h.name }.
20
+ sort.should == ["direct", "fanout", "headers", "topic"]
21
+
22
+ r.rabbitmq_version.should_not be_nil
23
+ r.erlang_version.should_not be_nil
24
+ end
25
+ end
26
+
27
+ #
28
+ # Nodes
29
+ #
30
+
31
+ describe "GET /api/nodes" do
32
+ it "lists cluster nodes with detailed status information for each one of them" do
33
+ nodes = subject.list_nodes
34
+ n = nodes.first
35
+
36
+ rabbit = n.applications.detect { |app| app.name == "rabbit" }
37
+ rabbit.description.should == "RabbitMQ"
38
+
39
+ n.name.should == "rabbit@localhost"
40
+ n.partitions.should == []
41
+ n.fd_used.should_not be_nil
42
+ n.fd_total.should_not be_nil
43
+ n.sockets_used.should_not be_nil
44
+ n.sockets_total.should_not be_nil
45
+ n.mem_used.should_not be_nil
46
+ n.mem_limit.should_not be_nil
47
+ n.disk_free_limit.should_not be_nil
48
+ n.disk_free.should_not be_nil
49
+ n.proc_used.should_not be_nil
50
+ n.proc_total.should_not be_nil
51
+ n.run_queue.should_not be_nil
52
+ end
53
+ end
54
+
55
+ describe "GET /api/node/:name" do
56
+ it "returns status information for a single cluster node" do
57
+ n = subject.node_info("rabbit@localhost")
58
+
59
+ rabbit = n.applications.detect { |app| app.name == "rabbit" }
60
+ rabbit.description.should == "RabbitMQ"
61
+
62
+ n.name.should == "rabbit@localhost"
63
+ n.partitions.should == []
64
+ n.fd_used.should_not be_nil
65
+ n.fd_total.should_not be_nil
66
+ n.sockets_used.should_not be_nil
67
+ n.sockets_total.should_not be_nil
68
+ n.mem_used.should_not be_nil
69
+ n.mem_limit.should_not be_nil
70
+ n.disk_free_limit.should_not be_nil
71
+ n.disk_free.should_not be_nil
72
+ n.proc_used.should_not be_nil
73
+ n.proc_total.should_not be_nil
74
+ n.run_queue.should_not be_nil
75
+ n.running.should be_true
76
+ end
77
+ end
78
+
79
+ #
80
+ # Extensions
81
+ #
82
+
83
+ describe "GET /api/extensions" do
84
+ it "returns a list of enabled management plugin extensions" do
85
+ xs = subject.list_extensions
86
+ f = xs.first
87
+
88
+ f.javascript.should == "dispatcher.js"
89
+ end
90
+ end
91
+
92
+ #
93
+ # Definitions
94
+ #
95
+
96
+ describe "GET /api/definitions" do
97
+
98
+ end
99
+
100
+ describe "POST /api/definitions" do
101
+
102
+ end
103
+
104
+ #
105
+ # Connections
106
+ #
107
+
108
+ describe "GET /api/connections" do
109
+ before :all do
110
+ @connection = Bunny.new
111
+ @connection.start
112
+ end
113
+ after :all do
114
+ @connection.close
115
+ end
116
+
117
+ it "returns a list of all active connections" do
118
+ xs = subject.list_connections
119
+ f = xs.first
120
+
121
+ f.name.should =~ /127.0.0.1/
122
+ f.client_properties.product.should == "Bunny"
123
+ end
124
+ end
125
+
126
+ describe "GET /api/connections/:name" do
127
+ before :all do
128
+ @connection = Bunny.new
129
+ @connection.start
130
+ end
131
+ after :all do
132
+ @connection.close
133
+ end
134
+
135
+ it "returns information about the connection" do
136
+ xs = subject.list_connections
137
+ c = subject.connection_info(xs.first.name)
138
+
139
+ c.name.should =~ /127.0.0.1/
140
+ c.client_properties.product.should == "Bunny"
141
+ end
142
+ end
143
+
144
+ describe "DELETE /api/connections/:name" do
145
+ before :all do
146
+ @connection = Bunny.new
147
+ @connection.start
148
+ end
149
+ after :all do
150
+ @connection.close if @connection.open?
151
+ end
152
+
153
+
154
+ it "closes the connection" do
155
+ pending "Needs investigation, DELETE does not seem to close the connection"
156
+ xs = subject.list_connections
157
+ c = subject.close_connection(xs.first.name)
158
+
159
+ c.name.should =~ /127.0.0.1/
160
+ c.client_properties.product.should == "Bunny"
161
+
162
+ @connection.should_not be_open
163
+ end
164
+ end
165
+
166
+
167
+ #
168
+ # Channels
169
+ #
170
+
171
+ describe "GET /api/channels" do
172
+ before :all do
173
+ @connection = Bunny.new
174
+ @connection.start
175
+ @channel = @connection.create_channel
176
+ end
177
+ after :all do
178
+ @connection.close
179
+ end
180
+
181
+ it "returns a list of all active channels" do
182
+ xs = subject.list_channels
183
+ f = xs.first
184
+
185
+ f.number.should be >= 1
186
+ f.prefetch_count.should be >= 0
187
+ end
188
+ end
189
+
190
+ describe "GET /api/channels/:name" do
191
+ before :all do
192
+ @connection = Bunny.new
193
+ @connection.start
194
+ @channel = @connection.create_channel
195
+ end
196
+ after :all do
197
+ @connection.close
198
+ end
199
+
200
+ it "returns information about the channel" do
201
+ xs = subject.list_channels
202
+ c = subject.channel_info(xs.first.name)
203
+
204
+ c.number.should be >= 1
205
+ c.prefetch_count.should be >= 0
206
+ end
207
+ end
208
+
209
+ #
210
+ # Exchanges
211
+ #
212
+
213
+ describe "GET /api/exchanges" do
214
+ it "returns a list of all exchanges in the cluster" do
215
+ xs = subject.list_exchanges
216
+ f = xs.first
217
+
218
+ f.type.should_not be_nil
219
+ f.name.should_not be_nil
220
+ f.vhost.should_not be_nil
221
+ f.durable.should_not be_nil
222
+ f.auto_delete.should_not be_nil
223
+ end
224
+ end
225
+
226
+ describe "GET /api/exchanges/:vhost" do
227
+ it "returns a list of all exchanges in a vhost" do
228
+ xs = subject.list_exchanges("/")
229
+ f = xs.first
230
+
231
+ f.vhost.should == "/"
232
+ end
233
+ end
234
+
235
+ describe "GET /api/exchanges/:vhost/:name" do
236
+ it "returns information about the exchange" do
237
+ e = subject.exchange_info("/", "amq.fanout")
238
+
239
+ e.type.should == "fanout"
240
+ e.name.should == "amq.fanout"
241
+ e.durable.should be_true
242
+ e.vhost.should == "/"
243
+ e.internal.should be_false
244
+ e.auto_delete.should be_false
245
+ end
246
+ end
247
+
248
+ describe "GET /api/exchanges/:vhost/:name/bindings/source" do
249
+ before :all do
250
+ @connection = Bunny.new
251
+ @connection.start
252
+ @channel = @connection.create_channel
253
+ end
254
+ after :all do
255
+ @connection.close
256
+ end
257
+
258
+ it "returns a list of all bindings in which the given exchange is the source" do
259
+ e = @channel.fanout("http.api.tests.fanout", :durable => true)
260
+ q = @channel.queue("http.api.tests.queue1", :durable => true)
261
+ q.bind(e)
262
+
263
+ xs = subject.list_bindings_by_source("/", "http.api.tests.fanout")
264
+ f = xs.first
265
+
266
+ f.destination.should == q.name
267
+ f.destination_type.should == "queue"
268
+ f.routing_key.should == ""
269
+ f.source.should == e.name
270
+ f.vhost.should == "/"
271
+
272
+ e.delete
273
+ q.delete
274
+ end
275
+ end
276
+
277
+
278
+ describe "GET /api/exchanges/:vhost/:name/bindings/destination" do
279
+ before :all do
280
+ @connection = Bunny.new
281
+ @connection.start
282
+ @channel = @connection.create_channel
283
+ end
284
+ after :all do
285
+ @connection.close
286
+ end
287
+
288
+ it "returns a list of all bindings in which the given exchange is the source" do
289
+ e1 = @channel.fanout("http.api.tests.fanout1", :durable => true)
290
+ e2 = @channel.fanout("http.api.tests.fanout2", :durable => true)
291
+ e1.bind(e2)
292
+
293
+ xs = subject.list_bindings_by_destination("/", "http.api.tests.fanout1")
294
+ f = xs.first
295
+
296
+ f.destination.should == e1.name
297
+ f.destination_type.should == "exchange"
298
+ f.routing_key.should == ""
299
+ f.source.should == e2.name
300
+ f.vhost.should == "/"
301
+
302
+ e1.delete
303
+ e2.delete
304
+ end
305
+ end
306
+
307
+
308
+
309
+ describe "POST /api/exchanges/:vhost/:name/publish" do
310
+ it "publishes a messages to the exchange"
311
+ end
312
+
313
+ describe "GET /api/queues" do
314
+ before :all do
315
+ @connection = Bunny.new
316
+ @connection.start
317
+ @channel = @connection.create_channel
318
+ end
319
+ after :all do
320
+ @connection.close
321
+ end
322
+
323
+ it "returns a list of all queues" do
324
+ q = @channel.queue("", :exclusive => true)
325
+
326
+ xs = subject.list_queues
327
+ xs.detect { |x| x.name == q.name }.should_not be_empty
328
+ end
329
+ end
330
+
331
+ describe "GET /api/queues/:vhost" do
332
+ before :all do
333
+ @connection = Bunny.new
334
+ @connection.start
335
+ @channel = @connection.create_channel
336
+ end
337
+ after :all do
338
+ @connection.close
339
+ end
340
+
341
+ it "returns a list of all queues" do
342
+ q = @channel.queue("", :exclusive => true)
343
+
344
+ xs = subject.list_queues("/")
345
+ xs.detect { |x| x.name == q.name }.should_not be_empty
346
+ end
347
+ end
348
+
349
+ describe "GET /api/queues/:vhost/:name" do
350
+ before :all do
351
+ @connection = Bunny.new
352
+ @connection.start
353
+ @channel = @connection.create_channel
354
+ end
355
+ after :all do
356
+ @connection.close
357
+ end
358
+
359
+ it "returns information about a queue" do
360
+ q = @channel.queue("", :exclusive => true, :durable => false)
361
+ i = subject.queue_info("/", q.name)
362
+
363
+ i.durable.should be_false
364
+ i.durable.should == q.durable?
365
+
366
+ i.name.should == q.name
367
+ i.auto_delete.should == q.auto_delete?
368
+ i.active_consumers.should == 0
369
+ i.backing_queue_status.avg_ack_egress_rate.should == 0.0
370
+ end
371
+ end
372
+
373
+ describe "PUT /api/queues/:vhost/:name" do
374
+ before :all do
375
+ @connection = Bunny.new
376
+ @connection.start
377
+ @channel = @connection.create_channel
378
+ end
379
+ after :all do
380
+ @connection.close
381
+ end
382
+
383
+ it "declares a queue"
384
+ end
385
+
386
+ describe "DELETE /api/queues/:vhost/:name" do
387
+ it "deletes a queue"
388
+ end
389
+
390
+ describe "GET /api/queues/:vhost/:name/bindings" do
391
+ it "returns a list of bindings for a queue"
392
+ end
393
+
394
+ describe "DELETE /api/queues/:vhost/:name/contents" do
395
+ it "purges a queue"
396
+ end
397
+
398
+ describe "GET /api/queues/:vhost/:name/get" do
399
+ it "fetches a message from a queue, a la basic.get"
400
+ end
401
+
402
+ describe "GET /api/bindings" do
403
+ it "returns a list of all bindings" do
404
+ xs = subject.list_bindings
405
+ b = xs.first
406
+
407
+ b.destination.should_not be_nil
408
+ b.destination_type.should_not be_nil
409
+ b.source.should_not be_nil
410
+ b.routing_key.should_not be_nil
411
+ b.vhost.should_not be_nil
412
+ end
413
+ end
414
+
415
+ describe "GET /api/bindings/:vhost" do
416
+ it "returns a list of all bindings in a vhost" do
417
+ xs = subject.list_bindings("/")
418
+ b = xs.first
419
+
420
+ b.destination.should_not be_nil
421
+ b.destination_type.should_not be_nil
422
+ b.source.should_not be_nil
423
+ b.routing_key.should_not be_nil
424
+ b.vhost.should_not be_nil
425
+ end
426
+ end
427
+
428
+ describe "GET /api/bindings/:vhost/e/:exchange/q/:queue" do
429
+ it "returns a list of all bindings between an exchange and a queue"
430
+ end
431
+
432
+ describe "POST /api/bindings/:vhost/e/:exchange/q/:queue" do
433
+ it "creates a binding between an exchange and a queue"
434
+ end
435
+
436
+ describe "GET /api/bindings/:vhost/e/:exchange/q/:queue/props" do
437
+ it "returns an individual binding between an exchange and a queue"
438
+ end
439
+
440
+ describe "DELETE /api/bindings/:vhost/e/:exchange/q/:queue/props" do
441
+ it "deletes an individual binding between an exchange and a queue"
442
+ end
443
+
444
+ describe "GET /api/vhosts" do
445
+ it "returns a list of vhosts" do
446
+ xs = subject.list_vhosts
447
+ v = xs.first
448
+
449
+ v.name.should_not be_nil
450
+ v.tracing.should be_false
451
+ end
452
+ end
453
+
454
+ describe "GET /api/vhosts/:name" do
455
+ it "returns infomation about a vhost" do
456
+ v = subject.vhost_info("/")
457
+
458
+ v.name.should_not be_nil
459
+ v.tracing.should be_false
460
+ end
461
+ end
462
+
463
+ describe "POST /api/vhosts/:name" do
464
+ it "creates a vhost"
465
+ end
466
+
467
+ describe "PUT /api/vhosts/:name" do
468
+ it "updates a vhost"
469
+ end
470
+
471
+ describe "GET /api/vhosts/:name/permissions" do
472
+ it "returns a list of permissions in a vhost"
473
+ end
474
+
475
+ describe "GET /api/users" do
476
+ it "returns a list of all users" do
477
+ xs = subject.list_users
478
+ u = xs.first
479
+
480
+ u.name.should_not be_nil
481
+ u.password_hash.should_not be_nil
482
+ u.tags.should_not be_nil
483
+ end
484
+ end
485
+
486
+ describe "GET /api/users/:name" do
487
+ it "returns information about a user"
488
+ end
489
+
490
+ describe "PUT /api/users/:name" do
491
+ it "updates information about a user"
492
+ end
493
+
494
+ describe "POST /api/users/:name" do
495
+ it "creates a user"
496
+ end
497
+
498
+ describe "GET /api/users/:name/permissions" do
499
+ it "returns a list of permissions for a user"
500
+ end
501
+
502
+ describe "GET /api/whoami" do
503
+ it "returns information about the current user"
504
+ end
505
+
506
+ describe "GET /api/permissions" do
507
+ it "lists all permissions"
508
+ end
509
+
510
+ describe "GET /api/permissions/:vhost/:user" do
511
+ it "returns a list of permissions of a user in a vhost"
512
+ end
513
+
514
+ describe "PUT /api/permissions/:vhost/:user" do
515
+ it "updates permissions of a user in a vhost"
516
+ end
517
+
518
+ describe "DELETE /api/permissions/:vhost/:user" do
519
+ it "clears permissions of a user in a vhost"
520
+ end
521
+
522
+ #
523
+ # Parameters
524
+ #
525
+
526
+ describe "GET /api/parameters" do
527
+ it "returns a list of all parameters" do
528
+ xs = subject.list_parameters
529
+ xs.should be_kind_of(Array)
530
+ end
531
+ end
532
+
533
+ describe "GET /api/parameters/:component" do
534
+ it "returns a list of all parameters for a component"
535
+ end
536
+
537
+ describe "GET /api/parameters/:component/:vhost" do
538
+ it "returns a list of all parameters for a component in a vhost"
539
+ end
540
+
541
+ describe "GET /api/parameters/:component/:vhost/:name" do
542
+ it "returns information about a specific parameter"
543
+ end
544
+
545
+ describe "PUT /api/parameters/:component/:vhost/:name" do
546
+ it "updates information about a specific parameter"
547
+ end
548
+
549
+ describe "DELETE /api/parameters/:component/:vhost/:name" do
550
+ it "clears information about a specific parameter"
551
+ end
552
+
553
+
554
+ #
555
+ # Policies
556
+ #
557
+
558
+ describe "GET /api/policies" do
559
+ it "returns a list of all policies" do
560
+ xs = subject.list_policies
561
+ xs.should be_kind_of(Array)
562
+ end
563
+ end
564
+
565
+ describe "GET /api/policies/:vhost" do
566
+ it "returns a list of all policies in a vhost"
567
+ end
568
+
569
+ describe "GET /api/policies/:vhost/:name" do
570
+ it "returns information about a policy in a vhost"
571
+ end
572
+
573
+ describe "PUT /api/policies/:vhost/:name" do
574
+ it "updates information about a policy in a vhost"
575
+ end
576
+
577
+ describe "DELETE /api/policies/:vhost/:name" do
578
+ it "clears information about a policy in a vhost"
579
+ end
580
+
581
+
582
+ #
583
+ # Aliveness Test
584
+ #
585
+
586
+ describe "GET /api/aliveness-test/:vhost" do
587
+ it "performs aliveness check" do
588
+ r = subject.aliveness_test("/")
589
+
590
+ r.should be_true
591
+ end
592
+ end
593
+ end
@@ -0,0 +1,12 @@
1
+ # -*- encoding: utf-8; mode: ruby -*-
2
+
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
4
+
5
+ require 'bundler'
6
+ Bundler.setup(:default, :test)
7
+
8
+
9
+ require "effin_utf8"
10
+ require "rspec"
11
+ require "rabbitmq/http/client"
12
+ require "bunny"
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rabbitmq_http_api_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0.pre1
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Michael Klishin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: hashie
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: 1.2.0
21
+ none: false
22
+ requirement: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 1.2.0
27
+ none: false
28
+ prerelease: false
29
+ type: :runtime
30
+ - !ruby/object:Gem::Dependency
31
+ name: multi_json
32
+ version_requirements: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ~>
35
+ - !ruby/object:Gem::Version
36
+ version: 1.4.0
37
+ none: false
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ version: 1.4.0
43
+ none: false
44
+ prerelease: false
45
+ type: :runtime
46
+ - !ruby/object:Gem::Dependency
47
+ name: faraday
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ~>
51
+ - !ruby/object:Gem::Version
52
+ version: 0.8.4
53
+ none: false
54
+ requirement: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ version: 0.8.4
59
+ none: false
60
+ prerelease: false
61
+ type: :runtime
62
+ - !ruby/object:Gem::Dependency
63
+ name: faraday_middleware
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 0.9.0
69
+ none: false
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ version: 0.9.0
75
+ none: false
76
+ prerelease: false
77
+ type: :runtime
78
+ - !ruby/object:Gem::Dependency
79
+ name: effin_utf8
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ~>
83
+ - !ruby/object:Gem::Version
84
+ version: 1.0.0
85
+ none: false
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: 1.0.0
91
+ none: false
92
+ prerelease: false
93
+ type: :runtime
94
+ description: RabbitMQ HTTP API client for Ruby
95
+ email:
96
+ - michael@defprotocol.org
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - .gitignore
102
+ - ChangeLog.md
103
+ - Gemfile
104
+ - LICENSE.txt
105
+ - README.md
106
+ - Rakefile
107
+ - lib/rabbitmq/http/client.rb
108
+ - lib/rabbitmq/http/client/version.rb
109
+ - rabbitmq_http_client.gemspec
110
+ - spec/integration/client_spec.rb
111
+ - spec/spec_helper.rb
112
+ homepage: http://github.com/ruby-amqp/rabbitmq_http_api_client
113
+ licenses:
114
+ - MIT
115
+ - Mozilla Public License
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: !binary |-
125
+ MA==
126
+ none: false
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - !binary |-
130
+ Pg==
131
+ - !ruby/object:Gem::Version
132
+ version: 1.3.1
133
+ none: false
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 1.8.24
137
+ signing_key:
138
+ specification_version: 3
139
+ summary: RabbitMQ HTTP API client for Ruby
140
+ test_files:
141
+ - spec/integration/client_spec.rb
142
+ - spec/spec_helper.rb