Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Storage] Update type hints for Blob batch operations #25785

Merged
merged 2 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from azure.core.exceptions import HttpResponseError, ResourceNotFoundError
from azure.core.paging import ItemPaged
from azure.core.pipeline import Pipeline
from azure.core.pipeline.transport import HttpRequest
from azure.core.pipeline.transport import HttpRequest, HttpResponse
from azure.core.tracing.decorator import distributed_trace

from ._shared.base_client import StorageAccountHostsMixin, TransportWrapper, parse_connection_str, parse_query
Expand All @@ -44,7 +44,6 @@
from ._serialize import get_modify_conditions, get_container_cpk_scope_info, get_api_version, get_access_conditions

if TYPE_CHECKING:
from azure.core.pipeline.transport import HttpResponse # pylint: disable=ungrouped-imports
from datetime import datetime
from ._models import ( # pylint: disable=unused-import
PublicAccess,
Expand Down Expand Up @@ -1017,7 +1016,7 @@ def delete_blob(
and retains the blob or snapshot for specified number of days.
After specified number of days, blob's data is removed from the service during garbage collection.
Soft deleted blob or snapshot is accessible through :func:`list_blobs()` specifying `include=["deleted"]`
option. Soft-deleted blob or snapshot can be restored using :func:`~BlobClient.undelete()`
option. Soft-deleted blob or snapshot can be restored using :func:`~azure.storage.blob.BlobClient.undelete()`

:param blob: The blob with which to interact. If specified, this value will override
a blob value specified in the blob URL.
Expand Down Expand Up @@ -1252,10 +1251,10 @@ def _generate_delete_blobs_subrequest_options(

return query_parameters, header_parameters

def _generate_delete_blobs_options(self,
*blobs, # type: List[Union[str, BlobProperties, dict]]
**kwargs
):
def _generate_delete_blobs_options(
self, *blobs: Union[str, Dict[str, Any], BlobProperties],
**kwargs: Any
):
timeout = kwargs.pop('timeout', None)
raise_on_any_failure = kwargs.pop('raise_on_any_failure', True)
delete_snapshots = kwargs.pop('delete_snapshots', None)
Expand Down Expand Up @@ -1309,8 +1308,10 @@ def _generate_delete_blobs_options(self,
return reqs, kwargs

@distributed_trace
def delete_blobs(self, *blobs, **kwargs):
# type: (...) -> Iterator[HttpResponse]
def delete_blobs(
self, *blobs: Union[str, Dict[str, Any], BlobProperties],
**kwargs: Any
) -> Iterator[HttpResponse]:
"""Marks the specified blobs or snapshots for deletion.

The blobs are later deleted during garbage collection.
Expand All @@ -1321,7 +1322,7 @@ def delete_blobs(self, *blobs, **kwargs):
and retains the blobs or snapshots for specified number of days.
After specified number of days, blobs' data is removed from the service during garbage collection.
Soft deleted blobs or snapshots are accessible through :func:`list_blobs()` specifying `include=["deleted"]`
Soft-deleted blobs or snapshots can be restored using :func:`~BlobClient.undelete()`
Soft-deleted blobs or snapshots can be restored using :func:`~azure.storage.blob.BlobClient.undelete()`

The maximum number of blobs that can be deleted in a single request is 256.

Expand Down Expand Up @@ -1353,7 +1354,7 @@ def delete_blobs(self, *blobs, **kwargs):
timeout for subrequest:
key: 'timeout', value type: int

:type blobs: list[str], list[dict], or list[~azure.storage.blob.BlobProperties]
:type blobs: str or dict(str, Any) or ~azure.storage.blob.BlobProperties
:keyword str delete_snapshots:
Required if a blob has associated snapshots. Values include:
- "only": Deletes only the blobs snapshots.
Expand Down Expand Up @@ -1442,11 +1443,11 @@ def _generate_set_tiers_subrequest_options(

return query_parameters, header_parameters

def _generate_set_tiers_options(self,
blob_tier, # type: Optional[Union[str, StandardBlobTier, PremiumPageBlobTier]]
*blobs, # type: List[Union[str, BlobProperties, dict]]
**kwargs
):
def _generate_set_tiers_options(
self, blob_tier: Optional[Union[str, 'StandardBlobTier', 'PremiumPageBlobTier']],
*blobs: Union[str, Dict[str, Any], BlobProperties],
**kwargs: Any
):
timeout = kwargs.pop('timeout', None)
raise_on_any_failure = kwargs.pop('raise_on_any_failure', True)
rehydrate_priority = kwargs.pop('rehydrate_priority', None)
Expand Down Expand Up @@ -1490,12 +1491,10 @@ def _generate_set_tiers_options(self,

@distributed_trace
def set_standard_blob_tier_blobs(
self,
standard_blob_tier, # type: Optional[Union[str, StandardBlobTier]]
*blobs, # type: List[Union[str, BlobProperties, dict]]
**kwargs
):
# type: (...) -> Iterator[HttpResponse]
self, standard_blob_tier: Optional[Union[str, 'StandardBlobTier']],
*blobs: Union[str, Dict[str, Any], BlobProperties],
**kwargs: Any
) -> Iterator[HttpResponse]:
"""This operation sets the tier on block blobs.

A block blob's tier determines Hot/Cool/Archive storage type.
Expand Down Expand Up @@ -1540,7 +1539,7 @@ def set_standard_blob_tier_blobs(
timeout for subrequest:
key: 'timeout', value type: int

:type blobs: list[str], list[dict], or list[~azure.storage.blob.BlobProperties]
:type blobs: str or dict(str, Any) or ~azure.storage.blob.BlobProperties
:keyword ~azure.storage.blob.RehydratePriority rehydrate_priority:
Indicates the priority with which to rehydrate an archived blob
:keyword str if_tags_match_condition:
Expand All @@ -1563,12 +1562,10 @@ def set_standard_blob_tier_blobs(

@distributed_trace
def set_premium_page_blob_tier_blobs(
self,
premium_page_blob_tier, # type: Optional[Union[str, PremiumPageBlobTier]]
*blobs, # type: List[Union[str, BlobProperties, dict]]
**kwargs
):
# type: (...) -> Iterator[HttpResponse]
self, premium_page_blob_tier: Optional[Union[str, 'PremiumPageBlobTier']],
*blobs: Union[str, Dict[str, Any], BlobProperties],
**kwargs: Any
) -> Iterator[HttpResponse]:
"""Sets the page blob tiers on all blobs. This API is only supported for page blobs on premium accounts.

The maximum number of blobs that can be updated in a single request is 256.
Expand Down Expand Up @@ -1599,7 +1596,7 @@ def set_premium_page_blob_tier_blobs(
timeout for subrequest:
key: 'timeout', value type: int

:type blobs: list[str], list[dict], or list[~azure.storage.blob.BlobProperties]
:type blobs: str or dict(str, Any) or ~azure.storage.blob.BlobProperties
:keyword int timeout:
The timeout parameter is expressed in seconds. This method may make
multiple calls to the Azure service and the timeout will apply to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -875,8 +875,8 @@ async def delete_blob(
If a delete retention policy is enabled for the service, then this operation soft deletes the blob or snapshot
and retains the blob or snapshot for specified number of days.
After specified number of days, blob's data is removed from the service during garbage collection.
Soft deleted blob or snapshot is accessible through :func:`list_blobs()` specifying `include=["deleted"]`
option. Soft-deleted blob or snapshot can be restored using :func:`~BlobClient.undelete()`
Soft deleted blobs or snapshots are accessible through :func:`list_blobs()` specifying `include=["deleted"]`
Soft-deleted blob or snapshot can be restored using :func:`~azure.storage.blob.aio.BlobClient.undelete()`

:param blob: The blob with which to interact. If specified, this value will override
a blob value specified in the blob URL.
Expand Down Expand Up @@ -1046,9 +1046,9 @@ async def download_blob(
**kwargs)

@distributed_trace_async
async def delete_blobs( # pylint: disable=arguments-differ
self, *blobs: List[Union[str, BlobProperties, dict]],
**kwargs
async def delete_blobs(
self, *blobs: Union[str, Dict[str, Any], BlobProperties],
**kwargs: Any
) -> AsyncIterator[AsyncHttpResponse]:
"""Marks the specified blobs or snapshots for deletion.

Expand All @@ -1060,7 +1060,7 @@ async def delete_blobs( # pylint: disable=arguments-differ
and retains the blobs or snapshots for specified number of days.
After specified number of days, blobs' data is removed from the service during garbage collection.
Soft deleted blobs or snapshots are accessible through :func:`list_blobs()` specifying `include=["deleted"]`
Soft-deleted blobs or snapshots can be restored using :func:`~BlobClient.undelete()`
Soft-deleted blobs or snapshots can be restored using :func:`~azure.storage.blob.aio.BlobClient.undelete()`

The maximum number of blobs that can be deleted in a single request is 256.

Expand Down Expand Up @@ -1090,7 +1090,7 @@ async def delete_blobs( # pylint: disable=arguments-differ
timeout for subrequest:
key: 'timeout', value type: int

:type blobs: list[str], list[dict], or list[~azure.storage.blob.BlobProperties]
:type blobs: str or dict(str, Any) or ~azure.storage.blob.BlobProperties
:keyword str delete_snapshots:
Required if a blob has associated snapshots. Values include:
- "only": Deletes only the blobs snapshots.
Expand Down Expand Up @@ -1138,12 +1138,11 @@ async def delete_blobs( # pylint: disable=arguments-differ

return await self._batch_send(*reqs, **options)

@distributed_trace
@distributed_trace_async
async def set_standard_blob_tier_blobs(
self,
standard_blob_tier: Union[str, 'StandardBlobTier'],
*blobs: List[Union[str, BlobProperties, dict]],
**kwargs
self, standard_blob_tier: Union[str, 'StandardBlobTier'],
*blobs: Union[str, Dict[str, Any], BlobProperties],
**kwargs: Any
) -> AsyncIterator[AsyncHttpResponse]:
"""This operation sets the tier on block blobs.

Expand Down Expand Up @@ -1184,7 +1183,7 @@ async def set_standard_blob_tier_blobs(
timeout for subrequest:
key: 'timeout', value type: int

:type blobs: list[str], list[dict], or list[~azure.storage.blob.BlobProperties]
:type blobs: str or dict(str, Any) or ~azure.storage.blob.BlobProperties
:keyword ~azure.storage.blob.RehydratePriority rehydrate_priority:
Indicates the priority with which to rehydrate an archived blob
:keyword str if_tags_match_condition:
Expand All @@ -1206,12 +1205,11 @@ async def set_standard_blob_tier_blobs(

return await self._batch_send(*reqs, **options)

@distributed_trace
@distributed_trace_async
async def set_premium_page_blob_tier_blobs(
self,
premium_page_blob_tier: Union[str, 'PremiumPageBlobTier'],
*blobs: List[Union[str, BlobProperties, dict]],
**kwargs
self, premium_page_blob_tier: Union[str, 'PremiumPageBlobTier'],
*blobs: Union[str, Dict[str, Any], BlobProperties],
**kwargs: Any
) -> AsyncIterator[AsyncHttpResponse]:
"""Sets the page blob tiers on the blobs. This API is only supported for page blobs on premium accounts.

Expand Down Expand Up @@ -1242,7 +1240,7 @@ async def set_premium_page_blob_tier_blobs(
timeout for subrequest:
key: 'timeout', value type: int

:type blobs: list[str], list[dict], or list[~azure.storage.blob.BlobProperties]
:type blobs: str or dict(str, Any) or ~azure.storage.blob.BlobProperties
:keyword int timeout:
The timeout parameter is expressed in seconds. This method may make
multiple calls to the Azure service and the timeout will apply to
Expand Down