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
@@ -7,7 +7,7 @@
7
7
 
8
8
  import os
9
9
 
10
- from typing import Union, Iterable, AnyStr, IO, Any, Dict # pylint: disable=unused-import
10
+ from typing import Any, AnyStr, cast, Dict, IO, Iterable, Optional, Union, TYPE_CHECKING
11
11
  from ._version import VERSION
12
12
  from ._blob_client import BlobClient
13
13
  from ._container_client import ContainerClient
@@ -18,7 +18,7 @@ from ._quick_query_helper import BlobQueryReader
18
18
  from ._shared_access_signature import generate_account_sas, generate_container_sas, generate_blob_sas
19
19
  from ._shared.policies import ExponentialRetry, LinearRetry
20
20
  from ._shared.response_handlers import PartialBatchErrorException
21
- from ._shared.models import(
21
+ from ._shared.models import (
22
22
  LocationMode,
23
23
  ResourceTypes,
24
24
  AccountSasPermissions,
@@ -26,9 +26,7 @@ from ._shared.models import(
26
26
  UserDelegationKey,
27
27
  Services
28
28
  )
29
- from ._generated.models import (
30
- RehydratePriority,
31
- )
29
+ from ._generated.models import RehydratePriority
32
30
  from ._models import (
33
31
  BlobType,
34
32
  BlockState,
@@ -67,15 +65,18 @@ from ._models import (
67
65
  )
68
66
  from ._list_blobs_helper import BlobPrefix
69
67
 
68
+ if TYPE_CHECKING:
69
+ from azure.core.credentials import AzureNamedKeyCredential, AzureSasCredential, TokenCredential
70
+
70
71
  __version__ = VERSION
71
72
 
72
73
 
73
74
  def upload_blob_to_url(
74
- blob_url, # type: str
75
- data, # type: Union[Iterable[AnyStr], IO[AnyStr]]
76
- credential=None, # type: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long
77
- **kwargs):
78
- # type: (...) -> Dict[str, Any]
75
+ blob_url: str,
76
+ data: Union[Iterable[AnyStr], IO[AnyStr]],
77
+ credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
78
+ **kwargs: Any
79
+ ) -> Dict[str, Any]:
79
80
  """Upload data to a given URL
80
81
 
81
82
  The data will be uploaded as a block blob.
@@ -125,10 +126,10 @@ def upload_blob_to_url(
125
126
  :rtype: dict(str, Any)
126
127
  """
127
128
  with BlobClient.from_blob_url(blob_url, credential=credential) as client:
128
- return client.upload_blob(data=data, blob_type=BlobType.BlockBlob, **kwargs)
129
+ return cast(BlobClient, client).upload_blob(data=data, blob_type=BlobType.BLOCKBLOB, **kwargs)
129
130
 
130
131
 
131
- def _download_to_stream(client, handle, **kwargs):
132
+ def _download_to_stream(client: BlobClient, handle: IO[bytes], **kwargs: Any) -> None:
132
133
  """
133
134
  Download data to specified open file-handle.
134
135
 
@@ -140,11 +141,11 @@ def _download_to_stream(client, handle, **kwargs):
140
141
 
141
142
 
142
143
  def download_blob_from_url(
143
- blob_url, # type: str
144
- output, # type: str
145
- credential=None, # type: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long
146
- **kwargs):
147
- # type: (...) -> None
144
+ blob_url: str,
145
+ output: Union[str, IO[bytes]],
146
+ credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
147
+ **kwargs: Any
148
+ ) -> None:
148
149
  """Download the contents of a blob to a local file or stream.
149
150
 
150
151
  :param str blob_url:
@@ -194,7 +195,7 @@ def download_blob_from_url(
194
195
  overwrite = kwargs.pop('overwrite', False)
195
196
  with BlobClient.from_blob_url(blob_url, credential=credential) as client:
196
197
  if hasattr(output, 'write'):
197
- _download_to_stream(client, output, **kwargs)
198
+ _download_to_stream(client, cast(IO[bytes], output), **kwargs)
198
199
  else:
199
200
  if not overwrite and os.path.isfile(output):
200
201
  raise ValueError(f"The file '{output}' already exists.")