Skip to content

Commit

Permalink
Python 2.7 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
lmazuel committed Oct 2, 2019
1 parent 6c2a173 commit 830b87e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -43,6 +43,7 @@
from ..models import ( # pylint: disable=unused-import
AccessPolicy,
ContentSettings,
StandardBlobTier,
PremiumPageBlobTier)


Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions sdk/storage/azure-storage-blob/tests/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions sdk/storage/azure-storage-blob/tests/test_container_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 830b87e

Please sign in to comment.