bkjones / pyrabbit

A Python module to communicate w/ the RabbitMQ HTTP Management API
http://pyrabbit.readthedocs.org
BSD 3-Clause "New" or "Revised" License
97 stars 86 forks source link

API does not have exchange to exchange binding #55

Open nvalerkos opened 7 years ago

nvalerkos commented 7 years ago

ie. /api/bindings/[VHOST]/e/[SourceExchange]/e/[TargetExchange] JSON {"vhost":"vhostname","source":"SourceExchange","destination_type":"e","destination":"TargetExchange","routing_key":"","arguments":{}}

nvalerkos commented 7 years ago

also no delete binding.

nvalerkos commented 7 years ago

` def delete_binding_exchange(self, vhost, exchange_source, exchange_destination, properties_key="~"): """ Deletes a binding between an exchange and an exchange on a given vhost.

    :param string vhost: vhost housing the exchange/queue to bind
    :param string exchange_source: the source exchange for the binding
    :param string exchange_destination: the target exchange to bind to the source exchange
    :param string properties_key: the routing key to use for the binding
    """

    vhost = quote(vhost, '')
    exchange_source = quote(exchange_source, '')
    exchange_destination = quote(exchange_destination, '')
    if properties_key == "~":
        body = json.dumps({"vhost":vhost,"source":exchange_source,"destination_type":"e","destination":exchange_destination,"properties_key":""})
    else:
        body = json.dumps({"vhost":vhost,"source":exchange_source,"destination_type":"e","destination":exchange_destination,"properties_key":properties_key})
    path = Client.urls['rt_bindings_between_exch_exch'] % (vhost,
                                                            exchange_source,
                                                            exchange_destination,
                                                            properties_key
                                                            )
    return self.http.do_call(path, 'DELETE', body=body, headers=Client.json_headers)`
nvalerkos commented 7 years ago

` def create_binding_exchange(self, vhost, exchange_source, exchange_destination, properties_key="", args=None): """ Creates a binding between an exchange and an exchange on a given vhost.

    :param string vhost: vhost housing the exchange/queue to bind
    :param string exchange_source: the source exchange of the binding
    :param string exchange_destination: the exchange to bind to the exchange
    :param string properties_key: the routing key to use for the binding
    :param list args: extra arguments to associate w/ the binding.
    :returns: boolean
    """

    vhost = quote(vhost, '')
    exchange_source = quote(exchange_source, '')
    exchange_destination = quote(exchange_destination, '')
    body = json.dumps({"vhost":vhost,"source":exchange_source,"destination_type":"e","destination":exchange_destination,"properties_key": properties_key, "arguments":args or []})
    path = Client.urls['bindings_between_exch_exch'] % (vhost,
                                                         exchange_source,
                                                         exchange_destination)
    binding = self.http.do_call(path, 'POST', body=body,
                                headers=Client.json_headers)
    return binding`
nvalerkos commented 7 years ago

I forgot to add the urls add those between 86-87 line: 'bindings_between_exch_exch': 'bindings/%s/e/%s/e/%s', 'rt_bindings_between_exch_exch': 'bindings/%s/e/%s/e/%s/%s',

nvalerkos commented 7 years ago

please also add:

` def create_policy(self, vhost, name, pattern, apply_to, definition): """ Creates a policy to the server.

    :param string vhost: vhost housing of the policy to be created.
    :param string name: Name of the policy to be created.
    :param string pattern: Pattern of the policy to be applied.
    :param string apply_to: Apply to 'queues' or 'exchanges' or 'all'.
    :param string definition: Definition of the policy to create.
    """
    vhost = quote(vhost, '')
    name = quote(name, '')

    body = json.dumps({"vhost":vhost,"name":name,"pattern":pattern,"apply-to":apply_to,"definition": definition})
    path = Client.urls['policies'] % (vhost,
                                        name)
    return self.http.do_call(path, 'PUT', body=body, headers=Client.json_headers)

def delete_policy(self, vhost, name):
    """
    Deletes a policy from the server.

    :param string vhost: vhost housing of the policy to delete
    :param string name: Name of the policy to delete from the server.
    """
    vhost = quote(vhost, '')
    name = quote(name, '')
    body = json.dumps({"vhost":vhost,"name":name,"component":"policy"})
    path = Client.urls['policies'] % (vhost,
                                        name)
    return self.http.do_call(path, 'DELETE', body=body, headers=Client.json_headers)

` and on the urls the 95 before the }

,'policies': 'policies/%s/%s'

chaos95 commented 6 years ago

I'm a bit late to this party, but I have a fork that adds exchange to exchange bindings at https://github.com/chaos95/pyrabbit

nvalerkos commented 6 years ago

Yeap.. A bit. Can you make the change on yours?

chaos95 commented 6 years ago

I'll take a crack at it; give me a day or two :)

nvalerkos commented 6 years ago

No worries

On Tue, Jun 26, 2018, 08:17 Morgan Larosa notifications@github.com wrote:

I'll take a crack at it; give me a day or two :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bkjones/pyrabbit/issues/55#issuecomment-400181529, or mute the thread https://github.com/notifications/unsubscribe-auth/AeOSt0NxyQjUynRgtqz8_ey8lZs6FSE2ks5uAcPQgaJpZM4POHv6 .