azure-storage-blob 12.25.0b1__py3-none-any.whl → 12.26.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.
- azure/storage/blob/__init__.py +3 -2
- azure/storage/blob/_blob_client.py +94 -41
- azure/storage/blob/_blob_client_helpers.py +19 -4
- azure/storage/blob/_blob_service_client.py +16 -13
- azure/storage/blob/_container_client.py +25 -22
- azure/storage/blob/_deserialize.py +1 -1
- azure/storage/blob/_download.py +7 -7
- azure/storage/blob/_encryption.py +177 -184
- azure/storage/blob/_generated/_azure_blob_storage.py +1 -1
- azure/storage/blob/_generated/_configuration.py +2 -2
- azure/storage/blob/_generated/_serialization.py +3 -3
- azure/storage/blob/_generated/aio/_azure_blob_storage.py +1 -1
- azure/storage/blob/_generated/aio/_configuration.py +2 -2
- azure/storage/blob/_generated/aio/operations/_append_blob_operations.py +5 -4
- azure/storage/blob/_generated/aio/operations/_blob_operations.py +5 -25
- azure/storage/blob/_generated/aio/operations/_block_blob_operations.py +9 -7
- azure/storage/blob/_generated/aio/operations/_container_operations.py +1 -19
- azure/storage/blob/_generated/aio/operations/_page_blob_operations.py +5 -10
- azure/storage/blob/_generated/aio/operations/_service_operations.py +1 -8
- azure/storage/blob/_generated/models/__init__.py +2 -0
- azure/storage/blob/_generated/models/_azure_blob_storage_enums.py +6 -0
- azure/storage/blob/_generated/operations/_append_blob_operations.py +12 -9
- azure/storage/blob/_generated/operations/_blob_operations.py +32 -49
- azure/storage/blob/_generated/operations/_block_blob_operations.py +21 -13
- azure/storage/blob/_generated/operations/_container_operations.py +19 -37
- azure/storage/blob/_generated/operations/_page_blob_operations.py +17 -19
- azure/storage/blob/_generated/operations/_service_operations.py +9 -17
- azure/storage/blob/_lease.py +1 -0
- azure/storage/blob/_quick_query_helper.py +20 -24
- azure/storage/blob/_serialize.py +1 -0
- azure/storage/blob/_shared/__init__.py +7 -7
- azure/storage/blob/_shared/authentication.py +49 -32
- azure/storage/blob/_shared/avro/avro_io.py +45 -43
- azure/storage/blob/_shared/avro/avro_io_async.py +42 -41
- azure/storage/blob/_shared/avro/datafile.py +24 -21
- azure/storage/blob/_shared/avro/datafile_async.py +15 -15
- azure/storage/blob/_shared/avro/schema.py +196 -217
- azure/storage/blob/_shared/base_client.py +87 -61
- azure/storage/blob/_shared/base_client_async.py +58 -51
- azure/storage/blob/_shared/constants.py +1 -1
- azure/storage/blob/_shared/models.py +93 -92
- azure/storage/blob/_shared/parser.py +3 -3
- azure/storage/blob/_shared/policies.py +176 -145
- azure/storage/blob/_shared/policies_async.py +59 -70
- azure/storage/blob/_shared/request_handlers.py +51 -47
- azure/storage/blob/_shared/response_handlers.py +49 -45
- azure/storage/blob/_shared/shared_access_signature.py +67 -71
- azure/storage/blob/_shared/uploads.py +56 -49
- azure/storage/blob/_shared/uploads_async.py +72 -61
- azure/storage/blob/_shared_access_signature.py +3 -1
- azure/storage/blob/_version.py +1 -1
- azure/storage/blob/aio/__init__.py +3 -2
- azure/storage/blob/aio/_blob_client_async.py +241 -44
- azure/storage/blob/aio/_blob_service_client_async.py +13 -11
- azure/storage/blob/aio/_container_client_async.py +28 -25
- azure/storage/blob/aio/_download_async.py +16 -12
- azure/storage/blob/aio/_lease_async.py +1 -0
- azure/storage/blob/aio/_quick_query_helper_async.py +194 -0
- {azure_storage_blob-12.25.0b1.dist-info → azure_storage_blob-12.26.0.dist-info}/METADATA +7 -7
- azure_storage_blob-12.26.0.dist-info/RECORD +85 -0
- {azure_storage_blob-12.25.0b1.dist-info → azure_storage_blob-12.26.0.dist-info}/WHEEL +1 -1
- azure_storage_blob-12.25.0b1.dist-info/RECORD +0 -84
- {azure_storage_blob-12.25.0b1.dist-info → azure_storage_blob-12.26.0.dist-info}/LICENSE +0 -0
- {azure_storage_blob-12.25.0b1.dist-info → azure_storage_blob-12.26.0.dist-info}/top_level.txt +0 -0
@@ -145,7 +145,7 @@ class BlobServiceClient( # type: ignore [misc]
|
|
145
145
|
|
146
146
|
:param str hostname:
|
147
147
|
The hostname of the current location mode.
|
148
|
-
:
|
148
|
+
:return: A formatted endpoint URL including current location mode hostname.
|
149
149
|
:rtype: str
|
150
150
|
"""
|
151
151
|
return f"{self.scheme}://{hostname}/{self._query_str}"
|
@@ -177,7 +177,7 @@ class BlobServiceClient( # type: ignore [misc]
|
|
177
177
|
:keyword str audience: The audience to use when requesting tokens for Azure Active Directory
|
178
178
|
authentication. Only has an effect when credential is of type TokenCredential. The value could be
|
179
179
|
https://storage.azure.com/ (default) or https://<account>.blob.core.windows.net.
|
180
|
-
:
|
180
|
+
:return: A Blob service client.
|
181
181
|
:rtype: ~azure.storage.blob.BlobServiceClient
|
182
182
|
|
183
183
|
.. admonition:: Example:
|
@@ -235,7 +235,7 @@ class BlobServiceClient( # type: ignore [misc]
|
|
235
235
|
The information can also be retrieved if the user has a SAS to a container or blob.
|
236
236
|
The keys in the returned dictionary include 'sku_name' and 'account_kind'.
|
237
237
|
|
238
|
-
:
|
238
|
+
:return: A dict of account information (SKU and account type).
|
239
239
|
:rtype: dict(str, str)
|
240
240
|
|
241
241
|
.. admonition:: Example:
|
@@ -309,7 +309,7 @@ class BlobServiceClient( # type: ignore [misc]
|
|
309
309
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
310
310
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
311
311
|
#other-client--per-operation-configuration>`__.
|
312
|
-
:
|
312
|
+
:return: An object containing blob service properties such as
|
313
313
|
analytics logging, hour/minute metrics, cors rules, etc.
|
314
314
|
:rtype: Dict[str, Any]
|
315
315
|
|
@@ -379,6 +379,7 @@ class BlobServiceClient( # type: ignore [misc]
|
|
379
379
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
380
380
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
381
381
|
#other-client--per-operation-configuration>`__.
|
382
|
+
:return: None
|
382
383
|
:rtype: None
|
383
384
|
|
384
385
|
.. admonition:: Example:
|
@@ -443,7 +444,7 @@ class BlobServiceClient( # type: ignore [misc]
|
|
443
444
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
444
445
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
445
446
|
#other-client--per-operation-configuration>`__.
|
446
|
-
:
|
447
|
+
:return: An iterable (auto-paging) of ContainerProperties.
|
447
448
|
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.storage.blob.ContainerProperties]
|
448
449
|
|
449
450
|
.. admonition:: Example:
|
@@ -496,7 +497,7 @@ class BlobServiceClient( # type: ignore [misc]
|
|
496
497
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
497
498
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
498
499
|
#other-client--per-operation-configuration>`__.
|
499
|
-
:
|
500
|
+
:return: An iterable (auto-paging) response of BlobProperties.
|
500
501
|
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.storage.blob.FilteredBlob]
|
501
502
|
"""
|
502
503
|
|
@@ -545,7 +546,7 @@ class BlobServiceClient( # type: ignore [misc]
|
|
545
546
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
546
547
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
547
548
|
#other-client--per-operation-configuration>`__.
|
548
|
-
:
|
549
|
+
:return: A container client to interact with the newly created container.
|
549
550
|
:rtype: ~azure.storage.blob.aio.ContainerClient
|
550
551
|
|
551
552
|
.. admonition:: Example:
|
@@ -607,6 +608,7 @@ class BlobServiceClient( # type: ignore [misc]
|
|
607
608
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
608
609
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
609
610
|
#other-client--per-operation-configuration>`__.
|
611
|
+
:return: None
|
610
612
|
:rtype: None
|
611
613
|
|
612
614
|
.. admonition:: Example:
|
@@ -646,7 +648,7 @@ class BlobServiceClient( # type: ignore [misc]
|
|
646
648
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
647
649
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
648
650
|
#other-client--per-operation-configuration>`__.
|
649
|
-
:
|
651
|
+
:return: A container client for the renamed container.
|
650
652
|
:rtype: ~azure.storage.blob.ContainerClient
|
651
653
|
"""
|
652
654
|
renamed_container = self.get_container_client(new_name)
|
@@ -685,7 +687,7 @@ class BlobServiceClient( # type: ignore [misc]
|
|
685
687
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
686
688
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
687
689
|
#other-client--per-operation-configuration>`__.
|
688
|
-
:
|
690
|
+
:return: The recovered soft-deleted ContainerClient.
|
689
691
|
:rtype: ~azure.storage.blob.aio.ContainerClient
|
690
692
|
"""
|
691
693
|
new_name = kwargs.pop('new_name', None)
|
@@ -709,7 +711,7 @@ class BlobServiceClient( # type: ignore [misc]
|
|
709
711
|
The container. This can either be the name of the container,
|
710
712
|
or an instance of ContainerProperties.
|
711
713
|
:type container: str or ~azure.storage.blob.ContainerProperties
|
712
|
-
:
|
714
|
+
:return: A ContainerClient.
|
713
715
|
:rtype: ~azure.storage.blob.aio.ContainerClient
|
714
716
|
|
715
717
|
.. admonition:: Example:
|
@@ -760,7 +762,7 @@ class BlobServiceClient( # type: ignore [misc]
|
|
760
762
|
:type snapshot: str or dict(str, Any)
|
761
763
|
:keyword str version_id: The version id parameter is an opaque DateTime value that, when present,
|
762
764
|
specifies the version of the blob to operate on.
|
763
|
-
:
|
765
|
+
:return: A BlobClient.
|
764
766
|
:rtype: ~azure.storage.blob.aio.BlobClient
|
765
767
|
|
766
768
|
.. admonition:: Example:
|
@@ -186,7 +186,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
186
186
|
:keyword str audience: The audience to use when requesting tokens for Azure Active Directory
|
187
187
|
authentication. Only has an effect when credential is of type TokenCredential. The value could be
|
188
188
|
https://storage.azure.com/ (default) or https://<account>.blob.core.windows.net.
|
189
|
-
:
|
189
|
+
:return: A container client.
|
190
190
|
:rtype: ~azure.storage.blob.ContainerClient
|
191
191
|
"""
|
192
192
|
try:
|
@@ -239,7 +239,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
239
239
|
:keyword str audience: The audience to use when requesting tokens for Azure Active Directory
|
240
240
|
authentication. Only has an effect when credential is of type TokenCredential. The value could be
|
241
241
|
https://storage.azure.com/ (default) or https://<account>.blob.core.windows.net.
|
242
|
-
:
|
242
|
+
:return: A container client.
|
243
243
|
:rtype: ~azure.storage.blob.ContainerClient
|
244
244
|
|
245
245
|
.. admonition:: Example:
|
@@ -286,7 +286,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
286
286
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
287
287
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
288
288
|
#other-client--per-operation-configuration>`__.
|
289
|
-
:
|
289
|
+
:return: A dictionary of response headers.
|
290
290
|
:rtype: Dict[str, Union[str, datetime]]
|
291
291
|
|
292
292
|
.. admonition:: Example:
|
@@ -331,7 +331,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
331
331
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
332
332
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
333
333
|
#other-client--per-operation-configuration>`__.
|
334
|
-
:
|
334
|
+
:return: The renamed container.
|
335
335
|
:rtype: ~azure.storage.blob.ContainerClient
|
336
336
|
"""
|
337
337
|
lease = kwargs.pop('lease', None)
|
@@ -385,6 +385,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
385
385
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
386
386
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
387
387
|
#other-client--per-operation-configuration>`__.
|
388
|
+
:return: None
|
388
389
|
:rtype: None
|
389
390
|
|
390
391
|
.. admonition:: Example:
|
@@ -451,7 +452,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
451
452
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
452
453
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
453
454
|
#other-client--per-operation-configuration>`__.
|
454
|
-
:
|
455
|
+
:return: A BlobLeaseClient object, that can be run in a context manager.
|
455
456
|
:rtype: ~azure.storage.blob.aio.BlobLeaseClient
|
456
457
|
|
457
458
|
.. admonition:: Example:
|
@@ -476,7 +477,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
476
477
|
The information can also be retrieved if the user has a SAS to a container or blob.
|
477
478
|
The keys in the returned dictionary include 'sku_name' and 'account_kind'.
|
478
479
|
|
479
|
-
:
|
480
|
+
:return: A dict of account information (SKU and account type).
|
480
481
|
:rtype: dict(str, str)
|
481
482
|
"""
|
482
483
|
try:
|
@@ -536,7 +537,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
536
537
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
537
538
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
538
539
|
#other-client--per-operation-configuration>`__.
|
539
|
-
:
|
540
|
+
:return: boolean
|
540
541
|
:rtype: bool
|
541
542
|
"""
|
542
543
|
try:
|
@@ -578,7 +579,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
578
579
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
579
580
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
580
581
|
#other-client--per-operation-configuration>`__.
|
581
|
-
:
|
582
|
+
:return: Container-updated property dict (Etag and last modified).
|
582
583
|
:rtype: Dict[str, Union[str, datetime]]
|
583
584
|
|
584
585
|
.. admonition:: Example:
|
@@ -613,7 +614,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
613
614
|
|
614
615
|
Defaults to current container's credentials.
|
615
616
|
|
616
|
-
:
|
617
|
+
:return: A BlobServiceClient.
|
617
618
|
:rtype: ~azure.storage.blob.BlobServiceClient
|
618
619
|
|
619
620
|
.. admonition:: Example:
|
@@ -656,7 +657,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
656
657
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
657
658
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
658
659
|
#other-client--per-operation-configuration>`__.
|
659
|
-
:
|
660
|
+
:return: Access policy information in a dict.
|
660
661
|
:rtype: dict[str, Any]
|
661
662
|
|
662
663
|
.. admonition:: Example:
|
@@ -723,7 +724,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
723
724
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
724
725
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
725
726
|
#other-client--per-operation-configuration>`__.
|
726
|
-
:
|
727
|
+
:return: Container-updated property dict (Etag and last modified).
|
727
728
|
:rtype: dict[str, str or ~datetime.datetime]
|
728
729
|
|
729
730
|
.. admonition:: Example:
|
@@ -787,7 +788,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
787
788
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
788
789
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
789
790
|
#other-client--per-operation-configuration>`__.
|
790
|
-
:
|
791
|
+
:return: An iterable (auto-paging) response of BlobProperties.
|
791
792
|
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.storage.blob.BlobProperties]
|
792
793
|
|
793
794
|
.. admonition:: Example:
|
@@ -840,7 +841,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
840
841
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
841
842
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
842
843
|
#other-client--per-operation-configuration>`__.
|
843
|
-
:
|
844
|
+
:return: An iterable (auto-paging) response of blob names as strings.
|
844
845
|
:rtype: ~azure.core.async_paging.AsyncItemPaged[str]
|
845
846
|
"""
|
846
847
|
if kwargs.pop('prefix', None):
|
@@ -873,7 +874,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
873
874
|
include: Optional[Union[List[str], str]] = None,
|
874
875
|
delimiter: str = "/",
|
875
876
|
**kwargs: Any
|
876
|
-
) -> AsyncItemPaged[BlobProperties]:
|
877
|
+
) -> AsyncItemPaged[Union[BlobProperties, BlobPrefix]]:
|
877
878
|
"""Returns a generator to list the blobs under the specified container.
|
878
879
|
The generator will lazily follow the continuation tokens returned by
|
879
880
|
the service. This operation will list blobs in accordance with a hierarchy,
|
@@ -898,8 +899,9 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
898
899
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
899
900
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
900
901
|
#other-client--per-operation-configuration>`__.
|
901
|
-
:
|
902
|
-
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.storage.blob.BlobProperties
|
902
|
+
:return: An iterable (auto-paging) response of BlobProperties.
|
903
|
+
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.storage.blob.BlobProperties or
|
904
|
+
~azure.storage.blob.aio.BlobPrefix]
|
903
905
|
"""
|
904
906
|
if kwargs.pop('prefix', None):
|
905
907
|
raise ValueError("Passing 'prefix' has no effect on filtering, " +
|
@@ -944,7 +946,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
944
946
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
945
947
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
946
948
|
#other-client--per-operation-configuration>`__.
|
947
|
-
:
|
949
|
+
:return: An iterable (auto-paging) response of FilteredBlob.
|
948
950
|
:rtype: ~azure.core.paging.ItemPaged[~azure.storage.blob.BlobProperties]
|
949
951
|
"""
|
950
952
|
results_per_page = kwargs.pop('results_per_page', None)
|
@@ -1071,7 +1073,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
1071
1073
|
function(current: int, total: Optional[int]) where current is the number of bytes transferred
|
1072
1074
|
so far, and total is the size of the blob or None if the size is unknown.
|
1073
1075
|
:paramtype progress_hook: Callable[[int, Optional[int]], Awaitable[None]]
|
1074
|
-
:
|
1076
|
+
:return: A BlobClient to interact with the newly uploaded blob.
|
1075
1077
|
:rtype: ~azure.storage.blob.aio.BlobClient
|
1076
1078
|
|
1077
1079
|
.. admonition:: Example:
|
@@ -1121,7 +1123,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
1121
1123
|
and retains the blob or snapshot for specified number of days.
|
1122
1124
|
After specified number of days, blob's data is removed from the service during garbage collection.
|
1123
1125
|
Soft deleted blobs or snapshots are accessible through :func:`list_blobs()` specifying `include=["deleted"]`
|
1124
|
-
Soft-deleted blob or snapshot can be restored using :func:`~azure.storage.blob.aio.BlobClient.
|
1126
|
+
Soft-deleted blob or snapshot can be restored using :func:`~azure.storage.blob.aio.BlobClient.undelete_blob()`
|
1125
1127
|
|
1126
1128
|
:param str blob: The blob with which to interact.
|
1127
1129
|
:param str delete_snapshots:
|
@@ -1169,6 +1171,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
1169
1171
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
1170
1172
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
1171
1173
|
#other-client--per-operation-configuration>`__.
|
1174
|
+
:return: None
|
1172
1175
|
:rtype: None
|
1173
1176
|
"""
|
1174
1177
|
if isinstance(blob, BlobProperties):
|
@@ -1295,7 +1298,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
1295
1298
|
the timeout will apply to each call individually.
|
1296
1299
|
multiple calls to the Azure service and the timeout will apply to
|
1297
1300
|
each call individually.
|
1298
|
-
:
|
1301
|
+
:return: A streaming object. (StorageStreamDownloader)
|
1299
1302
|
:rtype: ~azure.storage.blob.aio.StorageStreamDownloader
|
1300
1303
|
"""
|
1301
1304
|
if isinstance(blob, BlobProperties):
|
@@ -1327,7 +1330,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
1327
1330
|
and retains the blobs or snapshots for specified number of days.
|
1328
1331
|
After specified number of days, blobs' data is removed from the service during garbage collection.
|
1329
1332
|
Soft deleted blobs or snapshots are accessible through :func:`list_blobs()` specifying `include=["deleted"]`
|
1330
|
-
Soft-deleted blobs or snapshots can be restored using :func:`~azure.storage.blob.aio.BlobClient.
|
1333
|
+
Soft-deleted blobs or snapshots can be restored using :func:`~azure.storage.blob.aio.BlobClient.undelete_blob()`
|
1331
1334
|
|
1332
1335
|
The maximum number of blobs that can be deleted in a single request is 256.
|
1333
1336
|
|
@@ -1393,7 +1396,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
1393
1396
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
1394
1397
|
#other-client--per-operation-configuration>`__.
|
1395
1398
|
:return: An async iterator of responses, one for each blob in order
|
1396
|
-
:rtype:
|
1399
|
+
:rtype: AsyncIterator[~azure.core.pipeline.transport.AsyncHttpResponse]
|
1397
1400
|
|
1398
1401
|
.. admonition:: Example:
|
1399
1402
|
|
@@ -1485,7 +1488,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
1485
1488
|
is raised even if there is a single operation failure. For optimal performance,
|
1486
1489
|
this should be set to False.
|
1487
1490
|
:return: An async iterator of responses, one for each blob in order
|
1488
|
-
:rtype:
|
1491
|
+
:rtype: AsyncIterator[~azure.core.pipeline.transport.AsyncHttpResponse]
|
1489
1492
|
"""
|
1490
1493
|
if self._is_localhost:
|
1491
1494
|
kwargs['url_prepend'] = self.account_name
|
@@ -1546,7 +1549,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
1546
1549
|
is raised even if there is a single operation failure. For optimal performance,
|
1547
1550
|
this should be set to False.
|
1548
1551
|
:return: An async iterator of responses, one for each blob in order
|
1549
|
-
:rtype:
|
1552
|
+
:rtype: AsyncIterator[~azure.core.pipeline.transport.AsyncHttpResponse]
|
1550
1553
|
"""
|
1551
1554
|
if self._is_localhost:
|
1552
1555
|
kwargs['url_prepend'] = self.account_name
|
@@ -1577,7 +1580,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
|
|
1577
1580
|
or the response returned from :func:`~BlobClient.create_snapshot()`.
|
1578
1581
|
:keyword str version_id: The version id parameter is an opaque DateTime value that, when present,
|
1579
1582
|
specifies the version of the blob to operate on.
|
1580
|
-
:
|
1583
|
+
:return: A BlobClient.
|
1581
1584
|
:rtype: ~azure.storage.blob.aio.BlobClient
|
1582
1585
|
|
1583
1586
|
.. admonition:: Example:
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# pylint: disable=invalid-overridden-method
|
7
7
|
# mypy: disable-error-code=override
|
8
8
|
|
9
|
-
import asyncio
|
9
|
+
import asyncio # pylint: disable=do-not-import-asyncio
|
10
10
|
import codecs
|
11
11
|
import sys
|
12
12
|
import warnings
|
@@ -46,8 +46,10 @@ T = TypeVar('T', bytes, str)
|
|
46
46
|
async def process_content(data: Any, start_offset: int, end_offset: int, encryption: Dict[str, Any]) -> bytes:
|
47
47
|
if data is None:
|
48
48
|
raise ValueError("Response cannot be None.")
|
49
|
-
|
50
|
-
|
49
|
+
if hasattr(data.response, "is_stream_consumed") and data.response.is_stream_consumed:
|
50
|
+
content = data.response.content
|
51
|
+
else:
|
52
|
+
content = b"".join([d async for d in data])
|
51
53
|
if encryption.get('key') is not None or encryption.get('resolver') is not None:
|
52
54
|
try:
|
53
55
|
return decrypt_blob(
|
@@ -57,12 +59,14 @@ async def process_content(data: Any, start_offset: int, end_offset: int, encrypt
|
|
57
59
|
content,
|
58
60
|
start_offset,
|
59
61
|
end_offset,
|
60
|
-
data.response.headers
|
62
|
+
data.response.headers
|
63
|
+
)
|
61
64
|
except Exception as error:
|
62
65
|
raise HttpResponseError(
|
63
66
|
message="Decryption failed.",
|
64
67
|
response=data.response,
|
65
|
-
error=error
|
68
|
+
error=error
|
69
|
+
) from error
|
66
70
|
return content
|
67
71
|
|
68
72
|
|
@@ -449,7 +453,7 @@ class StorageStreamDownloader(Generic[T]): # pylint: disable=too-many-instance-
|
|
449
453
|
|
450
454
|
NOTE: If the stream has been partially read, some data may be re-downloaded by the iterator.
|
451
455
|
|
452
|
-
:
|
456
|
+
:return: An async iterator of the chunks in the download stream.
|
453
457
|
:rtype: AsyncIterator[bytes]
|
454
458
|
|
455
459
|
.. admonition:: Example:
|
@@ -523,7 +527,7 @@ class StorageStreamDownloader(Generic[T]): # pylint: disable=too-many-instance-
|
|
523
527
|
The number of chars to download from the stream. Leave unspecified
|
524
528
|
or set negative to download all chars. Note, this can only be used
|
525
529
|
when encoding is specified on `download_blob`.
|
526
|
-
:
|
530
|
+
:return:
|
527
531
|
The requested data as bytes or a string if encoding was specified. If
|
528
532
|
the return value is empty, there is no more data to read.
|
529
533
|
:rtype: T
|
@@ -676,7 +680,7 @@ class StorageStreamDownloader(Generic[T]): # pylint: disable=too-many-instance-
|
|
676
680
|
Read the entire contents of this blob.
|
677
681
|
This operation is blocking until all data is downloaded.
|
678
682
|
|
679
|
-
:
|
683
|
+
:return: The requested data as bytes or a string if encoding was specified.
|
680
684
|
:rtype: T
|
681
685
|
"""
|
682
686
|
return await self.read()
|
@@ -688,7 +692,7 @@ class StorageStreamDownloader(Generic[T]): # pylint: disable=too-many-instance-
|
|
688
692
|
The stream to download to. This can be an open file-handle,
|
689
693
|
or any writable stream. The stream must be seekable if the download
|
690
694
|
uses more than one parallel connection.
|
691
|
-
:
|
695
|
+
:return: The number of bytes read.
|
692
696
|
:rtype: int
|
693
697
|
"""
|
694
698
|
if self._text_mode:
|
@@ -805,7 +809,7 @@ class StorageStreamDownloader(Generic[T]): # pylint: disable=too-many-instance-
|
|
805
809
|
|
806
810
|
:param int max_concurrency:
|
807
811
|
The number of parallel connections with which to download.
|
808
|
-
:
|
812
|
+
:return: The contents of the file as bytes.
|
809
813
|
:rtype: bytes
|
810
814
|
"""
|
811
815
|
warnings.warn(
|
@@ -830,7 +834,7 @@ class StorageStreamDownloader(Generic[T]): # pylint: disable=too-many-instance-
|
|
830
834
|
The number of parallel connections with which to download.
|
831
835
|
:param str encoding:
|
832
836
|
Test encoding to decode the downloaded bytes. Default is UTF-8.
|
833
|
-
:
|
837
|
+
:return: The content of the file as a str.
|
834
838
|
:rtype: str
|
835
839
|
"""
|
836
840
|
warnings.warn(
|
@@ -856,7 +860,7 @@ class StorageStreamDownloader(Generic[T]): # pylint: disable=too-many-instance-
|
|
856
860
|
uses more than one parallel connection.
|
857
861
|
:param int max_concurrency:
|
858
862
|
The number of parallel connections with which to download.
|
859
|
-
:
|
863
|
+
:return: The properties of the downloaded blob.
|
860
864
|
:rtype: Any
|
861
865
|
"""
|
862
866
|
warnings.warn(
|
@@ -107,6 +107,7 @@ class BlobLeaseClient(): # pylint: disable=client-accepts-api-version-keyword
|
|
107
107
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
108
108
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
109
109
|
#other-client--per-operation-configuration>`__.
|
110
|
+
:return: None
|
110
111
|
:rtype: None
|
111
112
|
"""
|
112
113
|
mod_conditions = get_modify_conditions(kwargs)
|
@@ -0,0 +1,194 @@
|
|
1
|
+
# -------------------------------------------------------------------------
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
3
|
+
# Licensed under the MIT License. See License.txt in the project root for
|
4
|
+
# license information.
|
5
|
+
# --------------------------------------------------------------------------
|
6
|
+
|
7
|
+
from io import BytesIO
|
8
|
+
from typing import (
|
9
|
+
Any, AsyncGenerator, AsyncIterable, Dict, IO, Optional, Type,
|
10
|
+
TYPE_CHECKING
|
11
|
+
)
|
12
|
+
|
13
|
+
from .._shared.avro.avro_io_async import AsyncDatumReader
|
14
|
+
from .._shared.avro.datafile_async import AsyncDataFileReader
|
15
|
+
|
16
|
+
if TYPE_CHECKING:
|
17
|
+
from .._models import BlobQueryError
|
18
|
+
|
19
|
+
|
20
|
+
class BlobQueryReader: # pylint: disable=too-many-instance-attributes
|
21
|
+
"""A streaming object to read query results."""
|
22
|
+
|
23
|
+
name: str
|
24
|
+
"""The name of the blob being queried."""
|
25
|
+
container: str
|
26
|
+
"""The name of the container where the blob is."""
|
27
|
+
response_headers: Dict[str, Any]
|
28
|
+
"""The response headers of the quick query request."""
|
29
|
+
record_delimiter: str
|
30
|
+
"""The delimiter used to separate lines, or records with the data. The `records`
|
31
|
+
method will return these lines via a generator."""
|
32
|
+
|
33
|
+
def __init__(
|
34
|
+
self, name: str = None, # type: ignore [assignment]
|
35
|
+
container: str = None, # type: ignore [assignment]
|
36
|
+
errors: Any = None,
|
37
|
+
record_delimiter: str = '\n',
|
38
|
+
encoding: Optional[str] = None,
|
39
|
+
headers: Dict[str, Any] = None, # type: ignore [assignment]
|
40
|
+
response: Any = None,
|
41
|
+
error_cls: Type["BlobQueryError"] = None, # type: ignore [assignment]
|
42
|
+
) -> None:
|
43
|
+
self.name = name
|
44
|
+
self.container = container
|
45
|
+
self.response_headers = headers
|
46
|
+
self.record_delimiter = record_delimiter
|
47
|
+
self._size = 0
|
48
|
+
self._bytes_processed = 0
|
49
|
+
self._errors = errors
|
50
|
+
self._encoding = encoding
|
51
|
+
self._parsed_results = AsyncDataFileReader(QuickQueryStreamer(response), AsyncDatumReader())
|
52
|
+
self._error_cls = error_cls
|
53
|
+
|
54
|
+
async def _setup(self):
|
55
|
+
self._parsed_results = await self._parsed_results.init()
|
56
|
+
first_result = await self._parsed_results.__anext__()
|
57
|
+
self._first_result = self._process_record(first_result) # pylint: disable=attribute-defined-outside-init
|
58
|
+
|
59
|
+
def __len__(self) -> int:
|
60
|
+
return self._size
|
61
|
+
|
62
|
+
def _process_record(self, result: Dict[str, Any]) -> Optional[bytes]:
|
63
|
+
self._size = result.get('totalBytes', self._size)
|
64
|
+
self._bytes_processed = result.get('bytesScanned', self._bytes_processed)
|
65
|
+
if 'data' in result:
|
66
|
+
return result.get('data')
|
67
|
+
if 'fatal' in result:
|
68
|
+
error = self._error_cls(
|
69
|
+
error=result['name'],
|
70
|
+
is_fatal=result['fatal'],
|
71
|
+
description=result['description'],
|
72
|
+
position=result['position']
|
73
|
+
)
|
74
|
+
if self._errors:
|
75
|
+
self._errors(error)
|
76
|
+
return None
|
77
|
+
|
78
|
+
async def _aiter_stream(self) -> AsyncGenerator[bytes, None]:
|
79
|
+
if self._first_result is not None:
|
80
|
+
yield self._first_result
|
81
|
+
async for next_result in self._parsed_results:
|
82
|
+
processed_result = self._process_record(next_result)
|
83
|
+
if processed_result is not None:
|
84
|
+
yield processed_result
|
85
|
+
|
86
|
+
async def readall(self) -> bytes:
|
87
|
+
"""Return all query results.
|
88
|
+
|
89
|
+
This operation is blocking until all data is downloaded.
|
90
|
+
|
91
|
+
:return: The query results.
|
92
|
+
:rtype: bytes
|
93
|
+
"""
|
94
|
+
stream = BytesIO()
|
95
|
+
await self.readinto(stream)
|
96
|
+
data = stream.getvalue()
|
97
|
+
if self._encoding:
|
98
|
+
return data.decode(self._encoding) # type: ignore [return-value]
|
99
|
+
return data
|
100
|
+
|
101
|
+
async def readinto(self, stream: IO) -> None:
|
102
|
+
"""Download the query result to a stream.
|
103
|
+
|
104
|
+
:param IO stream:
|
105
|
+
The stream to download to. This can be an open file-handle,
|
106
|
+
or any writable stream.
|
107
|
+
:return: None
|
108
|
+
"""
|
109
|
+
async for record in self._aiter_stream():
|
110
|
+
stream.write(record)
|
111
|
+
|
112
|
+
async def records(self) -> AsyncIterable[bytes]:
|
113
|
+
"""Returns a record generator for the query result.
|
114
|
+
|
115
|
+
Records will be returned line by line.
|
116
|
+
|
117
|
+
:return: A record generator for the query result.
|
118
|
+
:rtype: AsyncIterable[bytes]
|
119
|
+
"""
|
120
|
+
delimiter = self.record_delimiter.encode('utf-8')
|
121
|
+
async for record_chunk in self._aiter_stream():
|
122
|
+
for record in record_chunk.split(delimiter):
|
123
|
+
if self._encoding:
|
124
|
+
yield record.decode(self._encoding) # type: ignore [misc]
|
125
|
+
else:
|
126
|
+
yield record
|
127
|
+
|
128
|
+
|
129
|
+
class QuickQueryStreamer:
|
130
|
+
"""File-like streaming iterator."""
|
131
|
+
|
132
|
+
def __init__(self, generator):
|
133
|
+
self.generator = generator
|
134
|
+
self.iterator = generator.__aiter__()
|
135
|
+
self._buf = b""
|
136
|
+
self._point = 0
|
137
|
+
self._download_offset = 0
|
138
|
+
self._buf_start = 0
|
139
|
+
self.file_length = None
|
140
|
+
|
141
|
+
def __len__(self):
|
142
|
+
return self.file_length
|
143
|
+
|
144
|
+
def __aiter__(self):
|
145
|
+
return self.iterator
|
146
|
+
|
147
|
+
@staticmethod
|
148
|
+
def seekable():
|
149
|
+
return True
|
150
|
+
|
151
|
+
async def __anext__(self):
|
152
|
+
next_part = await self.iterator.__anext__()
|
153
|
+
self._download_offset += len(next_part)
|
154
|
+
return next_part
|
155
|
+
|
156
|
+
def tell(self):
|
157
|
+
return self._point
|
158
|
+
|
159
|
+
async def seek(self, offset, whence=0):
|
160
|
+
if whence == 0:
|
161
|
+
self._point = offset
|
162
|
+
elif whence == 1:
|
163
|
+
self._point += offset
|
164
|
+
else:
|
165
|
+
raise ValueError("whence must be 0 or 1")
|
166
|
+
if self._point < 0: # pylint: disable=consider-using-max-builtin
|
167
|
+
self._point = 0
|
168
|
+
|
169
|
+
async def read(self, size):
|
170
|
+
try:
|
171
|
+
# keep reading from the generator until the buffer of this stream has enough data to read
|
172
|
+
while self._point + size > self._download_offset:
|
173
|
+
self._buf += await self.__anext__()
|
174
|
+
except StopAsyncIteration:
|
175
|
+
self.file_length = self._download_offset
|
176
|
+
|
177
|
+
start_point = self._point
|
178
|
+
|
179
|
+
# EOF
|
180
|
+
self._point = min(self._point + size, self._download_offset)
|
181
|
+
|
182
|
+
relative_start = start_point - self._buf_start
|
183
|
+
if relative_start < 0:
|
184
|
+
raise ValueError("Buffer has dumped too much data")
|
185
|
+
relative_end = relative_start + size
|
186
|
+
data = self._buf[relative_start:relative_end]
|
187
|
+
|
188
|
+
# dump the extra data in buffer
|
189
|
+
# buffer start--------------------16bytes----current read position
|
190
|
+
dumped_size = max(relative_end - 16 - relative_start, 0)
|
191
|
+
self._buf_start += dumped_size
|
192
|
+
self._buf = self._buf[dumped_size:]
|
193
|
+
|
194
|
+
return data
|