diff --git a/sdk/storage/azure-storage-blob/HISTORY.md b/sdk/storage/azure-storage-blob/HISTORY.md index 589ad149ff7a..fc7b15ce0895 100644 --- a/sdk/storage/azure-storage-blob/HISTORY.md +++ b/sdk/storage/azure-storage-blob/HISTORY.md @@ -22,6 +22,7 @@ - Removed types that were accidentally exposed from two modules. Only `BlobServiceClient`, `ContainerClient`, `BlobClient` and `LeaseClient` should be imported from azure.storage.blob.aio - `Logging` has been renamed to `BlobAnalyticsLogging`. +- Client and model files have been made internal. Users should import from the top level modules `azure.storage.blob` and `azure.storage.blob.aio` only. - All operations that take Etag conditional parameters (`if_match` and `if_none_match`) now take explicit `etag` and `match_condition` parameters, where `etag` is the Etag value, and `match_condition` is an instance of `azure.core.MatchConditions`. - The `generate_shared_access_signature` methods on each of `BlobServiceClient`, `ContainerClient` and `BlobClient` have been replaced by module level functions `generate_account_sas`, `generate_container_sas` and `generate_blob_sas`. - The batch APIs now have an additional keyword only argument `raise_on_any_failure` which defaults to True. This will raise an error even if there's a partial batch failure. diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/__init__.py b/sdk/storage/azure-storage-blob/azure/storage/blob/__init__.py index a26a856358cd..e1cd2c43f717 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/__init__.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/__init__.py @@ -6,13 +6,13 @@ import os -from typing import Union, Iterable, AnyStr, IO, Any # pylint: disable=unused-import -from .version import VERSION -from .blob_client import BlobClient -from .container_client import ContainerClient -from .blob_service_client import BlobServiceClient -from .lease import LeaseClient -from .download import StorageStreamDownloader +from typing import Union, Iterable, AnyStr, IO, Any, Dict # pylint: disable=unused-import +from ._version import VERSION +from ._blob_client import BlobClient +from ._container_client import ContainerClient +from ._blob_service_client import BlobServiceClient +from ._lease import LeaseClient +from ._download import StorageStreamDownloader from ._shared_access_signature import generate_account_sas, generate_container_sas, generate_blob_sas from ._shared.policies import ExponentialRetry, LinearRetry from ._shared.response_handlers import PartialBatchErrorException @@ -26,7 +26,7 @@ from ._generated.models import ( RehydratePriority ) -from .models import ( +from ._models import ( BlobType, BlockState, StandardBlobTier, @@ -59,7 +59,7 @@ def upload_blob_to_url( data, # type: Union[Iterable[AnyStr], IO[AnyStr]] credential=None, # type: Any **kwargs): - # type: (...) -> dict[str, Any] + # type: (...) -> Dict[str, Any] """Upload data to a given URL The data will be uploaded as a block blob. diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/blob_client.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_blob_client.py similarity index 99% rename from sdk/storage/azure-storage-blob/azure/storage/blob/blob_client.py rename to sdk/storage/azure-storage-blob/azure/storage/blob/_blob_client.py index c4e94c40e8a7..492212c3f55f 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/blob_client.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_blob_client.py @@ -43,14 +43,14 @@ upload_block_blob, upload_append_blob, upload_page_blob) -from .models import BlobType, BlobBlock -from .download import StorageStreamDownloader -from .lease import LeaseClient, get_access_conditions +from ._models import BlobType, BlobBlock +from ._download import StorageStreamDownloader +from ._lease import LeaseClient, get_access_conditions if TYPE_CHECKING: from datetime import datetime from ._generated.models import BlockList - from .models import ( # pylint: disable=unused-import + from ._models import ( # pylint: disable=unused-import ContainerProperties, BlobProperties, BlobSasPermissions, @@ -470,7 +470,7 @@ def upload_blob( # pylint: disable=too-many-locals return upload_append_blob(**options) def _download_blob_options(self, offset=None, length=None, **kwargs): - # type: (Optional[int], Optional[int], bool, **Any) -> Dict[str, Any] + # type: (Optional[int], Optional[int], **Any) -> Dict[str, Any] if self.require_encryption and not self.key_encryption_key: raise ValueError("Encryption required but no key was provided.") if length is not None and offset is None: @@ -514,7 +514,7 @@ def _download_blob_options(self, offset=None, length=None, **kwargs): @distributed_trace def download_blob(self, offset=None, length=None, **kwargs): - # type: (Optional[int], Optional[int], bool, **Any) -> Iterable[bytes] + # type: (Optional[int], Optional[int], **Any) -> Iterable[bytes] """Downloads a blob to a stream with automatic chunking. :param int offset: @@ -1692,7 +1692,7 @@ def stage_block_from_url( process_storage_error(error) def _get_block_list_result(self, blocks): - # type: (BlockList) -> Tuple(List[BlobBlock], List[BlobBlock]) + # type: (BlockList) -> Tuple[List[BlobBlock], List[BlobBlock]] committed = [] # type: List uncommitted = [] # type: List if blocks.committed_blocks: @@ -1863,7 +1863,7 @@ def commit_block_list( # type: ignore @distributed_trace def set_premium_page_blob_tier(self, premium_page_blob_tier, **kwargs): - # type: (Union[str, PremiumPageBlobTier], Optional[int], Optional[Union[LeaseClient, str]], **Any) -> None + # type: (Union[str, PremiumPageBlobTier], **Any) -> None """Sets the page blob tiers on the blob. This API is only supported for page blobs on premium accounts. :param premium_page_blob_tier: @@ -1902,6 +1902,8 @@ def _get_page_ranges_options( # type: ignore # type: (...) -> Dict[str, Any] access_conditions = get_access_conditions(kwargs.pop('lease', None)) mod_conditions = get_modify_conditions(kwargs) + if length is not None and offset is None: + raise ValueError("Offset value must not be None if length is set.") if length is not None: length = offset + length - 1 # Reformat to an inclusive range index page_range, _ = validate_and_format_range_headers( @@ -1931,7 +1933,7 @@ def get_page_ranges( # type: ignore previous_snapshot_diff=None, # type: Optional[Union[str, Dict[str, Any]]] **kwargs ): - # type: (...) -> Tuple(List[Dict[str, int]], List[Dict[str, int]]) + # type: (...) -> Tuple[List[Dict[str, int]], List[Dict[str, int]]] """Returns the list of valid page ranges for a Page Blob or snapshot of a page blob. @@ -2638,8 +2640,8 @@ def append_block( # type: ignore def _append_block_from_url_options( # type: ignore self, copy_source_url, # type: str - source_offset=None, # type Optional[int] - source_length=None, # type Optional[int] + source_offset=None, # type: Optional[int] + source_length=None, # type: Optional[int] **kwargs ): # type: (...) -> Dict[str, Any] @@ -2696,8 +2698,8 @@ def _append_block_from_url_options( # type: ignore @distributed_trace def append_block_from_url(self, copy_source_url, # type: str - source_offset=None, # type Optional[int] - source_length=None, # type Optional[int] + source_offset=None, # type: Optional[int] + source_length=None, # type: Optional[int] **kwargs): # type: (...) -> Dict[str, Union[str, datetime, int]] """ diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/blob_service_client.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_blob_service_client.py similarity index 98% rename from sdk/storage/azure-storage-blob/azure/storage/blob/blob_service_client.py rename to sdk/storage/azure-storage-blob/azure/storage/blob/_blob_service_client.py index d4116459aa7d..120d699d7fcf 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/blob_service_client.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_blob_service_client.py @@ -26,17 +26,17 @@ parse_to_internal_user_delegation_key from ._generated import AzureBlobStorage from ._generated.models import StorageErrorException, StorageServiceProperties, KeyInfo -from .container_client import ContainerClient -from .blob_client import BlobClient -from .models import ContainerPropertiesPaged +from ._container_client import ContainerClient +from ._blob_client import BlobClient +from ._models import ContainerPropertiesPaged if TYPE_CHECKING: from datetime import datetime from azure.core.pipeline.transport import HttpTransport from azure.core.pipeline.policies import HTTPPolicy from ._shared.models import UserDelegationKey - from .lease import LeaseClient - from .models import ( + from ._lease import LeaseClient + from ._models import ( BlobProperties, ContainerProperties, BlobAnalyticsLogging, @@ -163,7 +163,7 @@ def get_user_delegation_key(self, key_start_time, # type: datetime key_expiry_time, # type: datetime **kwargs # type: Any ): - # type: (datetime, datetime, Optional[int]) -> UserDelegationKey + # type: (...) -> UserDelegationKey """ Obtain a user delegation key for the purpose of signing SAS tokens. A token credential must be present on the service object for this request to succeed. @@ -189,8 +189,8 @@ def get_user_delegation_key(self, key_start_time, # type: datetime return parse_to_internal_user_delegation_key(user_delegation_key) # type: ignore @distributed_trace - def get_account_information(self, **kwargs): # type: ignore - # type: (Optional[int]) -> Dict[str, str] + def get_account_information(self, **kwargs): + # type: (Any) -> Dict[str, str] """Gets information related to the storage account. The information can also be retrieved if the user has a SAS to a container or blob. @@ -214,7 +214,7 @@ def get_account_information(self, **kwargs): # type: ignore process_storage_error(error) @distributed_trace - def get_service_stats(self, **kwargs): # type: ignore + def get_service_stats(self, **kwargs): # type: (**Any) -> Dict[str, Any] """Retrieves statistics related to replication for the Blob service. 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 similarity index 99% rename from sdk/storage/azure-storage-blob/azure/storage/blob/container_client.py rename to sdk/storage/azure-storage-blob/azure/storage/blob/_container_client.py index 8be14c88a6ee..afd99e081a93 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 @@ -36,23 +36,24 @@ SignedIdentifier) from ._deserialize import deserialize_container_properties from ._serialize import get_modify_conditions -from .models import ( # pylint: disable=unused-import +from ._models import ( # pylint: disable=unused-import ContainerProperties, BlobProperties, BlobPropertiesPaged, BlobType, BlobPrefix) -from .lease import LeaseClient, get_access_conditions -from .blob_client import BlobClient +from ._lease import LeaseClient, get_access_conditions +from ._blob_client import BlobClient if TYPE_CHECKING: from azure.core.pipeline.transport import HttpTransport, HttpResponse # pylint: disable=ungrouped-imports from azure.core.pipeline.policies import HTTPPolicy # pylint: disable=ungrouped-imports from datetime import datetime - from .models import ( # pylint: disable=unused-import + from ._models import ( # pylint: disable=unused-import PublicAccess, AccessPolicy, ContentSettings, + StandardBlobTier, PremiumPageBlobTier) @@ -363,7 +364,7 @@ def acquire_lease( return lease @distributed_trace - def get_account_information(self, **kwargs): # type: ignore + def get_account_information(self, **kwargs): # type: (**Any) -> Dict[str, str] """Gets information related to the storage account. diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_deserialize.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_deserialize.py index cd41c59baf88..4f3e468da42d 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_deserialize.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_deserialize.py @@ -5,8 +5,16 @@ # -------------------------------------------------------------------------- # pylint: disable=no-self-use +from typing import ( # pylint: disable=unused-import + Tuple, Dict, List, + TYPE_CHECKING +) + from ._shared.response_handlers import deserialize_metadata -from .models import BlobProperties, ContainerProperties +from ._models import BlobProperties, ContainerProperties + +if TYPE_CHECKING: + from azure.storage.blob._generated.models import PageList def deserialize_blob_properties(response, obj, headers): @@ -39,7 +47,7 @@ def deserialize_container_properties(response, obj, headers): def get_page_ranges_result(ranges): - # type: (PageList) -> Tuple(List[Dict[str, int]], List[Dict[str, int]]) + # type: (PageList) -> Tuple[List[Dict[str, int]], List[Dict[str, int]]] page_range = [] # type: ignore clear_range = [] # type: List if ranges.page_range: diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/download.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_download.py similarity index 100% rename from sdk/storage/azure-storage-blob/azure/storage/blob/download.py rename to sdk/storage/azure-storage-blob/azure/storage/blob/_download.py diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/lease.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_lease.py similarity index 99% rename from sdk/storage/azure-storage-blob/azure/storage/blob/lease.py rename to sdk/storage/azure-storage-blob/azure/storage/blob/_lease.py index 200adab9d432..0a60f2f69d2f 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/lease.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_lease.py @@ -78,7 +78,7 @@ def __exit__(self, *args): @distributed_trace def acquire(self, lease_duration=-1, **kwargs): - # type: (int, Optional[int], **Any) -> None + # type: (int, **Any) -> None """Requests a new lease. If the container does not have an active lease, the Blob service creates a diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/models.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_models.py similarity index 100% rename from sdk/storage/azure-storage-blob/azure/storage/blob/models.py rename to sdk/storage/azure-storage-blob/azure/storage/blob/_models.py diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/encryption.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/encryption.py index 25c160463fad..62607cc0cf85 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/encryption.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/encryption.py @@ -20,7 +20,7 @@ from azure.core.exceptions import HttpResponseError -from ..version import VERSION +from .._version import VERSION from . import encode_base64, decode_base64_to_bytes diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/models.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/models.py index 2c491acdf8e3..5d3af184c967 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/models.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/models.py @@ -331,11 +331,11 @@ class Services(object): """Specifies the services accessible with the account SAS. :param bool blob: - Access for the `~azure.storage.blob.blob_service_client.BlobServiceClient` + Access for the `~azure.storage.blob.BlobServiceClient` :param bool queue: - Access for the `~azure.storage.queue.queue_service_client.QueueServiceClient` + Access for the `~azure.storage.queue.QueueServiceClient` :param bool file: - Access for the `~azure.storage.file.file_service_client.FileServiceClient` + Access for the `~azure.storage.file.FileServiceClient` """ def __init__(self, blob=False, queue=False, file=False): diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/policies.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/policies.py index 75385f38b4bf..9dd8ffb23ad6 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/policies.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/policies.py @@ -40,7 +40,7 @@ ) from azure.core.exceptions import AzureError, ServiceRequestError, ServiceResponseError -from ..version import VERSION +from .._version import VERSION from .models import LocationMode try: diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_upload_helpers.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_upload_helpers.py index 3875c8d0755d..e86f00ff7e35 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_upload_helpers.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_upload_helpers.py @@ -28,7 +28,7 @@ AppendPositionAccessConditions, ModifiedAccessConditions, ) -from .models import BlobProperties, ContainerProperties +from ._models import BlobProperties, ContainerProperties if TYPE_CHECKING: from datetime import datetime # pylint: disable=unused-import diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/version.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_version.py similarity index 100% rename from sdk/storage/azure-storage-blob/azure/storage/blob/version.py rename to sdk/storage/azure-storage-blob/azure/storage/blob/_version.py diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/aio/__init__.py b/sdk/storage/azure-storage-blob/azure/storage/blob/aio/__init__.py index 9ceac2ed30aa..42707365104b 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/aio/__init__.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/aio/__init__.py @@ -6,12 +6,12 @@ import os -from ..models import BlobType +from .._models import BlobType from .._shared.policies_async import ExponentialRetry, LinearRetry -from .blob_client_async import BlobClient -from .container_client_async import ContainerClient -from .blob_service_client_async import BlobServiceClient -from .lease_async import LeaseClient +from ._blob_client_async import BlobClient +from ._container_client_async import ContainerClient +from ._blob_service_client_async import BlobServiceClient +from ._lease_async import LeaseClient async def upload_blob_to_url( diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/aio/blob_client_async.py b/sdk/storage/azure-storage-blob/azure/storage/blob/aio/_blob_client_async.py similarity index 99% rename from sdk/storage/azure-storage-blob/azure/storage/blob/aio/blob_client_async.py rename to sdk/storage/azure-storage-blob/azure/storage/blob/aio/_blob_client_async.py index 9e793fe05738..2dc140974303 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/aio/blob_client_async.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/aio/_blob_client_async.py @@ -20,20 +20,20 @@ from .._generated.aio import AzureBlobStorage from .._generated.models import StorageErrorException, CpkInfo from .._deserialize import deserialize_blob_properties -from ..blob_client import BlobClient as BlobClientBase +from .._blob_client import BlobClient as BlobClientBase from ._upload_helpers import ( upload_block_blob, upload_append_blob, upload_page_blob) -from ..models import BlobType, BlobBlock -from ..lease import get_access_conditions -from .lease_async import LeaseClient -from .download_async import StorageStreamDownloader +from .._models import BlobType, BlobBlock +from .._lease import get_access_conditions +from ._lease_async import LeaseClient +from ._download_async import StorageStreamDownloader if TYPE_CHECKING: from datetime import datetime from azure.core.pipeline.policies import HTTPPolicy - from ..models import ( # pylint: disable=unused-import + from .._models import ( # pylint: disable=unused-import ContainerProperties, BlobProperties, BlobSasPermissions, @@ -914,7 +914,7 @@ async def abort_copy(self, copy_id, **kwargs): @distributed_trace_async async def acquire_lease(self, lease_duration=-1, lease_id=None, **kwargs): - # type: (int, Optional[str], Optional[int], Any) -> LeaseClient + # type: (int, Optional[str], Any) -> LeaseClient """Requests a new lease. If the blob does not have an active lease, the Blob @@ -1204,7 +1204,7 @@ async def commit_block_list( # type: ignore @distributed_trace_async async def set_premium_page_blob_tier(self, premium_page_blob_tier, **kwargs): - # type: (Union[str, PremiumPageBlobTier], Optional[int], Optional[Union[LeaseClient, str]], **Any) -> None + # type: (Union[str, PremiumPageBlobTier], **Any) -> None """Sets the page blob tiers on the blob. This API is only supported for page blobs on premium accounts. :param premium_page_blob_tier: @@ -1241,7 +1241,7 @@ async def get_page_ranges( # type: ignore previous_snapshot_diff=None, # type: Optional[Union[str, Dict[str, Any]]] **kwargs ): - # type: (...) -> List[dict[str, int]] + # type: (...) -> Tuple[List[Dict[str, int]], List[Dict[str, int]]] """Returns the list of valid page ranges for a Page Blob or snapshot of a page blob. @@ -1575,7 +1575,7 @@ async def upload_pages_from_url(self, source_url, # type: str @distributed_trace_async async def clear_page(self, offset, length, **kwargs): - # type: (int, int) -> Dict[str, Union[str, datetime]] + # type: (int, int, Any) -> Dict[str, Union[str, datetime]] """Clears a range of pages. :param int offset: @@ -1710,8 +1710,8 @@ async def append_block( # type: ignore @distributed_trace_async() async def append_block_from_url(self, copy_source_url, # type: str - source_offset=None, # type Optional[int] - source_length=None, # type Optional[int] + source_offset=None, # type: Optional[int] + source_length=None, # type: Optional[int] **kwargs): # type: (...) -> Dict[str, Union[str, datetime, int]] """ diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/aio/blob_service_client_async.py b/sdk/storage/azure-storage-blob/azure/storage/blob/aio/_blob_service_client_async.py similarity index 97% rename from sdk/storage/azure-storage-blob/azure/storage/blob/aio/blob_service_client_async.py rename to sdk/storage/azure-storage-blob/azure/storage/blob/aio/_blob_service_client_async.py index 647eae35c136..84e66bb478c3 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/aio/blob_service_client_async.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/aio/_blob_service_client_async.py @@ -23,26 +23,26 @@ from .._shared.response_handlers import parse_to_internal_user_delegation_key from .._generated.aio import AzureBlobStorage from .._generated.models import StorageErrorException, StorageServiceProperties, KeyInfo -from ..blob_service_client import BlobServiceClient as BlobServiceClientBase -from .container_client_async import ContainerClient -from .blob_client_async import BlobClient -from ..models import ContainerProperties -from .models import ContainerPropertiesPaged +from .._blob_service_client import BlobServiceClient as BlobServiceClientBase +from ._container_client_async import ContainerClient +from ._blob_client_async import BlobClient +from .._models import ContainerProperties +from ._models import ContainerPropertiesPaged if TYPE_CHECKING: from datetime import datetime from azure.core.pipeline.transport import HttpTransport from azure.core.pipeline.policies import HTTPPolicy - from .._shared.models import AccountSasPermissions, ResourceTypes - from .lease_async import LeaseClient - from ..models import ( + from .._shared.models import AccountSasPermissions, ResourceTypes, UserDelegationKey + from ._lease_async import LeaseClient + from .._models import ( BlobProperties, BlobAnalyticsLogging, Metrics, RetentionPolicy, StaticWebsite, CorsRule, - PublicAccess + PublicAccess, ) @@ -118,7 +118,7 @@ async def get_user_delegation_key(self, key_start_time, # type: datetime key_expiry_time, # type: datetime **kwargs # type: Any ): - # type: (datetime, datetime, Optional[int]) -> UserDelegationKey + # type: (...) -> UserDelegationKey """ Obtain a user delegation key for the purpose of signing SAS tokens. A token credential must be present on the service object for this request to succeed. @@ -144,8 +144,8 @@ async def get_user_delegation_key(self, key_start_time, # type: datetime return parse_to_internal_user_delegation_key(user_delegation_key) # type: ignore @distributed_trace_async - async def get_account_information(self, **kwargs): # type: ignore - # type: (Optional[int]) -> Dict[str, str] + async def get_account_information(self, **kwargs): + # type: (Any) -> Dict[str, str] """Gets information related to the storage account. The information can also be retrieved if the user has a SAS to a container or blob. @@ -169,7 +169,7 @@ async def get_account_information(self, **kwargs): # type: ignore process_storage_error(error) @distributed_trace_async - async def get_service_stats(self, **kwargs): # type: ignore + async def get_service_stats(self, **kwargs): # type: (Any) -> Dict[str, Any] """Retrieves statistics related to replication for the Blob service. @@ -469,7 +469,7 @@ def get_container_client(self, container): The container that the blob is in. :type container: str or ~azure.storage.blob.ContainerProperties :returns: A ContainerClient. - :rtype: ~azure.core.blob.aio.ContainerClient + :rtype: ~azure.storage.blob.aio.ContainerClient .. admonition:: Example: 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 similarity index 98% rename from sdk/storage/azure-storage-blob/azure/storage/blob/aio/container_client_async.py rename to sdk/storage/azure-storage-blob/azure/storage/blob/aio/_container_client_async.py index 91e2452a1488..cb3baa058737 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 @@ -30,19 +30,19 @@ SignedIdentifier) from .._deserialize import deserialize_container_properties from .._serialize import get_modify_conditions -from ..container_client import ContainerClient as ContainerClientBase -from ..lease import get_access_conditions -from ..models import ContainerProperties, BlobProperties, BlobType # pylint: disable=unused-import -from .models import BlobPropertiesPaged, BlobPrefix -from .lease_async import LeaseClient -from .blob_client_async import BlobClient +from .._container_client import ContainerClient as ContainerClientBase +from .._lease import get_access_conditions +from .._models import ContainerProperties, BlobProperties, BlobType # pylint: disable=unused-import +from ._models import BlobPropertiesPaged, BlobPrefix +from ._lease_async import LeaseClient +from ._blob_client_async import BlobClient if TYPE_CHECKING: from azure.core.pipeline.transport import HttpTransport from azure.core.pipeline.policies import HTTPPolicy - from ..models import ContainerSasPermissions, PublicAccess + from .._models import ContainerSasPermissions, PublicAccess from datetime import datetime - from ..models import ( # pylint: disable=unused-import + from .._models import ( # pylint: disable=unused-import AccessPolicy, ContentSettings, StandardBlobTier, @@ -104,7 +104,7 @@ class ContainerClient(AsyncStorageAccountHostsMixin, ContainerClientBase): """ def __init__( self, account_url, # type: str - container_name=None, # type: str + container_name, # type: str credential=None, # type: Optional[Any] **kwargs # type: Any ): @@ -269,7 +269,7 @@ async def acquire_lease( return lease @distributed_trace_async - async def get_account_information(self, **kwargs): # type: ignore + async def get_account_information(self, **kwargs): # type: (**Any) -> Dict[str, str] """Gets information related to the storage account. diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/aio/download_async.py b/sdk/storage/azure-storage-blob/azure/storage/blob/aio/_download_async.py similarity index 99% rename from sdk/storage/azure-storage-blob/azure/storage/blob/aio/download_async.py rename to sdk/storage/azure-storage-blob/azure/storage/blob/aio/_download_async.py index 1a37cc217895..ea83862e4ae5 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/aio/download_async.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/aio/_download_async.py @@ -15,7 +15,7 @@ from .._shared.request_handlers import validate_and_format_range_headers from .._shared.response_handlers import process_storage_error, parse_length_from_content_range from .._deserialize import get_page_ranges_result -from ..download import process_range_and_offset, _ChunkDownloader +from .._download import process_range_and_offset, _ChunkDownloader async def process_content(data, start_offset, end_offset, encryption): diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/aio/lease_async.py b/sdk/storage/azure-storage-blob/azure/storage/blob/aio/_lease_async.py similarity index 99% rename from sdk/storage/azure-storage-blob/azure/storage/blob/aio/lease_async.py rename to sdk/storage/azure-storage-blob/azure/storage/blob/aio/_lease_async.py index 21a27093f9ad..a38ef95842ad 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/aio/lease_async.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/aio/_lease_async.py @@ -16,7 +16,7 @@ StorageErrorException, LeaseAccessConditions) from .._serialize import get_modify_conditions -from ..lease import LeaseClient as LeaseClientBase +from .._lease import LeaseClient as LeaseClientBase if TYPE_CHECKING: from datetime import datetime diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/aio/models.py b/sdk/storage/azure-storage-blob/azure/storage/blob/aio/_models.py similarity index 99% rename from sdk/storage/azure-storage-blob/azure/storage/blob/aio/models.py rename to sdk/storage/azure-storage-blob/azure/storage/blob/aio/_models.py index 0a7cf719cd91..312802255d70 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/aio/models.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/aio/_models.py @@ -10,7 +10,7 @@ from azure.core.async_paging import AsyncPageIterator, AsyncItemPaged -from ..models import BlobProperties, ContainerProperties +from .._models import BlobProperties, ContainerProperties from .._shared.response_handlers import return_context_and_deserialized, process_storage_error from .._shared.models import DictMixin diff --git a/sdk/storage/azure-storage-blob/setup.py b/sdk/storage/azure-storage-blob/setup.py index 63becf5ff97b..1f2840e2a373 100644 --- a/sdk/storage/azure-storage-blob/setup.py +++ b/sdk/storage/azure-storage-blob/setup.py @@ -53,7 +53,7 @@ pass # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py'), 'r') as fd: +with open(os.path.join(package_folder_path, '_version.py'), 'r') as fd: version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) diff --git a/sdk/storage/azure-storage-blob/tests/test_blob_encryption.py b/sdk/storage/azure-storage-blob/tests/test_blob_encryption.py index c315c0173b0d..603e5e108634 100644 --- a/sdk/storage/azure-storage-blob/tests/test_blob_encryption.py +++ b/sdk/storage/azure-storage-blob/tests/test_blob_encryption.py @@ -25,7 +25,7 @@ _generate_AES_CBC_cipher, _ERROR_OBJECT_INVALID, ) -from azure.storage.blob.blob_client import _ERROR_UNSUPPORTED_METHOD_FOR_ENCRYPTION +from azure.storage.blob._blob_client import _ERROR_UNSUPPORTED_METHOD_FOR_ENCRYPTION from cryptography.hazmat.primitives.padding import PKCS7 from azure.storage.blob import ( diff --git a/sdk/storage/azure-storage-blob/tests/test_blob_encryption_async.py b/sdk/storage/azure-storage-blob/tests/test_blob_encryption_async.py index f1e5a2d34726..e263fc934b69 100644 --- a/sdk/storage/azure-storage-blob/tests/test_blob_encryption_async.py +++ b/sdk/storage/azure-storage-blob/tests/test_blob_encryption_async.py @@ -29,7 +29,7 @@ _generate_AES_CBC_cipher, _ERROR_OBJECT_INVALID, ) -from azure.storage.blob.blob_client import _ERROR_UNSUPPORTED_METHOD_FOR_ENCRYPTION +from azure.storage.blob._blob_client import _ERROR_UNSUPPORTED_METHOD_FOR_ENCRYPTION from cryptography.hazmat.primitives.padding import PKCS7 from azure.storage.blob import BlobType diff --git a/sdk/storage/azure-storage-blob/tests/test_blob_storage_account_async.py b/sdk/storage/azure-storage-blob/tests/test_blob_storage_account_async.py index 486709f00f25..173ef7660da7 100644 --- a/sdk/storage/azure-storage-blob/tests/test_blob_storage_account_async.py +++ b/sdk/storage/azure-storage-blob/tests/test_blob_storage_account_async.py @@ -19,7 +19,7 @@ BlobClient, ) -from azure.storage.blob.models import ( +from azure.storage.blob import ( StandardBlobTier ) diff --git a/sdk/storage/azure-storage-blob/tests/test_cpk.py b/sdk/storage/azure-storage-blob/tests/test_cpk.py index 8ce8e01b4ab3..e2c4aeb5d38c 100644 --- a/sdk/storage/azure-storage-blob/tests/test_cpk.py +++ b/sdk/storage/azure-storage-blob/tests/test_cpk.py @@ -13,9 +13,11 @@ BlobServiceClient, BlobType, BlobBlock, + CustomerProvidedEncryptionKey, + BlobSasPermissions, generate_blob_sas ) -from azure.storage.blob.models import CustomerProvidedEncryptionKey, BlobSasPermissions + from testcase import ( StorageTestCase, TestMode, diff --git a/sdk/storage/azure-storage-blob/tests/test_cpk_async.py b/sdk/storage/azure-storage-blob/tests/test_cpk_async.py index db4b7ea27864..450d41de6fcb 100644 --- a/sdk/storage/azure-storage-blob/tests/test_cpk_async.py +++ b/sdk/storage/azure-storage-blob/tests/test_cpk_async.py @@ -12,9 +12,16 @@ from azure.core.exceptions import HttpResponseError from azure.core.pipeline.transport import AioHttpTransport from multidict import CIMultiDict, CIMultiDictProxy -from azure.storage.blob import BlobType, BlobBlock, generate_blob_sas +from azure.storage.blob import ( + BlobType, + BlobBlock, + CustomerProvidedEncryptionKey, + BlobSasPermissions, + generate_blob_sas +) + from azure.storage.blob.aio import BlobServiceClient -from azure.storage.blob.models import CustomerProvidedEncryptionKey, BlobSasPermissions + from testcase import ( StorageTestCase, TestMode, diff --git a/sdk/storage/azure-storage-file/HISTORY.md b/sdk/storage/azure-storage-file/HISTORY.md index 2db50ac13e99..d29d2d22e440 100644 --- a/sdk/storage/azure-storage-file/HISTORY.md +++ b/sdk/storage/azure-storage-file/HISTORY.md @@ -19,6 +19,7 @@ To use a directory_url, the method `from_directory_url` must be used. - `max_concurrency` - `validate_content` - `timeout` etc. +- Client and model files have been made internal. Users should import from the top level modules `azure.storage.file` and `azure.storage.file.aio` only. - The `generate_shared_access_signature` methods on each of `FileServiceClient`, `ShareClient` and `FileClient` have been replaced by module level functions `generate_account_sas`, `generate_share_sas` and `generate_file_sas`. - `start_range` and `end_range` params are now renamed to and behave like`offset` and `length` in the following APIs: diff --git a/sdk/storage/azure-storage-file/azure/storage/file/__init__.py b/sdk/storage/azure-storage-file/azure/storage/file/__init__.py index 9099ce806096..5dcc7e6555ef 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/__init__.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/__init__.py @@ -4,11 +4,11 @@ # license information. # -------------------------------------------------------------------------- -from .version import VERSION -from .file_client import FileClient -from .directory_client import DirectoryClient -from .share_client import ShareClient -from .file_service_client import FileServiceClient +from ._version import VERSION +from ._file_client import FileClient +from ._directory_client import DirectoryClient +from ._share_client import ShareClient +from ._file_service_client import FileServiceClient from ._shared_access_signature import generate_account_sas, generate_share_sas, generate_file_sas from ._shared.policies import ExponentialRetry, LinearRetry from ._shared.models import ( @@ -16,7 +16,7 @@ ResourceTypes, AccountSasPermissions, StorageErrorCode) -from .models import ( +from ._models import ( ShareProperties, DirectoryProperties, Handle, diff --git a/sdk/storage/azure-storage-file/azure/storage/file/_deserialize.py b/sdk/storage/azure-storage-file/azure/storage/file/_deserialize.py index e566c394298e..5475e6d14e0d 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/_deserialize.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/_deserialize.py @@ -4,7 +4,7 @@ # license information. # -------------------------------------------------------------------------- -from .models import ShareProperties, DirectoryProperties, FileProperties +from ._models import ShareProperties, DirectoryProperties, FileProperties from ._shared.response_handlers import deserialize_metadata diff --git a/sdk/storage/azure-storage-file/azure/storage/file/directory_client.py b/sdk/storage/azure-storage-file/azure/storage/file/_directory_client.py similarity index 97% rename from sdk/storage/azure-storage-file/azure/storage/file/directory_client.py rename to sdk/storage/azure-storage-file/azure/storage/file/_directory_client.py index 9f279c3ed6ad..07b648d4c6fd 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/directory_client.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/_directory_client.py @@ -30,11 +30,12 @@ from ._shared.parser import _str from ._parser import _get_file_permission, _datetime_to_str from ._deserialize import deserialize_directory_properties -from .file_client import FileClient -from .models import DirectoryPropertiesPaged, HandlesPaged, NTFSAttributes # pylint: disable=unused-import +from ._file_client import FileClient +from ._models import DirectoryPropertiesPaged, HandlesPaged, NTFSAttributes # pylint: disable=unused-import if TYPE_CHECKING: - from .models import ShareProperties, DirectoryProperties, ContentSettings + from datetime import datetime + from ._models import ShareProperties, DirectoryProperties, ContentSettings from ._generated.models import HandleItem @@ -178,10 +179,10 @@ def _format_url(self, hostname): @classmethod def from_connection_string( cls, conn_str, # type: str - share_name=None, # type: str - directory_path=None, # type: Optional[str] - credential=None, # type: Optional[Any] - **kwargs # type: Any + share_name, # type: str + directory_path, # type: str + credential=None, # type: Optional[Any] + **kwargs # type: Any ): # type: (...) -> DirectoryClient """Create DirectoryClient from a Connection String. @@ -259,7 +260,7 @@ def get_subdirectory_client(self, directory_name, **kwargs): _location_mode=self._location_mode, **kwargs) @distributed_trace - def create_directory(self, **kwargs): # type: ignore + def create_directory(self, **kwargs): # type: (Any) -> Dict[str, Any] """Creates a new directory under the directory referenced by the client. @@ -295,7 +296,7 @@ def create_directory(self, **kwargs): # type: ignore @distributed_trace def delete_directory(self, **kwargs): - # type: (Optional[int], **Any) -> None + # type: (**Any) -> None """Marks the directory for deletion. The directory is later deleted during garbage collection. @@ -473,7 +474,7 @@ def get_directory_properties(self, **kwargs): return response # type: ignore @distributed_trace - def set_directory_metadata(self, metadata, **kwargs): # type: ignore + def set_directory_metadata(self, metadata, **kwargs): # type: (Dict[str, Any], Any) -> Dict[str, Any] """Sets the metadata for the directory. @@ -507,7 +508,8 @@ def set_http_headers(self, file_attributes="none", # type: Union[str, NTFSAttri file_last_write_time="preserve", # type: Union[str, datetime] file_permission=None, # type: Optional[str] permission_key=None, # type: Optional[str] - **kwargs): # type: ignore + **kwargs # type: Any + ): # type: (...) -> Dict[str, Any] """Sets HTTP headers on the directory. diff --git a/sdk/storage/azure-storage-file/azure/storage/file/download.py b/sdk/storage/azure-storage-file/azure/storage/file/_download.py similarity index 100% rename from sdk/storage/azure-storage-file/azure/storage/file/download.py rename to sdk/storage/azure-storage-file/azure/storage/file/_download.py diff --git a/sdk/storage/azure-storage-file/azure/storage/file/file_client.py b/sdk/storage/azure-storage-file/azure/storage/file/_file_client.py similarity index 97% rename from sdk/storage/azure-storage-file/azure/storage/file/file_client.py rename to sdk/storage/azure-storage-file/azure/storage/file/_file_client.py index 010dc65e7770..c8b77a42c31e 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/file_client.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/_file_client.py @@ -32,12 +32,12 @@ from ._shared.parser import _str from ._parser import _get_file_permission, _datetime_to_str from ._deserialize import deserialize_file_properties, deserialize_file_stream -from .models import HandlesPaged, NTFSAttributes # pylint: disable=unused-import -from .download import StorageStreamDownloader +from ._models import HandlesPaged, NTFSAttributes # pylint: disable=unused-import +from ._download import StorageStreamDownloader if TYPE_CHECKING: from datetime import datetime - from .models import ShareProperties, ContentSettings, FileProperties + from ._models import ShareProperties, ContentSettings, FileProperties, Handle from ._generated.models import HandleItem @@ -226,11 +226,11 @@ def _format_url(self, hostname): @classmethod def from_connection_string( cls, conn_str, # type: str - share_name=None, # type: str - file_path=None, # type: Optional[str] + share_name, # type: str + file_path, # type: str snapshot=None, # type: Optional[Union[str, Dict[str, Any]]] credential=None, # type: Optional[Any] - **kwargs # type: Any + **kwargs # type: Any ): # type: (...) -> FileClient """Create FileClient from a Connection String. @@ -518,7 +518,7 @@ def start_copy_from_url( process_storage_error(error) def abort_copy(self, copy_id, **kwargs): - # type: (Union[str, FileProperties], Any) -> Dict[str, Any] + # type: (Union[str, FileProperties], Any) -> None """Abort an ongoing copy operation. This will leave a destination file with zero length and full metadata. @@ -661,9 +661,9 @@ def set_http_headers(self, content_settings, # type: ContentSettings file_last_write_time="preserve", # type: Union[str, datetime] file_permission=None, # type: Optional[str] permission_key=None, # type: Optional[str] - **kwargs # Any - ): # type: ignore - # type: (ContentSettings, Optional[int], Optional[Any]) -> Dict[str, Any] + **kwargs # type: Any + ): + # type: (...) -> Dict[str, Any] """Sets HTTP headers on the file. :param ~azure.storage.file.ContentSettings content_settings: @@ -722,8 +722,8 @@ def set_http_headers(self, content_settings, # type: ContentSettings process_storage_error(error) @distributed_trace - def set_file_metadata(self, metadata=None, **kwargs): # type: ignore - #type: (Optional[Dict[str, Any]], Any) -> Dict[str, Any] + def set_file_metadata(self, metadata=None, **kwargs): + # type: (Optional[Dict[str, Any]], Any) -> Dict[str, Any] """Sets user-defined metadata for the specified file as one or more name-value pairs. @@ -811,7 +811,7 @@ def _upload_range_from_url_options(source_url, # type: str offset, # type: int length, # type: int source_offset, # type: int - **kwargs + **kwargs # type: Any ): # type: (...) -> Dict[str, Any] @@ -838,11 +838,11 @@ def _upload_range_from_url_options(source_url, # type: str return options @distributed_trace - def upload_range_from_url(self, source_url, # type: str - offset, # type: int - length, # type: int - source_offset, # type: int - **kwargs # type: Any + def upload_range_from_url(self, source_url, + offset, + length, + source_offset, + **kwargs ): # type: (str, int, int, int, **Any) -> Dict[str, Any] ''' @@ -882,12 +882,12 @@ def upload_range_from_url(self, source_url, # type: str process_storage_error(error) @distributed_trace - def get_ranges( # type: ignore - self, offset=None, # type: Optional[int] - length=None, # type: Optional[int] - **kwargs + def get_ranges( # type: ignore + self, offset=None, # type: Optional[int] + length=None, # type: Optional[int] + **kwargs # type: Any ): - # type: (...) -> List[dict[str, int]] + # type: (...) -> List[Dict[str, int]] """Returns the list of valid ranges of a file. :param int offset: @@ -963,7 +963,7 @@ def clear_range( # type: ignore process_storage_error(error) @distributed_trace - def resize_file(self, size, **kwargs): # type: ignore + def resize_file(self, size, **kwargs): # type: (int, Any) -> Dict[str, Any] """Resizes a file to the specified size. @@ -990,7 +990,7 @@ def resize_file(self, size, **kwargs): # type: ignore @distributed_trace def list_handles(self, **kwargs): - # type: (int, Any) -> ItemPaged[Handle] + # type: (Any) -> ItemPaged[Handle] """Lists handles for file. :keyword int timeout: diff --git a/sdk/storage/azure-storage-file/azure/storage/file/file_service_client.py b/sdk/storage/azure-storage-file/azure/storage/file/_file_service_client.py similarity index 99% rename from sdk/storage/azure-storage-file/azure/storage/file/file_service_client.py rename to sdk/storage/azure-storage-file/azure/storage/file/_file_service_client.py index e1a23a172fbd..1b597bf0753f 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/file_service_client.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/_file_service_client.py @@ -22,12 +22,12 @@ from ._generated import AzureFileStorage from ._generated.models import StorageErrorException, StorageServiceProperties from ._generated.version import VERSION -from .share_client import ShareClient -from .models import SharePropertiesPaged +from ._share_client import ShareClient +from ._models import SharePropertiesPaged if TYPE_CHECKING: from datetime import datetime - from .models import Metrics, CorsRule, ShareProperties + from ._models import Metrics, CorsRule, ShareProperties class FileServiceClient(StorageAccountHostsMixin): diff --git a/sdk/storage/azure-storage-file/azure/storage/file/models.py b/sdk/storage/azure-storage-file/azure/storage/file/_models.py similarity index 99% rename from sdk/storage/azure-storage-file/azure/storage/file/models.py rename to sdk/storage/azure-storage-file/azure/storage/file/_models.py index de65f213a916..bf99c6dee92e 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/models.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/_models.py @@ -7,7 +7,7 @@ # pylint: disable=super-init-not-called, too-many-lines from azure.core.paging import PageIterator -from azure.storage.file._parser import _parse_datetime_from_str +from ._parser import _parse_datetime_from_str from ._shared.response_handlers import return_context_and_deserialized, process_storage_error from ._shared.models import DictMixin, get_enum_value from ._generated.models import StorageErrorException diff --git a/sdk/storage/azure-storage-file/azure/storage/file/share_client.py b/sdk/storage/azure-storage-file/azure/storage/file/_share_client.py similarity index 97% rename from sdk/storage/azure-storage-file/azure/storage/file/share_client.py rename to sdk/storage/azure-storage-file/azure/storage/file/_share_client.py index 4938f769c00d..191f263d482d 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/share_client.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/_share_client.py @@ -5,7 +5,7 @@ # -------------------------------------------------------------------------- from typing import ( # pylint: disable=unused-import - Optional, Union, Dict, Any, TYPE_CHECKING + Optional, Union, Dict, Any, Iterable, TYPE_CHECKING ) try: from urllib.parse import urlparse, quote, unquote @@ -30,11 +30,11 @@ DeleteSnapshotsOptionType, SharePermission) from ._deserialize import deserialize_share_properties, deserialize_permission_key, deserialize_permission -from .directory_client import DirectoryClient -from .file_client import FileClient +from ._directory_client import DirectoryClient +from ._file_client import FileClient if TYPE_CHECKING: - from .models import ShareProperties, AccessPolicy + from ._models import ShareProperties, AccessPolicy class ShareClient(StorageAccountHostsMixin): @@ -237,7 +237,7 @@ def get_file_client(self, file_path): _pipeline=_pipeline, _location_mode=self._location_mode) @distributed_trace - def create_share(self, **kwargs): # type: ignore + def create_share(self, **kwargs): # type: (Any) -> Dict[str, Any] """Creates a new Share under the account. If a share with the same name already exists, the operation fails. @@ -396,7 +396,7 @@ def get_share_properties(self, **kwargs): return props # type: ignore @distributed_trace - def set_share_quota(self, quota, **kwargs): # type: ignore + def set_share_quota(self, quota, **kwargs): # type: (int, Any) -> Dict[str, Any] """Sets the quota for the share. @@ -428,7 +428,7 @@ def set_share_quota(self, quota, **kwargs): # type: ignore process_storage_error(error) @distributed_trace - def set_share_metadata(self, metadata, **kwargs): # type: ignore + def set_share_metadata(self, metadata, **kwargs): # type: (Dict[str, Any], Any) -> Dict[str, Any] """Sets the metadata for the share. @@ -490,7 +490,7 @@ def get_share_access_policy(self, **kwargs): } @distributed_trace - def set_share_access_policy(self, signed_identifiers, **kwargs): # type: ignore + def set_share_access_policy(self, signed_identifiers, **kwargs): # type: (Dict[str, AccessPolicy], Any) -> Dict[str, str] """Sets the permissions for the share, or stored access policies that may be used with Shared Access Signatures. The permissions @@ -528,7 +528,7 @@ def set_share_access_policy(self, signed_identifiers, **kwargs): # type: ignore process_storage_error(error) @distributed_trace - def get_share_stats(self, **kwargs): # type: ignore + def get_share_stats(self, **kwargs): # type: (Any) -> int """Gets the approximate size of the data stored on the share in bytes. @@ -550,13 +550,13 @@ def get_share_stats(self, **kwargs): # type: ignore process_storage_error(error) @distributed_trace - def list_directories_and_files( # type: ignore + def list_directories_and_files( self, directory_name=None, # type: Optional[str] name_starts_with=None, # type: Optional[str] marker=None, # type: Optional[str] **kwargs # type: Any ): - # type: (...) -> Iterable[dict[str,str]] + # type: (...) -> Iterable[Dict[str,str]] """Lists the directories and files under the share. :param str directory_name: @@ -664,7 +664,7 @@ def create_directory(self, directory_name, **kwargs): :keyword int timeout: The timeout parameter is expressed in seconds. :returns: DirectoryClient - :rtype: ~azure.storage.file.directory_client.DirectoryClient + :rtype: ~azure.storage.file.DirectoryClient """ directory = self.get_directory_client(directory_name) kwargs.setdefault('merge_span', True) diff --git a/sdk/storage/azure-storage-file/azure/storage/file/_shared/base_client.py b/sdk/storage/azure-storage-file/azure/storage/file/_shared/base_client.py index 2b9fade672ea..93c3bec18b27 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/_shared/base_client.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/_shared/base_client.py @@ -28,7 +28,7 @@ from azure.core.configuration import Configuration from azure.core.exceptions import HttpResponseError from azure.core.pipeline import Pipeline -from azure.core.pipeline.transport import RequestsTransport, HttpTransport +from azure.core.pipeline.transport import RequestsTransport, HttpTransport # pylint: disable=unused-import from azure.core.pipeline.policies import ( RedirectPolicy, ContentDecodePolicy, diff --git a/sdk/storage/azure-storage-file/azure/storage/file/_shared/base_client_async.py b/sdk/storage/azure-storage-file/azure/storage/file/_shared/base_client_async.py index 77f6e48ef5ab..872145e073bd 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/_shared/base_client_async.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/_shared/base_client_async.py @@ -36,7 +36,9 @@ if TYPE_CHECKING: from azure.core.pipeline import Pipeline + from azure.core.pipeline.transport import HttpRequest from azure.core.configuration import Configuration + _LOGGER = logging.getLogger(__name__) diff --git a/sdk/storage/azure-storage-file/azure/storage/file/_shared/encryption.py b/sdk/storage/azure-storage-file/azure/storage/file/_shared/encryption.py index 25c160463fad..62607cc0cf85 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/_shared/encryption.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/_shared/encryption.py @@ -20,7 +20,7 @@ from azure.core.exceptions import HttpResponseError -from ..version import VERSION +from .._version import VERSION from . import encode_base64, decode_base64_to_bytes diff --git a/sdk/storage/azure-storage-file/azure/storage/file/_shared/models.py b/sdk/storage/azure-storage-file/azure/storage/file/_shared/models.py index c14d8cad8b8e..df4d8537b423 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/_shared/models.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/_shared/models.py @@ -330,11 +330,11 @@ class Services(object): """Specifies the services accessible with the account SAS. :param bool blob: - Access for the `~azure.storage.blob.blob_service_client.BlobServiceClient` + Access for the `~azure.storage.blob.BlobServiceClient` :param bool queue: - Access for the `~azure.storage.queue.queue_service_client.QueueServiceClient` + Access for the `~azure.storage.queue.QueueServiceClient` :param bool file: - Access for the `~azure.storage.file.file_service_client.FileServiceClient` + Access for the `~azure.storage.file.FileServiceClient` """ def __init__(self, blob=False, queue=False, file=False): diff --git a/sdk/storage/azure-storage-file/azure/storage/file/_shared/policies.py b/sdk/storage/azure-storage-file/azure/storage/file/_shared/policies.py index 75385f38b4bf..9dd8ffb23ad6 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/_shared/policies.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/_shared/policies.py @@ -40,7 +40,7 @@ ) from azure.core.exceptions import AzureError, ServiceRequestError, ServiceResponseError -from ..version import VERSION +from .._version import VERSION from .models import LocationMode try: diff --git a/sdk/storage/azure-storage-file/azure/storage/file/version.py b/sdk/storage/azure-storage-file/azure/storage/file/_version.py similarity index 100% rename from sdk/storage/azure-storage-file/azure/storage/file/version.py rename to sdk/storage/azure-storage-file/azure/storage/file/_version.py diff --git a/sdk/storage/azure-storage-file/azure/storage/file/aio/__init__.py b/sdk/storage/azure-storage-file/azure/storage/file/aio/__init__.py index 9ba6e4a802c0..4e4af3a9a02b 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/aio/__init__.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/aio/__init__.py @@ -4,10 +4,10 @@ # license information. # -------------------------------------------------------------------------- -from .file_client_async import FileClient -from .directory_client_async import DirectoryClient -from .share_client_async import ShareClient -from .file_service_client_async import FileServiceClient +from ._file_client_async import FileClient +from ._directory_client_async import DirectoryClient +from ._share_client_async import ShareClient +from ._file_service_client_async import FileServiceClient __all__ = [ diff --git a/sdk/storage/azure-storage-file/azure/storage/file/aio/directory_client_async.py b/sdk/storage/azure-storage-file/azure/storage/file/aio/_directory_client_async.py similarity index 97% rename from sdk/storage/azure-storage-file/azure/storage/file/aio/directory_client_async.py rename to sdk/storage/azure-storage-file/azure/storage/file/aio/_directory_client_async.py index 8fd2e2b59165..53a118d004ea 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/aio/directory_client_async.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/aio/_directory_client_async.py @@ -25,12 +25,13 @@ from .._shared.request_handlers import add_metadata_headers from .._shared.response_handlers import return_response_headers, process_storage_error from .._deserialize import deserialize_directory_properties -from ..directory_client import DirectoryClient as DirectoryClientBase -from .file_client_async import FileClient -from .models import DirectoryPropertiesPaged, HandlesPaged +from .._directory_client import DirectoryClient as DirectoryClientBase +from ._file_client_async import FileClient +from ._models import DirectoryPropertiesPaged, HandlesPaged if TYPE_CHECKING: - from ..models import ShareProperties, DirectoryProperties, ContentSettings, NTFSAttributes + from datetime import datetime + from .._models import ShareProperties, DirectoryProperties, ContentSettings, NTFSAttributes from .._generated.models import HandleItem @@ -153,7 +154,7 @@ def get_subdirectory_client(self, directory_name, **kwargs): _pipeline=_pipeline, _location_mode=self._location_mode, loop=self._loop, **kwargs) @distributed_trace_async - async def create_directory(self, **kwargs): # type: ignore + async def create_directory(self, **kwargs): # type: (Any) -> Dict[str, Any] """Creates a new directory under the directory referenced by the client. @@ -368,7 +369,7 @@ async def get_directory_properties(self, **kwargs): return response # type: ignore @distributed_trace_async - async def set_directory_metadata(self, metadata, **kwargs): # type: ignore + async def set_directory_metadata(self, metadata, **kwargs): # type: (Dict[str, Any], Any) -> Dict[str, Any] """Sets the metadata for the directory. @@ -402,7 +403,8 @@ async def set_http_headers(self, file_attributes="none", # type: Union[str, NTF file_last_write_time="preserve", # type: Union[str, datetime] file_permission=None, # type: Optional[str] permission_key=None, # type: Optional[str] - **kwargs): # type: ignore + **kwargs # type: Any + ): # type: (...) -> Dict[str, Any] """Sets HTTP headers on the directory. @@ -465,7 +467,7 @@ async def create_subdirectory( :keyword int timeout: The timeout parameter is expressed in seconds. :returns: DirectoryClient - :rtype: ~azure.storage.file.aio.directory_client_async.DirectoryClient + :rtype: ~azure.storage.file.aio.DirectoryClient .. admonition:: Example: @@ -545,7 +547,7 @@ async def upload_file( :keyword str encoding: Defaults to UTF-8. :returns: FileClient - :rtype: ~azure.storage.file.aio.file_client_async.FileClient + :rtype: ~azure.storage.file.aio.FileClient .. admonition:: Example: diff --git a/sdk/storage/azure-storage-file/azure/storage/file/aio/download_async.py b/sdk/storage/azure-storage-file/azure/storage/file/aio/_download_async.py similarity index 99% rename from sdk/storage/azure-storage-file/azure/storage/file/aio/download_async.py rename to sdk/storage/azure-storage-file/azure/storage/file/aio/_download_async.py index 9dcd99917624..9f6f19c7f701 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/aio/download_async.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/aio/_download_async.py @@ -14,7 +14,7 @@ from .._shared.encryption import decrypt_blob from .._shared.request_handlers import validate_and_format_range_headers from .._shared.response_handlers import process_storage_error, parse_length_from_content_range -from ..download import process_range_and_offset, _ChunkDownloader +from .._download import process_range_and_offset, _ChunkDownloader async def process_content(data, start_offset, end_offset, encryption): diff --git a/sdk/storage/azure-storage-file/azure/storage/file/aio/file_client_async.py b/sdk/storage/azure-storage-file/azure/storage/file/aio/_file_client_async.py similarity index 97% rename from sdk/storage/azure-storage-file/azure/storage/file/aio/file_client_async.py rename to sdk/storage/azure-storage-file/azure/storage/file/aio/_file_client_async.py index 04ee473344d3..a475e69e6313 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/aio/file_client_async.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/aio/_file_client_async.py @@ -26,13 +26,13 @@ from .._shared.request_handlers import add_metadata_headers, get_length from .._shared.response_handlers import return_response_headers, process_storage_error from .._deserialize import deserialize_file_properties, deserialize_file_stream -from ..file_client import FileClient as FileClientBase -from .models import HandlesPaged -from .download_async import StorageStreamDownloader +from .._file_client import FileClient as FileClientBase +from ._models import HandlesPaged +from ._download_async import StorageStreamDownloader if TYPE_CHECKING: from datetime import datetime - from ..models import ShareProperties, ContentSettings, FileProperties, NTFSAttributes + from .._models import ShareProperties, ContentSettings, FileProperties, NTFSAttributes from .._generated.models import HandleItem @@ -399,7 +399,7 @@ async def start_copy_from_url( @distributed_trace_async async def abort_copy(self, copy_id, **kwargs): - # type: (Union[str, FileProperties], Any) -> Dict[str, Any] + # type: (Union[str, FileProperties], Any) -> None """Abort an ongoing copy operation. This will leave a destination file with zero length and full metadata. @@ -543,9 +543,9 @@ async def set_http_headers(self, content_settings, # type: ContentSettings file_last_write_time="preserve", # type: Union[str, datetime] file_permission=None, # type: Optional[str] permission_key=None, # type: Optional[str] - **kwargs # Any - ): # type: ignore - # type: (ContentSettings, Optional[int], Optional[Any]) -> Dict[str, Any] + **kwargs # type: Any + ): + # type: (...) -> Dict[str, Any] """Sets HTTP headers on the file. :param ~azure.storage.file.ContentSettings content_settings: @@ -688,11 +688,11 @@ async def upload_range( # type: ignore process_storage_error(error) @distributed_trace_async - async def upload_range_from_url(self, source_url, # type: str - offset, # type: int - length, # type: int - source_offset, # type: int - **kwargs # type: Any + async def upload_range_from_url(self, source_url, + offset, + length, + source_offset, + **kwargs ): # type: (str, int, int, int, **Any) -> Dict[str, Any] ''' @@ -739,7 +739,7 @@ async def get_ranges( # type: ignore length=None, # type: Optional[int] **kwargs ): - # type: (...) -> List[dict[str, int]] + # type: (...) -> List[Dict[str, int]] """Returns the list of valid ranges of a file. :param int offset: @@ -815,7 +815,7 @@ async def clear_range( # type: ignore process_storage_error(error) @distributed_trace_async - async def resize_file(self, size, **kwargs): # type: ignore + async def resize_file(self, size, **kwargs): # type: (int, Any) -> Dict[str, Any] """Resizes a file to the specified size. diff --git a/sdk/storage/azure-storage-file/azure/storage/file/aio/file_service_client_async.py b/sdk/storage/azure-storage-file/azure/storage/file/aio/_file_service_client_async.py similarity index 98% rename from sdk/storage/azure-storage-file/azure/storage/file/aio/file_service_client_async.py rename to sdk/storage/azure-storage-file/azure/storage/file/aio/_file_service_client_async.py index a2050a86e276..9248ae52a9b4 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/aio/file_service_client_async.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/aio/_file_service_client_async.py @@ -21,14 +21,14 @@ from .._generated.aio import AzureFileStorage from .._generated.models import StorageErrorException, StorageServiceProperties from .._generated.version import VERSION -from ..file_service_client import FileServiceClient as FileServiceClientBase -from .share_client_async import ShareClient -from .models import SharePropertiesPaged +from .._file_service_client import FileServiceClient as FileServiceClientBase +from ._share_client_async import ShareClient +from ._models import SharePropertiesPaged if TYPE_CHECKING: from datetime import datetime from .._shared.models import ResourceTypes, AccountSasPermissions - from ..models import Metrics, CorsRule, ShareProperties + from .._models import Metrics, CorsRule, ShareProperties class FileServiceClient(AsyncStorageAccountHostsMixin, FileServiceClientBase): diff --git a/sdk/storage/azure-storage-file/azure/storage/file/aio/models.py b/sdk/storage/azure-storage-file/azure/storage/file/aio/_models.py similarity index 99% rename from sdk/storage/azure-storage-file/azure/storage/file/aio/models.py rename to sdk/storage/azure-storage-file/azure/storage/file/aio/_models.py index e5419a5d9135..49b3d36ee309 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/aio/models.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/aio/_models.py @@ -11,7 +11,7 @@ from .._shared.response_handlers import return_context_and_deserialized, process_storage_error from .._generated.models import StorageErrorException from .._generated.models import DirectoryItem -from ..models import Handle, ShareProperties +from .._models import Handle, ShareProperties def _wrap_item(item): diff --git a/sdk/storage/azure-storage-file/azure/storage/file/aio/share_client_async.py b/sdk/storage/azure-storage-file/azure/storage/file/aio/_share_client_async.py similarity index 97% rename from sdk/storage/azure-storage-file/azure/storage/file/aio/share_client_async.py rename to sdk/storage/azure-storage-file/azure/storage/file/aio/_share_client_async.py index 9ccb64e7281e..f7f19a6ccfef 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/aio/share_client_async.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/aio/_share_client_async.py @@ -5,7 +5,7 @@ # -------------------------------------------------------------------------- from typing import ( # pylint: disable=unused-import - Optional, Union, Dict, Any, TYPE_CHECKING + Optional, Union, Dict, Any, Iterable, TYPE_CHECKING ) from azure.core.tracing.decorator import distributed_trace @@ -25,12 +25,12 @@ SignedIdentifier, DeleteSnapshotsOptionType) from .._deserialize import deserialize_share_properties, deserialize_permission -from ..share_client import ShareClient as ShareClientBase -from .directory_client_async import DirectoryClient -from .file_client_async import FileClient +from .._share_client import ShareClient as ShareClientBase +from ._directory_client_async import DirectoryClient +from ._file_client_async import FileClient if TYPE_CHECKING: - from ..models import ShareProperties, AccessPolicy + from .._models import ShareProperties, AccessPolicy class ShareClient(AsyncStorageAccountHostsMixin, ShareClientBase): @@ -292,7 +292,7 @@ async def get_share_properties(self, **kwargs): return props # type: ignore @distributed_trace_async - async def set_share_quota(self, quota, **kwargs): # type: ignore + async def set_share_quota(self, quota, **kwargs): # type: (int, Any) -> Dict[str, Any] """Sets the quota for the share. @@ -324,7 +324,7 @@ async def set_share_quota(self, quota, **kwargs): # type: ignore process_storage_error(error) @distributed_trace_async - async def set_share_metadata(self, metadata, **kwargs): # type: ignore + async def set_share_metadata(self, metadata, **kwargs): # type: (Dict[str, Any], Any) -> Dict[str, Any] """Sets the metadata for the share. @@ -386,7 +386,7 @@ async def get_share_access_policy(self, **kwargs): } @distributed_trace_async - async def set_share_access_policy(self, signed_identifiers, **kwargs): # type: ignore + async def set_share_access_policy(self, signed_identifiers, **kwargs): # type: (Dict[str, AccessPolicy], Any) -> Dict[str, str] """Sets the permissions for the share, or stored access policies that may be used with Shared Access Signatures. The permissions @@ -425,7 +425,7 @@ async def set_share_access_policy(self, signed_identifiers, **kwargs): # type: i process_storage_error(error) @distributed_trace_async - async def get_share_stats(self, **kwargs): # type: ignore + async def get_share_stats(self, **kwargs): # type: (Any) -> int """Gets the approximate size of the data stored on the share in bytes. @@ -453,7 +453,7 @@ def list_directories_and_files( # type: ignore marker=None, # type: Optional[str] **kwargs # type: Any ): - # type: (...) -> Iterable[dict[str,str]] + # type: (...) -> Iterable[Dict[str,str]] """Lists the directories and files under the share. :param str directory_name: diff --git a/sdk/storage/azure-storage-file/setup.py b/sdk/storage/azure-storage-file/setup.py index 24ce7e90317c..46cc22477463 100644 --- a/sdk/storage/azure-storage-file/setup.py +++ b/sdk/storage/azure-storage-file/setup.py @@ -36,7 +36,7 @@ pass # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py'), 'r') as fd: +with open(os.path.join(package_folder_path, '_version.py'), 'r') as fd: version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) diff --git a/sdk/storage/azure-storage-file/tests/test_handle.py b/sdk/storage/azure-storage-file/tests/test_handle.py index bbd4c295d633..ab9d29f7524d 100644 --- a/sdk/storage/azure-storage-file/tests/test_handle.py +++ b/sdk/storage/azure-storage-file/tests/test_handle.py @@ -13,10 +13,12 @@ ResourceNotFoundError, ResourceExistsError) -from azure.storage.file.file_service_client import FileServiceClient -from azure.storage.file.directory_client import DirectoryClient -from azure.storage.file.file_client import FileClient -from azure.storage.file.share_client import ShareClient +from azure.storage.file import ( + FileServiceClient, + DirectoryClient, + FileClient, + ShareClient +) from filetestcase import ( FileTestCase, record, diff --git a/sdk/storage/azure-storage-queue/HISTORY.md b/sdk/storage/azure-storage-queue/HISTORY.md index 5ff6703625bb..0b0d14f44760 100644 --- a/sdk/storage/azure-storage-queue/HISTORY.md +++ b/sdk/storage/azure-storage-queue/HISTORY.md @@ -20,9 +20,9 @@ should be imported from azure.storage.queue.aio to `inserted_on`, `next_visible_on`, `expires_on`, respectively. - `Logging` has been renamed to `QueueAnalyticsLogging`. - `enqueue_message` is now called `send_message`. +- Client and model files have been made internal. Users should import from the top level modules `azure.storage.queue` and `azure.storage.queue.aio` only. - The `generate_shared_access_signature` methods on both `QueueServiceClient` and `QueueClient` have been replaced by module level functions `generate_account_sas` and `generate_queue_sas`. - **New features** - `ResourceTypes`, and `Services` now have method `from_string` which takes parameters as a string. diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/__init__.py b/sdk/storage/azure-storage-queue/azure/storage/queue/__init__.py index 0ef1b11b7f69..bb0ae7ae77d2 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/__init__.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/__init__.py @@ -4,9 +4,9 @@ # license information. # -------------------------------------------------------------------------- -from .version import VERSION -from .queue_client import QueueClient -from .queue_service_client import QueueServiceClient +from ._version import VERSION +from ._queue_client import QueueClient +from ._queue_service_client import QueueServiceClient from ._shared_access_signature import generate_account_sas, generate_queue_sas from ._shared.policies import ExponentialRetry, LinearRetry from ._shared.models import( @@ -23,7 +23,7 @@ TextXMLEncodePolicy, TextXMLDecodePolicy ) -from .models import ( +from ._models import ( QueueMessage, QueueProperties, QueueSasPermissions, diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/_deserialize.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_deserialize.py index 3137faa0aaa4..893e2558accf 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/_deserialize.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_deserialize.py @@ -8,7 +8,7 @@ from azure.core.exceptions import ResourceExistsError from ._shared.models import StorageErrorCode -from .models import QueueProperties +from ._models import QueueProperties def deserialize_metadata(response, obj, headers): diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/models.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_models.py similarity index 100% rename from sdk/storage/azure-storage-queue/azure/storage/queue/models.py rename to sdk/storage/azure-storage-queue/azure/storage/queue/_models.py diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/queue_client.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_client.py similarity index 98% rename from sdk/storage/azure-storage-queue/azure/storage/queue/queue_client.py rename to sdk/storage/azure-storage-queue/azure/storage/queue/_queue_client.py index 8fbef4de4fa4..1d4cd58792bb 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/queue_client.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_client.py @@ -29,13 +29,12 @@ from ._generated import AzureQueueStorage from ._generated.models import StorageErrorException, SignedIdentifier from ._generated.models import QueueMessage as GenQueueMessage - -from .models import QueueMessage, AccessPolicy, MessagesPaged +from ._models import QueueMessage, AccessPolicy, MessagesPaged if TYPE_CHECKING: from datetime import datetime from azure.core.pipeline.policies import HTTPPolicy - from .models import QueueProperties + from ._models import QueueProperties class QueueClient(StorageAccountHostsMixin): @@ -116,7 +115,7 @@ def __init__( @classmethod def from_queue_url(cls, queue_url, credential=None, **kwargs): - # type: (str, Optional[Any], Any) -> None + # type: (str, Optional[Any], Any) -> QueueClient """A client to interact with a specific Queue. :param str queue_url: The full URI to the queue, including SAS token if used. @@ -486,8 +485,8 @@ def send_message( # type: ignore process_storage_error(error) @distributed_trace - def receive_messages(self, **kwargs): # type: ignore - # type: (Optional[Any]) -> ItemPaged[Message] + def receive_messages(self, **kwargs): + # type: (Optional[Any]) -> ItemPaged[QueueMessage] """Removes one or more messages from the front of the queue. When a message is retrieved from the queue, the response includes the message @@ -515,7 +514,7 @@ def receive_messages(self, **kwargs): # type: ignore The server timeout, expressed in seconds. :return: Returns a message iterator of dict-like Message objects. - :rtype: ~azure.core.paging.ItemPaged[~azure.storage.queue.Message] + :rtype: ~azure.core.paging.ItemPaged[~azure.storage.queue.QueueMessage] .. admonition:: Example: @@ -546,7 +545,7 @@ def receive_messages(self, **kwargs): # type: ignore process_storage_error(error) @distributed_trace - def update_message(self, message, pop_receipt=None, content=None, **kwargs): # type: ignore + def update_message(self, message, pop_receipt=None, content=None, **kwargs): # type: (Any, Optional[str], Optional[Any], Any) -> QueueMessage """Updates the visibility timeout of a message. You can also use this operation to update the contents of a message. @@ -642,7 +641,7 @@ def update_message(self, message, pop_receipt=None, content=None, **kwargs): # t process_storage_error(error) @distributed_trace - def peek_messages(self, max_messages=None, **kwargs): # type: ignore + def peek_messages(self, max_messages=None, **kwargs): # type: (Optional[int], Optional[Any]) -> List[QueueMessage] """Retrieves one or more messages from the front of the queue, but does not alter the visibility of the message. diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/queue_service_client.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_service_client.py similarity index 98% rename from sdk/storage/azure-storage-queue/azure/storage/queue/queue_service_client.py rename to sdk/storage/azure-storage-queue/azure/storage/queue/_queue_service_client.py index 259e9f395db2..46b975d2e761 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/queue_service_client.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_service_client.py @@ -22,14 +22,14 @@ from ._generated import AzureQueueStorage from ._generated.models import StorageServiceProperties, StorageErrorException -from .models import QueuePropertiesPaged -from .queue_client import QueueClient +from ._models import QueuePropertiesPaged +from ._queue_client import QueueClient if TYPE_CHECKING: from datetime import datetime from azure.core.configuration import Configuration from azure.core.pipeline.policies import HTTPPolicy - from .models import ( + from ._models import ( QueueProperties, QueueAnalyticsLogging, Metrics, @@ -287,7 +287,7 @@ def list_queues( calls to the service in which case the timeout value specified will be applied to each individual call. :returns: An iterable (auto-paging) of QueueProperties. - :rtype: ~azure.core.paging.ItemPaged[~azure.core.queue.models.QueueProperties] + :rtype: ~azure.core.paging.ItemPaged[~azure.storage.queue.QueueProperties] .. admonition:: Example: @@ -397,8 +397,8 @@ def get_queue_client(self, queue, **kwargs): The queue. This can either be the name of the queue, or an instance of QueueProperties. :type queue: str or ~azure.storage.queue.QueueProperties - :returns: A :class:`~azure.core.queue.queue_client.QueueClient` object. - :rtype: ~azure.core.queue.queue_client.QueueClient + :returns: A :class:`~azure.storage.queue.QueueClient` object. + :rtype: ~azure.storage.queue.QueueClient .. admonition:: Example: diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/base_client.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/base_client.py index 2b9fade672ea..93c3bec18b27 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/base_client.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/base_client.py @@ -28,7 +28,7 @@ from azure.core.configuration import Configuration from azure.core.exceptions import HttpResponseError from azure.core.pipeline import Pipeline -from azure.core.pipeline.transport import RequestsTransport, HttpTransport +from azure.core.pipeline.transport import RequestsTransport, HttpTransport # pylint: disable=unused-import from azure.core.pipeline.policies import ( RedirectPolicy, ContentDecodePolicy, diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/base_client_async.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/base_client_async.py index 77f6e48ef5ab..872145e073bd 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/base_client_async.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/base_client_async.py @@ -36,7 +36,9 @@ if TYPE_CHECKING: from azure.core.pipeline import Pipeline + from azure.core.pipeline.transport import HttpRequest from azure.core.configuration import Configuration + _LOGGER = logging.getLogger(__name__) diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/encryption.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/encryption.py index 25c160463fad..62607cc0cf85 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/encryption.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/encryption.py @@ -20,7 +20,7 @@ from azure.core.exceptions import HttpResponseError -from ..version import VERSION +from .._version import VERSION from . import encode_base64, decode_base64_to_bytes diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/models.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/models.py index 6ddfaee28734..5d6d602510ec 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/models.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/models.py @@ -330,11 +330,11 @@ class Services(object): """Specifies the services accessible with the account SAS. :param bool blob: - Access for the `~azure.storage.blob.blob_service_client.BlobServiceClient` + Access for the `~azure.storage.blob.BlobServiceClient` :param bool queue: - Access for the `~azure.storage.queue.queue_service_client.QueueServiceClient` + Access for the `~azure.storage.queue.QueueServiceClient` :param bool file: - Access for the `~azure.storage.file.file_service_client.FileServiceClient` + Access for the `~azure.storage.file.FileServiceClient` """ def __init__(self, blob=False, queue=False, file=False): diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/policies.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/policies.py index 75385f38b4bf..9dd8ffb23ad6 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/policies.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/policies.py @@ -40,7 +40,7 @@ ) from azure.core.exceptions import AzureError, ServiceRequestError, ServiceResponseError -from ..version import VERSION +from .._version import VERSION from .models import LocationMode try: diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/version.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_version.py similarity index 100% rename from sdk/storage/azure-storage-queue/azure/storage/queue/version.py rename to sdk/storage/azure-storage-queue/azure/storage/queue/_version.py diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/aio/__init__.py b/sdk/storage/azure-storage-queue/azure/storage/queue/aio/__init__.py index 3a817ac4988d..15781aefaf2e 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/aio/__init__.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/aio/__init__.py @@ -4,8 +4,8 @@ # license information. # -------------------------------------------------------------------------- -from .queue_client_async import QueueClient -from .queue_service_client_async import QueueServiceClient +from ._queue_client_async import QueueClient +from ._queue_service_client_async import QueueServiceClient __all__ = [ diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/aio/models.py b/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_models.py similarity index 98% rename from sdk/storage/azure-storage-queue/azure/storage/queue/aio/models.py rename to sdk/storage/azure-storage-queue/azure/storage/queue/aio/_models.py index 4fa12459f6ce..1886411aec77 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/aio/models.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_models.py @@ -12,7 +12,7 @@ process_storage_error, return_context_and_deserialized) from .._generated.models import StorageErrorException -from ..models import QueueMessage, QueueProperties +from .._models import QueueMessage, QueueProperties class MessagesPaged(AsyncPageIterator): diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/aio/queue_client_async.py b/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py similarity index 96% rename from sdk/storage/azure-storage-queue/azure/storage/queue/aio/queue_client_async.py rename to sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py index 48a3f7e97e7f..906a0513c1be 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/aio/queue_client_async.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py @@ -41,16 +41,16 @@ from .._generated.models import StorageErrorException, SignedIdentifier from .._generated.models import QueueMessage as GenQueueMessage -from ..models import QueueMessage, AccessPolicy -from .models import MessagesPaged +from .._models import QueueMessage, AccessPolicy +from ._models import MessagesPaged from .._shared.policies_async import ExponentialRetry -from ..queue_client import QueueClient as QueueClientBase +from .._queue_client import QueueClient as QueueClientBase if TYPE_CHECKING: from datetime import datetime from azure.core.pipeline.policies import HTTPPolicy - from ..models import QueueSasPermissions, QueueProperties + from .._models import QueueSasPermissions, QueueProperties class QueueClient(AsyncStorageAccountHostsMixin, QueueClientBase): @@ -118,7 +118,7 @@ def __init__( self._loop = loop @distributed_trace_async - async def create_queue(self, **kwargs): # type: ignore + async def create_queue(self, **kwargs): # type: (Optional[Any]) -> None """Creates a new queue in the storage account. @@ -157,7 +157,7 @@ async def create_queue(self, **kwargs): # type: ignore process_storage_error(error) @distributed_trace_async - async def delete_queue(self, **kwargs): # type: ignore + async def delete_queue(self, **kwargs): # type: (Optional[Any]) -> None """Deletes the specified queue and any messages it contains. @@ -189,7 +189,7 @@ async def delete_queue(self, **kwargs): # type: ignore process_storage_error(error) @distributed_trace_async - async def get_queue_properties(self, **kwargs): # type: ignore + async def get_queue_properties(self, **kwargs): # type: (Optional[Any]) -> QueueProperties """Returns all user-defined metadata for the specified queue. @@ -220,7 +220,7 @@ async def get_queue_properties(self, **kwargs): # type: ignore return response # type: ignore @distributed_trace_async - async def set_queue_metadata(self, metadata=None, **kwargs): # type: ignore + async def set_queue_metadata(self, metadata=None, **kwargs): # type: (Optional[Dict[str, Any]], Optional[Any]) -> None """Sets user-defined metadata on the specified queue. @@ -253,7 +253,7 @@ async def set_queue_metadata(self, metadata=None, **kwargs): # type: ignore process_storage_error(error) @distributed_trace_async - async def get_queue_access_policy(self, **kwargs): # type: ignore + async def get_queue_access_policy(self, **kwargs): # type: (Optional[Any]) -> Dict[str, Any] """Returns details about any stored access policies specified on the queue that may be used with Shared Access Signatures. @@ -273,8 +273,8 @@ async def get_queue_access_policy(self, **kwargs): # type: ignore return {s.id: s.access_policy or AccessPolicy() for s in identifiers} @distributed_trace_async - async def set_queue_access_policy(self, signed_identifiers, **kwargs): # type: ignore - # type: (Dict[str, AccessPolicy], Optional[int], Optional[Any]) -> None + async def set_queue_access_policy(self, signed_identifiers, **kwargs): + # type: (Dict[str, AccessPolicy], Optional[Any]) -> None """Sets stored access policies for the queue that may be used with Shared Access Signatures. @@ -406,8 +406,8 @@ async def send_message( # type: ignore process_storage_error(error) @distributed_trace - def receive_messages(self, **kwargs): # type: ignore - # type: (Optional[Any]) -> AsyncItemPaged[Message] + def receive_messages(self, **kwargs): + # type: (Optional[Any]) -> AsyncItemPaged[QueueMessage] """Removes one or more messages from the front of the queue. When a message is retrieved from the queue, the response includes the message @@ -435,7 +435,7 @@ def receive_messages(self, **kwargs): # type: ignore The server timeout, expressed in seconds. :return: Returns a message iterator of dict-like Message objects. - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.storage.queue.Message] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.storage.queue.QueueMessage] .. admonition:: Example: @@ -470,11 +470,11 @@ def receive_messages(self, **kwargs): # type: ignore async def update_message( self, message, - pop_receipt=None, # type: ignore + pop_receipt=None, content=None, **kwargs ): - # type: (Any, int, Optional[str], Optional[Any], Optional[int], Any) -> QueueMessage + # type: (Any, int, Optional[str], Optional[Any], Any) -> QueueMessage """Updates the visibility timeout of a message. You can also use this operation to update the contents of a message. @@ -569,7 +569,7 @@ async def update_message( process_storage_error(error) @distributed_trace_async - async def peek_messages(self, max_messages=None, **kwargs): # type: ignore + async def peek_messages(self, max_messages=None, **kwargs): # type: (Optional[int], Optional[Any]) -> List[QueueMessage] """Retrieves one or more messages from the front of the queue, but does not alter the visibility of the message. @@ -626,7 +626,7 @@ async def peek_messages(self, max_messages=None, **kwargs): # type: ignore process_storage_error(error) @distributed_trace_async - async def clear_messages(self, **kwargs): # type: ignore + async def clear_messages(self, **kwargs): # type: (Optional[Any]) -> None """Deletes all messages from the specified queue. @@ -649,7 +649,7 @@ async def clear_messages(self, **kwargs): # type: ignore process_storage_error(error) @distributed_trace_async - async def delete_message(self, message, pop_receipt=None, **kwargs): # type: ignore + async def delete_message(self, message, pop_receipt=None, **kwargs): # type: (Any, Optional[str], Any) -> None """Deletes the specified message. diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/aio/queue_service_client_async.py b/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_service_client_async.py similarity index 97% rename from sdk/storage/azure-storage-queue/azure/storage/queue/aio/queue_service_client_async.py rename to sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_service_client_async.py index 2e8e2ef36862..35e6d4a26205 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/aio/queue_service_client_async.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_service_client_async.py @@ -19,21 +19,21 @@ from azure.core.tracing.decorator_async import distributed_trace_async from .._shared.policies_async import ExponentialRetry -from ..queue_service_client import QueueServiceClient as QueueServiceClientBase +from .._queue_service_client import QueueServiceClient as QueueServiceClientBase from .._shared.models import LocationMode from .._shared.base_client_async import AsyncStorageAccountHostsMixin, AsyncTransportWrapper from .._shared.response_handlers import process_storage_error from .._generated.aio import AzureQueueStorage from .._generated.models import StorageServiceProperties, StorageErrorException -from .models import QueuePropertiesPaged -from .queue_client_async import QueueClient +from ._models import QueuePropertiesPaged +from ._queue_client_async import QueueClient if TYPE_CHECKING: from datetime import datetime from azure.core.configuration import Configuration from azure.core.pipeline.policies import HTTPPolicy - from ..models import ( + from .._models import ( QueueProperties, QueueAnalyticsLogging, Metrics, @@ -247,7 +247,7 @@ def list_queues( calls to the service in which case the timeout value specified will be applied to each individual call. :returns: An iterable (auto-paging) of QueueProperties. - :rtype: ~azure.core.paging.AsyncItemPaged[~azure.core.queue.models.QueueProperties] + :rtype: ~azure.core.paging.AsyncItemPaged[~azure.storage.queue.QueueProperties] .. admonition:: Example: @@ -357,7 +357,7 @@ def get_queue_client(self, queue, **kwargs): The queue. This can either be the name of the queue, or an instance of QueueProperties. :type queue: str or ~azure.storage.queue.QueueProperties - :returns: A :class:`~azure.core.queue.queue_client.QueueClient` object. + :returns: A :class:`~azure.storage.queue.aio.QueueClient` object. :rtype: ~azure.storage.queue.aio.QueueClient .. admonition:: Example: diff --git a/sdk/storage/azure-storage-queue/setup.py b/sdk/storage/azure-storage-queue/setup.py index 0a71c9ad7af8..94d01b04a765 100644 --- a/sdk/storage/azure-storage-queue/setup.py +++ b/sdk/storage/azure-storage-queue/setup.py @@ -36,7 +36,7 @@ pass # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py'), 'r') as fd: +with open(os.path.join(package_folder_path, '_version.py'), 'r') as fd: version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', # type: ignore fd.read(), re.MULTILINE).group(1)