Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API does not have exchange to exchange binding #55

Open
nvalerkos opened this issue Sep 6, 2017 · 9 comments
Open

API does not have exchange to exchange binding #55

nvalerkos opened this issue Sep 6, 2017 · 9 comments

Comments

@nvalerkos
Copy link

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

@nvalerkos
Copy link
Author

also no delete binding.

@nvalerkos
Copy link
Author

` 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
Copy link
Author

nvalerkos commented Sep 6, 2017

` 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
Copy link
Author

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
Copy link
Author

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
Copy link

chaos95 commented Jun 26, 2018

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
Copy link
Author

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

@chaos95
Copy link

chaos95 commented Jun 26, 2018

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

@nvalerkos
Copy link
Author

nvalerkos commented Jun 26, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants