def create_vhost(broker: dict, vhost: str) -> None: if is_present(broker=broker, vhost=vhost): raise VhostAlreadyExists(vhost) url = 'https://{}/api/vhosts/{}'.format(broker['host'], vhost) response = requests.put('https://{}/api/vhosts/{}'.format( broker['host'], vhost), auth=(broker['user'], broker['passwd'])) handle_rest_response(response=response, url=url)
def get_bindings(broker: dict, vhost: str) -> List[Binding]: url = 'https://{}/api/bindings/{}'.format(broker['host'], vhost) response = requests.get(url=url, auth=(broker['user'], broker['passwd'])) handle_rest_response(response=response, url=url) return map(lambda i: Binding(i), response.json())
def delete_binding(broker: dict, vhost: str, binding: Binding) -> None: url = 'https://{}/api/bindings/{}/{}/{}'.format(broker['host'], vhost, binding.path(), binding.properties_key) response = requests.delete(url=url, auth=(broker['user'], broker['passwd'])) handle_rest_response(response=response, url=url)
def get_permissions(broker: dict, vhost: str, user: str) -> dict: url = 'https://{}/api/permissions/{}/{}'.format(broker['host'], vhost, user) response = requests.get(url=url, auth=(broker['user'], broker['passwd'])) handle_rest_response(response=response, url=url) return response.json()
def delete_permissions(broker: dict, vhost: str, user: str) -> None: url = 'https://{}/api/permissions/{}/{}'.format(broker['host'], vhost, user) response = requests.delete(url=url, auth=(broker['user'], broker['passwd'])) handle_rest_response(response=response, url=url)
def delete_user(broker: dict, name: str) -> None: url = 'https://{}/api/users/{}'.format(broker['host'], name) response = requests.delete(url=url, auth=(broker['user'], broker['passwd'])) handle_rest_response(response=response, url=url)
def get_users(broker: dict) -> dict: url = 'https://{}/api/users'.format(broker['host']) response = requests.get(url=url, auth=(broker['user'], broker['passwd'])) handle_rest_response(response=response, url=url) return map(lambda i: i['name'], response.json())
def get_user_by_name(broker: dict, name: str) -> dict: url = 'https://{}/api/users/{}'.format(broker['host'], name) response = requests.get(url=url, auth=(broker['user'], broker['passwd'])) handle_rest_response(response=response, url=url) return response.json()
def delete_vhost(broker: dict, vhost: str) -> None: if not is_present(broker=broker, vhost=vhost): raise VhostNotFound(vhost) url = 'https://{}/api/vhosts/{}'.format(broker['host'], vhost) response = requests.delete(url, auth=(broker['user'], broker['passwd'])) handle_rest_response(response=response, url=url)