rabbitmq_http_api_client 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ed47214540d24f2baaea45ea02e7acdfa82dbaa4
4
+ data.tar.gz: 4d24a9b4fc6e28d5d1650a9e087c3214083bfa4b
5
+ SHA512:
6
+ metadata.gz: f19d37c7a1e9a8440e97aa499c5ed9d3228928849ba0a9f4c13f0db7e8371f82e9857ae49c4f2729cfc2d2e3991fcbf39b26f3bc0e9fe3130d7ae76960cf7a4e
7
+ data.tar.gz: 906477027358a4bf5e51fb23abde12e46f106bcfa5e348966097a45c0561103e6b31ff64bf0f21657cf0da6d3a81be6919bfc60ca23bf452688b13f1a77792cb
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ bin/*
data/.travis.yml ADDED
@@ -0,0 +1,19 @@
1
+ bundler_args: --without development
2
+ script: "bundle exec rspec -cfs spec"
3
+ rvm:
4
+ - "2.0"
5
+ - "1.9.3"
6
+ - "jruby-19mode"
7
+ - "1.9.2"
8
+ - "rbx-19mode"
9
+ - "1.8.7"
10
+ notifications:
11
+ email: michael@rabbitmq.com
12
+ services:
13
+ - rabbitmq
14
+ branches:
15
+ only:
16
+ - master
17
+ matrix:
18
+ allow_failures:
19
+ - rvm: rbx-19mode
data/ChangeLog.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## Changes Between 0.2.0 and 0.3.0
2
+
3
+ ### MultiJSON Upgrade
4
+
5
+ The library now depends on `multi_json ~> 1.7.0`.
6
+
7
+
1
8
  ## Changes Between 0.1.0 and 0.2.0
2
9
 
3
10
  ### Support for more HTTP API operations
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
3
3
  group :development, :test do
4
4
  gem "rspec"
5
5
  gem "json"
6
- gem "bunny", ">= 0.9.0.pre3"
6
+ gem "bunny", ">= 0.10.2"
7
7
  end
8
8
 
9
9
  # Specify your gem's dependencies in superintendent.gemspec
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # RabbitMQ HTTP API Client for Ruby
2
2
 
3
- This gem is a RabbitMQ HTTP API Client for Ruby. It supports
3
+ This gem is a [RabbitMQ HTTP API](http://hg.rabbitmq.com/rabbitmq-management/raw-file/450b7ea22cfd/priv/www/api/index.html) client for Ruby. It supports
4
4
 
5
5
  * Getting cluster overview information
6
6
  * Getting cluster nodes status (# file descriptors used, RAM consumption and so on)
@@ -16,6 +16,7 @@ and will support more HTTP API features in the future
16
16
 
17
17
  ## Supported Ruby Versions
18
18
 
19
+ * MRI 2.0
19
20
  * MRI 1.9.3
20
21
  * JRuby 1.7+
21
22
  * Rubinius 2.0+
@@ -45,7 +46,271 @@ Or install it yourself as:
45
46
 
46
47
  ## Usage
47
48
 
48
- TODO: Write usage instructions here
49
+ To require the client:
50
+
51
+ ``` ruby
52
+ require "rabbitmq/http/client"
53
+ ```
54
+
55
+ ### Specifying Endpoint and Credentials
56
+
57
+ Use `RabbitMQ::HTTP::Client#connect` to specify RabbitMQ HTTP API endpoint (e.g. `http://127.0.0.1:15672`) and credentials:
58
+
59
+ ``` ruby
60
+ require "rabbitmq/http/client"
61
+
62
+ endpoint = "http://127.0.0.1:55672"
63
+ client = RabbitMQ::HTTP::Client.new(endpoint, :username => "guest", :password => "guest")
64
+ ```
65
+
66
+ ### Client API Design Overview
67
+
68
+ All client methods return arrays or hash-like structures that can be used
69
+ like JSON, via `Hash#[]` or regular method access:
70
+
71
+ ``` ruby
72
+ r = client.overview
73
+
74
+ puts r[:rabbitmq_version]
75
+ puts r.erlang_version
76
+ ```
77
+
78
+
79
+
80
+ ### Node and Cluster Status
81
+
82
+ ``` ruby
83
+ # Get cluster information overview
84
+ h = client.overview
85
+
86
+ # List cluster nodes with detailed status info for each one of them
87
+ nodes = client.list_nodes
88
+ n = nodes.first
89
+ puts n.sockets_used
90
+ puts n.mem_used
91
+ puts n.run_queue
92
+
93
+ # Get detailed status of a node
94
+ n = client.node_info("rabbit@localhost")
95
+ puts n.disk_free
96
+ puts n.proc_used
97
+ puts n.fd_total
98
+
99
+ # Get Management Plugin extension list
100
+ xs = client.list_extensions
101
+
102
+ # List all the entities (vhosts, queues, exchanges, bindings, users, etc)
103
+ defs = client.list_definitions
104
+ ```
105
+
106
+ ### Operations on Connections
107
+
108
+ ``` ruby
109
+ # List all connections to a node
110
+ conns = client.list_connections
111
+ conn = conns.first
112
+ puts conn.name
113
+ puts conn.client_properties.product
114
+
115
+ # Get a connection information by name
116
+ conns = client.list_connections
117
+ conn = client.connection_info(conns.first.name)
118
+ puts conn.name
119
+ puts conn.client_properties.product
120
+
121
+ # Forcefully close a connection
122
+ conns = client.list_connections
123
+ client.close_connection(conns.first.name)
124
+ ```
125
+
126
+ ### Operations on Channels
127
+
128
+ ``` ruby
129
+ # List all channels
130
+ channs = client.list_channels
131
+ ch = channs.first
132
+ puts ch.number
133
+ puts ch.prefetch_count
134
+ puts ch.name
135
+
136
+
137
+ # Get a channel information by name
138
+ conns = client.list_channels
139
+ conn = client.channel_info(conns.first.name)
140
+ puts conn.name
141
+ ```
142
+
143
+ ### Operations on Exchanges
144
+
145
+ ``` ruby
146
+ # List all exchanges in the cluster
147
+ xs = client.list_exchanges
148
+ x = xs.first
149
+
150
+ puts x.type
151
+ puts x.name
152
+ puts x.vhost
153
+ puts x.durable
154
+ puts x.auto_delete
155
+
156
+ # List all exchanges in a vhost
157
+ xs = client.list_exchanges("myapp.production")
158
+ x = xs.first
159
+
160
+ puts x.type
161
+ puts x.name
162
+ puts x.vhost
163
+
164
+ # Get information about an exchange in a vhost
165
+ x = client.exchange_info("/", "log.events")
166
+
167
+ puts x.type
168
+ puts x.name
169
+ puts x.vhost
170
+
171
+ # List all exchanges in a vhost for which an exchange is the source
172
+ client.list_bindings_by_source("/", "log.events")
173
+
174
+ # List all exchanges in a vhost for which an exchange is the destination
175
+ client.list_bindings_by_destination("/", "command.handlers.email")
176
+ ```
177
+
178
+ ### Operations on Queues
179
+
180
+ ``` ruby
181
+ # List all queues in a node
182
+ qs = client.list_queues
183
+ q = qs.first
184
+
185
+ puts q.name
186
+ puts q.auto_delete
187
+ puts q.durable
188
+ puts q.backing_queue_status
189
+ puts q.active_consumers
190
+
191
+
192
+ # Declare a queue
193
+ client.declare_queue("/", "collector1.megacorp.local", :durable => false, :auto_delete => true)
194
+
195
+ # Delete a queue
196
+ client.delete_queue("/", "collector1.megacorp.local")
197
+
198
+ # List bindings for a queue
199
+ bs = client.list_queue_bindings("/", "collector1.megacorp.local")
200
+
201
+ # Purge a queue
202
+ client.purge_queue("/", "collector1.megacorp.local")
203
+
204
+ # Fetch messages from a queue
205
+ ms = client.get_messages("/", "collector1.megacorp.local", :count => 10, :requeue => false, :encoding => "auto")
206
+ m = ms.first
207
+
208
+ puts m.properties.content_type
209
+ puts m.payload
210
+ puts m.payload_encoding
211
+ ```
212
+
213
+ ### Operations on Bindings
214
+
215
+ ``` ruby
216
+ # List all bindings
217
+ bs = client.list_bindings
218
+ b = bs.first
219
+
220
+ puts b.destination
221
+ puts b.destination_type
222
+ puts b.source
223
+ puts b.routing_key
224
+ puts b.vhost
225
+
226
+ # List all bindings in a vhost
227
+ bs = client.list_bindings("/")
228
+
229
+ # List all binsings between an exchange and a queue
230
+ bs = client.list_bindings_between_queue_and_exchange("/", "collector1.megacorp.local", "log.events")
231
+ ```
232
+
233
+ ### Operations on Vhosts
234
+
235
+ ``` ruby
236
+ # List all vhosts
237
+ vs = client.list_vhosts
238
+ v = vs.first
239
+
240
+ puts v.name
241
+ puts v.tracing
242
+
243
+ # Get information about a vhost
244
+ v = client.vhost_info("/")
245
+
246
+ puts v.name
247
+ puts v.tracing
248
+
249
+ # Create a vhost
250
+ client.create_vhost("myapp.staging")
251
+
252
+ # Delete a vhost
253
+ client.delete_vhost("myapp.staging")
254
+ ```
255
+
256
+ ### Operations on Users
257
+
258
+ ``` ruby
259
+ # List all users
260
+ us = client.list_users
261
+ u = us.first
262
+
263
+ puts u.name
264
+ puts u.password_hash
265
+ puts u.tags
266
+
267
+ # Get information about a user
268
+ u = client.user_info("guest")
269
+
270
+ puts u.name
271
+ puts u.password_hash
272
+ puts u.tags
273
+
274
+ # Update information about a user
275
+ client.update_user("myapp", :tags => "services", :password => "t0ps3krEt")
276
+
277
+ # Delete a user
278
+ client.delete_user("myapp")
279
+ ```
280
+
281
+ ### Operations on Permissions
282
+
283
+ ``` ruby
284
+ # List all permissions
285
+ ps = client.list_permissions
286
+
287
+ puts p.user
288
+ puts p.read
289
+ puts p.write
290
+ puts p.configure
291
+ puts p.vhost
292
+
293
+ # List all permissions in a vhost
294
+ ps = client.list_permissions("/")
295
+
296
+ puts p.user
297
+ puts p.read
298
+ puts p.write
299
+ puts p.configure
300
+ puts p.vhost
301
+
302
+ # List permissions of a user
303
+ ps = client.user_permissions("guest")
304
+
305
+ # List permissions of a user in a vhost
306
+ ps = client.list_permissions_of("/", "guest")
307
+
308
+ # Update permissions of a user in a vhost
309
+ ps = client.update_permissions_of("/", "guest", :write => ".*", :read => ".*", :configure => ".*")
310
+
311
+ # Clear permissions of a user in a vhost
312
+ ps = client.clear_permissions_of("/", "guest")
313
+ ```
49
314
 
50
315
  ## Contributing
51
316
 
@@ -1,7 +1,7 @@
1
1
  module RabbitMQ
2
2
  module HTTP
3
3
  class Client
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
6
6
  end
7
7
  end
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
19
19
  gem.require_paths = ["lib"]
20
20
 
21
21
  gem.add_dependency "hashie", "~> 1.2.0"
22
- gem.add_dependency "multi_json", "~> 1.4.0"
22
+ gem.add_dependency "multi_json", "~> 1.7.0"
23
23
  gem.add_dependency "faraday", "~> 0.8.4"
24
24
  gem.add_dependency "faraday_middleware", "~> 0.9.0"
25
25
  gem.add_dependency "effin_utf8", "~> 1.0.0"
@@ -25,8 +25,11 @@ describe RabbitMQ::HTTP::Client do
25
25
  it "returns an overview" do
26
26
  r = subject.overview
27
27
 
28
- r.exchange_types.map { |h| h.name }.
29
- sort.should == ["direct", "fanout", "headers", "topic"]
28
+ ts = r.exchange_types.map { |h| h.name }.
29
+ sort
30
+ ["direct", "fanout", "headers", "topic"].each do |t|
31
+ ts.should include(t)
32
+ end
30
33
 
31
34
  r.rabbitmq_version.should_not be_nil
32
35
  r.erlang_version.should_not be_nil
@@ -45,7 +48,7 @@ describe RabbitMQ::HTTP::Client do
45
48
  rabbit = n.applications.detect { |app| app.name == "rabbit" }
46
49
  rabbit.description.should == "RabbitMQ"
47
50
 
48
- n.name.should == "rabbit@localhost"
51
+ n.name.should =~ /^rabbit/
49
52
  n.partitions.should == []
50
53
  n.fd_used.should_not be_nil
51
54
  n.fd_total.should_not be_nil
@@ -63,12 +66,13 @@ describe RabbitMQ::HTTP::Client do
63
66
 
64
67
  describe "GET /api/node/:name" do
65
68
  it "returns status information for a single cluster node" do
66
- n = subject.node_info("rabbit@localhost")
69
+ ns = subject.list_nodes
70
+ n = subject.node_info(ns.first.name)
67
71
 
68
72
  rabbit = n.applications.detect { |app| app.name == "rabbit" }
69
73
  rabbit.description.should == "RabbitMQ"
70
74
 
71
- n.name.should == "rabbit@localhost"
75
+ n.name.should =~ /^rabbit/
72
76
  n.partitions.should == []
73
77
  n.fd_used.should_not be_nil
74
78
  n.fd_total.should_not be_nil
@@ -94,7 +98,7 @@ describe RabbitMQ::HTTP::Client do
94
98
  xs = subject.list_extensions
95
99
  f = xs.first
96
100
 
97
- f.javascript.should == "dispatcher.js"
101
+ ["dispatcher.js", "shovel.js"].should include(f.javascript)
98
102
  end
99
103
  end
100
104
 
@@ -287,6 +291,11 @@ describe RabbitMQ::HTTP::Client do
287
291
  it "publishes a messages to the exchange"
288
292
  end
289
293
 
294
+
295
+ #
296
+ # Queues
297
+ #
298
+
290
299
  describe "GET /api/queues" do
291
300
  before :all do
292
301
  @channel = @connection.create_channel
@@ -327,7 +336,7 @@ describe RabbitMQ::HTTP::Client do
327
336
 
328
337
  i.name.should == q.name
329
338
  i.auto_delete.should == q.auto_delete?
330
- i.active_consumers.should == 0
339
+ i.active_consumers.should be_nil
331
340
  i.backing_queue_status.avg_ack_egress_rate.should == 0.0
332
341
  end
333
342
  end
metadata CHANGED
@@ -1,96 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rabbitmq_http_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Michael Klishin
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-09 00:00:00.000000000 Z
11
+ date: 2013-08-26 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: hashie
16
- version_requirements: !ruby/object:Gem::Requirement
15
+ requirement: !ruby/object:Gem::Requirement
17
16
  requirements:
18
17
  - - ~>
19
18
  - !ruby/object:Gem::Version
20
19
  version: 1.2.0
21
- none: false
22
- requirement: !ruby/object:Gem::Requirement
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.2.0
27
- none: false
28
- prerelease: false
29
- type: :runtime
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: multi_json
32
- version_requirements: !ruby/object:Gem::Requirement
29
+ requirement: !ruby/object:Gem::Requirement
33
30
  requirements:
34
31
  - - ~>
35
32
  - !ruby/object:Gem::Version
36
- version: 1.4.0
37
- none: false
38
- requirement: !ruby/object:Gem::Requirement
33
+ version: 1.7.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
39
37
  requirements:
40
38
  - - ~>
41
39
  - !ruby/object:Gem::Version
42
- version: 1.4.0
43
- none: false
44
- prerelease: false
45
- type: :runtime
40
+ version: 1.7.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: faraday
48
- version_requirements: !ruby/object:Gem::Requirement
43
+ requirement: !ruby/object:Gem::Requirement
49
44
  requirements:
50
45
  - - ~>
51
46
  - !ruby/object:Gem::Version
52
47
  version: 0.8.4
53
- none: false
54
- requirement: !ruby/object:Gem::Requirement
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
55
51
  requirements:
56
52
  - - ~>
57
53
  - !ruby/object:Gem::Version
58
54
  version: 0.8.4
59
- none: false
60
- prerelease: false
61
- type: :runtime
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: faraday_middleware
64
- version_requirements: !ruby/object:Gem::Requirement
57
+ requirement: !ruby/object:Gem::Requirement
65
58
  requirements:
66
59
  - - ~>
67
60
  - !ruby/object:Gem::Version
68
61
  version: 0.9.0
69
- none: false
70
- requirement: !ruby/object:Gem::Requirement
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
71
65
  requirements:
72
66
  - - ~>
73
67
  - !ruby/object:Gem::Version
74
68
  version: 0.9.0
75
- none: false
76
- prerelease: false
77
- type: :runtime
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: effin_utf8
80
- version_requirements: !ruby/object:Gem::Requirement
71
+ requirement: !ruby/object:Gem::Requirement
81
72
  requirements:
82
73
  - - ~>
83
74
  - !ruby/object:Gem::Version
84
75
  version: 1.0.0
85
- none: false
86
- requirement: !ruby/object:Gem::Requirement
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
87
79
  requirements:
88
80
  - - ~>
89
81
  - !ruby/object:Gem::Version
90
82
  version: 1.0.0
91
- none: false
92
- prerelease: false
93
- type: :runtime
94
83
  description: RabbitMQ HTTP API client for Ruby
95
84
  email:
96
85
  - michael@defprotocol.org
@@ -99,6 +88,7 @@ extensions: []
99
88
  extra_rdoc_files: []
100
89
  files:
101
90
  - .gitignore
91
+ - .travis.yml
102
92
  - ChangeLog.md
103
93
  - Gemfile
104
94
  - LICENSE.txt
@@ -113,29 +103,26 @@ homepage: http://github.com/ruby-amqp/rabbitmq_http_api_client
113
103
  licenses:
114
104
  - MIT
115
105
  - Mozilla Public License
116
- post_install_message:
106
+ metadata: {}
107
+ post_install_message:
117
108
  rdoc_options: []
118
109
  require_paths:
119
110
  - lib
120
111
  required_ruby_version: !ruby/object:Gem::Requirement
121
112
  requirements:
122
- - - ! '>='
113
+ - - '>='
123
114
  - !ruby/object:Gem::Version
124
- version: !binary |-
125
- MA==
126
- none: false
115
+ version: '0'
127
116
  required_rubygems_version: !ruby/object:Gem::Requirement
128
117
  requirements:
129
- - - ! '>='
118
+ - - '>='
130
119
  - !ruby/object:Gem::Version
131
- version: !binary |-
132
- MA==
133
- none: false
120
+ version: '0'
134
121
  requirements: []
135
- rubyforge_project:
136
- rubygems_version: 1.8.24
137
- signing_key:
138
- specification_version: 3
122
+ rubyforge_project:
123
+ rubygems_version: 2.0.5
124
+ signing_key:
125
+ specification_version: 4
139
126
  summary: RabbitMQ HTTP API client for Ruby
140
127
  test_files:
141
128
  - spec/integration/client_spec.rb