azure-storage-blob 12.19.1__py3-none-any.whl → 12.20.0b1__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 (57) hide show
  1. azure/storage/blob/__init__.py +7 -5
  2. azure/storage/blob/_blob_client.py +12 -4
  3. azure/storage/blob/_blob_service_client.py +4 -3
  4. azure/storage/blob/_container_client.py +28 -12
  5. azure/storage/blob/_download.py +3 -3
  6. azure/storage/blob/_encryption.py +254 -165
  7. azure/storage/blob/_generated/_azure_blob_storage.py +21 -3
  8. azure/storage/blob/_generated/_configuration.py +4 -11
  9. azure/storage/blob/_generated/_serialization.py +41 -49
  10. azure/storage/blob/_generated/aio/_azure_blob_storage.py +23 -3
  11. azure/storage/blob/_generated/aio/_configuration.py +4 -11
  12. azure/storage/blob/_generated/aio/operations/_append_blob_operations.py +24 -58
  13. azure/storage/blob/_generated/aio/operations/_blob_operations.py +123 -306
  14. azure/storage/blob/_generated/aio/operations/_block_blob_operations.py +37 -86
  15. azure/storage/blob/_generated/aio/operations/_container_operations.py +98 -289
  16. azure/storage/blob/_generated/aio/operations/_page_blob_operations.py +51 -150
  17. azure/storage/blob/_generated/aio/operations/_service_operations.py +49 -125
  18. azure/storage/blob/_generated/models/_models_py3.py +31 -31
  19. azure/storage/blob/_generated/operations/_append_blob_operations.py +25 -59
  20. azure/storage/blob/_generated/operations/_blob_operations.py +123 -306
  21. azure/storage/blob/_generated/operations/_block_blob_operations.py +39 -88
  22. azure/storage/blob/_generated/operations/_container_operations.py +100 -291
  23. azure/storage/blob/_generated/operations/_page_blob_operations.py +52 -151
  24. azure/storage/blob/_generated/operations/_service_operations.py +50 -126
  25. azure/storage/blob/_models.py +3 -4
  26. azure/storage/blob/_serialize.py +1 -0
  27. azure/storage/blob/_shared/authentication.py +1 -1
  28. azure/storage/blob/_shared/avro/avro_io.py +0 -6
  29. azure/storage/blob/_shared/avro/avro_io_async.py +0 -6
  30. azure/storage/blob/_shared/avro/datafile.py +0 -4
  31. azure/storage/blob/_shared/avro/datafile_async.py +0 -4
  32. azure/storage/blob/_shared/avro/schema.py +4 -4
  33. azure/storage/blob/_shared/base_client.py +72 -87
  34. azure/storage/blob/_shared/base_client_async.py +115 -27
  35. azure/storage/blob/_shared/models.py +112 -20
  36. azure/storage/blob/_shared/parser.py +7 -6
  37. azure/storage/blob/_shared/policies.py +96 -66
  38. azure/storage/blob/_shared/policies_async.py +48 -21
  39. azure/storage/blob/_shared/response_handlers.py +14 -16
  40. azure/storage/blob/_shared/shared_access_signature.py +2 -3
  41. azure/storage/blob/_shared_access_signature.py +37 -27
  42. azure/storage/blob/_upload_helpers.py +4 -7
  43. azure/storage/blob/_version.py +1 -1
  44. azure/storage/blob/aio/__init__.py +2 -2
  45. azure/storage/blob/aio/_blob_client_async.py +16 -5
  46. azure/storage/blob/aio/_blob_service_client_async.py +3 -1
  47. azure/storage/blob/aio/_container_client_async.py +25 -8
  48. azure/storage/blob/aio/_download_async.py +9 -9
  49. azure/storage/blob/aio/_encryption_async.py +72 -0
  50. azure/storage/blob/aio/_upload_helpers.py +8 -10
  51. {azure_storage_blob-12.19.1.dist-info → azure_storage_blob-12.20.0b1.dist-info}/METADATA +9 -9
  52. azure_storage_blob-12.20.0b1.dist-info/RECORD +81 -0
  53. {azure_storage_blob-12.19.1.dist-info → azure_storage_blob-12.20.0b1.dist-info}/WHEEL +1 -1
  54. azure/storage/blob/_generated/py.typed +0 -1
  55. azure_storage_blob-12.19.1.dist-info/RECORD +0 -81
  56. {azure_storage_blob-12.19.1.dist-info → azure_storage_blob-12.20.0b1.dist-info}/LICENSE +0 -0
  57. {azure_storage_blob-12.19.1.dist-info → azure_storage_blob-12.20.0b1.dist-info}/top_level.txt +0 -0
@@ -21,7 +21,8 @@ from ._shared.models import(
21
21
  ResourceTypes,
22
22
  AccountSasPermissions,
23
23
  StorageErrorCode,
24
- UserDelegationKey
24
+ UserDelegationKey,
25
+ Services
25
26
  )
26
27
  from ._generated.models import (
27
28
  RehydratePriority,
@@ -60,7 +61,7 @@ from ._models import (
60
61
  ArrowType,
61
62
  ObjectReplicationPolicy,
62
63
  ObjectReplicationRule,
63
- ImmutabilityPolicy
64
+ ImmutabilityPolicy,
64
65
  )
65
66
  from ._list_blobs_helper import BlobPrefix
66
67
 
@@ -91,7 +92,7 @@ def upload_blob_to_url(
91
92
  - except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError.
92
93
  If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key"
93
94
  should be the storage account key.
94
- :paramtype credential: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long
95
+ :type credential: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long
95
96
  :keyword bool overwrite:
96
97
  Whether the blob to be uploaded should overwrite the current data.
97
98
  If True, upload_blob_to_url will overwrite any existing data. If set to False, the
@@ -155,7 +156,7 @@ def download_blob_from_url(
155
156
  - except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError.
156
157
  If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key"
157
158
  should be the storage account key.
158
- :paramtype credential: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long
159
+ :type credential: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long
159
160
  :keyword bool overwrite:
160
161
  Whether the local file should be overwritten if it already exists. The default value is
161
162
  `False` - in which case a ValueError will be raised if the file already exists. If set to
@@ -246,5 +247,6 @@ __all__ = [
246
247
  'ArrowType',
247
248
  'BlobQueryReader',
248
249
  'ObjectReplicationPolicy',
249
- 'ObjectReplicationRule'
250
+ 'ObjectReplicationRule',
251
+ 'Services',
250
252
  ]
@@ -449,7 +449,6 @@ class BlobClient(StorageAccountHostsMixin, StorageEncryptionMixin): # pylint: d
449
449
 
450
450
  if blob_type == BlobType.BlockBlob:
451
451
  kwargs['client'] = self._client.block_blob
452
- kwargs['data'] = data
453
452
  elif blob_type == BlobType.PageBlob:
454
453
  if self.encryption_version == '2.0' and (self.require_encryption or self.key_encryption_key is not None):
455
454
  raise ValueError("Encryption version 2.0 does not currently support page blobs.")
@@ -602,6 +601,8 @@ class BlobClient(StorageAccountHostsMixin, StorageEncryptionMixin): # pylint: d
602
601
  :keyword str source_authorization:
603
602
  Authenticate as a service principal using a client secret to access a source blob. Ensure "bearer " is
604
603
  the prefix of the source_authorization string.
604
+ :returns: Response from creating a new block blob for a given URL.
605
+ :rtype: Dict[str, Any]
605
606
  """
606
607
  options = self._upload_blob_from_url_options(
607
608
  source_url=self._encode_source_url(source_url),
@@ -613,7 +614,7 @@ class BlobClient(StorageAccountHostsMixin, StorageEncryptionMixin): # pylint: d
613
614
 
614
615
  @distributed_trace
615
616
  def upload_blob(
616
- self, data: Union[bytes, str, Iterable[AnyStr], IO[AnyStr]],
617
+ self, data: Union[bytes, str, Iterable[AnyStr], IO[bytes]],
617
618
  blob_type: Union[str, BlobType] = BlobType.BlockBlob,
618
619
  length: Optional[int] = None,
619
620
  metadata: Optional[Dict[str, str]] = None,
@@ -622,6 +623,7 @@ class BlobClient(StorageAccountHostsMixin, StorageEncryptionMixin): # pylint: d
622
623
  """Creates a new blob from a data source with automatic chunking.
623
624
 
624
625
  :param data: The blob data to upload.
626
+ :type data: Union[bytes, str, Iterable[AnyStr], IO[AnyStr]]
625
627
  :param ~azure.storage.blob.BlobType blob_type: The type of the blob. This can be
626
628
  either BlockBlob, PageBlob or AppendBlob. The default value is BlockBlob.
627
629
  :param int length:
@@ -1025,7 +1027,7 @@ class BlobClient(StorageAccountHostsMixin, StorageEncryptionMixin): # pylint: d
1025
1027
  These dialects can be passed through their respective classes, the QuickQueryDialect enum or as a string
1026
1028
 
1027
1029
  .. note::
1028
- "ParquetDialect" is in preview, so some features may not work as intended.
1030
+ "ParquetDialect" is in preview, so some features may not work as intended.
1029
1031
 
1030
1032
  :paramtype blob_format: ~azure.storage.blob.DelimitedTextDialect or ~azure.storage.blob.DelimitedJsonDialect
1031
1033
  or ~azure.storage.blob.QuickQueryDialect or str
@@ -1532,6 +1534,7 @@ class BlobClient(StorageAccountHostsMixin, StorageEncryptionMixin): # pylint: d
1532
1534
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
1533
1535
  #other-client--per-operation-configuration>`_.
1534
1536
  :returns: Blob-updated property dict (Etag and last modified)
1537
+ :rtype: Dict[str, Union[str, datetime]]
1535
1538
  """
1536
1539
  options = self._set_blob_metadata_options(metadata=metadata, **kwargs)
1537
1540
  try:
@@ -2515,6 +2518,7 @@ class BlobClient(StorageAccountHostsMixin, StorageEncryptionMixin): # pylint: d
2515
2518
  The string should be less than or equal to 64 bytes in size.
2516
2519
  For a given blob, the block_id must be the same size for each block.
2517
2520
  :param data: The blob data.
2521
+ :type data: Union[Iterable[AnyStr], IO[AnyStr]]
2518
2522
  :param int length: Size of the block.
2519
2523
  :keyword bool validate_content:
2520
2524
  If true, calculates an MD5 hash for each chunk of the blob. The storage
@@ -3284,7 +3288,7 @@ class BlobClient(StorageAccountHostsMixin, StorageEncryptionMixin): # pylint: d
3284
3288
  .. versionadded:: 12.2.0
3285
3289
  This operation was introduced in API version '2019-07-07'.
3286
3290
 
3287
- :param previous_snapshot_url:
3291
+ :param str previous_snapshot_url:
3288
3292
  Specifies the URL of a previous snapshot of the managed disk.
3289
3293
  The response will only contain pages that were changed between the target blob and
3290
3294
  its previous snapshot.
@@ -3812,6 +3816,8 @@ class BlobClient(StorageAccountHostsMixin, StorageEncryptionMixin): # pylint: d
3812
3816
  :keyword str source_authorization:
3813
3817
  Authenticate as a service principal using a client secret to access a source blob. Ensure "bearer " is
3814
3818
  the prefix of the source_authorization string.
3819
+ :returns: Response after uploading pages from specified URL.
3820
+ :rtype: Dict[str, Any]
3815
3821
  """
3816
3822
  options = self._upload_pages_from_url_options(
3817
3823
  source_url=self._encode_source_url(source_url),
@@ -4240,6 +4246,8 @@ class BlobClient(StorageAccountHostsMixin, StorageEncryptionMixin): # pylint: d
4240
4246
  :keyword str source_authorization:
4241
4247
  Authenticate as a service principal using a client secret to access a source blob. Ensure "bearer " is
4242
4248
  the prefix of the source_authorization string.
4249
+ :returns: Result after appending a new block.
4250
+ :rtype: Dict[str, Union[str, datetime, int]]
4243
4251
  """
4244
4252
  options = self._append_block_from_url_options(
4245
4253
  copy_source_url=self._encode_source_url(copy_source_url),
@@ -171,7 +171,7 @@ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
171
171
  Credentials provided here will take precedence over those in the connection string.
172
172
  If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key"
173
173
  should be the storage account key.
174
- :paramtype credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] # pylint: disable=line-too-long
174
+ :type credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] # pylint: disable=line-too-long
175
175
  :keyword str audience: The audience to use when requesting tokens for Azure Active Directory
176
176
  authentication. Only has an effect when credential is of type TokenCredential. The value could be
177
177
  https://storage.azure.com/ (default) or https://<account>.blob.core.windows.net.
@@ -551,6 +551,7 @@ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
551
551
  This value is not tracked or validated on the client. To configure client-side network timesouts
552
552
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
553
553
  #other-client--per-operation-configuration>`_.
554
+ :returns: A container client to interact with the newly created container.
554
555
  :rtype: ~azure.storage.blob.ContainerClient
555
556
 
556
557
  .. admonition:: Example:
@@ -588,7 +589,7 @@ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
588
589
  If specified, delete_container only succeeds if the
589
590
  container's lease is active and matches this ID.
590
591
  Required if the container has an active lease.
591
- :paramtype lease: ~azure.storage.blob.BlobLeaseClient or str
592
+ :type lease: ~azure.storage.blob.BlobLeaseClient or str
592
593
  :keyword ~datetime.datetime if_modified_since:
593
594
  A DateTime value. Azure expects the date value passed in to be UTC.
594
595
  If timezone is included, any non-UTC datetimes will be converted to UTC.
@@ -612,7 +613,6 @@ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
612
613
  This value is not tracked or validated on the client. To configure client-side network timesouts
613
614
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
614
615
  #other-client--per-operation-configuration>`_.
615
- :rtype: None
616
616
 
617
617
  .. admonition:: Example:
618
618
 
@@ -652,6 +652,7 @@ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
652
652
  This value is not tracked or validated on the client. To configure client-side network timesouts
653
653
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
654
654
  #other-client--per-operation-configuration>`_.
655
+ :returns: A container client for the renamed container.
655
656
  :rtype: ~azure.storage.blob.ContainerClient
656
657
  """
657
658
  renamed_container = self.get_container_client(new_name)
@@ -65,7 +65,7 @@ def _get_blob_name(blob):
65
65
  """Return the blob name.
66
66
 
67
67
  :param blob: A blob string or BlobProperties
68
- :paramtype blob: str or BlobProperties
68
+ :type blob: str or BlobProperties
69
69
  :returns: The name of the blob.
70
70
  :rtype: str
71
71
  """
@@ -202,7 +202,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
202
202
  - except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError.
203
203
  If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key"
204
204
  should be the storage account key.
205
- :paramtype credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
205
+ :type credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
206
206
  :keyword str audience: The audience to use when requesting tokens for Azure Active Directory
207
207
  authentication. Only has an effect when credential is of type TokenCredential. The value could be
208
208
  https://storage.azure.com/ (default) or https://<account>.blob.core.windows.net.
@@ -251,7 +251,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
251
251
  Credentials provided here will take precedence over those in the connection string.
252
252
  If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key"
253
253
  should be the storage account key.
254
- :paramtype credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
254
+ :type credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
255
255
  :keyword str audience: The audience to use when requesting tokens for Azure Active Directory
256
256
  authentication. Only has an effect when credential is of type TokenCredential. The value could be
257
257
  https://storage.azure.com/ (default) or https://<account>.blob.core.windows.net.
@@ -338,13 +338,14 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
338
338
  :keyword lease:
339
339
  Specify this to perform only if the lease ID given
340
340
  matches the active lease ID of the source container.
341
- :paramtype lease: ~azure.storage.blob.BlobLeaseClient or str
341
+ :type lease: ~azure.storage.blob.BlobLeaseClient or str
342
342
  :keyword int timeout:
343
343
  Sets the server-side timeout for the operation in seconds. For more details see
344
344
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
345
345
  This value is not tracked or validated on the client. To configure client-side network timesouts
346
346
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
347
347
  #other-client--per-operation-configuration>`_.
348
+ :returns: The renamed container client.
348
349
  :rtype: ~azure.storage.blob.ContainerClient
349
350
  """
350
351
  lease = kwargs.pop('lease', None)
@@ -792,8 +793,11 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
792
793
  process_storage_error(error)
793
794
 
794
795
  @distributed_trace
795
- def list_blobs(self, name_starts_with=None, include=None, **kwargs):
796
- # type: (Optional[str], Optional[Union[str, List[str]]], **Any) -> ItemPaged[BlobProperties]
796
+ def list_blobs(
797
+ self, name_starts_with: Optional[str] = None,
798
+ include: Optional[Union[str, List[str]]] = None,
799
+ **kwargs: Any
800
+ ) -> ItemPaged[BlobProperties]:
797
801
  """Returns a generator to list the blobs under the specified container.
798
802
  The generator will lazily follow the continuation tokens returned by
799
803
  the service.
@@ -824,6 +828,10 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
824
828
  :dedent: 8
825
829
  :caption: List the blobs in the container.
826
830
  """
831
+ if kwargs.pop('prefix', None):
832
+ raise ValueError("Passing 'prefix' has no effect on filtering, " +
833
+ "please use the 'name_starts_with' parameter instead.")
834
+
827
835
  if include and not isinstance(include, list):
828
836
  include = [include]
829
837
 
@@ -860,6 +868,10 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
860
868
  :returns: An iterable (auto-paging) response of blob names as strings.
861
869
  :rtype: ~azure.core.paging.ItemPaged[str]
862
870
  """
871
+ if kwargs.pop('prefix', None):
872
+ raise ValueError("Passing 'prefix' has no effect on filtering, " +
873
+ "please use the 'name_starts_with' parameter instead.")
874
+
863
875
  name_starts_with = kwargs.pop('name_starts_with', None)
864
876
  results_per_page = kwargs.pop('results_per_page', None)
865
877
  timeout = kwargs.pop('timeout', None)
@@ -881,12 +893,11 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
881
893
 
882
894
  @distributed_trace
883
895
  def walk_blobs(
884
- self, name_starts_with=None, # type: Optional[str]
885
- include=None, # type: Optional[Union[List[str], str]]
886
- delimiter="/", # type: str
887
- **kwargs # type: Optional[Any]
888
- ):
889
- # type: (...) -> ItemPaged[BlobProperties]
896
+ self, name_starts_with: Optional[str] = None,
897
+ include: Optional[Union[List[str], str]] = None,
898
+ delimiter: str = "/",
899
+ **kwargs: Any
900
+ ) -> ItemPaged[BlobProperties]:
890
901
  """Returns a generator to list the blobs under the specified container.
891
902
  The generator will lazily follow the continuation tokens returned by
892
903
  the service. This operation will list blobs in accordance with a hierarchy,
@@ -914,6 +925,10 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
914
925
  :returns: An iterable (auto-paging) response of BlobProperties.
915
926
  :rtype: ~azure.core.paging.ItemPaged[~azure.storage.blob.BlobProperties]
916
927
  """
928
+ if kwargs.pop('prefix', None):
929
+ raise ValueError("Passing 'prefix' has no effect on filtering, " +
930
+ "please use the 'name_starts_with' parameter instead.")
931
+
917
932
  if include and not isinstance(include, list):
918
933
  include = [include]
919
934
 
@@ -980,6 +995,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
980
995
 
981
996
  :param str name: The blob with which to interact.
982
997
  :param data: The blob data to upload.
998
+ :type data: Union[bytes, str, Iterable[AnyStr], IO[AnyStr]]
983
999
  :param ~azure.storage.blob.BlobType blob_type: The type of the blob. This can be
984
1000
  either BlockBlob, PageBlob or AppendBlob. The default value is BlockBlob.
985
1001
  :param int length:
@@ -236,7 +236,7 @@ class _ChunkIterator(object):
236
236
  self._current_content = content
237
237
  self._iter_downloader = downloader
238
238
  self._iter_chunks = None
239
- self._complete = (size == 0)
239
+ self._complete = size == 0
240
240
 
241
241
  def __len__(self):
242
242
  return self.size
@@ -700,10 +700,10 @@ class StorageStreamDownloader(Generic[T]): # pylint: disable=too-many-instance-
700
700
  self._encoding = encoding
701
701
  return self.readall()
702
702
 
703
- def readinto(self, stream: IO[T]) -> int:
703
+ def readinto(self, stream: IO[bytes]) -> int:
704
704
  """Download the contents of this file to a stream.
705
705
 
706
- :param IO[T] stream:
706
+ :param IO[bytes] stream:
707
707
  The stream to download to. This can be an open file-handle,
708
708
  or any writable stream. The stream must be seekable if the download
709
709
  uses more than one parallel connection.