diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/aio/container_client_async.py b/sdk/storage/azure-storage-blob/azure/storage/blob/aio/container_client_async.py index 7890b9aabe4a..177fe029aa01 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/aio/container_client_async.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/aio/container_client_async.py @@ -6,14 +6,14 @@ import functools from typing import ( # pylint: disable=unused-import - Union, Optional, Any, Iterable, AnyStr, Dict, List, Tuple, IO, + Union, Optional, Any, Iterable, AnyStr, Dict, List, Tuple, IO, AsyncIterator, TYPE_CHECKING ) from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.async_paging import AsyncItemPaged -from azure.core.pipeline.transport import HttpRequest +from azure.core.pipeline.transport import HttpRequest, AsyncHttpResponse from .._shared.base_client_async import AsyncStorageAccountHostsMixin from .._shared.policies_async import ExponentialRetry @@ -43,6 +43,7 @@ from ..models import ( # pylint: disable=unused-import AccessPolicy, ContentSettings, + StandardBlobTier, PremiumPageBlobTier) @@ -860,11 +861,11 @@ async def delete_blobs( @distributed_trace async def set_standard_blob_tier_blobs( - self, *blobs, # type: Union[str, BlobProperties] - standard_blob_tier, + self, + standard_blob_tier: Union[str, 'StandardBlobTier'], + *blobs: Union[str, BlobProperties], **kwargs - ): - # type: (Union[str, BlobProperties], Union[str, StandardBlobTier], Any) -> None + ) -> AsyncIterator[AsyncHttpResponse]: """This operation sets the tier on block blobs. A block blob's tier determines Hot/Cool/Archive storage type. @@ -912,11 +913,11 @@ async def set_standard_blob_tier_blobs( @distributed_trace async def set_premium_page_blob_tier_blobs( - self, *blobs, # type: Union[str, BlobProperties] - premium_page_blob_tier, + self, + premium_page_blob_tier: Union[str, 'PremiumPageBlobTier'], + *blobs: Union[str, BlobProperties], **kwargs - ): - # type: (Union[str, BlobProperties], Union[str, PremiumPageBlobTier], Optional[int], Optional[Union[LeaseClient, str]], **Any) -> None + ) -> AsyncIterator[AsyncHttpResponse]: """Sets the page blob tiers on the blobs. This API is only supported for page blobs on premium accounts. :param blobs: The blobs with which to interact. diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/container_client.py b/sdk/storage/azure-storage-blob/azure/storage/blob/container_client.py index 537032d151dc..404a3a2f8940 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/container_client.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/container_client.py @@ -997,13 +997,7 @@ def _generate_delete_blobs_options(self, snapshot=None, timeout=None, delete_sna return query_parameters, header_parameters @distributed_trace - def delete_blobs( - self, *blobs, # type: Union[str, BlobProperties] - delete_snapshots=None, # type: Optional[str] - lease=None, # type: Optional[Union[str, LeaseClient]] - timeout=None, # type: Optional[int] - **kwargs - ): + def delete_blobs(self, *blobs, **kwargs): # type: (...) -> None """Marks the specified blobs or snapshots for deletion. @@ -1057,7 +1051,10 @@ def delete_blobs( The timeout parameter is expressed in seconds. :rtype: None """ - options = BlobClient._generic_delete_blob_options( + delete_snapshots = kwargs.get('delete_snapshots', None) + lease = kwargs.get('lease', None) + timeout = kwargs.get('timeout', None) + options = BlobClient._generic_delete_blob_options( # pylint: disable=protected-access delete_snapshots=delete_snapshots, lease=lease, timeout=timeout, @@ -1105,11 +1102,12 @@ def _generate_set_tier_options(self, tier, timeout=None, rehydrate_priority=None @distributed_trace def set_standard_blob_tier_blobs( - self, *blobs, # type: Union[str, BlobProperties] - standard_blob_tier, + self, + standard_blob_tier, # type: Union[str, StandardBlobTier] + *blobs, # type: Union[str, BlobProperties] **kwargs ): - # type: (Union[str, BlobProperties], Union[str, StandardBlobTier], Any) -> None + # type: (...) -> Iterator[HttpResponse] """This operation sets the tier on block blobs. A block blob's tier determines Hot/Cool/Archive storage type. @@ -1157,11 +1155,12 @@ def set_standard_blob_tier_blobs( @distributed_trace def set_premium_page_blob_tier_blobs( - self, *blobs, # type: Union[str, BlobProperties] - premium_page_blob_tier, + self, + premium_page_blob_tier, # type: Union[str, PremiumPageBlobTier] + *blobs, # type: Union[str, BlobProperties] **kwargs ): - # type: (Union[str, BlobProperties], Union[str, PremiumPageBlobTier], Optional[int], Optional[Union[LeaseClient, str]], **Any) -> None + # type: (...) -> Iterator[HttpResponse] """Sets the page blob tiers on the blobs. This API is only supported for page blobs on premium accounts. :param blobs: The blobs with which to interact. diff --git a/sdk/storage/azure-storage-blob/tests/test_container.py b/sdk/storage/azure-storage-blob/tests/test_container.py index 8109ad2b29e9..475f887695d6 100644 --- a/sdk/storage/azure-storage-blob/tests/test_container.py +++ b/sdk/storage/azure-storage-blob/tests/test_container.py @@ -864,7 +864,7 @@ def test_list_blobs_with_include_snapshots(self): @record def test_list_blobs_with_include_metadata(self): # Arrange - + container = self._create_container() data = b'hello world' blob1 = container.get_blob_client('blob1') @@ -1043,10 +1043,10 @@ def test_standard_blob_tier_set_tier_api_batch(self): assert blob_ref.blob_tier_change_time is None parts = container.set_standard_blob_tier_blobs( + tier, 'blob1', 'blob2', 'blob3', - standard_blob_tier=tier ) parts = list(parts) @@ -1095,10 +1095,10 @@ def test_premium_tier_set_tier_api_batch(self): assert blob_ref.blob_tier_inferred parts = container.set_premium_page_blob_tier_blobs( + PremiumPageBlobTier.P50, 'blob1', 'blob2', 'blob3', - premium_page_blob_tier=PremiumPageBlobTier.P50 ) parts = list(parts) @@ -1146,7 +1146,7 @@ def recursive_walk(prefix): @record def test_list_blobs_with_include_multiple(self): # Arrange - + container = self._create_container() data = b'hello world' blob1 = container.get_blob_client('blob1') diff --git a/sdk/storage/azure-storage-blob/tests/test_container_async.py b/sdk/storage/azure-storage-blob/tests/test_container_async.py index 4106c3f0049c..3f511f8e60bc 100644 --- a/sdk/storage/azure-storage-blob/tests/test_container_async.py +++ b/sdk/storage/azure-storage-blob/tests/test_container_async.py @@ -1288,10 +1288,10 @@ async def _test_standard_blob_tier_set_tier_api_batch(self): assert blob_ref.blob_tier_change_time is None parts = await _to_list(await container.set_standard_blob_tier_blobs( + tier, 'blob1', 'blob2', 'blob3', - standard_blob_tier=tier )) assert len(parts) == 3 @@ -1344,10 +1344,10 @@ async def _test_premium_tier_set_tier_api_batch(self): assert blob_ref.blob_tier_inferred parts = await _to_list(container.set_premium_page_blob_tier_blobs( + PremiumPageBlobTier.P50, 'blob1', 'blob2', 'blob3', - premium_page_blob_tier=PremiumPageBlobTier.P50 )) assert len(parts) == 3