Skip to content

Commit 53baf36

Browse files
Merge pull request #5 from skolodyazhnyy/master
API to work with Exchange to Exchange bindings
2 parents 568ffe0 + 6643b1a commit 53baf36

File tree

1 file changed

+78
-1
lines changed

1 file changed

+78
-1
lines changed

src/RabbitMq/ManagementApi/Api/Binding.php

+78-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,21 @@ public function binding($vhost, $exchange, $queue)
4040
return $this->client->send(array('/api/bindings/{vhost}/e/{exchange}/q/{queue}', array('vhost' => $vhost, 'exchange' => $exchange, 'queue' => $queue)));
4141
}
4242

43+
/**
44+
* A list of all bindings between two exchanges. Remember, two exchanges can be bound together many times with
45+
* different parameters!
46+
*
47+
* @param string $vhost
48+
* @param string $source
49+
* @param string $destination
50+
*
51+
* @return array
52+
*/
53+
public function exchangeBinding($vhost, $source, $destination)
54+
{
55+
return $this->client->send(array('/api/bindings/{vhost}/e/{source}/e/{destination}', array('vhost' => $vhost, 'source' => $source, 'destination' => $destination)));
56+
}
57+
4358
/**
4459
* To create a new binding, POST to this URI. You will need a body looking something like this:
4560
*
@@ -73,6 +88,39 @@ public function create($vhost, $exchange, $queue, $routingKey = null, array $arg
7388
return $this->client->send(array('/api/bindings/{vhost}/e/{exchange}/q/{queue}', array('vhost' => $vhost, 'exchange' => $exchange, 'queue' => $queue)), 'POST', null, $parameters);
7489
}
7590

91+
/**
92+
* To create a new exchange to exchange binding, POST to this URI. You will need a body looking something like this:
93+
*
94+
* {
95+
* "routing_key": "my_routing_key",
96+
* "arguments": []
97+
* }
98+
*
99+
* All keys are optional. The response will contain a Location header telling you the URI of your new binding.
100+
*
101+
* @param string $vhost
102+
* @param string $source
103+
* @param string $destination
104+
* @param string|null $routingKey
105+
* @param array|null $arguments
106+
* @return array
107+
*/
108+
public function createExchange($vhost, $source, $destination, $routingKey = null, array $arguments = null)
109+
{
110+
$parameters = array();
111+
112+
if ($routingKey) {
113+
$parameters['routing_key'] = $routingKey;
114+
} else {
115+
$parameters['routing_key'] = '';
116+
}
117+
if ($arguments) {
118+
$parameters['arguments'] = $arguments;
119+
}
120+
121+
return $this->client->send(array('/api/bindings/{vhost}/e/{source}/e/{destination}', array('vhost' => $vhost, 'source' => $source, 'destination' => $destination)), 'POST', null, $parameters);
122+
}
123+
76124
/**
77125
* An individual binding between an exchange and a queue. The props part of the URI is a "name" for the binding
78126
* composed of its routing key and a hash of its arguments.
@@ -89,7 +137,22 @@ public function get($vhost, $exchange, $queue, $props)
89137
}
90138

91139
/**
92-
* Remove an individual binding.
140+
* An individual binding between two exchanges. The props part of the URI is a "name" for the binding
141+
* composed of its routing key and a hash of its arguments.
142+
*
143+
* @param string $vhost
144+
* @param string $source
145+
* @param string $destination
146+
* @param string $props
147+
* @return array
148+
*/
149+
public function getExchange($vhost, $source, $destination, $props)
150+
{
151+
return $this->client->send(array('/api/bindings/{vhost}/e/{source}/e/{destination}/{props}', array('vhost' => $vhost, 'source' => $source, 'destination' => $destination, 'props' => $props)));
152+
}
153+
154+
/**
155+
* Remove an individual binding between an exchange and a queue.
93156
*
94157
* @param string $vhost
95158
* @param string $exchange
@@ -101,4 +164,18 @@ public function delete($vhost, $exchange, $queue, $props)
101164
{
102165
return $this->client->send(array('/api/bindings/{vhost}/e/{exchange}/q/{queue}/{props}', array('vhost' => $vhost, 'exchange' => $exchange, 'queue' => $queue, 'props' => $props)), 'DELETE');
103166
}
167+
168+
/**
169+
* Remove an individual binding between two exchanges.
170+
*
171+
* @param string $vhost
172+
* @param string $source
173+
* @param string $destination
174+
* @param string $props
175+
* @return array
176+
*/
177+
public function deleteExchange($vhost, $source, $destination, $props)
178+
{
179+
return $this->client->send(array('/api/bindings/{vhost}/e/{source}/e/{destination}/{props}', array('vhost' => $vhost, 'source' => $source, 'destination' => $destination, 'props' => $props)), 'DELETE');
180+
}
104181
}

0 commit comments

Comments
 (0)