def from_connection_string(cls, conn_str, *, loop=None, **kwargs): """Create a Service Bus client from a connection string. :param conn_str: The connection string. :type conn_str: str Example: .. literalinclude:: ../examples/async_examples/test_examples_async.py :start-after: [START create_async_servicebus_client_connstr] :end-before: [END create_async_servicebus_client_connstr] :language: python :dedent: 4 :caption: Create a ServiceBusClient via a connection string. """ address, policy, key, _ = parse_conn_str(conn_str) parsed_namespace = urlparse(address) namespace, _, base = parsed_namespace.hostname.partition('.') return cls( service_namespace=namespace, shared_access_key_name=policy, shared_access_key_value=key, host_base='.' + base, loop=loop, **kwargs)
def from_connection_string(cls, conn_str, **kwargs): """Create a Service Bus client from a connection string. :param conn_str: The connection string. :type conn_str: str .. admonition:: Example: .. literalinclude:: ../samples/sync_samples/test_examples.py :start-after: [START create_servicebus_client_connstr] :end-before: [END create_servicebus_client_connstr] :language: python :dedent: 4 :caption: Create a ServiceBusClient via a connection string. """ address, policy, key, _, transport_type = parse_conn_str(conn_str) parsed_namespace = urlparse(address) namespace, _, base = parsed_namespace.hostname.partition('.') return cls( namespace, shared_access_key_name=policy, shared_access_key_value=key, transport_type=transport_type, host_base='.' + base, **kwargs)
def from_connection_string(cls, conn_str, name=None, **kwargs): """Create a Client from a Service Bus connection string. :param conn_str: The connection string. :type conn_str: str :param name: The name of the entity, if the 'EntityName' property is not included in the connection string. """ address, policy, key, entity = parse_conn_str(conn_str) entity = name or entity address = build_uri(address, entity) name = address.split('/')[-1] return cls(address, name, shared_access_key_name=policy, shared_access_key_value=key, **kwargs)
def from_connection_string(cls, conn_str, name, topic=None, **kwargs): # pylint: disable=arguments-differ """Create a SubscriptionClient from a connection string. :param conn_str: The connection string. :type conn_str: str :param name: The name of the Subscription. :type name: str :param topic: The name of the Topic, if the EntityName is not included in the connection string. :type topic: str """ address, policy, key, entity = parse_conn_str(conn_str) entity = topic or entity address = build_uri(address, entity) address += "/Subscriptions/" + name return cls(address, name, shared_access_key_name=policy, shared_access_key_value=key, **kwargs)
def from_connection_string(cls, conn_str, name, topic=None, **kwargs): # pylint: disable=arguments-differ """Create a SubscriptionClient from a connection string. :param conn_str: The connection string. :type conn_str: str :param name: The name of the Subscription. :type name: str :param topic: The name of the Topic, if the EntityName is not included in the connection string. :type topic: str """ address, policy, key, entity, transport_type = parse_conn_str(conn_str) entity = topic or entity address = build_uri(address, entity) address += "/Subscriptions/" + name return cls(address, name, shared_access_key_name=policy, shared_access_key_value=key, transport_type=transport_type, **kwargs)