azure-storage-blob 12.26.0b1__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 (72) hide show
  1. azure/storage/blob/__init__.py +6 -5
  2. azure/storage/blob/_blob_client.py +59 -38
  3. azure/storage/blob/_blob_client.pyi +780 -0
  4. azure/storage/blob/_blob_client_helpers.py +4 -3
  5. azure/storage/blob/_blob_service_client.py +57 -17
  6. azure/storage/blob/_blob_service_client.pyi +182 -0
  7. azure/storage/blob/_container_client.py +47 -22
  8. azure/storage/blob/_container_client.pyi +380 -0
  9. azure/storage/blob/_deserialize.py +1 -1
  10. azure/storage/blob/_download.py +7 -7
  11. azure/storage/blob/_encryption.py +177 -184
  12. azure/storage/blob/_generated/_azure_blob_storage.py +3 -2
  13. azure/storage/blob/_generated/_configuration.py +2 -2
  14. azure/storage/blob/_generated/_utils/__init__.py +6 -0
  15. azure/storage/blob/_generated/{_serialization.py → _utils/serialization.py} +4 -22
  16. azure/storage/blob/_generated/aio/_azure_blob_storage.py +3 -2
  17. azure/storage/blob/_generated/aio/_configuration.py +2 -2
  18. azure/storage/blob/_generated/aio/operations/_append_blob_operations.py +6 -10
  19. azure/storage/blob/_generated/aio/operations/_blob_operations.py +35 -39
  20. azure/storage/blob/_generated/aio/operations/_block_blob_operations.py +9 -13
  21. azure/storage/blob/_generated/aio/operations/_container_operations.py +20 -24
  22. azure/storage/blob/_generated/aio/operations/_page_blob_operations.py +13 -17
  23. azure/storage/blob/_generated/aio/operations/_service_operations.py +10 -14
  24. azure/storage/blob/_generated/models/_models_py3.py +30 -9
  25. azure/storage/blob/_generated/operations/_append_blob_operations.py +11 -15
  26. azure/storage/blob/_generated/operations/_blob_operations.py +60 -64
  27. azure/storage/blob/_generated/operations/_block_blob_operations.py +16 -20
  28. azure/storage/blob/_generated/operations/_container_operations.py +39 -43
  29. azure/storage/blob/_generated/operations/_page_blob_operations.py +23 -27
  30. azure/storage/blob/_generated/operations/_service_operations.py +19 -23
  31. azure/storage/blob/_lease.py +3 -2
  32. azure/storage/blob/_lease.pyi +81 -0
  33. azure/storage/blob/_list_blobs_helper.py +1 -1
  34. azure/storage/blob/_quick_query_helper.py +3 -3
  35. azure/storage/blob/_serialize.py +1 -0
  36. azure/storage/blob/_shared/__init__.py +7 -7
  37. azure/storage/blob/_shared/authentication.py +49 -32
  38. azure/storage/blob/_shared/avro/avro_io.py +44 -42
  39. azure/storage/blob/_shared/avro/avro_io_async.py +42 -41
  40. azure/storage/blob/_shared/avro/datafile.py +24 -21
  41. azure/storage/blob/_shared/avro/datafile_async.py +15 -15
  42. azure/storage/blob/_shared/avro/schema.py +196 -217
  43. azure/storage/blob/_shared/base_client.py +79 -70
  44. azure/storage/blob/_shared/base_client_async.py +53 -68
  45. azure/storage/blob/_shared/constants.py +1 -1
  46. azure/storage/blob/_shared/models.py +94 -92
  47. azure/storage/blob/_shared/parser.py +3 -3
  48. azure/storage/blob/_shared/policies.py +186 -147
  49. azure/storage/blob/_shared/policies_async.py +58 -69
  50. azure/storage/blob/_shared/request_handlers.py +50 -45
  51. azure/storage/blob/_shared/response_handlers.py +54 -45
  52. azure/storage/blob/_shared/shared_access_signature.py +65 -73
  53. azure/storage/blob/_shared/uploads.py +56 -49
  54. azure/storage/blob/_shared/uploads_async.py +70 -58
  55. azure/storage/blob/_version.py +1 -1
  56. azure/storage/blob/aio/__init__.py +8 -10
  57. azure/storage/blob/aio/_blob_client_async.py +81 -48
  58. azure/storage/blob/aio/_blob_client_async.pyi +763 -0
  59. azure/storage/blob/aio/_blob_service_client_async.py +54 -15
  60. azure/storage/blob/aio/_blob_service_client_async.pyi +187 -0
  61. azure/storage/blob/aio/_container_client_async.py +55 -26
  62. azure/storage/blob/aio/_container_client_async.pyi +384 -0
  63. azure/storage/blob/aio/_download_async.py +15 -11
  64. azure/storage/blob/aio/_lease_async.py +3 -2
  65. azure/storage/blob/aio/_lease_async.pyi +81 -0
  66. azure/storage/blob/aio/_quick_query_helper_async.py +3 -3
  67. {azure_storage_blob-12.26.0b1.dist-info → azure_storage_blob-12.27.0.dist-info}/METADATA +18 -6
  68. azure_storage_blob-12.27.0.dist-info/RECORD +94 -0
  69. {azure_storage_blob-12.26.0b1.dist-info → azure_storage_blob-12.27.0.dist-info}/WHEEL +1 -1
  70. azure_storage_blob-12.26.0b1.dist-info/RECORD +0 -85
  71. {azure_storage_blob-12.26.0b1.dist-info → azure_storage_blob-12.27.0.dist-info/licenses}/LICENSE +0 -0
  72. {azure_storage_blob-12.26.0b1.dist-info → azure_storage_blob-12.27.0.dist-info}/top_level.txt +0 -0
@@ -270,7 +270,7 @@ def _download_blob_options(
270
270
  The string representing the SDK package version.
271
271
  :param AzureBlobStorage client:
272
272
  The generated Blob Storage client.
273
- :returns: A dictionary containing the download blob options.
273
+ :return: A dictionary containing the download blob options.
274
274
  :rtype: Dict[str, Any]
275
275
  """
276
276
  if length is not None:
@@ -658,19 +658,20 @@ def _start_copy_from_url_options( # pylint:disable=too-many-statements
658
658
 
659
659
  options = {
660
660
  'copy_source': source_url,
661
- 'seal_blob': kwargs.pop('seal_destination_blob', None),
662
661
  'timeout': timeout,
663
662
  'modified_access_conditions': dest_mod_conditions,
664
- 'blob_tags_string': blob_tags_string,
665
663
  'headers': headers,
666
664
  'cls': return_response_headers,
667
665
  }
666
+
668
667
  if not incremental_copy:
669
668
  source_mod_conditions = get_source_conditions(kwargs)
670
669
  dest_access_conditions = get_access_conditions(kwargs.pop('destination_lease', None))
671
670
  options['source_modified_access_conditions'] = source_mod_conditions
672
671
  options['lease_access_conditions'] = dest_access_conditions
673
672
  options['tier'] = tier.value if tier else None
673
+ options['seal_blob'] = kwargs.pop('seal_destination_blob', None)
674
+ options['blob_tags_string'] = blob_tags_string
674
675
  options.update(kwargs)
675
676
  return options
676
677
 
@@ -131,13 +131,29 @@ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
131
131
  self._client._config.version = get_api_version(kwargs) # type: ignore [assignment]
132
132
  self._configure_encryption(kwargs)
133
133
 
134
- def _format_url(self, hostname):
134
+ def __enter__(self) -> Self:
135
+ self._client.__enter__()
136
+ return self
137
+
138
+ def __exit__(self, *args) -> None:
139
+ self._client.__exit__(*args)
140
+
141
+ def close(self) -> None:
142
+ """This method is to close the sockets opened by the client.
143
+ It need not be used when using with a context manager.
144
+
145
+ :return: None
146
+ :rtype: None
147
+ """
148
+ self._client.close()
149
+
150
+ def _format_url(self, hostname: str) -> str:
135
151
  """Format the endpoint URL according to the current location
136
152
  mode hostname.
137
153
 
138
154
  :param str hostname:
139
155
  The hostname of the current location mode.
140
- :returns: A formatted endpoint URL including current location mode hostname.
156
+ :return: A formatted endpoint URL including current location mode hostname.
141
157
  :rtype: str
142
158
  """
143
159
  return f"{self.scheme}://{hostname}/{self._query_str}"
@@ -166,10 +182,31 @@ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
166
182
  ~azure.core.credentials.AzureSasCredential or
167
183
  ~azure.core.credentials.TokenCredential or
168
184
  str or dict[str, str] or None
185
+ :keyword str api_version:
186
+ The Storage API version to use for requests. Default value is the most recent service version that is
187
+ compatible with the current SDK. Setting to an older version may result in reduced feature compatibility.
188
+
189
+ .. versionadded:: 12.2.0
190
+
191
+ :keyword str secondary_hostname:
192
+ The hostname of the secondary endpoint.
193
+ :keyword int max_block_size: The maximum chunk size for uploading a block blob in chunks.
194
+ Defaults to 4*1024*1024, or 4MB.
195
+ :keyword int max_single_put_size: If the blob size is less than or equal max_single_put_size, then the blob will
196
+ be uploaded with only one http PUT request. If the blob size is larger than max_single_put_size,
197
+ the blob will be uploaded in chunks. Defaults to 64*1024*1024, or 64MB.
198
+ :keyword int min_large_block_upload_threshold: The minimum chunk size required to use the memory efficient
199
+ algorithm when uploading a block blob. Defaults to 4*1024*1024+1.
200
+ :keyword bool use_byte_buffer: Use a byte buffer for block blob uploads. Defaults to False.
201
+ :keyword int max_page_size: The maximum chunk size for uploading a page blob. Defaults to 4*1024*1024, or 4MB.
202
+ :keyword int max_single_get_size: The maximum size for a blob to be downloaded in a single call,
203
+ the exceeded part will be downloaded in chunks (could be parallel). Defaults to 32*1024*1024, or 32MB.
204
+ :keyword int max_chunk_get_size: The maximum chunk size used for downloading a blob. Defaults to 4*1024*1024,
205
+ or 4MB.
169
206
  :keyword str audience: The audience to use when requesting tokens for Azure Active Directory
170
207
  authentication. Only has an effect when credential is of type TokenCredential. The value could be
171
208
  https://storage.azure.com/ (default) or https://<account>.blob.core.windows.net.
172
- :returns: A Blob service client.
209
+ :return: A Blob service client.
173
210
  :rtype: ~azure.storage.blob.BlobServiceClient
174
211
 
175
212
  .. admonition:: Example:
@@ -206,7 +243,7 @@ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
206
243
  This value is not tracked or validated on the client. To configure client-side network timesouts
207
244
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
208
245
  #other-client--per-operation-configuration>`__.
209
- :returns: The user delegation key.
246
+ :return: The user delegation key.
210
247
  :rtype: ~azure.storage.blob.UserDelegationKey
211
248
  """
212
249
  key_info = KeyInfo(start=_to_utc_datetime(key_start_time), expiry=_to_utc_datetime(key_expiry_time))
@@ -227,8 +264,8 @@ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
227
264
  The information can also be retrieved if the user has a SAS to a container or blob.
228
265
  The keys in the returned dictionary include 'sku_name' and 'account_kind'.
229
266
 
230
- :returns: A dict of account information (SKU and account type).
231
- :rtype: dict(str, str)
267
+ :return: A dict of account information (SKU and account type).
268
+ :rtype: Dict[str, str]
232
269
 
233
270
  .. admonition:: Example:
234
271
 
@@ -270,7 +307,7 @@ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
270
307
  This value is not tracked or validated on the client. To configure client-side network timesouts
271
308
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
272
309
  #other-client--per-operation-configuration>`__.
273
- :returns: The blob service stats.
310
+ :return: The blob service stats.
274
311
  :rtype: Dict[str, Any]
275
312
 
276
313
  .. admonition:: Example:
@@ -301,7 +338,7 @@ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
301
338
  This value is not tracked or validated on the client. To configure client-side network timesouts
302
339
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
303
340
  #other-client--per-operation-configuration>`__.
304
- :returns: An object containing blob service properties such as
341
+ :return: An object containing blob service properties such as
305
342
  analytics logging, hour/minute metrics, cors rules, etc.
306
343
  :rtype: Dict[str, Any]
307
344
 
@@ -371,6 +408,7 @@ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
371
408
  This value is not tracked or validated on the client. To configure client-side network timesouts
372
409
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
373
410
  #other-client--per-operation-configuration>`__.
411
+ :return: None
374
412
  :rtype: None
375
413
 
376
414
  .. admonition:: Example:
@@ -435,7 +473,7 @@ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
435
473
  This value is not tracked or validated on the client. To configure client-side network timesouts
436
474
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
437
475
  #other-client--per-operation-configuration>`__.
438
- :returns: An iterable (auto-paging) of ContainerProperties.
476
+ :return: An iterable (auto-paging) of ContainerProperties.
439
477
  :rtype: ~azure.core.paging.ItemPaged[~azure.storage.blob.ContainerProperties]
440
478
 
441
479
  .. admonition:: Example:
@@ -489,7 +527,7 @@ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
489
527
  This value is not tracked or validated on the client. To configure client-side network timesouts
490
528
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
491
529
  #other-client--per-operation-configuration>`__.
492
- :returns: An iterable (auto-paging) response of BlobProperties.
530
+ :return: An iterable (auto-paging) response of BlobProperties.
493
531
  :rtype: ~azure.core.paging.ItemPaged[~azure.storage.blob.FilteredBlob]
494
532
  """
495
533
 
@@ -521,7 +559,7 @@ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
521
559
  :param metadata:
522
560
  A dict with name-value pairs to associate with the
523
561
  container as metadata. Example: `{'Category':'test'}`
524
- :type metadata: dict(str, str)
562
+ :type metadata: Dict[str, str]
525
563
  :param public_access:
526
564
  Possible values include: 'container', 'blob'.
527
565
  :type public_access: str or ~azure.storage.blob.PublicAccess
@@ -538,7 +576,7 @@ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
538
576
  This value is not tracked or validated on the client. To configure client-side network timesouts
539
577
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
540
578
  #other-client--per-operation-configuration>`__.
541
- :returns: A container client to interact with the newly created container.
579
+ :return: A container client to interact with the newly created container.
542
580
  :rtype: ~azure.storage.blob.ContainerClient
543
581
 
544
582
  .. admonition:: Example:
@@ -600,6 +638,8 @@ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
600
638
  This value is not tracked or validated on the client. To configure client-side network timesouts
601
639
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
602
640
  #other-client--per-operation-configuration>`__.
641
+ :return: None
642
+ :rtype: None
603
643
 
604
644
  .. admonition:: Example:
605
645
 
@@ -638,7 +678,7 @@ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
638
678
  This value is not tracked or validated on the client. To configure client-side network timesouts
639
679
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
640
680
  #other-client--per-operation-configuration>`__.
641
- :returns: A container client for the renamed container.
681
+ :return: A container client for the renamed container.
642
682
  :rtype: ~azure.storage.blob.ContainerClient
643
683
  """
644
684
  renamed_container = self.get_container_client(new_name)
@@ -677,7 +717,7 @@ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
677
717
  This value is not tracked or validated on the client. To configure client-side network timesouts
678
718
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
679
719
  #other-client--per-operation-configuration>`__.
680
- :returns: The undeleted ContainerClient.
720
+ :return: The undeleted ContainerClient.
681
721
  :rtype: ~azure.storage.blob.ContainerClient
682
722
  """
683
723
  new_name = kwargs.pop('new_name', None)
@@ -701,7 +741,7 @@ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
701
741
  The container. This can either be the name of the container,
702
742
  or an instance of ContainerProperties.
703
743
  :type container: str or ~azure.storage.blob.ContainerProperties
704
- :returns: A ContainerClient.
744
+ :return: A ContainerClient.
705
745
  :rtype: ~azure.storage.blob.ContainerClient
706
746
 
707
747
  .. admonition:: Example:
@@ -747,10 +787,10 @@ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
747
787
  :param snapshot:
748
788
  The optional blob snapshot on which to operate. This can either be the ID of the snapshot,
749
789
  or a dictionary output returned by :func:`~azure.storage.blob.BlobClient.create_snapshot()`.
750
- :type snapshot: str or dict(str, Any)
790
+ :type snapshot: str or Dict[str, Any]
751
791
  :keyword str version_id: The version id parameter is an opaque DateTime value that, when present,
752
792
  specifies the version of the blob to operate on.
753
- :returns: A BlobClient.
793
+ :return: A BlobClient.
754
794
  :rtype: ~azure.storage.blob.BlobClient
755
795
 
756
796
  .. admonition:: Example:
@@ -0,0 +1,182 @@
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.credentials import AzureNamedKeyCredential, AzureSasCredential, TokenCredential
21
+ from azure.core.paging import ItemPaged
22
+ from azure.core.tracing.decorator import distributed_trace
23
+ from ._blob_client import BlobClient
24
+ from ._container_client import ContainerClient
25
+ from ._encryption import StorageEncryptionMixin
26
+ from ._lease import BlobLeaseClient
27
+ from ._models import (
28
+ BlobAnalyticsLogging,
29
+ ContainerEncryptionScope,
30
+ ContainerProperties,
31
+ CorsRule,
32
+ FilteredBlob,
33
+ Metrics,
34
+ PublicAccess,
35
+ RetentionPolicy,
36
+ StaticWebsite,
37
+ )
38
+ from ._shared.base_client import StorageAccountHostsMixin
39
+ from ._shared.models import UserDelegationKey
40
+
41
+ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
42
+ def __init__(
43
+ self,
44
+ account_url: str,
45
+ credential: Optional[
46
+ Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, TokenCredential]
47
+ ] = None,
48
+ *,
49
+ api_version: Optional[str] = None,
50
+ secondary_hostname: Optional[str] = None,
51
+ max_block_size: int = 4 * 1024 * 1024,
52
+ max_single_put_size: int = 64 * 1024 * 1024,
53
+ min_large_block_upload_threshold: int = 4 * 1024 * 1024 + 1,
54
+ use_byte_buffer: bool = False,
55
+ max_page_size: int = 4 * 1024 * 1024,
56
+ max_single_get_size: int = 32 * 1024 * 1024,
57
+ max_chunk_get_size: int = 4 * 1024 * 1024,
58
+ audience: Optional[str] = None,
59
+ **kwargs: Any
60
+ ) -> None: ...
61
+ def __enter__(self) -> Self: ...
62
+ def __exit__(
63
+ self, typ: Optional[type[BaseException]], exc: Optional[BaseException], tb: Optional[TracebackType]
64
+ ) -> None: ...
65
+ def close(self) -> None: ...
66
+ @classmethod
67
+ def from_connection_string(
68
+ cls,
69
+ conn_str: str,
70
+ credential: Optional[
71
+ Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, TokenCredential]
72
+ ] = None,
73
+ *,
74
+ api_version: Optional[str] = None,
75
+ secondary_hostname: Optional[str] = None,
76
+ max_block_size: int = 4 * 1024 * 1024,
77
+ max_single_put_size: int = 64 * 1024 * 1024,
78
+ min_large_block_upload_threshold: int = 4 * 1024 * 1024 + 1,
79
+ use_byte_buffer: bool = False,
80
+ max_page_size: int = 4 * 1024 * 1024,
81
+ max_single_get_size: int = 32 * 1024 * 1024,
82
+ max_chunk_get_size: int = 4 * 1024 * 1024,
83
+ audience: Optional[str] = None,
84
+ **kwargs: Any
85
+ ) -> Self: ...
86
+ @distributed_trace
87
+ def get_user_delegation_key(
88
+ self, key_start_time: datetime, key_expiry_time: datetime, *, timeout: Optional[int] = None, **kwargs: Any
89
+ ) -> UserDelegationKey: ...
90
+ @distributed_trace
91
+ def get_account_information(self, **kwargs: Any) -> Dict[str, str]: ...
92
+ @distributed_trace
93
+ def get_service_stats(self, *, timeout: Optional[int] = None, **kwargs: Any) -> Dict[str, Any]: ...
94
+ @distributed_trace
95
+ def get_service_properties(self, *, timeout: Optional[int] = None, **kwargs: Any) -> Dict[str, Any]: ...
96
+ @distributed_trace
97
+ def set_service_properties(
98
+ self,
99
+ analytics_logging: Optional[BlobAnalyticsLogging] = None,
100
+ hour_metrics: Optional[Metrics] = None,
101
+ minute_metrics: Optional[Metrics] = None,
102
+ cors: Optional[List[CorsRule]] = None,
103
+ target_version: Optional[str] = None,
104
+ delete_retention_policy: Optional[RetentionPolicy] = None,
105
+ static_website: Optional[StaticWebsite] = None,
106
+ *,
107
+ timeout: Optional[int] = None,
108
+ **kwargs: Any
109
+ ) -> None: ...
110
+ @distributed_trace
111
+ def list_containers(
112
+ self,
113
+ name_starts_with: Optional[str] = None,
114
+ include_metadata: bool = False,
115
+ *,
116
+ include_deleted: Optional[bool] = None,
117
+ include_system: Optional[bool] = None,
118
+ results_per_page: Optional[int] = None,
119
+ timeout: Optional[int] = None,
120
+ **kwargs: Any
121
+ ) -> ItemPaged[ContainerProperties]: ...
122
+ @distributed_trace
123
+ def find_blobs_by_tags(
124
+ self,
125
+ filter_expression: str,
126
+ *,
127
+ results_per_page: Optional[int] = None,
128
+ timeout: Optional[int] = None,
129
+ **kwargs: Any
130
+ ) -> ItemPaged[FilteredBlob]: ...
131
+ @distributed_trace
132
+ def create_container(
133
+ self,
134
+ name: str,
135
+ metadata: Optional[Dict[str, str]] = None,
136
+ public_access: Optional[Union[PublicAccess, str]] = None,
137
+ *,
138
+ container_encryption_scope: Optional[Union[dict, ContainerEncryptionScope]] = None,
139
+ timeout: Optional[int] = None,
140
+ **kwargs: Any
141
+ ) -> ContainerClient: ...
142
+ @distributed_trace
143
+ def delete_container(
144
+ self,
145
+ container: Union[ContainerProperties, str],
146
+ lease: Optional[Union[BlobLeaseClient, str]] = None,
147
+ *,
148
+ if_modified_since: Optional[datetime] = None,
149
+ if_unmodified_since: Optional[datetime] = None,
150
+ etag: Optional[str] = None,
151
+ match_condition: Optional[MatchConditions] = None,
152
+ timeout: Optional[int] = None,
153
+ **kwargs: Any
154
+ ) -> None: ...
155
+ @distributed_trace
156
+ def _rename_container(
157
+ self,
158
+ name: str,
159
+ new_name: str,
160
+ *,
161
+ lease: Optional[Union[BlobLeaseClient, str]] = None,
162
+ timeout: Optional[int] = None,
163
+ **kwargs: Any
164
+ ) -> ContainerClient: ...
165
+ @distributed_trace
166
+ def undelete_container(
167
+ self,
168
+ deleted_container_name: str,
169
+ deleted_container_version: str,
170
+ *,
171
+ timeout: Optional[int] = None,
172
+ **kwargs: Any
173
+ ) -> ContainerClient: ...
174
+ def get_container_client(self, container: Union[ContainerProperties, str]) -> ContainerClient: ...
175
+ def get_blob_client(
176
+ self,
177
+ container: Union[ContainerProperties, str],
178
+ blob: str,
179
+ snapshot: Optional[Union[Dict[str, Any], str]] = None,
180
+ *,
181
+ version_id: Optional[str] = None
182
+ ) -> BlobClient: ...
@@ -150,6 +150,22 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
150
150
  self._client = self._build_generated_client()
151
151
  self._configure_encryption(kwargs)
152
152
 
153
+ def __enter__(self) -> Self:
154
+ self._client.__enter__()
155
+ return self
156
+
157
+ def __exit__(self, *args) -> None:
158
+ self._client.__exit__(*args)
159
+
160
+ def close(self) -> None:
161
+ """This method is to close the sockets opened by the client.
162
+ It need not be used when using with a context manager.
163
+
164
+ :return: None
165
+ :rtype: None
166
+ """
167
+ self._client.close()
168
+
153
169
  def _build_generated_client(self) -> AzureBlobStorage:
154
170
  client = AzureBlobStorage(self.url, base_url=self.url, pipeline=self._pipeline)
155
171
  client._config.version = self._api_version # type: ignore [assignment] # pylint: disable=protected-access
@@ -193,7 +209,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
193
209
  :keyword str audience: The audience to use when requesting tokens for Azure Active Directory
194
210
  authentication. Only has an effect when credential is of type TokenCredential. The value could be
195
211
  https://storage.azure.com/ (default) or https://<account>.blob.core.windows.net.
196
- :returns: A container client.
212
+ :return: A container client.
197
213
  :rtype: ~azure.storage.blob.ContainerClient
198
214
  """
199
215
  try:
@@ -246,7 +262,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
246
262
  :keyword str audience: The audience to use when requesting tokens for Azure Active Directory
247
263
  authentication. Only has an effect when credential is of type TokenCredential. The value could be
248
264
  https://storage.azure.com/ (default) or https://<account>.blob.core.windows.net.
249
- :returns: A container client.
265
+ :return: A container client.
250
266
  :rtype: ~azure.storage.blob.ContainerClient
251
267
 
252
268
  .. admonition:: Example:
@@ -293,7 +309,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
293
309
  This value is not tracked or validated on the client. To configure client-side network timesouts
294
310
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
295
311
  #other-client--per-operation-configuration>`__.
296
- :returns: A dictionary of response headers.
312
+ :return: A dictionary of response headers.
297
313
  :rtype: Dict[str, Union[str, datetime]]
298
314
 
299
315
  .. admonition:: Example:
@@ -338,7 +354,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
338
354
  This value is not tracked or validated on the client. To configure client-side network timesouts
339
355
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
340
356
  #other-client--per-operation-configuration>`__.
341
- :returns: The renamed container client.
357
+ :return: The renamed container client.
342
358
  :rtype: ~azure.storage.blob.ContainerClient
343
359
  """
344
360
  lease = kwargs.pop('lease', None)
@@ -392,6 +408,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
392
408
  This value is not tracked or validated on the client. To configure client-side network timesouts
393
409
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
394
410
  #other-client--per-operation-configuration>`__.
411
+ :return: None
395
412
  :rtype: None
396
413
 
397
414
  .. admonition:: Example:
@@ -458,7 +475,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
458
475
  This value is not tracked or validated on the client. To configure client-side network timesouts
459
476
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
460
477
  #other-client--per-operation-configuration>`__.
461
- :returns: A BlobLeaseClient object, that can be run in a context manager.
478
+ :return: A BlobLeaseClient object, that can be run in a context manager.
462
479
  :rtype: ~azure.storage.blob.BlobLeaseClient
463
480
 
464
481
  .. admonition:: Example:
@@ -483,7 +500,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
483
500
  The information can also be retrieved if the user has a SAS to a container or blob.
484
501
  The keys in the returned dictionary include 'sku_name' and 'account_kind'.
485
502
 
486
- :returns: A dict of account information (SKU and account type).
503
+ :return: A dict of account information (SKU and account type).
487
504
  :rtype: dict(str, str)
488
505
  """
489
506
  try:
@@ -543,7 +560,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
543
560
  This value is not tracked or validated on the client. To configure client-side network timesouts
544
561
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
545
562
  #other-client--per-operation-configuration>`__.
546
- :returns: boolean
563
+ :return: boolean
547
564
  :rtype: bool
548
565
  """
549
566
  try:
@@ -594,7 +611,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
594
611
  This value is not tracked or validated on the client. To configure client-side network timesouts
595
612
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
596
613
  #other-client--per-operation-configuration>`__.
597
- :returns: Container-updated property dict (Etag and last modified).
614
+ :return: Container-updated property dict (Etag and last modified).
598
615
  :rtype: dict[str, str or datetime]
599
616
 
600
617
  .. admonition:: Example:
@@ -629,7 +646,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
629
646
 
630
647
  Defaults to current container's credentials.
631
648
 
632
- :returns: A BlobServiceClient.
649
+ :return: A BlobServiceClient.
633
650
  :rtype: ~azure.storage.blob.BlobServiceClient
634
651
 
635
652
  .. admonition:: Example:
@@ -671,7 +688,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
671
688
  This value is not tracked or validated on the client. To configure client-side network timesouts
672
689
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
673
690
  #other-client--per-operation-configuration>`__.
674
- :returns: Access policy information in a dict.
691
+ :return: Access policy information in a dict.
675
692
  :rtype: dict[str, Any]
676
693
 
677
694
  .. admonition:: Example:
@@ -738,7 +755,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
738
755
  This value is not tracked or validated on the client. To configure client-side network timesouts
739
756
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
740
757
  #other-client--per-operation-configuration>`__.
741
- :returns: Container-updated property dict (Etag and last modified).
758
+ :return: Container-updated property dict (Etag and last modified).
742
759
  :rtype: dict[str, str or ~datetime.datetime]
743
760
 
744
761
  .. admonition:: Example:
@@ -795,13 +812,16 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
795
812
  Options include: 'snapshots', 'metadata', 'uncommittedblobs', 'copy', 'deleted', 'deletedwithversions',
796
813
  'tags', 'versions', 'immutabilitypolicy', 'legalhold'.
797
814
  :type include: list[str] or str
815
+ :keyword int results_per_page:
816
+ Controls the maximum number of Blobs that will be included in each page of results if using
817
+ `ItemPaged.by_page()`.
798
818
  :keyword int timeout:
799
819
  Sets the server-side timeout for the operation in seconds. For more details see
800
820
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
801
821
  This value is not tracked or validated on the client. To configure client-side network timesouts
802
822
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
803
823
  #other-client--per-operation-configuration>`__.
804
- :returns: An iterable (auto-paging) response of BlobProperties.
824
+ :return: An iterable (auto-paging) response of BlobProperties.
805
825
  :rtype: ~azure.core.paging.ItemPaged[~azure.storage.blob.BlobProperties]
806
826
 
807
827
  .. admonition:: Example:
@@ -844,13 +864,16 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
844
864
  :keyword str name_starts_with:
845
865
  Filters the results to return only blobs whose names
846
866
  begin with the specified prefix.
867
+ :keyword int results_per_page:
868
+ Controls the maximum number of Blobs that will be included in each page of results if using
869
+ `ItemPaged.by_page()`.
847
870
  :keyword int timeout:
848
871
  Sets the server-side timeout for the operation in seconds. For more details see
849
872
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
850
873
  This value is not tracked or validated on the client. To configure client-side network timesouts
851
874
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
852
875
  #other-client--per-operation-configuration>`__.
853
- :returns: An iterable (auto-paging) response of blob names as strings.
876
+ :return: An iterable (auto-paging) response of blob names as strings.
854
877
  :rtype: ~azure.core.paging.ItemPaged[str]
855
878
  """
856
879
  if kwargs.pop('prefix', None):
@@ -883,7 +906,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
883
906
  include: Optional[Union[List[str], str]] = None,
884
907
  delimiter: str = "/",
885
908
  **kwargs: Any
886
- ) -> ItemPaged[BlobProperties]:
909
+ ) -> ItemPaged[Union[BlobProperties, BlobPrefix]]:
887
910
  """Returns a generator to list the blobs under the specified container.
888
911
  The generator will lazily follow the continuation tokens returned by
889
912
  the service. This operation will list blobs in accordance with a hierarchy,
@@ -908,8 +931,8 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
908
931
  This value is not tracked or validated on the client. To configure client-side network timesouts
909
932
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
910
933
  #other-client--per-operation-configuration>`__.
911
- :returns: An iterable (auto-paging) response of BlobProperties.
912
- :rtype: ~azure.core.paging.ItemPaged[~azure.storage.blob.BlobProperties]
934
+ :return: An iterable (auto-paging) response of BlobProperties or BlobPrefix.
935
+ :rtype: ~azure.core.paging.ItemPaged[~azure.storage.blob.BlobProperties or ~azure.storage.blob.BlobPrefix]
913
936
  """
914
937
  if kwargs.pop('prefix', None):
915
938
  raise ValueError("Passing 'prefix' has no effect on filtering, " +
@@ -954,7 +977,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
954
977
  This value is not tracked or validated on the client. To configure client-side network timesouts
955
978
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
956
979
  #other-client--per-operation-configuration>`__.
957
- :returns: An iterable (auto-paging) response of FilteredBlob.
980
+ :return: An iterable (auto-paging) response of FilteredBlob.
958
981
  :rtype: ~azure.core.paging.ItemPaged[~azure.storage.blob.BlobProperties]
959
982
  """
960
983
  results_per_page = kwargs.pop('results_per_page', None)
@@ -1078,7 +1101,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
1078
1101
  function(current: int, total: Optional[int]) where current is the number of bytes transferred
1079
1102
  so far, and total is the size of the blob or None if the size is unknown.
1080
1103
  :paramtype progress_hook: Callable[[int, Optional[int]], None]
1081
- :returns: A BlobClient to interact with the newly uploaded blob.
1104
+ :return: A BlobClient to interact with the newly uploaded blob.
1082
1105
  :rtype: ~azure.storage.blob.BlobClient
1083
1106
 
1084
1107
  .. admonition:: Example:
@@ -1128,7 +1151,8 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
1128
1151
  and retains the blob or snapshot for specified number of days.
1129
1152
  After specified number of days, blob's data is removed from the service during garbage collection.
1130
1153
  Soft deleted blob or snapshot is accessible through :func:`list_blobs()` specifying `include=["deleted"]`
1131
- option. Soft-deleted blob or snapshot can be restored using :func:`~azure.storage.blob.BlobClient.undelete()`
1154
+ option. Soft-deleted blob or snapshot can be restored using
1155
+ :func:`~azure.storage.blob.BlobClient.undelete_blob()`
1132
1156
 
1133
1157
  :param str blob: The blob with which to interact.
1134
1158
  :param str delete_snapshots:
@@ -1176,6 +1200,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
1176
1200
  This value is not tracked or validated on the client. To configure client-side network timesouts
1177
1201
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
1178
1202
  #other-client--per-operation-configuration>`__.
1203
+ :return: None
1179
1204
  :rtype: None
1180
1205
  """
1181
1206
  if isinstance(blob, BlobProperties):
@@ -1302,7 +1327,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
1302
1327
  the timeout will apply to each call individually.
1303
1328
  multiple calls to the Azure service and the timeout will apply to
1304
1329
  each call individually.
1305
- :returns: A streaming object (StorageStreamDownloader)
1330
+ :return: A streaming object (StorageStreamDownloader)
1306
1331
  :rtype: ~azure.storage.blob.StorageStreamDownloader
1307
1332
  """
1308
1333
  if isinstance(blob, BlobProperties):
@@ -1334,7 +1359,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
1334
1359
  and retains the blobs or snapshots for specified number of days.
1335
1360
  After specified number of days, blobs' data is removed from the service during garbage collection.
1336
1361
  Soft deleted blobs or snapshots are accessible through :func:`list_blobs()` specifying `include=["deleted"]`
1337
- Soft-deleted blobs or snapshots can be restored using :func:`~azure.storage.blob.BlobClient.undelete()`
1362
+ Soft-deleted blobs or snapshots can be restored using :func:`~azure.storage.blob.BlobClient.undelete_blob()`
1338
1363
 
1339
1364
  The maximum number of blobs that can be deleted in a single request is 256.
1340
1365
 
@@ -1586,7 +1611,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
1586
1611
  or the response returned from :func:`~BlobClient.create_snapshot()`.
1587
1612
  :keyword str version_id: The version id parameter is an opaque DateTime value that, when present,
1588
1613
  specifies the version of the blob to operate on.
1589
- :returns: A BlobClient.
1614
+ :return: A BlobClient.
1590
1615
  :rtype: ~azure.storage.blob.BlobClient
1591
1616
 
1592
1617
  .. admonition:: Example: