We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
rabbitmq_binding can't set empty routing_key
<!--- Verify first that your issue/request is not already reported in GitHub -->
##### ISSUE TYPE

<!--- Pick one below and delete the rest: -->
- Bug Report
##### COMPONENT NAME

<!--- Name of the plugin/module/task -->

messaging/rabbitmq_binding
##### ANSIBLE VERSION

```
ansible 2.0.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
```
##### CONFIGURATION

<!---
Mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->
##### OS / ENVIRONMENT

<!---
Mention the OS you are running Ansible from, and the OS you are
managing, or say “N/A” for anything that is not platform-specific.
-->

N/A
##### SUMMARY

<!--- Explain the problem briefly -->

Module set routing_key="#" by default, so rabbitmq can't work when routing_key isn't set in messages. I'm tried to set routing_key='' in task, but ansible just mark it as OK and doesn't add binding.
##### STEPS TO REPRODUCE

```
-  rabbitmq_binding: name=mailer destination=mailer type=queue
```

<!--- You can also paste gist.github.com links for larger files -->
##### EXPECTED RESULTS

<!--- What did you expect to happen when running the steps above? -->

```
$ rabbitmqctl list_bindings
Listing bindings ...
  exchange  mailer  queue  mailer  []
mailer  exchange  mailer  queue    []
$
```
##### ACTUAL RESULTS

<!--- What actually happened? If possible run with high verbosity (-vvvv) -->

```
$ rabbitmqctl list_bindings
Listing bindings ...
  exchange  mailer  queue  mailer  []
mailer  exchange  mailer  queue  #  []
$
```

<!--- Paste verbatim command output between quotes -->

```
TASK [RabbitMQ : add rabbitmq bindings] ****************************************
ok: [%host_ip%] => (item={u'source': u'mailer', u'destination': u'mailer', u'destination_type': u'queue'})
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `messaging/rabbitmq_binding.py`
Content:
```
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 
4 # (c) 2015, Manuel Sousa <manuel.sousa@gmail.com>
5 #
6 # This file is part of Ansible
7 #
8 # Ansible is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # Ansible is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with Ansible.  If not, see <http://www.gnu.org/licenses/>.
20 #
21 
22 DOCUMENTATION = '''
23 ---
24 module: rabbitmq_binding
25 author: "Manuel Sousa (@manuel-sousa)"
26 version_added: "2.0"
27 
28 short_description: This module manages rabbitMQ bindings
29 description:
30   - This module uses rabbitMQ Rest API to create/delete bindings
31 requirements: [ python requests ]
32 options:
33     state:
34         description:
35             - Whether the exchange should be present or absent
36             - Only present implemented atm
37         choices: [ "present", "absent" ]
38         required: false
39         default: present
40     name:
41         description:
42             - source exchange to create binding on
43         required: true
44         aliases: [ "src", "source" ]
45     login_user:
46         description:
47             - rabbitMQ user for connection
48         required: false
49         default: guest
50     login_password:
51         description:
52             - rabbitMQ password for connection
53         required: false
54         default: false
55     login_host:
56         description:
57             - rabbitMQ host for connection
58         required: false
59         default: localhost
60     login_port:
61         description:
62             - rabbitMQ management api port
63         required: false
64         default: 15672
65     vhost:
66         description:
67             - rabbitMQ virtual host
68             - default vhost is /
69         required: false
70         default: "/"
71     destination:
72         description:
73             - destination exchange or queue for the binding
74         required: true
75         aliases: [ "dst", "dest" ]
76     destination_type:
77         description:
78             - Either queue or exchange
79         required: true
80         choices: [ "queue", "exchange" ]
81         aliases: [ "type", "dest_type" ]
82     routing_key:
83         description:
84             - routing key for the binding
85             - default is #
86         required: false
87         default: "#"
88     arguments:
89         description:
90             - extra arguments for exchange. If defined this argument is a key/value dictionary
91         required: false
92         default: {}
93 '''
94 
95 EXAMPLES = '''
96 # Bind myQueue to directExchange with routing key info
97 - rabbitmq_binding: name=directExchange destination=myQueue type=queue routing_key=info
98 
99 # Bind directExchange to topicExchange with routing key *.info
100 - rabbitmq_binding: name=topicExchange destination=topicExchange type=exchange routing_key="*.info"
101 '''
102 
103 import requests
104 import urllib
105 import json
106 
107 def main():
108     module = AnsibleModule(
109         argument_spec = dict(
110             state = dict(default='present', choices=['present', 'absent'], type='str'),
111             name = dict(required=True, aliases=[ "src", "source" ], type='str'),
112             login_user = dict(default='guest', type='str'),
113             login_password = dict(default='guest', type='str', no_log=True),
114             login_host = dict(default='localhost', type='str'),
115             login_port = dict(default='15672', type='str'),
116             vhost = dict(default='/', type='str'),
117             destination = dict(required=True, aliases=[ "dst", "dest"], type='str'),
118             destination_type = dict(required=True, aliases=[ "type", "dest_type"], choices=[ "queue", "exchange" ],type='str'),
119             routing_key = dict(default='#', type='str'),
120             arguments = dict(default=dict(), type='dict')
121         ),
122         supports_check_mode = True
123     )
124 
125     if module.params['destination_type'] == "queue":
126         dest_type="q"
127     else:
128         dest_type="e"
129 
130     url = "http://%s:%s/api/bindings/%s/e/%s/%s/%s/%s" % (
131         module.params['login_host'],
132         module.params['login_port'],
133         urllib.quote(module.params['vhost'],''),
134         urllib.quote(module.params['name'],''),
135         dest_type,
136         urllib.quote(module.params['destination'],''),
137         urllib.quote(module.params['routing_key'],'')
138     )
139 
140     # Check if exchange already exists
141     r = requests.get( url, auth=(module.params['login_user'],module.params['login_password']))
142 
143     if r.status_code==200:
144         binding_exists = True
145         response = r.json()
146     elif r.status_code==404:
147         binding_exists = False
148         response = r.text
149     else:
150         module.fail_json(
151             msg = "Invalid response from RESTAPI when trying to check if exchange exists",
152             details = r.text
153         )
154 
155     if module.params['state']=='present':
156         change_required = not binding_exists
157     else:
158         change_required = binding_exists
159 
160     # Exit if check_mode
161     if module.check_mode:
162         module.exit_json(
163             changed= change_required,
164             name = module.params['name'],
165             details = response,
166             arguments = module.params['arguments']
167         )
168 
169     # Do changes
170     if change_required:
171         if module.params['state'] == 'present':
172             url = "http://%s:%s/api/bindings/%s/e/%s/%s/%s" % (
173                 module.params['login_host'],
174                 module.params['login_port'],
175                 urllib.quote(module.params['vhost'],''),
176                 urllib.quote(module.params['name'],''),
177                 dest_type,
178                 urllib.quote(module.params['destination'],'')
179             )
180 
181             r = requests.post(
182                     url,
183                     auth = (module.params['login_user'],module.params['login_password']),
184                     headers = { "content-type": "application/json"},
185                     data = json.dumps({
186                         "routing_key": module.params['routing_key'],
187                         "arguments": module.params['arguments']
188                     })
189                 )
190         elif module.params['state'] == 'absent':
191             r = requests.delete( url, auth = (module.params['login_user'],module.params['login_password']))
192 
193         if r.status_code == 204 or r.status_code == 201:
194             module.exit_json(
195                 changed = True,
196                 name = module.params['name'],
197                 destination = module.params['destination']
198             )
199         else:
200             module.fail_json(
201                 msg = "Error creating exchange",
202                 status = r.status_code,
203                 details = r.text
204             )
205 
206     else:
207         module.exit_json(
208             changed = False,
209             name = module.params['name']
210         )
211 
212 # import module snippets
213 from ansible.module_utils.basic import *
214 main()
215
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/messaging/rabbitmq_binding.py b/messaging/rabbitmq_binding.py
--- a/messaging/rabbitmq_binding.py
+++ b/messaging/rabbitmq_binding.py
@@ -127,6 +127,11 @@
     else:
         dest_type="e"
 
+    if module.params['routing_key'] == "":
+        props = "~"
+    else:
+        props = urllib.quote(module.params['routing_key'],'')
+
     url = "http://%s:%s/api/bindings/%s/e/%s/%s/%s/%s" % (
         module.params['login_host'],
         module.params['login_port'],
@@ -134,7 +139,7 @@
         urllib.quote(module.params['name'],''),
         dest_type,
         urllib.quote(module.params['destination'],''),
-        urllib.quote(module.params['routing_key'],'')
+        props
     )
 
     # Check if exchange already exists

{"golden_diff": "diff --git a/messaging/rabbitmq_binding.py b/messaging/rabbitmq_binding.py\n--- a/messaging/rabbitmq_binding.py\n+++ b/messaging/rabbitmq_binding.py\n@@ -127,6 +127,11 @@\n     else:\n         dest_type=\"e\"\n \n+    if module.params['routing_key'] == \"\":\n+        props = \"~\"\n+    else:\n+        props = urllib.quote(module.params['routing_key'],'')\n+\n     url = \"http://%s:%s/api/bindings/%s/e/%s/%s/%s/%s\" % (\n         module.params['login_host'],\n         module.params['login_port'],\n@@ -134,7 +139,7 @@\n         urllib.quote(module.params['name'],''),\n         dest_type,\n         urllib.quote(module.params['destination'],''),\n-        urllib.quote(module.params['routing_key'],'')\n+        props\n     )\n \n     # Check if exchange already exists\n", "issue": "rabbitmq_binding can't set empty routing_key\n<!--- Verify first that your issue/request is not already reported in GitHub -->\n##### ISSUE TYPE\n\n<!--- Pick one below and delete the rest: -->\n- Bug Report\n##### COMPONENT NAME\n\n<!--- Name of the plugin/module/task -->\n\nmessaging/rabbitmq_binding\n##### ANSIBLE VERSION\n\n```\nansible 2.0.1.0\n  config file = /etc/ansible/ansible.cfg\n  configured module search path = Default w/o overrides\n```\n##### CONFIGURATION\n\n<!---\nMention any settings you have changed/added/removed in ansible.cfg\n(or using the ANSIBLE_* environment variables).\n-->\n##### OS / ENVIRONMENT\n\n<!---\nMention the OS you are running Ansible from, and the OS you are\nmanaging, or say \u201cN/A\u201d for anything that is not platform-specific.\n-->\n\nN/A\n##### SUMMARY\n\n<!--- Explain the problem briefly -->\n\nModule set routing_key=\"#\" by default, so rabbitmq can't work when routing_key isn't set in messages. I'm tried to set routing_key='' in task, but ansible just mark it as OK and doesn't add binding.\n##### STEPS TO REPRODUCE\n\n```\n-  rabbitmq_binding: name=mailer destination=mailer type=queue\n```\n\n<!--- You can also paste gist.github.com links for larger files -->\n##### EXPECTED RESULTS\n\n<!--- What did you expect to happen when running the steps above? -->\n\n```\n$ rabbitmqctl list_bindings\nListing bindings ...\n  exchange  mailer  queue  mailer  []\nmailer  exchange  mailer  queue    []\n$\n```\n##### ACTUAL RESULTS\n\n<!--- What actually happened? If possible run with high verbosity (-vvvv) -->\n\n```\n$ rabbitmqctl list_bindings\nListing bindings ...\n  exchange  mailer  queue  mailer  []\nmailer  exchange  mailer  queue  #  []\n$\n```\n\n<!--- Paste verbatim command output between quotes -->\n\n```\nTASK [RabbitMQ : add rabbitmq bindings] ****************************************\nok: [%host_ip%] => (item={u'source': u'mailer', u'destination': u'mailer', u'destination_type': u'queue'})\n```\n\n", "before_files": [{"content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# (c) 2015, Manuel Sousa <manuel.sousa@gmail.com>\n#\n# This file is part of Ansible\n#\n# Ansible is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# Ansible is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with Ansible.  If not, see <http://www.gnu.org/licenses/>.\n#\n\nDOCUMENTATION = '''\n---\nmodule: rabbitmq_binding\nauthor: \"Manuel Sousa (@manuel-sousa)\"\nversion_added: \"2.0\"\n\nshort_description: This module manages rabbitMQ bindings\ndescription:\n  - This module uses rabbitMQ Rest API to create/delete bindings\nrequirements: [ python requests ]\noptions:\n    state:\n        description:\n            - Whether the exchange should be present or absent\n            - Only present implemented atm\n        choices: [ \"present\", \"absent\" ]\n        required: false\n        default: present\n    name:\n        description:\n            - source exchange to create binding on\n        required: true\n        aliases: [ \"src\", \"source\" ]\n    login_user:\n        description:\n            - rabbitMQ user for connection\n        required: false\n        default: guest\n    login_password:\n        description:\n            - rabbitMQ password for connection\n        required: false\n        default: false\n    login_host:\n        description:\n            - rabbitMQ host for connection\n        required: false\n        default: localhost\n    login_port:\n        description:\n            - rabbitMQ management api port\n        required: false\n        default: 15672\n    vhost:\n        description:\n            - rabbitMQ virtual host\n            - default vhost is /\n        required: false\n        default: \"/\"\n    destination:\n        description:\n            - destination exchange or queue for the binding\n        required: true\n        aliases: [ \"dst\", \"dest\" ]\n    destination_type:\n        description:\n            - Either queue or exchange\n        required: true\n        choices: [ \"queue\", \"exchange\" ]\n        aliases: [ \"type\", \"dest_type\" ]\n    routing_key:\n        description:\n            - routing key for the binding\n            - default is #\n        required: false\n        default: \"#\"\n    arguments:\n        description:\n            - extra arguments for exchange. If defined this argument is a key/value dictionary\n        required: false\n        default: {}\n'''\n\nEXAMPLES = '''\n# Bind myQueue to directExchange with routing key info\n- rabbitmq_binding: name=directExchange destination=myQueue type=queue routing_key=info\n\n# Bind directExchange to topicExchange with routing key *.info\n- rabbitmq_binding: name=topicExchange destination=topicExchange type=exchange routing_key=\"*.info\"\n'''\n\nimport requests\nimport urllib\nimport json\n\ndef main():\n    module = AnsibleModule(\n        argument_spec = dict(\n            state = dict(default='present', choices=['present', 'absent'], type='str'),\n            name = dict(required=True, aliases=[ \"src\", \"source\" ], type='str'),\n            login_user = dict(default='guest', type='str'),\n            login_password = dict(default='guest', type='str', no_log=True),\n            login_host = dict(default='localhost', type='str'),\n            login_port = dict(default='15672', type='str'),\n            vhost = dict(default='/', type='str'),\n            destination = dict(required=True, aliases=[ \"dst\", \"dest\"], type='str'),\n            destination_type = dict(required=True, aliases=[ \"type\", \"dest_type\"], choices=[ \"queue\", \"exchange\" ],type='str'),\n            routing_key = dict(default='#', type='str'),\n            arguments = dict(default=dict(), type='dict')\n        ),\n        supports_check_mode = True\n    )\n\n    if module.params['destination_type'] == \"queue\":\n        dest_type=\"q\"\n    else:\n        dest_type=\"e\"\n\n    url = \"http://%s:%s/api/bindings/%s/e/%s/%s/%s/%s\" % (\n        module.params['login_host'],\n        module.params['login_port'],\n        urllib.quote(module.params['vhost'],''),\n        urllib.quote(module.params['name'],''),\n        dest_type,\n        urllib.quote(module.params['destination'],''),\n        urllib.quote(module.params['routing_key'],'')\n    )\n\n    # Check if exchange already exists\n    r = requests.get( url, auth=(module.params['login_user'],module.params['login_password']))\n\n    if r.status_code==200:\n        binding_exists = True\n        response = r.json()\n    elif r.status_code==404:\n        binding_exists = False\n        response = r.text\n    else:\n        module.fail_json(\n            msg = \"Invalid response from RESTAPI when trying to check if exchange exists\",\n            details = r.text\n        )\n\n    if module.params['state']=='present':\n        change_required = not binding_exists\n    else:\n        change_required = binding_exists\n\n    # Exit if check_mode\n    if module.check_mode:\n        module.exit_json(\n            changed= change_required,\n            name = module.params['name'],\n            details = response,\n            arguments = module.params['arguments']\n        )\n\n    # Do changes\n    if change_required:\n        if module.params['state'] == 'present':\n            url = \"http://%s:%s/api/bindings/%s/e/%s/%s/%s\" % (\n                module.params['login_host'],\n                module.params['login_port'],\n                urllib.quote(module.params['vhost'],''),\n                urllib.quote(module.params['name'],''),\n                dest_type,\n                urllib.quote(module.params['destination'],'')\n            )\n\n            r = requests.post(\n                    url,\n                    auth = (module.params['login_user'],module.params['login_password']),\n                    headers = { \"content-type\": \"application/json\"},\n                    data = json.dumps({\n                        \"routing_key\": module.params['routing_key'],\n                        \"arguments\": module.params['arguments']\n                    })\n                )\n        elif module.params['state'] == 'absent':\n            r = requests.delete( url, auth = (module.params['login_user'],module.params['login_password']))\n\n        if r.status_code == 204 or r.status_code == 201:\n            module.exit_json(\n                changed = True,\n                name = module.params['name'],\n                destination = module.params['destination']\n            )\n        else:\n            module.fail_json(\n                msg = \"Error creating exchange\",\n                status = r.status_code,\n                details = r.text\n            )\n\n    else:\n        module.exit_json(\n            changed = False,\n            name = module.params['name']\n        )\n\n# import module snippets\nfrom ansible.module_utils.basic import *\nmain()\n", "path": "messaging/rabbitmq_binding.py"}], "after_files": [{"content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# (c) 2015, Manuel Sousa <manuel.sousa@gmail.com>\n#\n# This file is part of Ansible\n#\n# Ansible is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# Ansible is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with Ansible.  If not, see <http://www.gnu.org/licenses/>.\n#\n\nDOCUMENTATION = '''\n---\nmodule: rabbitmq_binding\nauthor: \"Manuel Sousa (@manuel-sousa)\"\nversion_added: \"2.0\"\n\nshort_description: This module manages rabbitMQ bindings\ndescription:\n  - This module uses rabbitMQ Rest API to create/delete bindings\nrequirements: [ python requests ]\noptions:\n    state:\n        description:\n            - Whether the exchange should be present or absent\n            - Only present implemented atm\n        choices: [ \"present\", \"absent\" ]\n        required: false\n        default: present\n    name:\n        description:\n            - source exchange to create binding on\n        required: true\n        aliases: [ \"src\", \"source\" ]\n    login_user:\n        description:\n            - rabbitMQ user for connection\n        required: false\n        default: guest\n    login_password:\n        description:\n            - rabbitMQ password for connection\n        required: false\n        default: false\n    login_host:\n        description:\n            - rabbitMQ host for connection\n        required: false\n        default: localhost\n    login_port:\n        description:\n            - rabbitMQ management api port\n        required: false\n        default: 15672\n    vhost:\n        description:\n            - rabbitMQ virtual host\n            - default vhost is /\n        required: false\n        default: \"/\"\n    destination:\n        description:\n            - destination exchange or queue for the binding\n        required: true\n        aliases: [ \"dst\", \"dest\" ]\n    destination_type:\n        description:\n            - Either queue or exchange\n        required: true\n        choices: [ \"queue\", \"exchange\" ]\n        aliases: [ \"type\", \"dest_type\" ]\n    routing_key:\n        description:\n            - routing key for the binding\n            - default is #\n        required: false\n        default: \"#\"\n    arguments:\n        description:\n            - extra arguments for exchange. If defined this argument is a key/value dictionary\n        required: false\n        default: {}\n'''\n\nEXAMPLES = '''\n# Bind myQueue to directExchange with routing key info\n- rabbitmq_binding: name=directExchange destination=myQueue type=queue routing_key=info\n\n# Bind directExchange to topicExchange with routing key *.info\n- rabbitmq_binding: name=topicExchange destination=topicExchange type=exchange routing_key=\"*.info\"\n'''\n\nimport requests\nimport urllib\nimport json\n\ndef main():\n    module = AnsibleModule(\n        argument_spec = dict(\n            state = dict(default='present', choices=['present', 'absent'], type='str'),\n            name = dict(required=True, aliases=[ \"src\", \"source\" ], type='str'),\n            login_user = dict(default='guest', type='str'),\n            login_password = dict(default='guest', type='str', no_log=True),\n            login_host = dict(default='localhost', type='str'),\n            login_port = dict(default='15672', type='str'),\n            vhost = dict(default='/', type='str'),\n            destination = dict(required=True, aliases=[ \"dst\", \"dest\"], type='str'),\n            destination_type = dict(required=True, aliases=[ \"type\", \"dest_type\"], choices=[ \"queue\", \"exchange\" ],type='str'),\n            routing_key = dict(default='#', type='str'),\n            arguments = dict(default=dict(), type='dict')\n        ),\n        supports_check_mode = True\n    )\n\n    if module.params['destination_type'] == \"queue\":\n        dest_type=\"q\"\n    else:\n        dest_type=\"e\"\n\n    if module.params['routing_key'] == \"\":\n        props = \"~\"\n    else:\n        props = urllib.quote(module.params['routing_key'],'')\n\n    url = \"http://%s:%s/api/bindings/%s/e/%s/%s/%s/%s\" % (\n        module.params['login_host'],\n        module.params['login_port'],\n        urllib.quote(module.params['vhost'],''),\n        urllib.quote(module.params['name'],''),\n        dest_type,\n        urllib.quote(module.params['destination'],''),\n        props\n    )\n\n    # Check if exchange already exists\n    r = requests.get( url, auth=(module.params['login_user'],module.params['login_password']))\n\n    if r.status_code==200:\n        binding_exists = True\n        response = r.json()\n    elif r.status_code==404:\n        binding_exists = False\n        response = r.text\n    else:\n        module.fail_json(\n            msg = \"Invalid response from RESTAPI when trying to check if exchange exists\",\n            details = r.text\n        )\n\n    if module.params['state']=='present':\n        change_required = not binding_exists\n    else:\n        change_required = binding_exists\n\n    # Exit if check_mode\n    if module.check_mode:\n        module.exit_json(\n            changed= change_required,\n            name = module.params['name'],\n            details = response,\n            arguments = module.params['arguments']\n        )\n\n    # Do changes\n    if change_required:\n        if module.params['state'] == 'present':\n            url = \"http://%s:%s/api/bindings/%s/e/%s/%s/%s\" % (\n                module.params['login_host'],\n                module.params['login_port'],\n                urllib.quote(module.params['vhost'],''),\n                urllib.quote(module.params['name'],''),\n                dest_type,\n                urllib.quote(module.params['destination'],'')\n            )\n\n            r = requests.post(\n                    url,\n                    auth = (module.params['login_user'],module.params['login_password']),\n                    headers = { \"content-type\": \"application/json\"},\n                    data = json.dumps({\n                        \"routing_key\": module.params['routing_key'],\n                        \"arguments\": module.params['arguments']\n                    })\n                )\n        elif module.params['state'] == 'absent':\n            r = requests.delete( url, auth = (module.params['login_user'],module.params['login_password']))\n\n        if r.status_code == 204 or r.status_code == 201:\n            module.exit_json(\n                changed = True,\n                name = module.params['name'],\n                destination = module.params['destination']\n            )\n        else:\n            module.fail_json(\n                msg = \"Error creating exchange\",\n                status = r.status_code,\n                details = r.text\n            )\n\n    else:\n        module.exit_json(\n            changed = False,\n            name = module.params['name']\n        )\n\n# import module snippets\nfrom ansible.module_utils.basic import *\nmain()\n", "path": "messaging/rabbitmq_binding.py"}]}