azure-storage-blob 12.21.0b1__py3-none-any.whl → 12.22.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. azure/storage/blob/__init__.py +19 -18
  2. azure/storage/blob/_blob_client.py +470 -1555
  3. azure/storage/blob/_blob_client_helpers.py +1242 -0
  4. azure/storage/blob/_blob_service_client.py +93 -112
  5. azure/storage/blob/_blob_service_client_helpers.py +27 -0
  6. azure/storage/blob/_container_client.py +169 -376
  7. azure/storage/blob/_container_client_helpers.py +261 -0
  8. azure/storage/blob/_deserialize.py +68 -44
  9. azure/storage/blob/_download.py +375 -241
  10. azure/storage/blob/_encryption.py +14 -7
  11. azure/storage/blob/_generated/py.typed +1 -0
  12. azure/storage/blob/_lease.py +52 -63
  13. azure/storage/blob/_list_blobs_helper.py +129 -135
  14. azure/storage/blob/_models.py +480 -277
  15. azure/storage/blob/_quick_query_helper.py +30 -31
  16. azure/storage/blob/_serialize.py +38 -56
  17. azure/storage/blob/_shared/avro/datafile.py +1 -1
  18. azure/storage/blob/_shared/avro/datafile_async.py +1 -1
  19. azure/storage/blob/_shared/base_client.py +1 -1
  20. azure/storage/blob/_shared/base_client_async.py +1 -1
  21. azure/storage/blob/_shared/policies.py +8 -6
  22. azure/storage/blob/_shared/policies_async.py +3 -1
  23. azure/storage/blob/_shared/response_handlers.py +6 -2
  24. azure/storage/blob/_shared/shared_access_signature.py +2 -2
  25. azure/storage/blob/_shared/uploads.py +1 -1
  26. azure/storage/blob/_shared/uploads_async.py +1 -1
  27. azure/storage/blob/_shared_access_signature.py +70 -53
  28. azure/storage/blob/_upload_helpers.py +75 -68
  29. azure/storage/blob/_version.py +1 -1
  30. azure/storage/blob/aio/__init__.py +19 -11
  31. azure/storage/blob/aio/_blob_client_async.py +554 -301
  32. azure/storage/blob/aio/_blob_service_client_async.py +148 -97
  33. azure/storage/blob/aio/_container_client_async.py +282 -139
  34. azure/storage/blob/aio/_download_async.py +408 -283
  35. azure/storage/blob/aio/_lease_async.py +61 -60
  36. azure/storage/blob/aio/_list_blobs_helper.py +94 -96
  37. azure/storage/blob/aio/_models.py +60 -38
  38. azure/storage/blob/aio/_upload_helpers.py +75 -66
  39. {azure_storage_blob-12.21.0b1.dist-info → azure_storage_blob-12.22.0.dist-info}/METADATA +7 -7
  40. {azure_storage_blob-12.21.0b1.dist-info → azure_storage_blob-12.22.0.dist-info}/RECORD +43 -39
  41. {azure_storage_blob-12.21.0b1.dist-info → azure_storage_blob-12.22.0.dist-info}/WHEEL +1 -1
  42. {azure_storage_blob-12.21.0b1.dist-info → azure_storage_blob-12.22.0.dist-info}/LICENSE +0 -0
  43. {azure_storage_blob-12.21.0b1.dist-info → azure_storage_blob-12.22.0.dist-info}/top_level.txt +0 -0
@@ -47,6 +47,10 @@ _GCM_TAG_LENGTH = 16
47
47
  _ERROR_OBJECT_INVALID = \
48
48
  '{0} does not define a complete interface. Value of {1} is either missing or invalid.'
49
49
 
50
+ _ERROR_UNSUPPORTED_METHOD_FOR_ENCRYPTION = (
51
+ 'The require_encryption flag is set, but encryption is not supported'
52
+ ' for this method.')
53
+
50
54
 
51
55
  class KeyEncryptionKey(Protocol):
52
56
 
@@ -357,7 +361,7 @@ def get_adjusted_upload_size(length: int, encryption_version: str) -> int:
357
361
  def get_adjusted_download_range_and_offset(
358
362
  start: int,
359
363
  end: int,
360
- length: int,
364
+ length: Optional[int],
361
365
  encryption_data: Optional[_EncryptionData]) -> Tuple[Tuple[int, int], Tuple[int, int]]:
362
366
  """
363
367
  Gets the new download range and offsets into the decrypted data for
@@ -374,7 +378,7 @@ def get_adjusted_download_range_and_offset(
374
378
 
375
379
  :param int start: The user-requested start index.
376
380
  :param int end: The user-requested end index.
377
- :param int length: The user-requested length. Only used for V1.
381
+ :param Optional[int] length: The user-requested length. Only used for V1.
378
382
  :param Optional[_EncryptionData] encryption_data: The encryption data to determine version and sizes.
379
383
  :return: (new start, new end), (start offset, end offset)
380
384
  :rtype: Tuple[Tuple[int, int], Tuple[int, int]]
@@ -451,17 +455,20 @@ def parse_encryption_data(metadata: Dict[str, Any]) -> Optional[_EncryptionData]
451
455
  return None
452
456
 
453
457
 
454
- def adjust_blob_size_for_encryption(size: int, encryption_data: _EncryptionData) -> int:
458
+ def adjust_blob_size_for_encryption(size: int, encryption_data: Optional[_EncryptionData]) -> int:
455
459
  """
456
460
  Adjusts the given blob size for encryption by subtracting the size of
457
461
  the encryption data (nonce + tag). This only has an affect for encryption V2.
458
462
 
459
463
  :param int size: The original blob size.
460
- :param _EncryptionData encryption_data: The encryption data to determine version and sizes.
464
+ :param Optional[_EncryptionData] encryption_data: The encryption data to determine version and sizes.
461
465
  :return: The new blob size.
462
466
  :rtype: int
463
467
  """
464
- if is_encryption_v2(encryption_data) and encryption_data.encrypted_region_info is not None:
468
+ if (encryption_data is not None and
469
+ encryption_data.encrypted_region_info is not None and
470
+ is_encryption_v2(encryption_data)):
471
+
465
472
  nonce_length = encryption_data.encrypted_region_info.nonce_length
466
473
  data_length = encryption_data.encrypted_region_info.data_length
467
474
  tag_length = encryption_data.encrypted_region_info.tag_length
@@ -836,7 +843,7 @@ def generate_blob_encryption_data(
836
843
 
837
844
  def decrypt_blob( # pylint: disable=too-many-locals,too-many-statements
838
845
  require_encryption: bool,
839
- key_encryption_key: KeyEncryptionKey,
846
+ key_encryption_key: Optional[KeyEncryptionKey],
840
847
  key_resolver: Optional[Callable[[str], KeyEncryptionKey]],
841
848
  content: bytes,
842
849
  start_offset: int,
@@ -848,7 +855,7 @@ def decrypt_blob( # pylint: disable=too-many-locals,too-many-statements
848
855
 
849
856
  :param bool require_encryption:
850
857
  Whether the calling blob service requires objects to be decrypted.
851
- :param KeyEncryptionKey key_encryption_key:
858
+ :param Optional[KeyEncryptionKey] key_encryption_key:
852
859
  The user-provided key-encryption-key. Must implement the following methods:
853
860
  wrap_key(key)
854
861
  - Wraps the specified key using an algorithm of the user's choice.
@@ -0,0 +1 @@
1
+ # Marker file for PEP 561.
@@ -7,57 +7,51 @@
7
7
 
8
8
  import uuid
9
9
 
10
- from typing import ( # pylint: disable=unused-import
11
- Union, Optional, Any, TypeVar, TYPE_CHECKING
12
- )
10
+ from typing import Any, Optional, Union, TYPE_CHECKING
13
11
 
14
12
  from azure.core.exceptions import HttpResponseError
15
13
  from azure.core.tracing.decorator import distributed_trace
16
14
 
17
- from ._shared.response_handlers import return_response_headers, process_storage_error
15
+ from ._shared.response_handlers import process_storage_error, return_response_headers
18
16
  from ._serialize import get_modify_conditions
19
17
 
20
18
  if TYPE_CHECKING:
19
+ from azure.storage.blob import BlobClient, ContainerClient
21
20
  from datetime import datetime
22
21
 
23
- BlobClient = TypeVar("BlobClient")
24
- ContainerClient = TypeVar("ContainerClient")
25
22
 
26
-
27
- class BlobLeaseClient(object): # pylint: disable=client-accepts-api-version-keyword
23
+ class BlobLeaseClient(): # pylint: disable=client-accepts-api-version-keyword
28
24
  """Creates a new BlobLeaseClient.
29
25
 
30
26
  This client provides lease operations on a BlobClient or ContainerClient.
31
-
32
- :ivar str id:
33
- The ID of the lease currently being maintained. This will be `None` if no
34
- lease has yet been acquired.
35
- :ivar str etag:
36
- The ETag of the lease currently being maintained. This will be `None` if no
37
- lease has yet been acquired or modified.
38
- :ivar ~datetime.datetime last_modified:
39
- The last modified timestamp of the lease currently being maintained.
40
- This will be `None` if no lease has yet been acquired or modified.
41
-
42
- :param client:
43
- The client of the blob or container to lease.
44
- :type client: ~azure.storage.blob.BlobClient or
45
- ~azure.storage.blob.ContainerClient
46
- :param str lease_id:
47
- A string representing the lease ID of an existing lease. This value does not
48
- need to be specified in order to acquire a new lease, or break one.
27
+ :param client: The client of the blob or container to lease.
28
+ :type client: Union[BlobClient, ContainerClient]
29
+ :param lease_id: A string representing the lease ID of an existing lease. This value does not need to be
30
+ specified in order to acquire a new lease, or break one.
31
+ :type lease_id: Optional[str]
49
32
  """
50
- def __init__(
51
- self, client, lease_id=None
52
- ): # pylint: disable=missing-client-constructor-parameter-credential,missing-client-constructor-parameter-kwargs
53
- # type: (Union[BlobClient, ContainerClient], Optional[str]) -> None
33
+
34
+ id: str
35
+ """The ID of the lease currently being maintained. This will be `None` if no
36
+ lease has yet been acquired."""
37
+ etag: Optional[str]
38
+ """The ETag of the lease currently being maintained. This will be `None` if no
39
+ lease has yet been acquired or modified."""
40
+ last_modified: Optional["datetime"]
41
+ """The last modified timestamp of the lease currently being maintained.
42
+ This will be `None` if no lease has yet been acquired or modified."""
43
+
44
+ def __init__( # pylint: disable=missing-client-constructor-parameter-credential, missing-client-constructor-parameter-kwargs
45
+ self, client: Union["BlobClient", "ContainerClient"],
46
+ lease_id: Optional[str] = None
47
+ ) -> None:
54
48
  self.id = lease_id or str(uuid.uuid4())
55
49
  self.last_modified = None
56
50
  self.etag = None
57
51
  if hasattr(client, 'blob_name'):
58
- self._client = client._client.blob # type: ignore # pylint: disable=protected-access
52
+ self._client = client._client.blob
59
53
  elif hasattr(client, 'container_name'):
60
- self._client = client._client.container # type: ignore # pylint: disable=protected-access
54
+ self._client = client._client.container
61
55
  else:
62
56
  raise TypeError("Lease must use either BlobClient or ContainerClient.")
63
57
 
@@ -68,8 +62,7 @@ class BlobLeaseClient(object): # pylint: disable=client-accepts-api-version-key
68
62
  self.release()
69
63
 
70
64
  @distributed_trace
71
- def acquire(self, lease_duration=-1, **kwargs):
72
- # type: (int, **Any) -> None
65
+ def acquire(self, lease_duration: int = -1, **kwargs: Any) -> None:
73
66
  """Requests a new lease.
74
67
 
75
68
  If the container does not have an active lease, the Blob service creates a
@@ -108,12 +101,12 @@ class BlobLeaseClient(object): # pylint: disable=client-accepts-api-version-key
108
101
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
109
102
  This value is not tracked or validated on the client. To configure client-side network timesouts
110
103
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
111
- #other-client--per-operation-configuration>`_.
104
+ #other-client--per-operation-configuration>`__.
112
105
  :rtype: None
113
106
  """
114
107
  mod_conditions = get_modify_conditions(kwargs)
115
108
  try:
116
- response = self._client.acquire_lease(
109
+ response: Any = self._client.acquire_lease(
117
110
  timeout=kwargs.pop('timeout', None),
118
111
  duration=lease_duration,
119
112
  proposed_lease_id=self.id,
@@ -122,13 +115,12 @@ class BlobLeaseClient(object): # pylint: disable=client-accepts-api-version-key
122
115
  **kwargs)
123
116
  except HttpResponseError as error:
124
117
  process_storage_error(error)
125
- self.id = response.get('lease_id') # type: str
126
- self.last_modified = response.get('last_modified') # type: datetime
127
- self.etag = response.get('etag') # type: str
118
+ self.id = response.get('lease_id')
119
+ self.last_modified = response.get('last_modified')
120
+ self.etag = response.get('etag')
128
121
 
129
122
  @distributed_trace
130
- def renew(self, **kwargs):
131
- # type: (Any) -> None
123
+ def renew(self, **kwargs: Any) -> None:
132
124
  """Renews the lease.
133
125
 
134
126
  The lease can be renewed if the lease ID specified in the
@@ -165,12 +157,12 @@ class BlobLeaseClient(object): # pylint: disable=client-accepts-api-version-key
165
157
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
166
158
  This value is not tracked or validated on the client. To configure client-side network timesouts
167
159
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
168
- #other-client--per-operation-configuration>`_.
160
+ #other-client--per-operation-configuration>`__.
169
161
  :return: None
170
162
  """
171
163
  mod_conditions = get_modify_conditions(kwargs)
172
164
  try:
173
- response = self._client.renew_lease(
165
+ response: Any = self._client.renew_lease(
174
166
  lease_id=self.id,
175
167
  timeout=kwargs.pop('timeout', None),
176
168
  modified_access_conditions=mod_conditions,
@@ -178,13 +170,12 @@ class BlobLeaseClient(object): # pylint: disable=client-accepts-api-version-key
178
170
  **kwargs)
179
171
  except HttpResponseError as error:
180
172
  process_storage_error(error)
181
- self.etag = response.get('etag') # type: str
182
- self.id = response.get('lease_id') # type: str
183
- self.last_modified = response.get('last_modified') # type: datetime
173
+ self.etag = response.get('etag')
174
+ self.id = response.get('lease_id')
175
+ self.last_modified = response.get('last_modified')
184
176
 
185
177
  @distributed_trace
186
- def release(self, **kwargs):
187
- # type: (Any) -> None
178
+ def release(self, **kwargs: Any) -> None:
188
179
  """Release the lease.
189
180
 
190
181
  The lease may be released if the client lease id specified matches
@@ -219,12 +210,12 @@ class BlobLeaseClient(object): # pylint: disable=client-accepts-api-version-key
219
210
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
220
211
  This value is not tracked or validated on the client. To configure client-side network timesouts
221
212
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
222
- #other-client--per-operation-configuration>`_.
213
+ #other-client--per-operation-configuration>`__.
223
214
  :return: None
224
215
  """
225
216
  mod_conditions = get_modify_conditions(kwargs)
226
217
  try:
227
- response = self._client.release_lease(
218
+ response: Any = self._client.release_lease(
228
219
  lease_id=self.id,
229
220
  timeout=kwargs.pop('timeout', None),
230
221
  modified_access_conditions=mod_conditions,
@@ -232,13 +223,12 @@ class BlobLeaseClient(object): # pylint: disable=client-accepts-api-version-key
232
223
  **kwargs)
233
224
  except HttpResponseError as error:
234
225
  process_storage_error(error)
235
- self.etag = response.get('etag') # type: str
236
- self.id = response.get('lease_id') # type: str
237
- self.last_modified = response.get('last_modified') # type: datetime
226
+ self.etag = response.get('etag')
227
+ self.id = response.get('lease_id')
228
+ self.last_modified = response.get('last_modified')
238
229
 
239
230
  @distributed_trace
240
- def change(self, proposed_lease_id, **kwargs):
241
- # type: (str, Any) -> None
231
+ def change(self, proposed_lease_id: str, **kwargs: Any) -> None:
242
232
  """Change the lease ID of an active lease.
243
233
 
244
234
  :param str proposed_lease_id:
@@ -272,12 +262,12 @@ class BlobLeaseClient(object): # pylint: disable=client-accepts-api-version-key
272
262
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
273
263
  This value is not tracked or validated on the client. To configure client-side network timesouts
274
264
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
275
- #other-client--per-operation-configuration>`_.
265
+ #other-client--per-operation-configuration>`__.
276
266
  :return: None
277
267
  """
278
268
  mod_conditions = get_modify_conditions(kwargs)
279
269
  try:
280
- response = self._client.change_lease(
270
+ response: Any = self._client.change_lease(
281
271
  lease_id=self.id,
282
272
  proposed_lease_id=proposed_lease_id,
283
273
  timeout=kwargs.pop('timeout', None),
@@ -286,13 +276,12 @@ class BlobLeaseClient(object): # pylint: disable=client-accepts-api-version-key
286
276
  **kwargs)
287
277
  except HttpResponseError as error:
288
278
  process_storage_error(error)
289
- self.etag = response.get('etag') # type: str
290
- self.id = response.get('lease_id') # type: str
291
- self.last_modified = response.get('last_modified') # type: datetime
279
+ self.etag = response.get('etag')
280
+ self.id = response.get('lease_id')
281
+ self.last_modified = response.get('last_modified')
292
282
 
293
283
  @distributed_trace
294
- def break_lease(self, lease_break_period=None, **kwargs):
295
- # type: (Optional[int], Any) -> int
284
+ def break_lease(self, lease_break_period: Optional[int] = None, **kwargs: Any) -> int:
296
285
  """Break the lease, if the container or blob has an active lease.
297
286
 
298
287
  Once a lease is broken, it cannot be renewed. Any authorized request can break the lease;
@@ -335,7 +324,7 @@ class BlobLeaseClient(object): # pylint: disable=client-accepts-api-version-key
335
324
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
336
325
  This value is not tracked or validated on the client. To configure client-side network timesouts
337
326
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
338
- #other-client--per-operation-configuration>`_.
327
+ #other-client--per-operation-configuration>`__.
339
328
  :return: Approximate time remaining in the lease period, in seconds.
340
329
  :rtype: int
341
330
  """
@@ -1,30 +1,30 @@
1
- # pylint: disable=too-many-lines
2
1
  # -------------------------------------------------------------------------
3
2
  # Copyright (c) Microsoft Corporation. All rights reserved.
4
3
  # Licensed under the MIT License. See License.txt in the project root for
5
4
  # license information.
6
5
  # --------------------------------------------------------------------------
7
6
 
7
+ from typing import Any, Callable, cast, List, Optional, Tuple, Union
8
8
  from urllib.parse import unquote
9
9
 
10
- from azure.core.paging import PageIterator, ItemPaged
11
10
  from azure.core.exceptions import HttpResponseError
11
+ from azure.core.paging import ItemPaged, PageIterator
12
12
 
13
13
  from ._deserialize import (
14
14
  get_blob_properties_from_generated_code,
15
15
  load_many_xml_nodes,
16
16
  load_xml_int,
17
17
  load_xml_string,
18
- parse_tags,
18
+ parse_tags
19
19
  )
20
20
  from ._generated.models import BlobItemInternal, BlobPrefix as GenBlobPrefix, FilterBlobItem
21
21
  from ._generated._serialization import Deserializer
22
22
  from ._models import BlobProperties, FilteredBlob
23
23
  from ._shared.models import DictMixin
24
24
  from ._shared.response_handlers import (
25
- return_context_and_deserialized,
26
- return_raw_deserialized,
27
25
  process_storage_error,
26
+ return_context_and_deserialized,
27
+ return_raw_deserialized
28
28
  )
29
29
 
30
30
 
@@ -36,43 +36,39 @@ class IgnoreListBlobsDeserializer(Deserializer):
36
36
 
37
37
 
38
38
  class BlobPropertiesPaged(PageIterator):
39
- """An Iterable of Blob properties.
39
+ """An Iterable of Blob properties."""
40
+
41
+ service_endpoint: Optional[str]
42
+ """The service URL."""
43
+ prefix: Optional[str]
44
+ """A blob name prefix being used to filter the list."""
45
+ marker: Optional[str]
46
+ """The continuation token of the current page of results."""
47
+ results_per_page: Optional[int]
48
+ """The maximum number of results retrieved per API call."""
49
+ continuation_token: Optional[str]
50
+ """The continuation token to retrieve the next page of results."""
51
+ location_mode: Optional[str]
52
+ """The location mode being used to list results. The available
53
+ options include "primary" and "secondary"."""
54
+ current_page: Optional[List[BlobProperties]]
55
+ """The current page of listed results."""
56
+ container: Optional[str]
57
+ """The container that the blobs are listed from."""
58
+ delimiter: Optional[str]
59
+ """A delimiting character used for hierarchy listing."""
60
+ command: Callable
61
+ """Function to retrieve the next page of items."""
40
62
 
41
- :ivar str service_endpoint: The service URL.
42
- :ivar str prefix: A blob name prefix being used to filter the list.
43
- :ivar str marker: The continuation token of the current page of results.
44
- :ivar int results_per_page: The maximum number of results retrieved per API call.
45
- :ivar str continuation_token: The continuation token to retrieve the next page of results.
46
- :ivar str location_mode: The location mode being used to list results. The available
47
- options include "primary" and "secondary".
48
- :ivar current_page: The current page of listed results.
49
- :vartype current_page: list(~azure.storage.blob.BlobProperties)
50
- :ivar str container: The container that the blobs are listed from.
51
- :ivar str delimiter: A delimiting character used for hierarchy listing.
52
-
53
- :param callable command: Function to retrieve the next page of items.
54
- :param str container: The name of the container.
55
- :param str prefix: Filters the results to return only blobs whose names
56
- begin with the specified prefix.
57
- :param int results_per_page: The maximum number of blobs to retrieve per
58
- call.
59
- :param str continuation_token: An opaque continuation token.
60
- :param str delimiter:
61
- Used to capture blobs whose names begin with the same substring up to
62
- the appearance of the delimiter character. The delimiter may be a single
63
- character or a string.
64
- :param location_mode: Specifies the location the request should be sent to.
65
- This mode only applies for RA-GRS accounts which allow secondary read access.
66
- Options include 'primary' or 'secondary'.
67
- """
68
63
  def __init__(
69
- self, command,
70
- container=None,
71
- prefix=None,
72
- results_per_page=None,
73
- continuation_token=None,
74
- delimiter=None,
75
- location_mode=None):
64
+ self, command: Callable,
65
+ container: str,
66
+ prefix: Optional[str] = None,
67
+ results_per_page: Optional[int] = None,
68
+ continuation_token: Optional[str] = None,
69
+ delimiter: Optional[str] = None,
70
+ location_mode: Optional[str] = None,
71
+ ) -> None:
76
72
  super(BlobPropertiesPaged, self).__init__(
77
73
  get_next=self._get_next_cb,
78
74
  extract_data=self._extract_data_cb,
@@ -100,7 +96,7 @@ class BlobPropertiesPaged(PageIterator):
100
96
  process_storage_error(error)
101
97
 
102
98
  def _extract_data_cb(self, get_next_return):
103
- self.location_mode, self._response = get_next_return
99
+ self.location_mode, self._response = cast(Tuple[Optional[str], Any], get_next_return)
104
100
  self.service_endpoint = self._response.service_endpoint
105
101
  self.prefix = self._response.prefix
106
102
  self.marker = self._response.marker
@@ -110,49 +106,49 @@ class BlobPropertiesPaged(PageIterator):
110
106
 
111
107
  return self._response.next_marker or None, self.current_page
112
108
 
113
- def _build_item(self, item):
109
+ def _build_item(self, item: Union[BlobItemInternal, BlobProperties]) -> BlobProperties:
114
110
  if isinstance(item, BlobProperties):
115
111
  return item
116
112
  if isinstance(item, BlobItemInternal):
117
113
  blob = get_blob_properties_from_generated_code(item) # pylint: disable=protected-access
118
- blob.container = self.container
114
+ blob.container = self.container # type: ignore [assignment]
119
115
  return blob
120
116
  return item
121
117
 
122
118
 
123
119
  class BlobNamesPaged(PageIterator):
124
- """An Iterable of Blob names.
125
-
126
- :ivar str service_endpoint: The service URL.
127
- :ivar str prefix: A blob name prefix being used to filter the list.
128
- :ivar str marker: The continuation token of the current page of results.
129
- :ivar int results_per_page: The maximum number of results retrieved per API call.
130
- :ivar str continuation_token: The continuation token to retrieve the next page of results.
131
- :ivar str location_mode: The location mode being used to list results. The available
132
- options include "primary" and "secondary".
133
- :ivar current_page: The current page of listed results.
134
- :vartype current_page: list(str)
135
- :ivar str container: The container that the blobs are listed from.
136
- :ivar str delimiter: A delimiting character used for hierarchy listing.
137
-
138
- :param callable command: Function to retrieve the next page of items.
139
- :param str container: The name of the container.
140
- :param str prefix: Filters the results to return only blobs whose names
141
- begin with the specified prefix.
142
- :param int results_per_page: The maximum number of blobs to retrieve per
143
- call.
144
- :param str continuation_token: An opaque continuation token.
145
- :param location_mode: Specifies the location the request should be sent to.
146
- This mode only applies for RA-GRS accounts which allow secondary read access.
147
- Options include 'primary' or 'secondary'.
148
- """
120
+ """An Iterable of Blob names."""
121
+
122
+ service_endpoint: Optional[str]
123
+ """The service URL."""
124
+ prefix: Optional[str]
125
+ """A blob name prefix being used to filter the list."""
126
+ marker: Optional[str]
127
+ """The continuation token of the current page of results."""
128
+ results_per_page: Optional[int]
129
+ """The maximum number of blobs to retrieve per call."""
130
+ continuation_token: Optional[str]
131
+ """The continuation token to retrieve the next page of results."""
132
+ location_mode: Optional[str]
133
+ """The location mode being used to list results. The available
134
+ options include "primary" and "secondary"."""
135
+ current_page: Optional[List[BlobProperties]]
136
+ """The current page of listed results."""
137
+ container: Optional[str]
138
+ """The container that the blobs are listed from."""
139
+ delimiter: Optional[str]
140
+ """A delimiting character used for hierarchy listing."""
141
+ command: Callable
142
+ """Function to retrieve the next page of items."""
143
+
149
144
  def __init__(
150
- self, command,
151
- container=None,
152
- prefix=None,
153
- results_per_page=None,
154
- continuation_token=None,
155
- location_mode=None):
145
+ self, command: Callable,
146
+ container: Optional[str] = None,
147
+ prefix: Optional[str] = None,
148
+ results_per_page: Optional[int] = None,
149
+ continuation_token: Optional[str] = None,
150
+ location_mode: Optional[str] = None
151
+ ) -> None:
156
152
  super(BlobNamesPaged, self).__init__(
157
153
  get_next=self._get_next_cb,
158
154
  extract_data=self._extract_data_cb,
@@ -226,74 +222,72 @@ class BlobPrefix(ItemPaged, DictMixin):
226
222
  """An Iterable of Blob properties.
227
223
 
228
224
  Returned from walk_blobs when a delimiter is used.
229
- Can be thought of as a virtual blob directory.
230
-
231
- :ivar str name: The prefix, or "directory name" of the blob.
232
- :ivar str service_endpoint: The service URL.
233
- :ivar str prefix: A blob name prefix being used to filter the list.
234
- :ivar str marker: The continuation token of the current page of results.
235
- :ivar int results_per_page: The maximum number of results retrieved per API call.
236
- :ivar str next_marker: The continuation token to retrieve the next page of results.
237
- :ivar str location_mode: The location mode being used to list results. The available
238
- options include "primary" and "secondary".
239
- :ivar current_page: The current page of listed results.
240
- :vartype current_page: list(~azure.storage.blob.BlobProperties)
241
- :ivar str container: The container that the blobs are listed from.
242
- :ivar str delimiter: A delimiting character used for hierarchy listing.
243
-
244
- :param callable command: Function to retrieve the next page of items.
245
- :param str prefix: Filters the results to return only blobs whose names
246
- begin with the specified prefix.
247
- :param int results_per_page: The maximum number of blobs to retrieve per
248
- call.
249
- :param str marker: An opaque continuation token.
250
- :param str delimiter:
251
- Used to capture blobs whose names begin with the same substring up to
252
- the appearance of the delimiter character. The delimiter may be a single
253
- character or a string.
254
- :param location_mode: Specifies the location the request should be sent to.
255
- This mode only applies for RA-GRS accounts which allow secondary read access.
256
- Options include 'primary' or 'secondary'.
257
- """
258
- def __init__(self, *args, **kwargs):
225
+ Can be thought of as a virtual blob directory."""
226
+
227
+ name: str
228
+ """The prefix, or "directory name" of the blob."""
229
+ service_endpoint: Optional[str]
230
+ """The service URL."""
231
+ prefix: str
232
+ """A blob name prefix being used to filter the list."""
233
+ marker: Optional[str]
234
+ """The continuation token of the current page of results."""
235
+ results_per_page: Optional[int]
236
+ """The maximum number of results retrieved per API call."""
237
+ next_marker: Optional[str]
238
+ """The continuation token to retrieve the next page of results."""
239
+ location_mode: str
240
+ """The location mode being used to list results. The available
241
+ options include "primary" and "secondary"."""
242
+ current_page: Optional[List[BlobProperties]]
243
+ """The current page of listed results."""
244
+ delimiter: str
245
+ """A delimiting character used for hierarchy listing."""
246
+ command: Callable
247
+ """Function to retrieve the next page of items."""
248
+ container: str
249
+ """The name of the container."""
250
+
251
+ def __init__(self, *args: Any, **kwargs: Any) -> None:
259
252
  super(BlobPrefix, self).__init__(*args, page_iterator_class=BlobPrefixPaged, **kwargs)
260
- self.name = kwargs.get('prefix')
261
- self.prefix = kwargs.get('prefix')
253
+ self.name = kwargs.get('prefix') # type: ignore [assignment]
254
+ self.prefix = kwargs.get('prefix') # type: ignore [assignment]
262
255
  self.results_per_page = kwargs.get('results_per_page')
263
- self.container = kwargs.get('container')
264
- self.delimiter = kwargs.get('delimiter')
265
- self.location_mode = kwargs.get('location_mode')
256
+ self.container = kwargs.get('container') # type: ignore [assignment]
257
+ self.delimiter = kwargs.get('delimiter') # type: ignore [assignment]
258
+ self.location_mode = kwargs.get('location_mode') # type: ignore [assignment]
266
259
 
267
260
 
268
261
  class FilteredBlobPaged(PageIterator):
269
- """An Iterable of Blob properties.
262
+ """An Iterable of Blob properties."""
263
+
264
+ service_endpoint: Optional[str]
265
+ """The service URL."""
266
+ prefix: Optional[str]
267
+ """A blob name prefix being used to filter the list."""
268
+ marker: Optional[str]
269
+ """The continuation token of the current page of results."""
270
+ results_per_page: Optional[int]
271
+ """The maximum number of results retrieved per API call."""
272
+ continuation_token: Optional[str]
273
+ """The continuation token to retrieve the next page of results."""
274
+ location_mode: Optional[str]
275
+ """The location mode being used to list results. The available
276
+ options include "primary" and "secondary"."""
277
+ current_page: Optional[List[BlobProperties]]
278
+ """The current page of listed results."""
279
+ command: Callable
280
+ """Function to retrieve the next page of items."""
281
+ container: Optional[str]
282
+ """The name of the container."""
270
283
 
271
- :ivar str service_endpoint: The service URL.
272
- :ivar str prefix: A blob name prefix being used to filter the list.
273
- :ivar str marker: The continuation token of the current page of results.
274
- :ivar int results_per_page: The maximum number of results retrieved per API call.
275
- :ivar str continuation_token: The continuation token to retrieve the next page of results.
276
- :ivar str location_mode: The location mode being used to list results. The available
277
- options include "primary" and "secondary".
278
- :ivar current_page: The current page of listed results.
279
- :vartype current_page: list(~azure.storage.blob.FilteredBlob)
280
- :ivar str container: The container that the blobs are listed from.
281
-
282
- :param callable command: Function to retrieve the next page of items.
283
- :param str container: The name of the container.
284
- :param int results_per_page: The maximum number of blobs to retrieve per
285
- call.
286
- :param str continuation_token: An opaque continuation token.
287
- :param location_mode: Specifies the location the request should be sent to.
288
- This mode only applies for RA-GRS accounts which allow secondary read access.
289
- Options include 'primary' or 'secondary'.
290
- """
291
284
  def __init__(
292
- self, command,
293
- container=None,
294
- results_per_page=None,
295
- continuation_token=None,
296
- location_mode=None):
285
+ self, command: Callable,
286
+ container: Optional[str] = None,
287
+ results_per_page: Optional[int] = None,
288
+ continuation_token: Optional[str] = None,
289
+ location_mode: Optional[str] = None
290
+ ) -> None:
297
291
  super(FilteredBlobPaged, self).__init__(
298
292
  get_next=self._get_next_cb,
299
293
  extract_data=self._extract_data_cb,