@@ -34,11 +34,14 @@ def _handle_response_error():
34
34
try :
35
35
yield
36
36
except HttpResponseError as response_error :
37
- new_response_error = HttpResponseError (
38
- message = response_error .model .detail ,
39
- response = response_error .response ,
40
- model = response_error .model
41
- )
37
+ try :
38
+ new_response_error = HttpResponseError (
39
+ message = response_error .model .detail ,
40
+ response = response_error .response ,
41
+ model = response_error .model
42
+ )
43
+ except AttributeError :
44
+ new_response_error = response_error
42
45
raise new_response_error
43
46
44
47
@@ -54,13 +57,20 @@ def _convert_xml_to_object(queue_name, et, class_):
54
57
55
58
56
59
class ServiceBusManagementClient :
60
+ """Use this client to create, update, list, and delete resources of a ServiceBus namespace
61
+
62
+ :param str fully_qualified_namespace:
63
+ :param credential:
64
+ :type credential: Union[TokenCredential, ServiceBusSharedKeyCredential]
65
+ :keyword Pipeline pipeline: If omitted, the standard pipeline is used.
66
+ :keyword HttpTransport transport: If omitted, the standard pipeline is used.
67
+ :keyword List[HTTPPolicy] policies: If omitted, the standard pipeline is used.
68
+
69
+ For keyword arguments, refer to TODO: add a link here
70
+ """
57
71
58
72
def __init__ (self , fully_qualified_namespace , credential , ** kwargs ):
59
73
# type: (str, Union[TokenCredential, ServiceBusSharedKeyCredential], Dict[str, Any]) -> None
60
- """
61
- :param fully_qualified_namespace:
62
- :param kwargs:
63
- """
64
74
self .fully_qualified_namespace = fully_qualified_namespace
65
75
self ._credential = credential
66
76
self ._endpoint = "https://" + fully_qualified_namespace
@@ -93,12 +103,14 @@ def _build_pipeline(self, **kwargs): # pylint: disable=no-self-use
93
103
return Pipeline (transport , policies )
94
104
95
105
@classmethod
96
- def from_connection_string (cls , connection_string ):
97
- # type: (str) -> ServiceBusManagementClient
98
- """
106
+ def from_connection_string (cls , connection_string , ** kwargs ):
107
+ # type: (str, Any ) -> ServiceBusManagementClient
108
+ """Create a client from connection string
99
109
100
110
:param str connection_string:
101
- :return:
111
+ :keyword Pipeline pipeline: If omitted, the standard pipeline is used.
112
+ :keyword HttpTransport transport: If omitted, the standard pipeline is used.
113
+ :keyword List[HTTPPolicy] policies: If omitted, the standard pipeline is used.
102
114
"""
103
115
endpoint , shared_access_key_name , shared_access_key , _ = parse_conn_str (connection_string )
104
116
if "//" in endpoint :
@@ -141,16 +153,30 @@ def _list_queues(self, skip, max_count, class_):
141
153
142
154
def get_queue (self , queue_name ):
143
155
# type: (str) -> QueueDescription
156
+ """Get a QueueDescription
157
+
158
+ :param str queue_name: The name of the queue
159
+ """
144
160
return self ._get_queue_object (queue_name , QueueDescription )
145
161
146
162
def get_queue_runtime_info (self , queue_name ):
147
163
# type: (str) -> QueueRuntimeInfo
164
+ """Get the runtime information of a queue
165
+
166
+ :param str queue_name: The name of the queue
167
+ """
148
168
return self ._get_queue_object (queue_name , QueueRuntimeInfo )
149
169
150
170
def create_queue (self , queue ):
151
171
# type: (Union[str, QueueDescription]) -> QueueDescription
152
- """Create a queue"""
153
-
172
+ """Create a queue
173
+
174
+ :param queue: The queue name or a `QueueDescription` instance. When it's a str, it will be the name
175
+ of the created queue. Other properties of the created queue will have default values decided by the
176
+ ServiceBus. Use a `QueueDesceiption` if you want to set queue properties other than the queue name.
177
+ :type queue: Union[str, QueueDescription].
178
+ :returns: `QueueDescription` returned from ServiceBus.
179
+ """
154
180
queue_name = None
155
181
try :
156
182
queue_name = queue .queue_name # type: ignore
@@ -182,7 +208,13 @@ def create_queue(self, queue):
182
208
183
209
def update_queue (self , queue_description ):
184
210
# type: (QueueDescription) -> QueueDescription
185
- """Update a queue"""
211
+ """
212
+
213
+ :param queue_description: The properties of this `QueueDescription` will be applied to the queue in
214
+ ServiceBus. Only a portion of properties can be updated.
215
+ Refer to https://docs.microsoft.com/en-us/rest/api/servicebus/update-queue.
216
+ :type queue_description: QueueDescription
217
+ """
186
218
if not queue_description .queue_name :
187
219
raise ValueError ("queue_description must have a non-empty queue_name" )
188
220
@@ -208,7 +240,10 @@ def update_queue(self, queue_description):
208
240
209
241
def delete_queue (self , queue_name ):
210
242
# type: (str) -> None
211
- """Create a queue"""
243
+ """Delete a queue
244
+
245
+ :param str queue_name: The name of the queue
246
+ """
212
247
213
248
if not queue_name :
214
249
raise ValueError ("queue_name must not be None or empty" )
@@ -217,8 +252,20 @@ def delete_queue(self, queue_name):
217
252
218
253
def list_queues (self , skip = 0 , max_count = 100 ):
219
254
# type: (int, int) -> List[QueueDescription]
255
+ """List the queues of a ServiceBus namespace
256
+
257
+ :param int skip: skip this number of queues
258
+ :param int max_count: return at most this number of queues if there are more than this number in
259
+ the ServiceBus namespace
260
+ """
220
261
return self ._list_queues (skip , max_count , QueueDescription )
221
262
222
263
def list_queues_runtime_info (self , skip = 0 , max_count = 100 ):
223
264
# type: (int, int) -> List[QueueRuntimeInfo]
265
+ """List the queues runtime info of a ServiceBus namespace
266
+
267
+ :param int skip: skip this number of queues
268
+ :param int max_count: return at most this number of queues if there are more than this number in
269
+ the ServiceBus namespace
270
+ """
224
271
return self ._list_queues (skip , max_count , QueueRuntimeInfo )
0 commit comments