azure-storage-blob 12.21.0b1__py3-none-any.whl → 12.23.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 (60) 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 +176 -377
  7. azure/storage/blob/_container_client_helpers.py +266 -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/_azure_blob_storage.py +2 -1
  12. azure/storage/blob/_generated/_serialization.py +2 -0
  13. azure/storage/blob/_generated/aio/_azure_blob_storage.py +2 -1
  14. azure/storage/blob/_generated/aio/operations/_append_blob_operations.py +1 -7
  15. azure/storage/blob/_generated/aio/operations/_blob_operations.py +21 -47
  16. azure/storage/blob/_generated/aio/operations/_block_blob_operations.py +2 -10
  17. azure/storage/blob/_generated/aio/operations/_container_operations.py +13 -26
  18. azure/storage/blob/_generated/aio/operations/_page_blob_operations.py +3 -14
  19. azure/storage/blob/_generated/aio/operations/_service_operations.py +14 -17
  20. azure/storage/blob/_generated/operations/_append_blob_operations.py +1 -7
  21. azure/storage/blob/_generated/operations/_blob_operations.py +21 -47
  22. azure/storage/blob/_generated/operations/_block_blob_operations.py +2 -10
  23. azure/storage/blob/_generated/operations/_container_operations.py +13 -26
  24. azure/storage/blob/_generated/operations/_page_blob_operations.py +3 -14
  25. azure/storage/blob/_generated/operations/_service_operations.py +14 -17
  26. azure/storage/blob/_generated/py.typed +1 -0
  27. azure/storage/blob/_lease.py +52 -63
  28. azure/storage/blob/_list_blobs_helper.py +129 -135
  29. azure/storage/blob/_models.py +480 -277
  30. azure/storage/blob/_quick_query_helper.py +30 -31
  31. azure/storage/blob/_serialize.py +39 -56
  32. azure/storage/blob/_shared/avro/datafile.py +1 -1
  33. azure/storage/blob/_shared/avro/datafile_async.py +1 -1
  34. azure/storage/blob/_shared/base_client.py +3 -1
  35. azure/storage/blob/_shared/base_client_async.py +1 -1
  36. azure/storage/blob/_shared/policies.py +16 -15
  37. azure/storage/blob/_shared/policies_async.py +21 -6
  38. azure/storage/blob/_shared/response_handlers.py +6 -2
  39. azure/storage/blob/_shared/shared_access_signature.py +21 -3
  40. azure/storage/blob/_shared/uploads.py +1 -1
  41. azure/storage/blob/_shared/uploads_async.py +1 -1
  42. azure/storage/blob/_shared_access_signature.py +110 -52
  43. azure/storage/blob/_upload_helpers.py +75 -68
  44. azure/storage/blob/_version.py +1 -1
  45. azure/storage/blob/aio/__init__.py +19 -11
  46. azure/storage/blob/aio/_blob_client_async.py +554 -301
  47. azure/storage/blob/aio/_blob_service_client_async.py +148 -97
  48. azure/storage/blob/aio/_container_client_async.py +289 -140
  49. azure/storage/blob/aio/_download_async.py +485 -337
  50. azure/storage/blob/aio/_lease_async.py +61 -60
  51. azure/storage/blob/aio/_list_blobs_helper.py +94 -96
  52. azure/storage/blob/aio/_models.py +60 -38
  53. azure/storage/blob/aio/_upload_helpers.py +75 -66
  54. {azure_storage_blob-12.21.0b1.dist-info → azure_storage_blob-12.23.0.dist-info}/METADATA +7 -7
  55. azure_storage_blob-12.23.0.dist-info/RECORD +84 -0
  56. {azure_storage_blob-12.21.0b1.dist-info → azure_storage_blob-12.23.0.dist-info}/WHEEL +1 -1
  57. azure/storage/blob/_generated/_vendor.py +0 -16
  58. azure_storage_blob-12.21.0b1.dist-info/RECORD +0 -81
  59. {azure_storage_blob-12.21.0b1.dist-info → azure_storage_blob-12.23.0.dist-info}/LICENSE +0 -0
  60. {azure_storage_blob-12.21.0b1.dist-info → azure_storage_blob-12.23.0.dist-info}/top_level.txt +0 -0
@@ -7,33 +7,30 @@
7
7
 
8
8
  import functools
9
9
  import warnings
10
+ from datetime import datetime
10
11
  from typing import (
11
- Any, AnyStr, Dict, List, IO, Iterable, Iterator, Optional, overload, Union,
12
+ Any, AnyStr, cast, Dict, List, IO, Iterable, Iterator, Optional, overload, Union,
12
13
  TYPE_CHECKING
13
14
  )
14
- from urllib.parse import urlparse, quote, unquote
15
-
15
+ from urllib.parse import unquote, urlparse
16
16
  from typing_extensions import Self
17
17
 
18
- from azure.core import MatchConditions
19
18
  from azure.core.exceptions import HttpResponseError, ResourceNotFoundError
20
19
  from azure.core.paging import ItemPaged
21
20
  from azure.core.pipeline import Pipeline
22
- from azure.core.pipeline.transport import HttpRequest
23
21
  from azure.core.tracing.decorator import distributed_trace
24
- from ._shared.base_client import StorageAccountHostsMixin, TransportWrapper, parse_connection_str, parse_query
25
- from ._shared.request_handlers import add_metadata_headers, serialize_iso
26
- from ._shared.response_handlers import (
27
- process_storage_error,
28
- return_response_headers,
29
- return_headers_and_deserialized
30
- )
31
- from ._generated import AzureBlobStorage
32
- from ._generated.models import SignedIdentifier
33
22
  from ._blob_client import BlobClient
23
+ from ._container_client_helpers import (
24
+ _format_url,
25
+ _generate_delete_blobs_options,
26
+ _generate_set_tiers_options,
27
+ _parse_url
28
+ )
34
29
  from ._deserialize import deserialize_container_properties
35
30
  from ._download import StorageStreamDownloader
36
31
  from ._encryption import StorageEncryptionMixin
32
+ from ._generated import AzureBlobStorage
33
+ from ._generated.models import SignedIdentifier
37
34
  from ._lease import BlobLeaseClient
38
35
  from ._list_blobs_helper import (
39
36
  BlobNamesPaged,
@@ -43,36 +40,30 @@ from ._list_blobs_helper import (
43
40
  IgnoreListBlobsDeserializer
44
41
  )
45
42
  from ._models import (
46
- ContainerProperties,
47
43
  BlobProperties,
48
44
  BlobType,
45
+ ContainerProperties,
49
46
  FilteredBlob
50
47
  )
51
- from ._serialize import get_modify_conditions, get_container_cpk_scope_info, get_api_version, get_access_conditions
48
+ from ._serialize import get_access_conditions, get_api_version, get_container_cpk_scope_info, get_modify_conditions
49
+ from ._shared.base_client import parse_connection_str, StorageAccountHostsMixin, TransportWrapper
50
+ from ._shared.request_handlers import add_metadata_headers, serialize_iso
51
+ from ._shared.response_handlers import (
52
+ process_storage_error,
53
+ return_headers_and_deserialized,
54
+ return_response_headers
55
+ )
52
56
 
53
57
  if TYPE_CHECKING:
54
58
  from azure.core.credentials import AzureNamedKeyCredential, AzureSasCredential, TokenCredential
55
59
  from azure.core.pipeline.transport import HttpResponse # pylint: disable=C4756
56
- from datetime import datetime
57
- from ._models import ( # pylint: disable=unused-import
58
- PublicAccess,
60
+ from azure.storage.blob import BlobServiceClient
61
+ from ._models import (
59
62
  AccessPolicy,
60
- StandardBlobTier,
61
- PremiumPageBlobTier)
62
-
63
-
64
- def _get_blob_name(blob):
65
- """Return the blob name.
66
-
67
- :param blob: A blob string or BlobProperties
68
- :type blob: str or BlobProperties
69
- :returns: The name of the blob.
70
- :rtype: str
71
- """
72
- try:
73
- return blob.get('name')
74
- except AttributeError:
75
- return blob
63
+ PremiumPageBlobTier,
64
+ PublicAccess,
65
+ StandardBlobTier
66
+ )
76
67
 
77
68
 
78
69
  class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # pylint: disable=too-many-public-methods
@@ -84,7 +75,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
84
75
 
85
76
  For more optional configuration, please click
86
77
  `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
87
- #optional-configuration>`_.
78
+ #optional-configuration>`__.
88
79
 
89
80
  :param str account_url:
90
81
  The URI to the storage account. In order to create a client given the full URI to the container,
@@ -143,23 +134,13 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
143
134
  :caption: Creating the container client directly.
144
135
  """
145
136
  def __init__(
146
- self, account_url: str,
147
- container_name: str,
148
- credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
149
- **kwargs: Any
150
- ) -> None:
151
- try:
152
- if not account_url.lower().startswith('http'):
153
- account_url = "https://" + account_url
154
- except AttributeError as exc:
155
- raise ValueError("Container URL must be a string.") from exc
156
- parsed_url = urlparse(account_url.rstrip('/'))
157
- if not container_name:
158
- raise ValueError("Please specify a container name.")
159
- if not parsed_url.netloc:
160
- raise ValueError(f"Invalid URL: {account_url}")
137
+ self, account_url: str,
138
+ container_name: str,
139
+ credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
140
+ **kwargs: Any
141
+ ) -> None:
142
+ parsed_url, sas_token = _parse_url(account_url=account_url, container_name=container_name)
161
143
 
162
- _, sas_token = parse_query(parsed_url.query)
163
144
  self.container_name = container_name
164
145
  # This parameter is used for the hierarchy traversal. Give precedence to credential.
165
146
  self._raw_credential = credential if credential else sas_token
@@ -169,23 +150,25 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
169
150
  self._client = self._build_generated_client()
170
151
  self._configure_encryption(kwargs)
171
152
 
172
- def _build_generated_client(self):
153
+ def _build_generated_client(self) -> AzureBlobStorage:
173
154
  client = AzureBlobStorage(self.url, base_url=self.url, pipeline=self._pipeline)
174
- client._config.version = self._api_version # pylint: disable=protected-access
155
+ client._config.version = self._api_version # type: ignore [assignment] # pylint: disable=protected-access
175
156
  return client
176
157
 
177
158
  def _format_url(self, hostname):
178
- container_name = self.container_name
179
- if isinstance(container_name, str):
180
- container_name = container_name.encode('UTF-8')
181
- return f"{self.scheme}://{hostname}/{quote(container_name)}{self._query_str}"
159
+ return _format_url(
160
+ container_name=self.container_name,
161
+ hostname=hostname,
162
+ scheme=self.scheme,
163
+ query_str=self._query_str
164
+ )
182
165
 
183
166
  @classmethod
184
167
  def from_container_url(
185
- cls, container_url: str,
186
- credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
187
- **kwargs: Any
188
- ) -> Self:
168
+ cls, container_url: str,
169
+ credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
170
+ **kwargs: Any
171
+ ) -> Self:
189
172
  """Create ContainerClient from a container url.
190
173
 
191
174
  :param str container_url:
@@ -234,11 +217,11 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
234
217
 
235
218
  @classmethod
236
219
  def from_connection_string(
237
- cls, conn_str: str,
238
- container_name: str,
239
- credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
240
- **kwargs: Any
241
- ) -> Self:
220
+ cls, conn_str: str,
221
+ container_name: str,
222
+ credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
223
+ **kwargs: Any
224
+ ) -> Self:
242
225
  """Create ContainerClient from a Connection String.
243
226
 
244
227
  :param str conn_str:
@@ -282,8 +265,11 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
282
265
  account_url, container_name=container_name, credential=credential, **kwargs)
283
266
 
284
267
  @distributed_trace
285
- def create_container(self, metadata=None, public_access=None, **kwargs):
286
- # type: (Optional[Dict[str, str]], Optional[Union[PublicAccess, str]], **Any) -> Dict[str, Union[str, datetime]]
268
+ def create_container(
269
+ self, metadata: Optional[Dict[str, str]] = None,
270
+ public_access: Optional[Union["PublicAccess", str]] = None,
271
+ **kwargs: Any
272
+ ) -> Dict[str, Union[str, "datetime"]]:
287
273
  """
288
274
  Creates a new container under the specified account. If the container
289
275
  with the same name already exists, the operation fails.
@@ -306,7 +292,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
306
292
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
307
293
  This value is not tracked or validated on the client. To configure client-side network timesouts
308
294
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
309
- #other-client--per-operation-configuration>`_.
295
+ #other-client--per-operation-configuration>`__.
310
296
  :returns: A dictionary of response headers.
311
297
  :rtype: Dict[str, Union[str, datetime]]
312
298
 
@@ -335,8 +321,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
335
321
  process_storage_error(error)
336
322
 
337
323
  @distributed_trace
338
- def _rename_container(self, new_name, **kwargs):
339
- # type: (str, **Any) -> ContainerClient
324
+ def _rename_container(self, new_name: str, **kwargs: Any) -> "ContainerClient":
340
325
  """Renames a container.
341
326
 
342
327
  Operation is successful only if the source container exists.
@@ -352,7 +337,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
352
337
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
353
338
  This value is not tracked or validated on the client. To configure client-side network timesouts
354
339
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
355
- #other-client--per-operation-configuration>`_.
340
+ #other-client--per-operation-configuration>`__.
356
341
  :returns: The renamed container client.
357
342
  :rtype: ~azure.storage.blob.ContainerClient
358
343
  """
@@ -374,9 +359,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
374
359
  process_storage_error(error)
375
360
 
376
361
  @distributed_trace
377
- def delete_container(
378
- self, **kwargs):
379
- # type: (Any) -> None
362
+ def delete_container(self, **kwargs: Any) -> None:
380
363
  """
381
364
  Marks the specified container for deletion. The container and any blobs
382
365
  contained within it are later deleted during garbage collection.
@@ -408,7 +391,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
408
391
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
409
392
  This value is not tracked or validated on the client. To configure client-side network timesouts
410
393
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
411
- #other-client--per-operation-configuration>`_.
394
+ #other-client--per-operation-configuration>`__.
412
395
  :rtype: None
413
396
 
414
397
  .. admonition:: Example:
@@ -435,10 +418,10 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
435
418
 
436
419
  @distributed_trace
437
420
  def acquire_lease(
438
- self, lease_duration=-1, # type: int
439
- lease_id=None, # type: Optional[str]
440
- **kwargs):
441
- # type: (...) -> BlobLeaseClient
421
+ self, lease_duration: int =-1,
422
+ lease_id: Optional[str] = None,
423
+ **kwargs: Any
424
+ ) -> BlobLeaseClient:
442
425
  """
443
426
  Requests a new lease. If the container does not have an active lease,
444
427
  the Blob service creates a lease on the container and returns a new
@@ -474,7 +457,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
474
457
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
475
458
  This value is not tracked or validated on the client. To configure client-side network timesouts
476
459
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
477
- #other-client--per-operation-configuration>`_.
460
+ #other-client--per-operation-configuration>`__.
478
461
  :returns: A BlobLeaseClient object, that can be run in a context manager.
479
462
  :rtype: ~azure.storage.blob.BlobLeaseClient
480
463
 
@@ -494,8 +477,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
494
477
  return lease
495
478
 
496
479
  @distributed_trace
497
- def get_account_information(self, **kwargs):
498
- # type: (**Any) -> Dict[str, str]
480
+ def get_account_information(self, **kwargs: Any) -> Dict[str, str]:
499
481
  """Gets information related to the storage account.
500
482
 
501
483
  The information can also be retrieved if the user has a SAS to a container or blob.
@@ -510,8 +492,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
510
492
  process_storage_error(error)
511
493
 
512
494
  @distributed_trace
513
- def get_container_properties(self, **kwargs):
514
- # type: (Any) -> ContainerProperties
495
+ def get_container_properties(self, **kwargs: Any) -> ContainerProperties:
515
496
  """Returns all user-defined metadata and system properties for the specified
516
497
  container. The data returned does not include the container's list of blobs.
517
498
 
@@ -524,7 +505,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
524
505
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
525
506
  This value is not tracked or validated on the client. To configure client-side network timesouts
526
507
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
527
- #other-client--per-operation-configuration>`_.
508
+ #other-client--per-operation-configuration>`__.
528
509
  :return: Properties for the specified container within a container object.
529
510
  :rtype: ~azure.storage.blob.ContainerProperties
530
511
 
@@ -552,8 +533,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
552
533
  return response # type: ignore
553
534
 
554
535
  @distributed_trace
555
- def exists(self, **kwargs):
556
- # type: (**Any) -> bool
536
+ def exists(self, **kwargs: Any) -> bool:
557
537
  """
558
538
  Returns True if a container exists and returns False otherwise.
559
539
 
@@ -562,7 +542,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
562
542
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
563
543
  This value is not tracked or validated on the client. To configure client-side network timesouts
564
544
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
565
- #other-client--per-operation-configuration>`_.
545
+ #other-client--per-operation-configuration>`__.
566
546
  :returns: boolean
567
547
  :rtype: bool
568
548
  """
@@ -576,11 +556,10 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
576
556
  return False
577
557
 
578
558
  @distributed_trace
579
- def set_container_metadata( # type: ignore
580
- self, metadata=None, # type: Optional[Dict[str, str]]
581
- **kwargs
582
- ):
583
- # type: (...) -> Dict[str, Union[str, datetime]]
559
+ def set_container_metadata(
560
+ self, metadata: Optional[Dict[str, str]] = None,
561
+ **kwargs: Any
562
+ ) -> Dict[str, Union[str, "datetime"]]:
584
563
  """Sets one or more user-defined name-value pairs for the specified
585
564
  container. Each call to this operation replaces all existing metadata
586
565
  attached to the container. To remove all metadata from the container,
@@ -614,7 +593,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
614
593
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
615
594
  This value is not tracked or validated on the client. To configure client-side network timesouts
616
595
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
617
- #other-client--per-operation-configuration>`_.
596
+ #other-client--per-operation-configuration>`__.
618
597
  :returns: Container-updated property dict (Etag and last modified).
619
598
  :rtype: dict[str, str or datetime]
620
599
 
@@ -645,8 +624,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
645
624
  process_storage_error(error)
646
625
 
647
626
  @distributed_trace
648
- def _get_blob_service_client(self): # pylint: disable=client-method-missing-kwargs
649
- # type: (...) -> BlobServiceClient
627
+ def _get_blob_service_client(self) -> "BlobServiceClient": # pylint: disable=client-method-missing-kwargs
650
628
  """Get a client to interact with the container's parent service account.
651
629
 
652
630
  Defaults to current container's credentials.
@@ -679,8 +657,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
679
657
  key_resolver_function=self.key_resolver_function, _pipeline=_pipeline)
680
658
 
681
659
  @distributed_trace
682
- def get_container_access_policy(self, **kwargs):
683
- # type: (Any) -> Dict[str, Any]
660
+ def get_container_access_policy(self, **kwargs: Any) -> Dict[str, Any]:
684
661
  """Gets the permissions for the specified container.
685
662
  The permissions indicate whether container data may be accessed publicly.
686
663
 
@@ -693,7 +670,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
693
670
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
694
671
  This value is not tracked or validated on the client. To configure client-side network timesouts
695
672
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
696
- #other-client--per-operation-configuration>`_.
673
+ #other-client--per-operation-configuration>`__.
697
674
  :returns: Access policy information in a dict.
698
675
  :rtype: dict[str, Any]
699
676
 
@@ -724,10 +701,10 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
724
701
 
725
702
  @distributed_trace
726
703
  def set_container_access_policy(
727
- self, signed_identifiers, # type: Dict[str, AccessPolicy]
728
- public_access=None, # type: Optional[Union[str, PublicAccess]]
729
- **kwargs
730
- ): # type: (...) -> Dict[str, Union[str, datetime]]
704
+ self, signed_identifiers: Dict[str, "AccessPolicy"],
705
+ public_access: Optional[Union[str, "PublicAccess"]] = None,
706
+ **kwargs: Any
707
+ ) -> Dict[str, Union[str, datetime]]:
731
708
  """Sets the permissions for the specified container or stored access
732
709
  policies that may be used with Shared Access Signatures. The permissions
733
710
  indicate whether blobs in a container may be accessed publicly.
@@ -760,7 +737,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
760
737
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
761
738
  This value is not tracked or validated on the client. To configure client-side network timesouts
762
739
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
763
- #other-client--per-operation-configuration>`_.
740
+ #other-client--per-operation-configuration>`__.
764
741
  :returns: Container-updated property dict (Etag and last modified).
765
742
  :rtype: dict[str, str or ~datetime.datetime]
766
743
 
@@ -789,14 +766,14 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
789
766
  access_conditions = get_access_conditions(lease)
790
767
  timeout = kwargs.pop('timeout', None)
791
768
  try:
792
- return self._client.container.set_access_policy(
769
+ return cast(Dict[str, Union[str, datetime]], self._client.container.set_access_policy(
793
770
  container_acl=signed_identifiers or None,
794
771
  timeout=timeout,
795
772
  access=public_access,
796
773
  lease_access_conditions=access_conditions,
797
774
  modified_access_conditions=mod_conditions,
798
775
  cls=return_response_headers,
799
- **kwargs)
776
+ **kwargs))
800
777
  except HttpResponseError as error:
801
778
  process_storage_error(error)
802
779
 
@@ -823,7 +800,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
823
800
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
824
801
  This value is not tracked or validated on the client. To configure client-side network timesouts
825
802
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
826
- #other-client--per-operation-configuration>`_.
803
+ #other-client--per-operation-configuration>`__.
827
804
  :returns: An iterable (auto-paging) response of BlobProperties.
828
805
  :rtype: ~azure.core.paging.ItemPaged[~azure.storage.blob.BlobProperties]
829
806
 
@@ -851,7 +828,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
851
828
  timeout=timeout,
852
829
  **kwargs)
853
830
  return ItemPaged(
854
- command, prefix=name_starts_with, results_per_page=results_per_page,
831
+ command, prefix=name_starts_with, results_per_page=results_per_page, container=self.container_name,
855
832
  page_iterator_class=BlobPropertiesPaged)
856
833
 
857
834
  @distributed_trace
@@ -872,7 +849,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
872
849
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
873
850
  This value is not tracked or validated on the client. To configure client-side network timesouts
874
851
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
875
- #other-client--per-operation-configuration>`_.
852
+ #other-client--per-operation-configuration>`__.
876
853
  :returns: An iterable (auto-paging) response of blob names as strings.
877
854
  :rtype: ~azure.core.paging.ItemPaged[str]
878
855
  """
@@ -897,6 +874,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
897
874
  command,
898
875
  prefix=name_starts_with,
899
876
  results_per_page=results_per_page,
877
+ container=self.container_name,
900
878
  page_iterator_class=BlobNamesPaged)
901
879
 
902
880
  @distributed_trace
@@ -905,7 +883,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
905
883
  include: Optional[Union[List[str], str]] = None,
906
884
  delimiter: str = "/",
907
885
  **kwargs: Any
908
- ) -> ItemPaged[BlobProperties]:
886
+ ) -> ItemPaged[BlobProperties]:
909
887
  """Returns a generator to list the blobs under the specified container.
910
888
  The generator will lazily follow the continuation tokens returned by
911
889
  the service. This operation will list blobs in accordance with a hierarchy,
@@ -929,7 +907,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
929
907
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
930
908
  This value is not tracked or validated on the client. To configure client-side network timesouts
931
909
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
932
- #other-client--per-operation-configuration>`_.
910
+ #other-client--per-operation-configuration>`__.
933
911
  :returns: An iterable (auto-paging) response of BlobProperties.
934
912
  :rtype: ~azure.core.paging.ItemPaged[~azure.storage.blob.BlobProperties]
935
913
  """
@@ -952,14 +930,14 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
952
930
  command,
953
931
  prefix=name_starts_with,
954
932
  results_per_page=results_per_page,
933
+ container=self.container_name,
955
934
  delimiter=delimiter)
956
935
 
957
936
  @distributed_trace
958
937
  def find_blobs_by_tags(
959
- self, filter_expression, # type: str
960
- **kwargs # type: Optional[Any]
961
- ):
962
- # type: (...) -> ItemPaged[FilteredBlob]
938
+ self, filter_expression: str,
939
+ **kwargs: Any
940
+ ) -> ItemPaged[FilteredBlob]:
963
941
  """Returns a generator to list the blobs under the specified container whose tags
964
942
  match the given search expression.
965
943
  The generator will lazily follow the continuation tokens returned by
@@ -975,7 +953,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
975
953
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
976
954
  This value is not tracked or validated on the client. To configure client-side network timesouts
977
955
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
978
- #other-client--per-operation-configuration>`_.
956
+ #other-client--per-operation-configuration>`__.
979
957
  :returns: An iterable (auto-paging) response of FilteredBlob.
980
958
  :rtype: ~azure.core.paging.ItemPaged[~azure.storage.blob.BlobProperties]
981
959
  """
@@ -987,18 +965,18 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
987
965
  where=filter_expression,
988
966
  **kwargs)
989
967
  return ItemPaged(
990
- command, results_per_page=results_per_page,
968
+ command, results_per_page=results_per_page, container=self.container_name,
991
969
  page_iterator_class=FilteredBlobPaged)
992
970
 
993
971
  @distributed_trace
994
972
  def upload_blob(
995
- self, name: str,
996
- data: Union[bytes, str, Iterable[AnyStr], IO[AnyStr]],
997
- blob_type: Union[str, BlobType] = BlobType.BlockBlob,
998
- length: Optional[int] = None,
999
- metadata: Optional[Dict[str, str]] = None,
1000
- **kwargs
1001
- ) -> BlobClient:
973
+ self, name: str,
974
+ data: Union[bytes, str, Iterable[AnyStr], IO[AnyStr]],
975
+ blob_type: Union[str, BlobType] = BlobType.BLOCKBLOB,
976
+ length: Optional[int] = None,
977
+ metadata: Optional[Dict[str, str]] = None,
978
+ **kwargs
979
+ ) -> BlobClient:
1002
980
  """Creates a new blob from a data source with automatic chunking.
1003
981
 
1004
982
  :param str name: The blob with which to interact.
@@ -1062,7 +1040,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
1062
1040
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
1063
1041
  This value is not tracked or validated on the client. To configure client-side network timesouts
1064
1042
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
1065
- #other-client--per-operation-configuration>`_. This method may make multiple calls to the service and
1043
+ #other-client--per-operation-configuration>`__. This method may make multiple calls to the service and
1066
1044
  the timeout will apply to each call individually.
1067
1045
  :keyword ~azure.storage.blob.PremiumPageBlobTier premium_page_blob_tier:
1068
1046
  A page blob tier value to set the blob to. The tier correlates to the size of the
@@ -1135,11 +1113,10 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
1135
1113
 
1136
1114
  @distributed_trace
1137
1115
  def delete_blob(
1138
- self, blob: str,
1139
- delete_snapshots: Optional[str] = None,
1140
- **kwargs: Any
1141
- ):
1142
- # type: (...) -> None
1116
+ self, blob: str,
1117
+ delete_snapshots: Optional[str] = None,
1118
+ **kwargs: Any
1119
+ ) -> None:
1143
1120
  """Marks the specified blob or snapshot for deletion.
1144
1121
 
1145
1122
  The blob is later deleted during garbage collection.
@@ -1163,6 +1140,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
1163
1140
  value that, when present, specifies the version of the blob to delete.
1164
1141
 
1165
1142
  .. versionadded:: 12.4.0
1143
+
1166
1144
  This keyword argument was introduced in API version '2019-12-12'.
1167
1145
 
1168
1146
  :keyword lease:
@@ -1197,7 +1175,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
1197
1175
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
1198
1176
  This value is not tracked or validated on the client. To configure client-side network timesouts
1199
1177
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
1200
- #other-client--per-operation-configuration>`_.
1178
+ #other-client--per-operation-configuration>`__.
1201
1179
  :rtype: None
1202
1180
  """
1203
1181
  if isinstance(blob, BlobProperties):
@@ -1216,35 +1194,35 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
1216
1194
 
1217
1195
  @overload
1218
1196
  def download_blob(
1219
- self, blob: str,
1220
- offset: int = None,
1221
- length: int = None,
1222
- *,
1223
- encoding: str,
1224
- **kwargs: Any
1197
+ self, blob: str,
1198
+ offset: Optional[int] = None,
1199
+ length: Optional[int] = None,
1200
+ *,
1201
+ encoding: str,
1202
+ **kwargs: Any
1225
1203
  ) -> StorageStreamDownloader[str]:
1226
1204
  ...
1227
1205
 
1228
1206
  @overload
1229
1207
  def download_blob(
1230
- self, blob: str,
1231
- offset: int = None,
1232
- length: int = None,
1233
- *,
1234
- encoding: None = None,
1235
- **kwargs: Any
1208
+ self, blob: str,
1209
+ offset: Optional[int] = None,
1210
+ length: Optional[int] = None,
1211
+ *,
1212
+ encoding: None = None,
1213
+ **kwargs: Any
1236
1214
  ) -> StorageStreamDownloader[bytes]:
1237
1215
  ...
1238
1216
 
1239
1217
  @distributed_trace
1240
1218
  def download_blob(
1241
- self, blob: str,
1242
- offset: int = None,
1243
- length: int = None,
1244
- *,
1245
- encoding: Optional[str] = None,
1246
- **kwargs: Any
1247
- ) -> StorageStreamDownloader:
1219
+ self, blob: str,
1220
+ offset: Optional[int] = None,
1221
+ length: Optional[int] = None,
1222
+ *,
1223
+ encoding: Union[str, None] = None,
1224
+ **kwargs: Any
1225
+ ) -> Union[StorageStreamDownloader[str], StorageStreamDownloader[bytes]]:
1248
1226
  """Downloads a blob to the StorageStreamDownloader. The readall() method must
1249
1227
  be used to read all the content or readinto() must be used to download the blob into
1250
1228
  a stream. Using chunks() returns an iterator which allows the user to iterate over the content in chunks.
@@ -1261,6 +1239,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
1261
1239
  value that, when present, specifies the version of the blob to download.
1262
1240
 
1263
1241
  .. versionadded:: 12.4.0
1242
+
1264
1243
  This keyword argument was introduced in API version '2019-12-12'.
1265
1244
 
1266
1245
  :keyword bool validate_content:
@@ -1319,7 +1298,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
1319
1298
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
1320
1299
  This value is not tracked or validated on the client. To configure client-side network timesouts
1321
1300
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
1322
- #other-client--per-operation-configuration>`_. This method may make multiple calls to the service and
1301
+ #other-client--per-operation-configuration>`__. This method may make multiple calls to the service and
1323
1302
  the timeout will apply to each call individually.
1324
1303
  multiple calls to the Azure service and the timeout will apply to
1325
1304
  each call individually.
@@ -1340,131 +1319,11 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
1340
1319
  encoding=encoding,
1341
1320
  **kwargs)
1342
1321
 
1343
- # This code is a copy from _generated.
1344
- # Once Autorest is able to provide request preparation this code should be removed.
1345
- def _generate_delete_blobs_subrequest_options(
1346
- self, snapshot=None,
1347
- version_id=None,
1348
- delete_snapshots=None,
1349
- lease_access_conditions=None,
1350
- modified_access_conditions=None,
1351
- **kwargs
1352
- ):
1353
- lease_id = None
1354
- if lease_access_conditions is not None:
1355
- lease_id = lease_access_conditions.lease_id
1356
- if_modified_since = None
1357
- if modified_access_conditions is not None:
1358
- if_modified_since = modified_access_conditions.if_modified_since
1359
- if_unmodified_since = None
1360
- if modified_access_conditions is not None:
1361
- if_unmodified_since = modified_access_conditions.if_unmodified_since
1362
- if_match = None
1363
- if modified_access_conditions is not None:
1364
- if_match = modified_access_conditions.if_match
1365
- if_none_match = None
1366
- if modified_access_conditions is not None:
1367
- if_none_match = modified_access_conditions.if_none_match
1368
- if_tags = None
1369
- if modified_access_conditions is not None:
1370
- if_tags = modified_access_conditions.if_tags
1371
-
1372
- # Construct parameters
1373
- timeout = kwargs.pop('timeout', None)
1374
- query_parameters = {}
1375
- if snapshot is not None:
1376
- query_parameters['snapshot'] = self._client._serialize.query("snapshot", snapshot, 'str') # pylint: disable=protected-access
1377
- if version_id is not None:
1378
- query_parameters['versionid'] = self._client._serialize.query("version_id", version_id, 'str') # pylint: disable=protected-access
1379
- if timeout is not None:
1380
- query_parameters['timeout'] = self._client._serialize.query("timeout", timeout, 'int', minimum=0) # pylint: disable=protected-access
1381
-
1382
- # Construct headers
1383
- header_parameters = {}
1384
- if delete_snapshots is not None:
1385
- header_parameters['x-ms-delete-snapshots'] = self._client._serialize.header( # pylint: disable=protected-access
1386
- "delete_snapshots", delete_snapshots, 'DeleteSnapshotsOptionType')
1387
- if lease_id is not None:
1388
- header_parameters['x-ms-lease-id'] = self._client._serialize.header( # pylint: disable=protected-access
1389
- "lease_id", lease_id, 'str')
1390
- if if_modified_since is not None:
1391
- header_parameters['If-Modified-Since'] = self._client._serialize.header( # pylint: disable=protected-access
1392
- "if_modified_since", if_modified_since, 'rfc-1123')
1393
- if if_unmodified_since is not None:
1394
- header_parameters['If-Unmodified-Since'] = self._client._serialize.header( # pylint: disable=protected-access
1395
- "if_unmodified_since", if_unmodified_since, 'rfc-1123')
1396
- if if_match is not None:
1397
- header_parameters['If-Match'] = self._client._serialize.header( # pylint: disable=protected-access
1398
- "if_match", if_match, 'str')
1399
- if if_none_match is not None:
1400
- header_parameters['If-None-Match'] = self._client._serialize.header( # pylint: disable=protected-access
1401
- "if_none_match", if_none_match, 'str')
1402
- if if_tags is not None:
1403
- header_parameters['x-ms-if-tags'] = self._client._serialize.header("if_tags", if_tags, 'str') # pylint: disable=protected-access
1404
-
1405
- return query_parameters, header_parameters
1406
-
1407
- def _generate_delete_blobs_options(
1408
- self, *blobs: Union[str, Dict[str, Any], BlobProperties],
1409
- **kwargs: Any
1410
- ):
1411
- timeout = kwargs.pop('timeout', None)
1412
- raise_on_any_failure = kwargs.pop('raise_on_any_failure', True)
1413
- delete_snapshots = kwargs.pop('delete_snapshots', None)
1414
- if_modified_since = kwargs.pop('if_modified_since', None)
1415
- if_unmodified_since = kwargs.pop('if_unmodified_since', None)
1416
- if_tags_match_condition = kwargs.pop('if_tags_match_condition', None)
1417
- kwargs.update({'raise_on_any_failure': raise_on_any_failure,
1418
- 'sas': self._query_str.replace('?', '&'),
1419
- 'timeout': '&timeout=' + str(timeout) if timeout else "",
1420
- 'path': self.container_name,
1421
- 'restype': 'restype=container&'
1422
- })
1423
-
1424
- reqs = []
1425
- for blob in blobs:
1426
- blob_name = _get_blob_name(blob)
1427
- container_name = self.container_name
1428
-
1429
- try:
1430
- options = BlobClient._generic_delete_blob_options( # pylint: disable=protected-access
1431
- snapshot=blob.get('snapshot'),
1432
- version_id=blob.get('version_id'),
1433
- delete_snapshots=delete_snapshots or blob.get('delete_snapshots'),
1434
- lease=blob.get('lease_id'),
1435
- if_modified_since=if_modified_since or blob.get('if_modified_since'),
1436
- if_unmodified_since=if_unmodified_since or blob.get('if_unmodified_since'),
1437
- etag=blob.get('etag'),
1438
- if_tags_match_condition=if_tags_match_condition or blob.get('if_tags_match_condition'),
1439
- match_condition=blob.get('match_condition') or MatchConditions.IfNotModified if blob.get('etag')
1440
- else None,
1441
- timeout=blob.get('timeout'),
1442
- )
1443
- except AttributeError:
1444
- options = BlobClient._generic_delete_blob_options( # pylint: disable=protected-access
1445
- delete_snapshots=delete_snapshots,
1446
- if_modified_since=if_modified_since,
1447
- if_unmodified_since=if_unmodified_since,
1448
- if_tags_match_condition=if_tags_match_condition
1449
- )
1450
-
1451
- query_parameters, header_parameters = self._generate_delete_blobs_subrequest_options(**options)
1452
-
1453
- req = HttpRequest(
1454
- "DELETE",
1455
- f"/{quote(container_name)}/{quote(blob_name, safe='/~')}{self._query_str}",
1456
- headers=header_parameters
1457
- )
1458
- req.format_parameters(query_parameters)
1459
- reqs.append(req)
1460
-
1461
- return reqs, kwargs
1462
-
1463
1322
  @distributed_trace
1464
1323
  def delete_blobs( # pylint: disable=delete-operation-wrong-return-type
1465
- self, *blobs: Union[str, Dict[str, Any], BlobProperties],
1466
- **kwargs: Any
1467
- ) -> Iterator["HttpResponse"]:
1324
+ self, *blobs: Union[str, Dict[str, Any], BlobProperties],
1325
+ **kwargs: Any
1326
+ ) -> Iterator["HttpResponse"]:
1468
1327
  """Marks the specified blobs or snapshots for deletion.
1469
1328
 
1470
1329
  The blobs are later deleted during garbage collection.
@@ -1507,7 +1366,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
1507
1366
  timeout for subrequest:
1508
1367
  key: 'timeout', value type: int
1509
1368
 
1510
- :type blobs: str or dict(str, Any) or ~azure.storage.blob.BlobProperties
1369
+ :type blobs: Union[str, Dict[str, Any], BlobProperties]
1511
1370
  :keyword str delete_snapshots:
1512
1371
  Required if a blob has associated snapshots. Values include:
1513
1372
  - "only": Deletes only the blobs snapshots.
@@ -1538,7 +1397,7 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
1538
1397
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
1539
1398
  This value is not tracked or validated on the client. To configure client-side network timesouts
1540
1399
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
1541
- #other-client--per-operation-configuration>`_.
1400
+ #other-client--per-operation-configuration>`__.
1542
1401
  :return: An iterator of responses, one for each blob in order
1543
1402
  :rtype: Iterator[~azure.core.pipeline.transport.HttpResponse]
1544
1403
 
@@ -1553,100 +1412,22 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
1553
1412
  """
1554
1413
  if len(blobs) == 0:
1555
1414
  return iter([])
1556
-
1557
- reqs, options = self._generate_delete_blobs_options(*blobs, **kwargs)
1415
+ if self._is_localhost:
1416
+ kwargs['url_prepend'] = self.account_name
1417
+
1418
+ reqs, options = _generate_delete_blobs_options(
1419
+ self._query_str,
1420
+ self.container_name,
1421
+ self._client,
1422
+ *blobs,
1423
+ **kwargs
1424
+ )
1558
1425
 
1559
1426
  return self._batch_send(*reqs, **options)
1560
1427
 
1561
- # This code is a copy from _generated.
1562
- # Once Autorest is able to provide request preparation this code should be removed.
1563
- def _generate_set_tiers_subrequest_options(
1564
- self, tier, snapshot=None, version_id=None, rehydrate_priority=None, lease_access_conditions=None, **kwargs
1565
- ):
1566
- if not tier:
1567
- raise ValueError("A blob tier must be specified")
1568
- if snapshot and version_id:
1569
- raise ValueError("Snapshot and version_id cannot be set at the same time")
1570
- if_tags = kwargs.pop('if_tags', None)
1571
-
1572
- lease_id = None
1573
- if lease_access_conditions is not None:
1574
- lease_id = lease_access_conditions.lease_id
1575
-
1576
- comp = "tier"
1577
- timeout = kwargs.pop('timeout', None)
1578
- # Construct parameters
1579
- query_parameters = {}
1580
- if snapshot is not None:
1581
- query_parameters['snapshot'] = self._client._serialize.query("snapshot", snapshot, 'str') # pylint: disable=protected-access
1582
- if version_id is not None:
1583
- query_parameters['versionid'] = self._client._serialize.query("version_id", version_id, 'str') # pylint: disable=protected-access
1584
- if timeout is not None:
1585
- query_parameters['timeout'] = self._client._serialize.query("timeout", timeout, 'int', minimum=0) # pylint: disable=protected-access
1586
- query_parameters['comp'] = self._client._serialize.query("comp", comp, 'str') # pylint: disable=protected-access, specify-parameter-names-in-call
1587
-
1588
- # Construct headers
1589
- header_parameters = {}
1590
- header_parameters['x-ms-access-tier'] = self._client._serialize.header("tier", tier, 'str') # pylint: disable=protected-access, specify-parameter-names-in-call
1591
- if rehydrate_priority is not None:
1592
- header_parameters['x-ms-rehydrate-priority'] = self._client._serialize.header( # pylint: disable=protected-access
1593
- "rehydrate_priority", rehydrate_priority, 'str')
1594
- if lease_id is not None:
1595
- header_parameters['x-ms-lease-id'] = self._client._serialize.header("lease_id", lease_id, 'str') # pylint: disable=protected-access
1596
- if if_tags is not None:
1597
- header_parameters['x-ms-if-tags'] = self._client._serialize.header("if_tags", if_tags, 'str') # pylint: disable=protected-access
1598
-
1599
- return query_parameters, header_parameters
1600
-
1601
- def _generate_set_tiers_options(
1602
- self, blob_tier: Optional[Union[str, 'StandardBlobTier', 'PremiumPageBlobTier']],
1603
- *blobs: Union[str, Dict[str, Any], BlobProperties],
1604
- **kwargs: Any
1605
- ):
1606
- timeout = kwargs.pop('timeout', None)
1607
- raise_on_any_failure = kwargs.pop('raise_on_any_failure', True)
1608
- rehydrate_priority = kwargs.pop('rehydrate_priority', None)
1609
- if_tags = kwargs.pop('if_tags_match_condition', None)
1610
- kwargs.update({'raise_on_any_failure': raise_on_any_failure,
1611
- 'sas': self._query_str.replace('?', '&'),
1612
- 'timeout': '&timeout=' + str(timeout) if timeout else "",
1613
- 'path': self.container_name,
1614
- 'restype': 'restype=container&'
1615
- })
1616
-
1617
- reqs = []
1618
- for blob in blobs:
1619
- blob_name = _get_blob_name(blob)
1620
- container_name = self.container_name
1621
-
1622
- try:
1623
- tier = blob_tier or blob.get('blob_tier')
1624
- query_parameters, header_parameters = self._generate_set_tiers_subrequest_options(
1625
- tier=tier,
1626
- snapshot=blob.get('snapshot'),
1627
- version_id=blob.get('version_id'),
1628
- rehydrate_priority=rehydrate_priority or blob.get('rehydrate_priority'),
1629
- lease_access_conditions=blob.get('lease_id'),
1630
- if_tags=if_tags or blob.get('if_tags_match_condition'),
1631
- timeout=timeout or blob.get('timeout')
1632
- )
1633
- except AttributeError:
1634
- query_parameters, header_parameters = self._generate_set_tiers_subrequest_options(
1635
- blob_tier, rehydrate_priority=rehydrate_priority, if_tags=if_tags)
1636
-
1637
- req = HttpRequest(
1638
- "PUT",
1639
- f"/{quote(container_name)}/{quote(blob_name, safe='/~')}{self._query_str}",
1640
- headers=header_parameters
1641
- )
1642
- req.format_parameters(query_parameters)
1643
- reqs.append(req)
1644
-
1645
- return reqs, kwargs
1646
-
1647
1428
  @distributed_trace
1648
1429
  def set_standard_blob_tier_blobs(
1649
- self, standard_blob_tier: Optional[Union[str, 'StandardBlobTier']],
1430
+ self, standard_blob_tier: Optional[Union[str, "StandardBlobTier"]],
1650
1431
  *blobs: Union[str, Dict[str, Any], BlobProperties],
1651
1432
  **kwargs: Any
1652
1433
  ) -> Iterator["HttpResponse"]:
@@ -1708,20 +1489,28 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
1708
1489
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
1709
1490
  This value is not tracked or validated on the client. To configure client-side network timesouts
1710
1491
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
1711
- #other-client--per-operation-configuration>`_.
1492
+ #other-client--per-operation-configuration>`__.
1712
1493
  :keyword bool raise_on_any_failure:
1713
1494
  This is a boolean param which defaults to True. When this is set, an exception
1714
1495
  is raised even if there is a single operation failure.
1715
1496
  :return: An iterator of responses, one for each blob in order
1716
1497
  :rtype: Iterator[~azure.core.pipeline.transport.HttpResponse]
1717
1498
  """
1718
- reqs, options = self._generate_set_tiers_options(standard_blob_tier, *blobs, **kwargs)
1499
+ if self._is_localhost:
1500
+ kwargs['url_prepend'] = self.account_name
1501
+ reqs, options = _generate_set_tiers_options(
1502
+ self._query_str,
1503
+ self.container_name,
1504
+ standard_blob_tier,
1505
+ self._client,
1506
+ *blobs,
1507
+ **kwargs)
1719
1508
 
1720
1509
  return self._batch_send(*reqs, **options)
1721
1510
 
1722
1511
  @distributed_trace
1723
1512
  def set_premium_page_blob_tier_blobs(
1724
- self, premium_page_blob_tier: Optional[Union[str, 'PremiumPageBlobTier']],
1513
+ self, premium_page_blob_tier: Optional[Union[str, "PremiumPageBlobTier"]],
1725
1514
  *blobs: Union[str, Dict[str, Any], BlobProperties],
1726
1515
  **kwargs: Any
1727
1516
  ) -> Iterator["HttpResponse"]:
@@ -1761,22 +1550,30 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
1761
1550
  https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
1762
1551
  This value is not tracked or validated on the client. To configure client-side network timesouts
1763
1552
  see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
1764
- #other-client--per-operation-configuration>`_.
1553
+ #other-client--per-operation-configuration>`__.
1765
1554
  :keyword bool raise_on_any_failure:
1766
1555
  This is a boolean param which defaults to True. When this is set, an exception
1767
1556
  is raised even if there is a single operation failure.
1768
1557
  :return: An iterator of responses, one for each blob in order
1769
1558
  :rtype: Iterator[~azure.core.pipeline.transport.HttpResponse]
1770
1559
  """
1771
- reqs, options = self._generate_set_tiers_options(premium_page_blob_tier, *blobs, **kwargs)
1560
+ if self._is_localhost:
1561
+ kwargs['url_prepend'] = self.account_name
1562
+ reqs, options = _generate_set_tiers_options(
1563
+ self._query_str,
1564
+ self.container_name,
1565
+ premium_page_blob_tier,
1566
+ self._client,
1567
+ *blobs,
1568
+ **kwargs)
1772
1569
 
1773
1570
  return self._batch_send(*reqs, **options)
1774
1571
 
1775
1572
  def get_blob_client(
1776
- self, blob: str,
1777
- snapshot: Optional[str] = None,
1778
- *,
1779
- version_id: Optional[str] = None
1573
+ self, blob: str,
1574
+ snapshot: Optional[str] = None,
1575
+ *,
1576
+ version_id: Optional[str] = None
1780
1577
  ) -> BlobClient:
1781
1578
  """Get a client to interact with the specified blob.
1782
1579
 
@@ -1807,7 +1604,9 @@ class ContainerClient(StorageAccountHostsMixin, StorageEncryptionMixin): # py
1807
1604
  "Please use 'BlobProperties.name' or any other str input type instead.",
1808
1605
  DeprecationWarning
1809
1606
  )
1810
- blob_name = _get_blob_name(blob)
1607
+ blob_name = blob.get('name')
1608
+ else:
1609
+ blob_name = blob
1811
1610
  _pipeline = Pipeline(
1812
1611
  transport=TransportWrapper(self._pipeline._transport), # pylint: disable = protected-access
1813
1612
  policies=self._pipeline._impl_policies # pylint: disable = protected-access