azure-storage-blob 12.26.0__py3-none-any.whl → 12.27.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 (50) hide show
  1. azure/storage/blob/__init__.py +3 -3
  2. azure/storage/blob/_blob_client.py +16 -0
  3. azure/storage/blob/_blob_client.pyi +780 -0
  4. azure/storage/blob/_blob_service_client.py +41 -4
  5. azure/storage/blob/_blob_service_client.pyi +182 -0
  6. azure/storage/blob/_container_client.py +22 -0
  7. azure/storage/blob/_container_client.pyi +380 -0
  8. azure/storage/blob/_generated/_azure_blob_storage.py +3 -2
  9. azure/storage/blob/_generated/_configuration.py +2 -2
  10. azure/storage/blob/_generated/_utils/__init__.py +6 -0
  11. azure/storage/blob/_generated/{_serialization.py → _utils/serialization.py} +4 -22
  12. azure/storage/blob/_generated/aio/_azure_blob_storage.py +3 -2
  13. azure/storage/blob/_generated/aio/_configuration.py +2 -2
  14. azure/storage/blob/_generated/aio/operations/_append_blob_operations.py +6 -10
  15. azure/storage/blob/_generated/aio/operations/_blob_operations.py +35 -39
  16. azure/storage/blob/_generated/aio/operations/_block_blob_operations.py +9 -13
  17. azure/storage/blob/_generated/aio/operations/_container_operations.py +20 -24
  18. azure/storage/blob/_generated/aio/operations/_page_blob_operations.py +13 -17
  19. azure/storage/blob/_generated/aio/operations/_service_operations.py +10 -14
  20. azure/storage/blob/_generated/models/_models_py3.py +30 -9
  21. azure/storage/blob/_generated/operations/_append_blob_operations.py +11 -15
  22. azure/storage/blob/_generated/operations/_blob_operations.py +60 -64
  23. azure/storage/blob/_generated/operations/_block_blob_operations.py +16 -20
  24. azure/storage/blob/_generated/operations/_container_operations.py +39 -43
  25. azure/storage/blob/_generated/operations/_page_blob_operations.py +23 -27
  26. azure/storage/blob/_generated/operations/_service_operations.py +19 -23
  27. azure/storage/blob/_lease.py +2 -2
  28. azure/storage/blob/_lease.pyi +81 -0
  29. azure/storage/blob/_list_blobs_helper.py +1 -1
  30. azure/storage/blob/_serialize.py +1 -0
  31. azure/storage/blob/_shared/base_client.py +0 -13
  32. azure/storage/blob/_shared/base_client_async.py +0 -22
  33. azure/storage/blob/_shared/models.py +1 -0
  34. azure/storage/blob/_shared/policies.py +10 -2
  35. azure/storage/blob/_shared/response_handlers.py +5 -0
  36. azure/storage/blob/_version.py +1 -1
  37. azure/storage/blob/aio/__init__.py +5 -8
  38. azure/storage/blob/aio/_blob_client_async.py +28 -8
  39. azure/storage/blob/aio/_blob_client_async.pyi +763 -0
  40. azure/storage/blob/aio/_blob_service_client_async.py +41 -4
  41. azure/storage/blob/aio/_blob_service_client_async.pyi +187 -0
  42. azure/storage/blob/aio/_container_client_async.py +27 -1
  43. azure/storage/blob/aio/_container_client_async.pyi +384 -0
  44. azure/storage/blob/aio/_lease_async.py +2 -2
  45. azure/storage/blob/aio/_lease_async.pyi +81 -0
  46. {azure_storage_blob-12.26.0.dist-info → azure_storage_blob-12.27.0.dist-info}/METADATA +17 -5
  47. {azure_storage_blob-12.26.0.dist-info → azure_storage_blob-12.27.0.dist-info}/RECORD +50 -41
  48. {azure_storage_blob-12.26.0.dist-info → azure_storage_blob-12.27.0.dist-info}/WHEEL +1 -1
  49. {azure_storage_blob-12.26.0.dist-info → azure_storage_blob-12.27.0.dist-info/licenses}/LICENSE +0 -0
  50. {azure_storage_blob-12.26.0.dist-info → azure_storage_blob-12.27.0.dist-info}/top_level.txt +0 -0
@@ -139,7 +139,23 @@ class BlobServiceClient( # type: ignore [misc]
139
139
  self._client._config.version = get_api_version(kwargs) # type: ignore [assignment]
140
140
  self._configure_encryption(kwargs)
141
141
 
142
- def _format_url(self, hostname):
142
+ async def __aenter__(self) -> Self:
143
+ await self._client.__aenter__()
144
+ return self
145
+
146
+ async def __aexit__(self, *args) -> None:
147
+ await self._client.__aexit__(*args)
148
+
149
+ async def close(self) -> None:
150
+ """This method is to close the sockets opened by the client.
151
+ It need not be used when using with a context manager.
152
+
153
+ :return: None
154
+ :rtype: None
155
+ """
156
+ await self._client.close()
157
+
158
+ def _format_url(self, hostname: str) -> str:
143
159
  """Format the endpoint URL according to the current location
144
160
  mode hostname.
145
161
 
@@ -174,6 +190,27 @@ class BlobServiceClient( # type: ignore [misc]
174
190
  ~azure.core.credentials.AzureSasCredential or
175
191
  ~azure.core.credentials_async.AsyncTokenCredential or
176
192
  str or dict[str, str] or None
193
+ :keyword str api_version:
194
+ The Storage API version to use for requests. Default value is the most recent service version that is
195
+ compatible with the current SDK. Setting to an older version may result in reduced feature compatibility.
196
+
197
+ .. versionadded:: 12.2.0
198
+
199
+ :keyword str secondary_hostname:
200
+ The hostname of the secondary endpoint.
201
+ :keyword int max_block_size: The maximum chunk size for uploading a block blob in chunks.
202
+ Defaults to 4*1024*1024, or 4MB.
203
+ :keyword int max_single_put_size: If the blob size is less than or equal max_single_put_size, then the blob will
204
+ be uploaded with only one http PUT request. If the blob size is larger than max_single_put_size,
205
+ the blob will be uploaded in chunks. Defaults to 64*1024*1024, or 64MB.
206
+ :keyword int min_large_block_upload_threshold: The minimum chunk size required to use the memory efficient
207
+ algorithm when uploading a block blob. Defaults to 4*1024*1024+1.
208
+ :keyword bool use_byte_buffer: Use a byte buffer for block blob uploads. Defaults to False.
209
+ :keyword int max_page_size: The maximum chunk size for uploading a page blob. Defaults to 4*1024*1024, or 4MB.
210
+ :keyword int max_single_get_size: The maximum size for a blob to be downloaded in a single call,
211
+ the exceeded part will be downloaded in chunks (could be parallel). Defaults to 32*1024*1024, or 32MB.
212
+ :keyword int max_chunk_get_size: The maximum chunk size used for downloading a blob. Defaults to 4*1024*1024,
213
+ or 4MB.
177
214
  :keyword str audience: The audience to use when requesting tokens for Azure Active Directory
178
215
  authentication. Only has an effect when credential is of type TokenCredential. The value could be
179
216
  https://storage.azure.com/ (default) or https://<account>.blob.core.windows.net.
@@ -236,7 +273,7 @@ class BlobServiceClient( # type: ignore [misc]
236
273
  The keys in the returned dictionary include 'sku_name' and 'account_kind'.
237
274
 
238
275
  :return: A dict of account information (SKU and account type).
239
- :rtype: dict(str, str)
276
+ :rtype: Dict[str, str]
240
277
 
241
278
  .. admonition:: Example:
242
279
 
@@ -529,7 +566,7 @@ class BlobServiceClient( # type: ignore [misc]
529
566
  :param metadata:
530
567
  A dict with name-value pairs to associate with the
531
568
  container as metadata. Example: `{'Category':'test'}`
532
- :type metadata: dict(str, str)
569
+ :type metadata: Dict[str, str]
533
570
  :param public_access:
534
571
  Possible values include: 'container', 'blob'.
535
572
  :type public_access: str or ~azure.storage.blob.PublicAccess
@@ -759,7 +796,7 @@ class BlobServiceClient( # type: ignore [misc]
759
796
  The optional blob snapshot on which to operate. This can either be the ID of the snapshot,
760
797
  or a dictionary output returned by
761
798
  :func:`~azure.storage.blob.aio.BlobClient.create_snapshot()`.
762
- :type snapshot: str or dict(str, Any)
799
+ :type snapshot: str or Dict[str, Any]
763
800
  :keyword str version_id: The version id parameter is an opaque DateTime value that, when present,
764
801
  specifies the version of the blob to operate on.
765
802
  :return: A BlobClient.
@@ -0,0 +1,187 @@
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
+ # pylint: skip-file
7
+
8
+ from datetime import datetime
9
+ from types import TracebackType
10
+ from typing import (
11
+ Any,
12
+ Dict,
13
+ List,
14
+ Optional,
15
+ Union,
16
+ )
17
+ from typing_extensions import Self
18
+
19
+ from azure.core import MatchConditions
20
+ from azure.core.async_paging import AsyncItemPaged
21
+ from azure.core.credentials import AzureNamedKeyCredential, AzureSasCredential
22
+ from azure.core.credentials_async import AsyncTokenCredential
23
+ from azure.core.tracing.decorator import distributed_trace
24
+ from azure.core.tracing.decorator_async import distributed_trace_async
25
+
26
+ from ._blob_client_async import BlobClient
27
+ from ._container_client_async import ContainerClient
28
+ from ._lease_async import BlobLeaseClient
29
+ from .._encryption import StorageEncryptionMixin
30
+ from .._models import (
31
+ BlobAnalyticsLogging,
32
+ ContainerEncryptionScope,
33
+ ContainerProperties,
34
+ CorsRule,
35
+ FilteredBlob,
36
+ Metrics,
37
+ PublicAccess,
38
+ RetentionPolicy,
39
+ StaticWebsite,
40
+ )
41
+ from .._shared.base_client import StorageAccountHostsMixin
42
+ from .._shared.base_client_async import AsyncStorageAccountHostsMixin
43
+ from .._shared.models import UserDelegationKey
44
+
45
+ class BlobServiceClient( # type: ignore [misc]
46
+ AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, StorageEncryptionMixin
47
+ ):
48
+ def __init__(
49
+ self,
50
+ account_url: str,
51
+ credential: Optional[
52
+ Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, AsyncTokenCredential]
53
+ ] = None,
54
+ *,
55
+ api_version: Optional[str] = None,
56
+ secondary_hostname: Optional[str] = None,
57
+ max_block_size: int = 4 * 1024 * 1024,
58
+ max_single_put_size: int = 64 * 1024 * 1024,
59
+ min_large_block_upload_threshold: int = 4 * 1024 * 1024 + 1,
60
+ use_byte_buffer: bool = False,
61
+ max_page_size: int = 4 * 1024 * 1024,
62
+ max_single_get_size: int = 32 * 1024 * 1024,
63
+ max_chunk_get_size: int = 4 * 1024 * 1024,
64
+ audience: Optional[str] = None,
65
+ **kwargs: Any
66
+ ) -> None: ...
67
+ async def __aenter__(self) -> Self: ...
68
+ async def __aexit__(
69
+ self, typ: Optional[type[BaseException]], exc: Optional[BaseException], tb: Optional[TracebackType]
70
+ ) -> None: ...
71
+ async def close(self) -> None: ...
72
+ @classmethod
73
+ def from_connection_string(
74
+ cls,
75
+ conn_str: str,
76
+ credential: Optional[
77
+ Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, AsyncTokenCredential]
78
+ ] = None,
79
+ *,
80
+ api_version: Optional[str] = None,
81
+ secondary_hostname: Optional[str] = None,
82
+ max_block_size: int = 4 * 1024 * 1024,
83
+ max_single_put_size: int = 64 * 1024 * 1024,
84
+ min_large_block_upload_threshold: int = 4 * 1024 * 1024 + 1,
85
+ use_byte_buffer: bool = False,
86
+ max_page_size: int = 4 * 1024 * 1024,
87
+ max_single_get_size: int = 32 * 1024 * 1024,
88
+ max_chunk_get_size: int = 4 * 1024 * 1024,
89
+ audience: Optional[str] = None,
90
+ **kwargs: Any
91
+ ) -> Self: ...
92
+ @distributed_trace_async
93
+ async def get_user_delegation_key(
94
+ self, key_start_time: datetime, key_expiry_time: datetime, *, timeout: Optional[int] = None, **kwargs: Any
95
+ ) -> UserDelegationKey: ...
96
+ @distributed_trace_async
97
+ async def get_account_information(self, **kwargs: Any) -> Dict[str, str]: ...
98
+ @distributed_trace_async
99
+ async def get_service_stats(self, *, timeout: Optional[int] = None, **kwargs: Any) -> Dict[str, Any]: ...
100
+ @distributed_trace_async
101
+ async def get_service_properties(self, *, timeout: Optional[int] = None, **kwargs: Any) -> Dict[str, Any]: ...
102
+ @distributed_trace_async
103
+ async def set_service_properties(
104
+ self,
105
+ analytics_logging: Optional[BlobAnalyticsLogging] = None,
106
+ hour_metrics: Optional[Metrics] = None,
107
+ minute_metrics: Optional[Metrics] = None,
108
+ cors: Optional[List[CorsRule]] = None,
109
+ target_version: Optional[str] = None,
110
+ delete_retention_policy: Optional[RetentionPolicy] = None,
111
+ static_website: Optional[StaticWebsite] = None,
112
+ **kwargs: Any
113
+ ) -> None: ...
114
+ @distributed_trace
115
+ def list_containers(
116
+ self,
117
+ name_starts_with: Optional[str] = None,
118
+ include_metadata: bool = False,
119
+ *,
120
+ include_deleted: Optional[bool] = None,
121
+ include_system: Optional[bool] = None,
122
+ results_per_page: Optional[int] = None,
123
+ timeout: Optional[int] = None,
124
+ **kwargs: Any
125
+ ) -> AsyncItemPaged[ContainerProperties]: ...
126
+ @distributed_trace
127
+ def find_blobs_by_tags(
128
+ self,
129
+ filter_expression: str,
130
+ *,
131
+ results_per_page: Optional[int] = None,
132
+ timeout: Optional[int] = None,
133
+ **kwargs: Any
134
+ ) -> AsyncItemPaged[FilteredBlob]: ...
135
+ @distributed_trace_async
136
+ async def create_container(
137
+ self,
138
+ name: str,
139
+ metadata: Optional[Dict[str, str]] = None,
140
+ public_access: Optional[Union[PublicAccess, str]] = None,
141
+ *,
142
+ container_encryption_scope: Optional[Union[dict, ContainerEncryptionScope]] = None,
143
+ timeout: Optional[int] = None,
144
+ **kwargs: Any
145
+ ) -> ContainerClient: ...
146
+ @distributed_trace_async
147
+ async def delete_container(
148
+ self,
149
+ container: Union[ContainerProperties, str],
150
+ lease: Optional[Union[BlobLeaseClient, str]] = None,
151
+ *,
152
+ if_modified_since: Optional[datetime] = None,
153
+ if_unmodified_since: Optional[datetime] = None,
154
+ etag: Optional[str] = None,
155
+ match_condition: Optional[MatchConditions] = None,
156
+ timeout: Optional[int] = None,
157
+ **kwargs: Any
158
+ ) -> None: ...
159
+ @distributed_trace_async
160
+ async def _rename_container(
161
+ self,
162
+ name: str,
163
+ new_name: str,
164
+ *,
165
+ lease: Optional[Union[BlobLeaseClient, str]] = None,
166
+ timeout: Optional[int] = None,
167
+ **kwargs: Any
168
+ ) -> ContainerClient: ...
169
+ @distributed_trace_async
170
+ async def undelete_container(
171
+ self,
172
+ deleted_container_name: str,
173
+ deleted_container_version: str,
174
+ *,
175
+ timeout: Optional[int] = None,
176
+ **kwargs: Any
177
+ ) -> ContainerClient: ...
178
+ def get_container_client(self, container: Union[ContainerProperties, str]) -> ContainerClient: ...
179
+ def get_blob_client(
180
+ self,
181
+ container: Union[ContainerProperties, str],
182
+ blob: str,
183
+ snapshot: Optional[Union[Dict[str, Any], str]] = None,
184
+ *,
185
+ version_id: Optional[str] = None,
186
+ **kwargs: Any
187
+ ) -> BlobClient: ...
@@ -62,7 +62,11 @@ if TYPE_CHECKING:
62
62
  )
63
63
 
64
64
 
65
- class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, StorageEncryptionMixin): # type: ignore [misc] # pylint: disable=too-many-public-methods
65
+ class ContainerClient( # type: ignore [misc] # pylint: disable=too-many-public-methods
66
+ AsyncStorageAccountHostsMixin,
67
+ StorageAccountHostsMixin,
68
+ StorageEncryptionMixin
69
+ ):
66
70
  """A client to interact with a specific container, although that container
67
71
  may not yet exist.
68
72
 
@@ -143,6 +147,22 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
143
147
  self._client = self._build_generated_client()
144
148
  self._configure_encryption(kwargs)
145
149
 
150
+ async def __aenter__(self) -> Self:
151
+ await self._client.__aenter__()
152
+ return self
153
+
154
+ async def __aexit__(self, *args) -> None:
155
+ await self._client.__aexit__(*args)
156
+
157
+ async def close(self) -> None:
158
+ """This method is to close the sockets opened by the client.
159
+ It need not be used when using with a context manager.
160
+
161
+ :return: None
162
+ :rtype: None
163
+ """
164
+ await self._client.close()
165
+
146
166
  def _build_generated_client(self) -> AzureBlobStorage:
147
167
  client = AzureBlobStorage(self.url, base_url=self.url, pipeline=self._pipeline)
148
168
  client._config.version = self._api_version # type: ignore [assignment] # pylint: disable=protected-access
@@ -782,6 +802,9 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
782
802
  Options include: 'snapshots', 'metadata', 'uncommittedblobs', 'copy', 'deleted', 'deletedwithversions',
783
803
  'tags', 'versions', 'immutabilitypolicy', 'legalhold'.
784
804
  :type include: list[str] or str
805
+ :keyword int results_per_page:
806
+ Controls the maximum number of Blobs that will be included in each page of results if using
807
+ `AsyncItemPaged.by_page()`.
785
808
  :keyword int timeout:
786
809
  Sets the server-side timeout for the operation in seconds. For more details see
787
810
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
@@ -835,6 +858,9 @@ class ContainerClient(AsyncStorageAccountHostsMixin, StorageAccountHostsMixin, S
835
858
  :keyword str name_starts_with:
836
859
  Filters the results to return only blobs whose names
837
860
  begin with the specified prefix.
861
+ :keyword int results_per_page:
862
+ Controls the maximum number of Blobs that will be included in each page of results if using
863
+ `AsyncItemPaged.by_page()`.
838
864
  :keyword int timeout:
839
865
  Sets the server-side timeout for the operation in seconds. For more details see
840
866
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.