Skip to content
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
2 changes: 0 additions & 2 deletions sdk/storage/azure-storage-blob/azure/storage/blob/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
def upload_blob_to_url(
blob_url, # type: str
data, # type: Union[Iterable[AnyStr], IO[AnyStr]]
overwrite=False, # type: bool
max_concurrency=1, # type: int
encoding='UTF-8', # type: str
credential=None, # type: Any
Expand Down Expand Up @@ -124,7 +123,6 @@ def upload_blob_to_url(
return client.upload_blob(
data=data,
blob_type=BlobType.BlockBlob,
overwrite=overwrite,
max_concurrency=max_concurrency,
encoding=encoding,
**kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ def __init__(
blob=None, # type: Optional[Union[str, BlobProperties]]
snapshot=None, # type: Optional[Union[str, Dict[str, Any]]]
credential=None, # type: Optional[Any]
loop=None, # type: Any
**kwargs # type: Any
):
# type: (...) -> None
Expand All @@ -113,10 +112,9 @@ def __init__(
blob=blob,
snapshot=snapshot,
credential=credential,
loop=loop,
**kwargs)
self._client = AzureBlobStorage(url=self.url, pipeline=self._pipeline, loop=loop)
self._loop = loop
self._client = AzureBlobStorage(url=self.url, pipeline=self._pipeline)
self._loop = kwargs.get('loop', None)

@distributed_trace_async
async def get_account_information(self, **kwargs): # type: ignore
Expand All @@ -138,12 +136,8 @@ async def get_account_information(self, **kwargs): # type: ignore
async def upload_blob(
self, data, # type: Union[Iterable[AnyStr], IO[AnyStr]]
blob_type=BlobType.BlockBlob, # type: Union[str, BlobType]
overwrite=False, # type: bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please open an issue to change the :param: directive for the keyword parameter to :keyword: in the docstring.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

length=None, # type: Optional[int]
metadata=None, # type: Optional[Dict[str, str]]
content_settings=None, # type: Optional[ContentSettings]
validate_content=False, # type: Optional[bool]
max_concurrency=1, # type: int
**kwargs
):
# type: (...) -> Any
Expand Down Expand Up @@ -242,12 +236,8 @@ async def upload_blob(
options = self._upload_blob_options(
data,
blob_type=blob_type,
overwrite=overwrite,
length=length,
metadata=metadata,
content_settings=content_settings,
validate_content=validate_content,
max_concurrency=max_concurrency,
**kwargs)
if blob_type == BlobType.BlockBlob:
return await upload_block_blob(**options)
Expand All @@ -256,8 +246,8 @@ async def upload_blob(
return await upload_append_blob(**options)

@distributed_trace_async
async def download_blob(self, offset=None, length=None, validate_content=False, **kwargs):
# type: (Optional[int], Optional[int], bool, Any) -> Iterable[bytes]
async def download_blob(self, offset=None, length=None, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove a bool from #type

# type: (Optional[int], Optional[int], Any) -> Iterable[bytes]
"""Downloads a blob to a stream with automatic chunking.

:param int offset:
Expand Down Expand Up @@ -324,7 +314,6 @@ async def download_blob(self, offset=None, length=None, validate_content=False,
options = self._download_blob_options(
offset=offset,
length=length,
validate_content=validate_content,
**kwargs)
extra_properties = {
'name': self.blob_name,
Expand Down Expand Up @@ -601,7 +590,6 @@ async def set_blob_metadata(self, metadata=None, **kwargs):
async def create_page_blob( # type: ignore
self, size, # type: int
content_settings=None, # type: Optional[ContentSettings]
sequence_number=None, # type: Optional[int]
metadata=None, # type: Optional[Dict[str, str]]
premium_page_blob_tier=None, # type: Optional[Union[str, PremiumPageBlobTier]]
**kwargs
Expand Down Expand Up @@ -664,7 +652,6 @@ async def create_page_blob( # type: ignore
options = self._create_page_blob_options(
size,
content_settings=content_settings,
sequence_number=sequence_number,
metadata=metadata,
premium_page_blob_tier=premium_page_blob_tier,
**kwargs)
Expand Down Expand Up @@ -1079,7 +1066,6 @@ async def stage_block(
self, block_id, # type: str
data, # type: Union[Iterable[AnyStr], IO[AnyStr]]
length=None, # type: Optional[int]
validate_content=False, # type: Optional[bool]
**kwargs
):
# type: (...) -> None
Expand Down Expand Up @@ -1119,7 +1105,6 @@ async def stage_block(
block_id,
data,
length=length,
validate_content=validate_content,
**kwargs)
try:
await self._client.block_blob.stage_block(**options)
Expand Down Expand Up @@ -1212,7 +1197,6 @@ async def commit_block_list( # type: ignore
self, block_list, # type: List[BlobBlock]
content_settings=None, # type: Optional[ContentSettings]
metadata=None, # type: Optional[Dict[str, str]]
validate_content=False, # type: Optional[bool]
**kwargs
):
# type: (...) -> Dict[str, Union[str, datetime]]
Expand Down Expand Up @@ -1275,7 +1259,6 @@ async def commit_block_list( # type: ignore
block_list,
content_settings=content_settings,
metadata=metadata,
validate_content=validate_content,
**kwargs)
try:
return await self._client.block_blob.commit_block_list(**options) # type: ignore
Expand Down Expand Up @@ -1498,7 +1481,6 @@ async def upload_page( # type: ignore
start_range, # type: int
end_range, # type: int
length=None, # type: Optional[int]
validate_content=False, # type: Optional[bool]
**kwargs
):
# type: (...) -> Dict[str, Union[str, datetime]]
Expand Down Expand Up @@ -1576,7 +1558,6 @@ async def upload_page( # type: ignore
start_range=start_range,
end_range=end_range,
length=length,
validate_content=validate_content,
**kwargs)
try:
return await self._client.page_blob.upload_pages(**options) # type: ignore
Expand All @@ -1588,7 +1569,6 @@ async def upload_pages_from_url(self, source_url, # type: str
range_start, # type: int
range_end, # type: int
source_range_start, # type: int
source_content_md5=None, # type: Optional[bytes]
**kwargs
):
# type: (...) -> Dict[str, Any]
Expand Down Expand Up @@ -1680,7 +1660,6 @@ async def upload_pages_from_url(self, source_url, # type: str
range_start=range_start,
range_end=range_end,
source_range_start=source_range_start,
source_content_md5=source_content_md5,
**kwargs
)
try:
Expand Down Expand Up @@ -1756,9 +1735,6 @@ async def clear_page(self, start_range, end_range, **kwargs):
async def append_block( # type: ignore
self, data, # type: Union[AnyStr, Iterable[AnyStr], IO[AnyStr]]
length=None, # type: Optional[int]
validate_content=False, # type: Optional[bool]
maxsize_condition=None, # type: Optional[int]
appendpos_condition=None, # type: Optional[int]
**kwargs
):
# type: (...) -> Dict[str, Union[str, datetime, int]]
Expand Down Expand Up @@ -1827,9 +1803,6 @@ async def append_block( # type: ignore
options = self._append_block_options(
data,
length=length,
validate_content=validate_content,
maxsize_condition=maxsize_condition,
appendpos_condition=appendpos_condition,
**kwargs
)
try:
Expand All @@ -1841,9 +1814,6 @@ async def append_block( # type: ignore
async def append_block_from_url(self, copy_source_url, # type: str
source_range_start=None, # type Optional[int]
source_range_end=None, # type Optional[int]
source_content_md5=None, # type: Optional[bytearray]
maxsize_condition=None, # type: Optional[int]
appendpos_condition=None, # type: Optional[int]
**kwargs):
# type: (...) -> Dict[str, Union[str, datetime, int]]
"""
Expand Down Expand Up @@ -1928,9 +1898,6 @@ async def append_block_from_url(self, copy_source_url, # type: str
copy_source_url,
source_range_start=source_range_start,
source_range_end=source_range_end,
source_content_md5=source_content_md5,
maxsize_condition=maxsize_condition,
appendpos_condition=appendpos_condition,
**kwargs
)
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,20 @@ class BlobServiceClient(AsyncStorageAccountHostsMixin, BlobServiceClientBase):
def __init__(
self, account_url, # type: str
credential=None, # type: Optional[Any]
loop=None, # type: Any
**kwargs # type: Any
):
# type: (...) -> None
kwargs['retry_policy'] = kwargs.get('retry_policy') or ExponentialRetry(**kwargs)
super(BlobServiceClient, self).__init__(
account_url,
credential=credential,
loop=loop,
**kwargs)
self._client = AzureBlobStorage(url=self.url, pipeline=self._pipeline, loop=loop)
self._loop = loop
self._client = AzureBlobStorage(url=self.url, pipeline=self._pipeline)
self._loop = kwargs.get('loop', None)

@distributed_trace_async
async def get_user_delegation_key(self, key_start_time, # type: datetime
key_expiry_time, # type: datetime
timeout=None, # type: Optional[int]
**kwargs # type: Any
):
# type: (datetime, datetime, Optional[int]) -> UserDelegationKey
Expand All @@ -134,6 +131,7 @@ async def get_user_delegation_key(self, key_start_time, # type: datetime
:rtype: ~azure.storage.blob._shared.models.UserDelegationKey
"""
key_info = KeyInfo(start=_to_utc_datetime(key_start_time), expiry=_to_utc_datetime(key_expiry_time))
timeout = kwargs.pop('timeout', None)
try:
user_delegation_key = await self._client.service.get_user_delegation_key(key_info=key_info,
timeout=timeout,
Expand Down Expand Up @@ -169,8 +167,8 @@ async def get_account_information(self, **kwargs): # type: ignore
process_storage_error(error)

@distributed_trace_async
async def get_service_stats(self, timeout=None, **kwargs): # type: ignore
# type: (Optional[int], **Any) -> Dict[str, Any]
async def get_service_stats(self, **kwargs): # type: ignore
# type: (Any) -> Dict[str, Any]
"""Retrieves statistics related to replication for the Blob service.

It is only available when read-access geo-redundant replication is enabled for
Expand Down Expand Up @@ -203,15 +201,16 @@ async def get_service_stats(self, timeout=None, **kwargs): # type: ignore
:dedent: 8
:caption: Getting service stats for the blob service.
"""
timeout = kwargs.pop('timeout', None)
try:
return await self._client.service.get_statistics( # type: ignore
timeout=timeout, use_location=LocationMode.SECONDARY, **kwargs)
except StorageErrorException as error:
process_storage_error(error)

@distributed_trace_async
async def get_service_properties(self, timeout=None, **kwargs):
# type: (Optional[int], Any) -> Dict[str, Any]
async def get_service_properties(self, **kwargs):
# type: (Any) -> Dict[str, Any]
"""Gets the properties of a storage account's Blob service, including
Azure Storage Analytics.

Expand All @@ -228,6 +227,7 @@ async def get_service_properties(self, timeout=None, **kwargs):
:dedent: 8
:caption: Getting service properties for the blob service.
"""
timeout = kwargs.pop('timeout', None)
try:
return await self._client.service.get_properties(timeout=timeout, **kwargs)
except StorageErrorException as error:
Expand All @@ -242,7 +242,6 @@ async def set_service_properties(
target_version=None, # type: Optional[str]
delete_retention_policy=None, # type: Optional[RetentionPolicy]
static_website=None, # type: Optional[StaticWebsite]
timeout=None, # type: Optional[int]
**kwargs
):
# type: (...) -> None
Expand Down Expand Up @@ -306,6 +305,7 @@ async def set_service_properties(
delete_retention_policy=delete_retention_policy,
static_website=static_website
)
timeout = kwargs.pop('timeout', None)
try:
await self._client.service.set_properties(props, timeout=timeout, **kwargs)
except StorageErrorException as error:
Expand All @@ -315,8 +315,6 @@ async def set_service_properties(
def list_containers(
self, name_starts_with=None, # type: Optional[str]
include_metadata=False, # type: Optional[bool]
results_per_page=None, # type: Optional[int]
timeout=None, # type: Optional[int]
**kwargs
):
# type: (...) -> AsyncItemPaged[ContainerProperties]
Expand Down Expand Up @@ -349,6 +347,8 @@ def list_containers(
:caption: Listing the containers in the blob service.
"""
include = 'metadata' if include_metadata else None
timeout = kwargs.pop('timeout', None)
results_per_page = kwargs.pop('results_per_page', None)
command = functools.partial(
self._client.service.list_containers_segment,
prefix=name_starts_with,
Expand All @@ -367,7 +367,6 @@ async def create_container(
self, name, # type: str
metadata=None, # type: Optional[Dict[str, str]]
public_access=None, # type: Optional[Union[PublicAccess, str]]
timeout=None, # type: Optional[int]
**kwargs
):
# type: (...) -> ContainerClient
Expand Down Expand Up @@ -399,6 +398,7 @@ async def create_container(
:caption: Creating a container in the blob service.
"""
container = self.get_container_client(name)
timeout = kwargs.pop('timeout', None)
kwargs.setdefault('merge_span', True)
await container.create_container(
metadata=metadata, public_access=public_access, timeout=timeout, **kwargs)
Expand All @@ -408,7 +408,6 @@ async def create_container(
async def delete_container(
self, container, # type: Union[ContainerProperties, str]
lease=None, # type: Optional[Union[LeaseClient, str]]
timeout=None, # type: Optional[int]
**kwargs
):
# type: (...) -> None
Expand Down Expand Up @@ -461,6 +460,7 @@ async def delete_container(
"""
container = self.get_container_client(container) # type: ignore
kwargs.setdefault('merge_span', True)
timeout = kwargs.pop('timeout', None)
await container.delete_container( # type: ignore
lease=lease,
timeout=timeout,
Expand Down
Loading