rabbitmq_http_api_client 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/ChangeLog.md +50 -0
- data/Gemfile +3 -1
- data/README.md +7 -5
- data/lib/rabbitmq/http/client/version.rb +1 -1
- data/lib/rabbitmq/http/client.rb +16 -0
- data/repl +3 -0
- data/spec/integration/client_spec.rb +102 -9
- data/spec/spec_helper.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c3e80aef7a45dabffb63bf86a447e35b26d0bef
|
4
|
+
data.tar.gz: 9d5176e73743320c8efdfbbdd1b42a4927110fcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56714e455a1c24092866bf4f16287abab7be613aced524666b839fbb20d1839992a4f86e2480175f39ccdf331a57a60ab2a201400c8ad9c3c972589d7ed94fc3
|
7
|
+
data.tar.gz: 07e576efb22122182602e6fab7fb6bed5c3637f7734abf94140dd5c22b0f125721861e03d7e227682ba99ddb597dc9d32137f5e36fe35a37b3c31436a71ee41a
|
data/.travis.yml
CHANGED
data/ChangeLog.md
CHANGED
@@ -1,3 +1,53 @@
|
|
1
|
+
## Changes Between 0.8.0 and 0.9.0
|
2
|
+
|
3
|
+
### New Queue Binding Methods
|
4
|
+
|
5
|
+
`RabbitMQ::HTTP::Client#queue_binding_info`,
|
6
|
+
`RabbitMQ::HTTP::Client#bind_queue`, and
|
7
|
+
`RabbitMQ::HTTP::Client#delete_queue_binding`
|
8
|
+
are new methods that operate on queue bindings:
|
9
|
+
|
10
|
+
``` ruby
|
11
|
+
c = RabbitMQ::HTTP::Client.new("http://guest:guest@127.0.0.1:15672")
|
12
|
+
|
13
|
+
c.bind_queue("/", "a.queue", "an.exchange", "routing.key")
|
14
|
+
c.queue_binding_info("/", "a.queue", "an.exchange", "properties.key")
|
15
|
+
c.delete_queue_binding("/", "a.queue", "an.exchange", "properties.key")
|
16
|
+
```
|
17
|
+
|
18
|
+
Contributed by Noah Magram.
|
19
|
+
|
20
|
+
|
21
|
+
## Changes Between 0.7.0 and 0.8.0
|
22
|
+
|
23
|
+
### Client#protocol_ports
|
24
|
+
|
25
|
+
`RabbitMQ::HTTP::Client#enabled_protocols` is a new method that returns
|
26
|
+
a hash of enabled protocols to their ports. The keys are the same as
|
27
|
+
returned by `Client#enabled_protocols`:
|
28
|
+
|
29
|
+
``` ruby
|
30
|
+
# when TLS and MQTT plugin is enabled
|
31
|
+
c.protocol_ports # => {"amqp" => 5672, "amqp/ssl" => 5671, "mqtt" => 1883}
|
32
|
+
```
|
33
|
+
|
34
|
+
### Client#enabled_protocols
|
35
|
+
|
36
|
+
`RabbitMQ::HTTP::Client#enabled_protocols` is a new method that returns
|
37
|
+
a list of enabled protocols. Some common values are:
|
38
|
+
|
39
|
+
* `amqp` (AMQP 0-9-1)
|
40
|
+
* `amqp/ssl` (AMQP 0-9-1 with TLS enabled)
|
41
|
+
* `mqtt`
|
42
|
+
* `stomp`
|
43
|
+
|
44
|
+
``` ruby
|
45
|
+
# when TLS and MQTT plugin is enabled
|
46
|
+
c.enabled_protocols # => ["amqp", "amqp/ssl", "mqtt"]
|
47
|
+
```
|
48
|
+
|
49
|
+
|
50
|
+
|
1
51
|
## Changes Between 0.6.0 and 0.7.0
|
2
52
|
|
3
53
|
### Support for Basic HTTP Auth Credentials in URI
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -7,6 +7,8 @@ This gem is a [RabbitMQ HTTP API](http://hg.rabbitmq.com/rabbitmq-management/raw
|
|
7
7
|
* Getting information about exchanges, queues, bindings
|
8
8
|
* Closing client connections
|
9
9
|
* Getting information about vhosts, users, permissions
|
10
|
+
* Getting information about enabled plugins, protocols, their ports, etc
|
11
|
+
* Managing vhosts, users, permissions
|
10
12
|
|
11
13
|
and will support more HTTP API features in the future
|
12
14
|
|
@@ -38,7 +40,7 @@ Add this line to your application's Gemfile:
|
|
38
40
|
|
39
41
|
And then execute:
|
40
42
|
|
41
|
-
$ bundle
|
43
|
+
$ bundle install
|
42
44
|
|
43
45
|
Or install it yourself as:
|
44
46
|
|
@@ -59,7 +61,7 @@ Use `RabbitMQ::HTTP::Client#connect` to specify RabbitMQ HTTP API endpoint (e.g.
|
|
59
61
|
``` ruby
|
60
62
|
require "rabbitmq/http/client"
|
61
63
|
|
62
|
-
endpoint = "http://127.0.0.1:
|
64
|
+
endpoint = "http://127.0.0.1:15672"
|
63
65
|
client = RabbitMQ::HTTP::Client.new(endpoint, :username => "guest", :password => "guest")
|
64
66
|
```
|
65
67
|
|
@@ -68,7 +70,7 @@ Alternatively, credentials can be specified in the endpoint URI:
|
|
68
70
|
``` ruby
|
69
71
|
require "rabbitmq/http/client"
|
70
72
|
|
71
|
-
client = RabbitMQ::HTTP::Client.new("http://guest:guest@127.0.0.1:
|
73
|
+
client = RabbitMQ::HTTP::Client.new("http://guest:guest@127.0.0.1:15672")
|
72
74
|
```
|
73
75
|
|
74
76
|
### Client API Design Overview
|
@@ -284,7 +286,7 @@ client.create_vhost("myapp.staging")
|
|
284
286
|
client.delete_vhost("myapp.staging")
|
285
287
|
```
|
286
288
|
|
287
|
-
###
|
289
|
+
### Managing Users
|
288
290
|
|
289
291
|
``` ruby
|
290
292
|
# List all users
|
@@ -309,7 +311,7 @@ client.update_user("myapp", :tags => "services", :password => "t0ps3krEt")
|
|
309
311
|
client.delete_user("myapp")
|
310
312
|
```
|
311
313
|
|
312
|
-
###
|
314
|
+
### Managing Permissions
|
313
315
|
|
314
316
|
``` ruby
|
315
317
|
# List all permissions
|
data/lib/rabbitmq/http/client.rb
CHANGED
@@ -179,6 +179,22 @@ module RabbitMQ
|
|
179
179
|
decode_resource_collection(@connection.get("/api/bindings/#{uri_encode(vhost)}/e/#{uri_encode(exchange)}/q/#{uri_encode(queue)}"))
|
180
180
|
end
|
181
181
|
|
182
|
+
def queue_binding_info(vhost, queue, exchange, properties_key)
|
183
|
+
decode_resource(@connection.get("/api/bindings/#{uri_encode(vhost)}/e/#{uri_encode(exchange)}/q/#{uri_encode(queue)}/#{uri_encode(properties_key)}"))
|
184
|
+
end
|
185
|
+
|
186
|
+
def bind_queue(vhost, queue, exchange, routing_key, arguments = [])
|
187
|
+
resp = @connection.post("/api/bindings/#{uri_encode(vhost)}/e/#{uri_encode(exchange)}/q/#{uri_encode(queue)}") do |req|
|
188
|
+
req.headers['Content-Type'] = 'application/json'
|
189
|
+
req.body = MultiJson.dump({ routing_key: routing_key, arguments: arguments })
|
190
|
+
end
|
191
|
+
resp.headers['location']
|
192
|
+
end
|
193
|
+
|
194
|
+
def delete_queue_binding(vhost, queue, exchange, properties_key)
|
195
|
+
resp = @connection.delete("/api/bindings/#{uri_encode(vhost)}/e/#{uri_encode(exchange)}/q/#{uri_encode(queue)}/#{uri_encode(properties_key)}")
|
196
|
+
resp.success?
|
197
|
+
end
|
182
198
|
|
183
199
|
|
184
200
|
|
data/repl
ADDED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require "spec_helper"
|
2
3
|
|
3
4
|
describe RabbitMQ::HTTP::Client do
|
@@ -521,6 +522,7 @@ describe RabbitMQ::HTTP::Client do
|
|
521
522
|
b.destination_type.should == "queue"
|
522
523
|
b.source.should == x.name
|
523
524
|
b.routing_key.should_not be_nil
|
525
|
+
b.properties_key.should_not be_nil
|
524
526
|
b.vhost.should == "/"
|
525
527
|
|
526
528
|
q.delete
|
@@ -529,15 +531,69 @@ describe RabbitMQ::HTTP::Client do
|
|
529
531
|
end
|
530
532
|
|
531
533
|
describe "POST /api/bindings/:vhost/e/:exchange/q/:queue" do
|
532
|
-
|
534
|
+
before :all do
|
535
|
+
@channel = @connection.create_channel
|
536
|
+
end
|
537
|
+
|
538
|
+
it "creates a binding between an exchange and a queue" do
|
539
|
+
routing_key = 'test.key'
|
540
|
+
q = @channel.queue("")
|
541
|
+
x = @channel.fanout("http.client.fanout")
|
542
|
+
q.bind(x)
|
543
|
+
|
544
|
+
b = subject.bind_queue("/", q.name, x.name, routing_key)
|
545
|
+
|
546
|
+
b.should == q.name + "/" + routing_key
|
547
|
+
|
548
|
+
q.delete
|
549
|
+
x.delete
|
550
|
+
end
|
533
551
|
end
|
534
552
|
|
535
553
|
describe "GET /api/bindings/:vhost/e/:exchange/q/:queue/props" do
|
536
|
-
|
554
|
+
before :all do
|
555
|
+
@channel = @connection.create_channel
|
556
|
+
end
|
557
|
+
|
558
|
+
it "returns an individual binding between an exchange and a queue" do
|
559
|
+
routing_key = 'test.key'
|
560
|
+
q = @channel.queue("")
|
561
|
+
x = @channel.fanout("http.client.fanout")
|
562
|
+
q.bind(x)
|
563
|
+
|
564
|
+
xs = subject.list_bindings_between_queue_and_exchange("/", q.name, x.name)
|
565
|
+
b1 = xs.first
|
566
|
+
|
567
|
+
b2 = subject.queue_binding_info("/", q.name, x.name, b1.properties_key)
|
568
|
+
|
569
|
+
b1.should == b2
|
570
|
+
|
571
|
+
end
|
537
572
|
end
|
538
573
|
|
539
574
|
describe "DELETE /api/bindings/:vhost/e/:exchange/q/:queue/props" do
|
540
|
-
|
575
|
+
before :all do
|
576
|
+
@channel = @connection.create_channel
|
577
|
+
end
|
578
|
+
|
579
|
+
it "deletes an individual binding between an exchange and a queue" do
|
580
|
+
routing_key = 'test.key'
|
581
|
+
q = @channel.queue("")
|
582
|
+
x = @channel.fanout("http.client.fanout")
|
583
|
+
q.bind(x)
|
584
|
+
|
585
|
+
xs = subject.list_bindings_between_queue_and_exchange("/", q.name, x.name)
|
586
|
+
b = xs.first
|
587
|
+
|
588
|
+
subject.delete_queue_binding("/", q.name, x.name, b.properties_key).should be_true
|
589
|
+
|
590
|
+
xs = subject.list_bindings_between_queue_and_exchange("/", q.name, x.name)
|
591
|
+
|
592
|
+
xs.size.should == 0
|
593
|
+
|
594
|
+
q.delete
|
595
|
+
x.delete
|
596
|
+
end
|
541
597
|
end
|
542
598
|
|
543
599
|
describe "GET /api/vhosts" do
|
@@ -571,14 +627,51 @@ describe RabbitMQ::HTTP::Client do
|
|
571
627
|
end
|
572
628
|
|
573
629
|
describe "PUT /api/vhosts/:name" do
|
574
|
-
|
630
|
+
gen = Rantly.new
|
631
|
+
|
632
|
+
[
|
633
|
+
"http-created",
|
634
|
+
"http_created",
|
635
|
+
"http created",
|
636
|
+
"создан по хатэтэпэ",
|
637
|
+
"creado a través de HTTP",
|
638
|
+
"通过http",
|
639
|
+
"HTTP를 통해 생성",
|
640
|
+
"HTTPを介して作成",
|
641
|
+
"created over http?",
|
642
|
+
"created @ http API",
|
643
|
+
"erstellt über http",
|
644
|
+
"http पर बनाया",
|
645
|
+
"ถูกสร้างขึ้นผ่าน HTTP",
|
646
|
+
"±!@^&#*"
|
647
|
+
].each do |vhost|
|
648
|
+
context "when vhost name is #{vhost}" do
|
649
|
+
it "creates a vhost" do
|
650
|
+
subject.create_vhost(vhost)
|
651
|
+
subject.create_vhost(vhost)
|
652
|
+
|
653
|
+
v = subject.vhost_info(vhost)
|
654
|
+
v.name.should == vhost
|
655
|
+
|
656
|
+
subject.delete_vhost(v.name)
|
657
|
+
end
|
658
|
+
end
|
659
|
+
end
|
575
660
|
|
576
|
-
|
577
|
-
|
578
|
-
|
661
|
+
1000.times do
|
662
|
+
vhost = gen.string
|
663
|
+
|
664
|
+
context "when vhost name is #{vhost}" do
|
665
|
+
it "creates a vhost" do
|
666
|
+
subject.create_vhost(vhost)
|
667
|
+
subject.create_vhost(vhost)
|
579
668
|
|
580
|
-
|
581
|
-
|
669
|
+
v = subject.vhost_info(vhost)
|
670
|
+
v.name.should == vhost
|
671
|
+
|
672
|
+
subject.delete_vhost(v.name)
|
673
|
+
end
|
674
|
+
end
|
582
675
|
end
|
583
676
|
end
|
584
677
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rabbitmq_http_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.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: 2013-
|
11
|
+
date: 2013-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- lib/rabbitmq/http/client.rb
|
99
99
|
- lib/rabbitmq/http/client/version.rb
|
100
100
|
- rabbitmq_http_api_client.gemspec
|
101
|
+
- repl
|
101
102
|
- spec/integration/client_spec.rb
|
102
103
|
- spec/spec_helper.rb
|
103
104
|
homepage: http://github.com/ruby-amqp/rabbitmq_http_api_client
|