veterinarian 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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/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
@@ -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.
@@ -0,0 +1,58 @@
1
+ # Veterinarian, a RabbitMQ HTTP API Client for Ruby
2
+
3
+ Veterinarian 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
+ * Publishing messages via HTTP
9
+ * Closing client connections
10
+ * Getting information about vhosts, users, permissions
11
+
12
+ ## Supported Ruby Versions
13
+
14
+ * MRI 1.9.3
15
+ * JRuby 1.7+
16
+ * Rubinius 2.0+
17
+ * MRI 1.9.2
18
+ * MRI 1.8.7
19
+
20
+ ## Supported RabbitMQ Versions
21
+
22
+ * RabbitMQ 3.x
23
+ * RabbitMQ 2.x
24
+
25
+ All versions require [RabbitMQ Management UI plugin](http://www.rabbitmq.com/management.html) to be installed and enabled.
26
+
27
+ ## Installation
28
+
29
+ Add this line to your application's Gemfile:
30
+
31
+ gem 'veterinarian'
32
+
33
+ And then execute:
34
+
35
+ $ bundle
36
+
37
+ Or install it yourself as:
38
+
39
+ $ gem install veterinarian
40
+
41
+ ## Usage
42
+
43
+ TODO: Write usage instructions here
44
+
45
+ ## Contributing
46
+
47
+ 1. Fork it
48
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
49
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
50
+ 4. Push to the branch (`git push origin my-new-feature`)
51
+ 5. Create new Pull Request
52
+
53
+
54
+ ## License & Copyright
55
+
56
+ Double-licensed under the MIT and Mozilla Public License (same as RabbitMQ).
57
+
58
+ (c) Michael S. Klishin, 2012-2013.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ require "veterinarian/version"
2
+ require "veterinarian/client"
@@ -0,0 +1,187 @@
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 Veterinarian
10
+ class Client
11
+
12
+ #
13
+ # API
14
+ #
15
+
16
+ def self.connect(endpoint, options = {})
17
+ new(endpoint, options)
18
+ end
19
+
20
+ def initialize(endpoint, options = {})
21
+ @endpoint = endpoint
22
+ @options = options
23
+
24
+ initialize_connection(endpoint, options)
25
+ end
26
+
27
+ def overview
28
+ decode_resource(@connection.get("/api/overview"))
29
+ end
30
+
31
+ def list_nodes
32
+ decode_resource_collection(@connection.get("/api/nodes"))
33
+ end
34
+
35
+ def node_info(name)
36
+ decode_resource(@connection.get("/api/nodes/#{uri_encode(name)}"))
37
+ end
38
+
39
+ def list_extensions
40
+ decode_resource_collection(@connection.get("/api/extensions"))
41
+ end
42
+
43
+ def list_definitions
44
+ decode_resource_collection(@connection.get("/api/definitions"))
45
+ end
46
+
47
+ def upload_definitions(defs)
48
+ raise NotImplementedError.new
49
+ end
50
+
51
+ def list_connections
52
+ decode_resource_collection(@connection.get("/api/connections"))
53
+ end
54
+
55
+ def connection_info(name)
56
+ decode_resource(@connection.get("/api/connections/#{uri_encode(name)}"))
57
+ end
58
+
59
+ def close_connection(name)
60
+ decode_resource(@connection.delete("/api/connections/#{uri_encode(name)}"))
61
+ end
62
+
63
+ def list_channels
64
+ decode_resource_collection(@connection.get("/api/channels"))
65
+ end
66
+
67
+ def channel_info(name)
68
+ decode_resource(@connection.get("/api/channels/#{uri_encode(name)}"))
69
+ end
70
+
71
+ def list_exchanges(vhost = nil)
72
+ path = if vhost.nil?
73
+ "/api/exchanges"
74
+ else
75
+ "/api/exchanges/#{uri_encode(vhost)}"
76
+ end
77
+
78
+ decode_resource_collection(@connection.get(path))
79
+ end
80
+
81
+ def exchange_info(vhost, name)
82
+ decode_resource(@connection.get("/api/exchanges/#{uri_encode(vhost)}/#{uri_encode(name)}"))
83
+ end
84
+
85
+ def list_bindings_by_source(vhost, exchange)
86
+ decode_resource_collection(@connection.get("/api/exchanges/#{uri_encode(vhost)}/#{uri_encode(exchange)}/bindings/source"))
87
+ end
88
+
89
+ def list_bindings_by_destination(vhost, exchange)
90
+ decode_resource_collection(@connection.get("/api/exchanges/#{uri_encode(vhost)}/#{uri_encode(exchange)}/bindings/destination"))
91
+ end
92
+
93
+ def list_queues(vhost = nil)
94
+ path = if vhost.nil?
95
+ "/api/queues"
96
+ else
97
+ "/api/queues/#{uri_encode(vhost)}"
98
+ end
99
+
100
+ decode_resource_collection(@connection.get(path))
101
+ end
102
+
103
+ def queue_info(vhost, name)
104
+ decode_resource(@connection.get("/api/queues/#{uri_encode(vhost)}/#{uri_encode(name)}"))
105
+ end
106
+
107
+ def declare_queue(vhost, name, attributes)
108
+ raise NotImplementedError.new
109
+ end
110
+
111
+ def delete_queue(vhost, name)
112
+ raise NotImplementedError.new
113
+ end
114
+
115
+ def purge_queue(vhost, name)
116
+ raise NotImplementedError.new
117
+ end
118
+
119
+
120
+ def list_bindings(vhost = nil)
121
+ path = if vhost.nil?
122
+ "/api/bindings"
123
+ else
124
+ "/api/bindings/#{uri_encode(vhost)}"
125
+ end
126
+
127
+ decode_resource_collection(@connection.get(path))
128
+ end
129
+
130
+ def list_vhosts
131
+ decode_resource_collection(@connection.get("/api/vhosts"))
132
+ end
133
+
134
+ def vhost_info(name)
135
+ decode_resource(@connection.get("/api/vhosts/#{uri_encode(name)}"))
136
+ end
137
+
138
+
139
+
140
+ def list_users
141
+ decode_resource_collection(@connection.get("/api/users"))
142
+ end
143
+
144
+
145
+
146
+ def list_policies
147
+ decode_resource_collection(@connection.get("/api/policies"))
148
+ end
149
+
150
+
151
+ def list_parameters
152
+ decode_resource_collection(@connection.get("/api/parameters"))
153
+ end
154
+
155
+
156
+
157
+ def aliveness_test(vhost)
158
+ r = @connection.get("/api/aliveness-test/#{uri_encode(vhost)}")
159
+ r.body["status"] == "ok"
160
+ end
161
+
162
+
163
+ protected
164
+
165
+ def initialize_connection(endpoint, options = {})
166
+ @connection = Faraday.new(:url => endpoint) do |conn|
167
+ conn.basic_auth options.fetch(:username, "guest"), options.fetch(:password, "guest")
168
+ conn.use FaradayMiddleware::FollowRedirects, :limit => 3
169
+ conn.response :json, :content_type => /\bjson$/
170
+
171
+ conn.adapter options.fetch(:adapter, Faraday.default_adapter)
172
+ end
173
+ end
174
+
175
+ def uri_encode(s)
176
+ CGI.escape(s)
177
+ end
178
+
179
+ def decode_resource(response)
180
+ Hashie::Mash.new(response.body)
181
+ end
182
+
183
+ def decode_resource_collection(response)
184
+ response.body.map { |i| Hashie::Mash.new(i) }
185
+ end
186
+ end # Client
187
+ end # Veterinarian
@@ -0,0 +1,3 @@
1
+ module Veterinarian
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,593 @@
1
+ require "spec_helper"
2
+
3
+ describe Veterinarian::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 "veterinarian"
12
+ require "bunny"
@@ -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 'veterinarian/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "veterinarian"
8
+ gem.version = Veterinarian::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/veterinarian"
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
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: veterinarian
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
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
+ - Gemfile
103
+ - LICENSE.txt
104
+ - README.md
105
+ - Rakefile
106
+ - lib/veterinarian.rb
107
+ - lib/veterinarian/client.rb
108
+ - lib/veterinarian/version.rb
109
+ - spec/integration/client_spec.rb
110
+ - spec/spec_helper.rb
111
+ - veterinarian.gemspec
112
+ homepage: http://github.com/ruby-amqp/veterinarian
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
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: !binary |-
132
+ MA==
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