From 96361b5511881cd2dcff2e6d5d036d60a969e2ff Mon Sep 17 00:00:00 2001
From: Paolo Bellagente
Date: Wed, 12 Feb 2025 15:27:52 +0100
Subject: [PATCH] get_bindings_from_exchange, get_bindings_to_exchange,
get_consumers
---
pyrabbit2/api.py | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/pyrabbit2/api.py b/pyrabbit2/api.py
index bbb8ab8..1cccb1f 100644
--- a/pyrabbit2/api.py
+++ b/pyrabbit2/api.py
@@ -82,6 +82,7 @@ class Client(object):
'definitions': 'definitions',
'extensions': 'extensions',
'cluster-name': 'cluster-name',
+ 'consumers': 'consumers'
}
json_headers = {"content-type": "application/json"}
@@ -904,13 +905,22 @@ def get_queue_bindings(self, vhost, qname):
return bindings
def get_bindings_from_exchange(self, vhost, exch):
- pass
+ vhost = quote(vhost, '')
+ exch = quote(exch, '')
+ path = Client.urls['bindings_by_source_exch'] % (vhost, exch)
+ bindings = self._call(path, 'GET')
+ return bindings
def get_bindings_to_exchange(self, vhost, exch):
- pass
+ vhost = quote(vhost, '')
+ exch = quote(exch, '')
+ path = Client.urls['bindings_by_dest_exch'] % (vhost, exch)
+ bindings = self._call(path, 'GET')
+ return bindings
+ raise NotImplementedError
def get_bindings_between_exch_and_queue(self, vhost, exch, queue):
- pass
+ raise NotImplementedError
def create_binding(self, vhost, exchange, queue, rt_key=None, args=None):
"""
@@ -1049,3 +1059,10 @@ def get_cluster_name(self):
"""
path = Client.urls['cluster-name']
return self._call(path, 'GET')
+
+ def get_consumers(self):
+ """
+ Get A list of all consumers.
+ """
+ path= Client.urls['consumers']
+ return self._call(path, 'GET')
\ No newline at end of file