azure.servicebus.management package

class azure.servicebus.management.AccessRights(value)[source]

Access rights of the entity

listen = 'Listen'
manage = 'Manage'
send = 'Send'
class azure.servicebus.management.AuthorizationRule(*, type: Optional[str] = None, claim_type: Optional[str] = None, claim_value: Optional[str] = None, rights: Optional[List[str]] = None, created_time: Optional[datetime.datetime] = None, modified_time: Optional[datetime.datetime] = None, key_name: Optional[str] = None, primary_key: Optional[str] = None, secondary_key: Optional[str] = None, **kwargs)[source]

Authorization rule of an entity.

Parameters
  • type (str) –

  • claim_type (str) –

  • claim_value (str) –

  • rights (list[str]) – Access rights of the entity. Values are ‘Send’, ‘Listen’, or ‘Manage’.

  • created_time (datetime) – The date and time when the authorization rule was created.

  • modified_time (datetime) – The date and time when the authorization rule was modified.

  • key_name (str) – The authorization rule key name.

  • primary_key (str) – The primary key of the authorization rule.

  • secondary_key (str) – The primary key of the authorization rule.

as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionaly use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

key_transformer (function) – A key transformer function.

Returns

A dict JSON compatible object

Return type

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod enable_additional_properties_sending()
classmethod from_dict(data, key_extractors=None, content_type=None)

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod is_xml_model()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict

validate()

Validate this model recursively and return a list of ValidationError.

Returns

A list of validation error

Return type

list

class azure.servicebus.management.EntityAvailabilityStatus(value)[source]

Availibility status of the entity

available = 'Available'
limited = 'Limited'
renaming = 'Renaming'
restoring = 'Restoring'
unknown = 'Unknown'
class azure.servicebus.management.EntityStatus(value)[source]

Status of a Service Bus resource

active = 'Active'
creating = 'Creating'
deleting = 'Deleting'
disabled = 'Disabled'
receive_disabled = 'ReceiveDisabled'
renaming = 'Renaming'
restoring = 'Restoring'
send_disabled = 'SendDisabled'
unknown = 'Unknown'
class azure.servicebus.management.MessageCountDetails(*, active_message_count: Optional[int] = None, dead_letter_message_count: Optional[int] = None, scheduled_message_count: Optional[int] = None, transfer_dead_letter_message_count: Optional[int] = None, transfer_message_count: Optional[int] = None, **kwargs)[source]

Details about the message counts in queue.

Parameters
  • active_message_count (int) – Number of active messages in the queue, topic, or subscription.

  • dead_letter_message_count (int) – Number of messages that are dead lettered.

  • scheduled_message_count (int) – Number of scheduled messages.

  • transfer_dead_letter_message_count (int) – Number of messages transferred into dead letters.

  • transfer_message_count (int) – Number of messages transferred to another queue, topic, or subscription.

as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionaly use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

key_transformer (function) – A key transformer function.

Returns

A dict JSON compatible object

Return type

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod enable_additional_properties_sending()
classmethod from_dict(data, key_extractors=None, content_type=None)

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod is_xml_model()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict

validate()

Validate this model recursively and return a list of ValidationError.

Returns

A list of validation error

Return type

list

class azure.servicebus.management.QueueDescription(**kwargs)[source]

Description of a Service Bus queue resource.

Parameters
  • queue_name (str) – Name of the queue.

  • authorization_rules (list[AuthorizationRule]) – Authorization rules for resource.

  • auto_delete_on_idle (timedelta) – ISO 8601 timeSpan idle interval after which the queue is automatically deleted. The minimum duration is 5 minutes.

  • dead_lettering_on_message_expiration (bool) – A value that indicates whether this queue has dead letter support when a message expires.

  • default_message_time_to_live (timedelta) – ISO 8601 default message timespan to live value. This is the duration after which the message expires, starting from when the message is sent to Service Bus. This is the default value used when TimeToLive is not set on a message itself.

  • duplicate_detection_history_time_window (timedelta) – ISO 8601 timeSpan structure that defines the duration of the duplicate detection history. The default value is 10 minutes.

  • entity_availability_status (str or EntityAvailabilityStatus) – Availibility status of the entity. Possible values include: “Available”, “Limited”, “Renaming”, “Restoring”, “Unknown”.

  • enable_batched_operations (bool) – Value that indicates whether server-side batched operations are enabled.

  • enable_express (bool) – A value that indicates whether Express Entities are enabled. An express queue holds a message in memory temporarily before writing it to persistent storage.

  • enable_partitioning (bool) – A value that indicates whether the queue is to be partitioned across multiple message brokers.

  • is_anonymous_accessible (bool) – A value indicating if the resource can be accessed without authorization.

  • lock_duration (timedelta) – ISO 8601 timespan duration of a peek-lock; that is, the amount of time that the message is locked for other receivers. The maximum value for LockDuration is 5 minutes; the default value is 1 minute.

  • max_delivery_count (int) – The maximum delivery count. A message is automatically deadlettered after this number of deliveries. Default value is 10.

  • max_size_in_megabytes (int) – The maximum size of the queue in megabytes, which is the size of memory allocated for the queue.

  • requires_duplicate_detection (bool) – A value indicating if this queue requires duplicate detection.

  • requires_session (bool) – A value that indicates whether the queue supports the concept of sessions.

  • status (str or EntityStatus) – Status of a Service Bus resource. Possible values include: “Active”, “Creating”, “Deleting”, “Disabled”, “ReceiveDisabled”, “Renaming”, “Restoring”, “SendDisabled”, “Unknown”.

  • support_ordering (bool) – A value that indicates whether the queue supports ordering.

class azure.servicebus.management.QueueRuntimeInfo(**kwargs)[source]

Service Bus queue metrics.

Parameters
  • queue_name (str) – Name of the queue.

  • accessed_at (datetime) – Last time a message was sent, or the last time there was a receive request to this queue.

  • created_at (datetime) – The exact time the queue was created.

  • updated_at (datetime) – The exact time a message was updated in the queue.

  • size_in_bytes (int) – The size of the queue, in bytes.

  • message_count (int) – The number of messages in the queue.

  • message_count_details (MessageCountDetails) – Details about the message counts in queue.

class azure.servicebus.management.ServiceBusManagementClient(fully_qualified_namespace: str, credential: Union[TokenCredential, ServiceBusSharedKeyCredential], **kwargs: Dict[str, Any])[source]

Use this client to create, update, list, and delete resources of a ServiceBus namespace.

Parameters
  • fully_qualified_namespace (str) – The fully qualified host name for the Service Bus namespace.

  • credential (Union[TokenCredential, ServiceBusSharedKeyCredential]) – To authenticate to manage the entities of the ServiceBus namespace.

create_queue(queue: Union[str, azure.servicebus.management._models.QueueDescription], **kwargs: Any) → azure.servicebus.management._models.QueueDescription[source]

Create a queue.

Parameters

queue (Union[str, QueueDescription]) – The queue name or a QueueDescription instance. When it’s a str, it will be the name of the created queue. Other properties of the created queue will have default values decided by the ServiceBus. Use a QueueDescription if you want to set queue properties other than the queue name.

Return type

QueueDescription

delete_queue(queue_name: str, **kwargs: Any)None[source]

Delete a queue.

Parameters

queue_name (str) – The name of the queue.

Return type

None

classmethod from_connection_string(conn_str: str, **kwargs: Any) → azure.servicebus.management._management_client.ServiceBusManagementClient[source]

Create a client from connection string.

Parameters

conn_str (str) – The connection string of the Service Bus Namespace.

Return type

ServiceBusManagementClient

get_queue(queue_name: str, **kwargs: Any) → azure.servicebus.management._models.QueueDescription[source]

Get a QueueDescription.

Parameters

queue_name (str) – The name of the queue.

Return type

QueueDescription

get_queue_runtime_info(queue_name: str, **kwargs: Any) → azure.servicebus.management._models.QueueRuntimeInfo[source]

Get the runtime information of a queue.

Parameters

queue_name (str) – The name of the queue.

Return type

QueueRuntimeInfo

list_queues(**kwargs: Any) → List[azure.servicebus.management._models.QueueDescription][source]

List the queues of a ServiceBus namespace.

Keyword Arguments
  • start_index (int) – skip this number of queues.

  • max_count (int) – return at most this number of queues if there are more than this number in the ServiceBus namespace.

Return type

List[QueueDescription]

list_queues_runtime_info(**kwargs: Any) → List[azure.servicebus.management._models.QueueRuntimeInfo][source]

List the runtime info of the queues in a ServiceBus namespace.

Keyword Arguments
  • start_index (int) – skip this number of queues.

  • max_count (int) – return at most this number of queues if there are more than this number in the ServiceBus namespace.

Return type

List[QueueRuntimeInfo]

update_queue(queue_description: azure.servicebus.management._models.QueueDescription, **kwargs: Any) → azure.servicebus.management._models.QueueDescription[source]

Update a queue.

Parameters

queue_description (QueueDescription) – The properties of this QueueDescription will be applied to the queue in ServiceBus. Only a portion of properties can be updated. Refer to https://docs.microsoft.com/en-us/rest/api/servicebus/update-queue.

Return type

QueueDescription