azure-storage-blob 12.21.0b1__py3-none-any.whl → 12.23.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 (60) 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 +176 -377
  7. azure/storage/blob/_container_client_helpers.py +266 -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/_azure_blob_storage.py +2 -1
  12. azure/storage/blob/_generated/_serialization.py +2 -0
  13. azure/storage/blob/_generated/aio/_azure_blob_storage.py +2 -1
  14. azure/storage/blob/_generated/aio/operations/_append_blob_operations.py +1 -7
  15. azure/storage/blob/_generated/aio/operations/_blob_operations.py +21 -47
  16. azure/storage/blob/_generated/aio/operations/_block_blob_operations.py +2 -10
  17. azure/storage/blob/_generated/aio/operations/_container_operations.py +13 -26
  18. azure/storage/blob/_generated/aio/operations/_page_blob_operations.py +3 -14
  19. azure/storage/blob/_generated/aio/operations/_service_operations.py +14 -17
  20. azure/storage/blob/_generated/operations/_append_blob_operations.py +1 -7
  21. azure/storage/blob/_generated/operations/_blob_operations.py +21 -47
  22. azure/storage/blob/_generated/operations/_block_blob_operations.py +2 -10
  23. azure/storage/blob/_generated/operations/_container_operations.py +13 -26
  24. azure/storage/blob/_generated/operations/_page_blob_operations.py +3 -14
  25. azure/storage/blob/_generated/operations/_service_operations.py +14 -17
  26. azure/storage/blob/_generated/py.typed +1 -0
  27. azure/storage/blob/_lease.py +52 -63
  28. azure/storage/blob/_list_blobs_helper.py +129 -135
  29. azure/storage/blob/_models.py +480 -277
  30. azure/storage/blob/_quick_query_helper.py +30 -31
  31. azure/storage/blob/_serialize.py +39 -56
  32. azure/storage/blob/_shared/avro/datafile.py +1 -1
  33. azure/storage/blob/_shared/avro/datafile_async.py +1 -1
  34. azure/storage/blob/_shared/base_client.py +3 -1
  35. azure/storage/blob/_shared/base_client_async.py +1 -1
  36. azure/storage/blob/_shared/policies.py +16 -15
  37. azure/storage/blob/_shared/policies_async.py +21 -6
  38. azure/storage/blob/_shared/response_handlers.py +6 -2
  39. azure/storage/blob/_shared/shared_access_signature.py +21 -3
  40. azure/storage/blob/_shared/uploads.py +1 -1
  41. azure/storage/blob/_shared/uploads_async.py +1 -1
  42. azure/storage/blob/_shared_access_signature.py +110 -52
  43. azure/storage/blob/_upload_helpers.py +75 -68
  44. azure/storage/blob/_version.py +1 -1
  45. azure/storage/blob/aio/__init__.py +19 -11
  46. azure/storage/blob/aio/_blob_client_async.py +554 -301
  47. azure/storage/blob/aio/_blob_service_client_async.py +148 -97
  48. azure/storage/blob/aio/_container_client_async.py +289 -140
  49. azure/storage/blob/aio/_download_async.py +485 -337
  50. azure/storage/blob/aio/_lease_async.py +61 -60
  51. azure/storage/blob/aio/_list_blobs_helper.py +94 -96
  52. azure/storage/blob/aio/_models.py +60 -38
  53. azure/storage/blob/aio/_upload_helpers.py +75 -66
  54. {azure_storage_blob-12.21.0b1.dist-info → azure_storage_blob-12.23.0.dist-info}/METADATA +7 -7
  55. azure_storage_blob-12.23.0.dist-info/RECORD +84 -0
  56. {azure_storage_blob-12.21.0b1.dist-info → azure_storage_blob-12.23.0.dist-info}/WHEEL +1 -1
  57. azure/storage/blob/_generated/_vendor.py +0 -16
  58. azure_storage_blob-12.21.0b1.dist-info/RECORD +0 -81
  59. {azure_storage_blob-12.21.0b1.dist-info → azure_storage_blob-12.23.0.dist-info}/LICENSE +0 -0
  60. {azure_storage_blob-12.21.0b1.dist-info → azure_storage_blob-12.23.0.dist-info}/top_level.txt +0 -0
@@ -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,