From 15348b3bcebea6d542ef65b3ccd94040e96aa15a Mon Sep 17 00:00:00 2001 From: Vincent Tran Date: Tue, 23 Apr 2024 12:35:04 -0700 Subject: [PATCH 01/15] Rehydrate --- .../azure/storage/fileshare/_models.py | 6 ++++++ .../azure/storage/fileshare/_share_client.py | 4 ++++ .../azure/storage/fileshare/aio/_share_client_async.py | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_models.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_models.py index dc42fef21bc3..135f28c4b89e 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_models.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_models.py @@ -341,6 +341,10 @@ class ShareProperties(DictMixin): Possible values include: 'NoRootSquash', 'RootSquash', 'AllSquash'. :ivar list(str) protocols: Indicates the protocols enabled on the share. The protocol can be either SMB or NFS. + :ivar bool enable_snapshot_virtual_directory_access: + Supported in service version 2023-08-03 and greater. Specifies whether the snapshot + virtual directory should be accessible at the root of the share mount point when NFS + is enabled. if not specified, the default is True. """ def __init__(self, **kwargs): @@ -364,6 +368,8 @@ def __init__(self, **kwargs): self.protocols = [protocol.strip() for protocol in kwargs.get('x-ms-enabled-protocols', None).split(',')]\ if kwargs.get('x-ms-enabled-protocols', None) else None self.root_squash = kwargs.get('x-ms-root-squash', None) + self.enable_snapshot_virtual_directory_access = \ + kwargs.get('x-ms-enable-snapshot-virtual-directory-access') @classmethod def _from_generated(cls, generated): props = cls() diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_share_client.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_share_client.py index 6335fd7ed1c4..3172d1afca37 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_share_client.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_share_client.py @@ -86,6 +86,10 @@ class ShareClient(StorageAccountHostsMixin): # pylint: disable=too-many-public-m :keyword str secondary_hostname: The hostname of the secondary endpoint. :keyword int max_range_size: The maximum range size used for a file upload. Defaults to 4*1024*1024. + :keyword bool enable_snapshot_virtual_directory_access: + Supported in service version 2023-08-03 and greater. Specifies whether the snapshot + virtual directory should be accessible at the root of the share mount point when NFS + is enabled. Default value is True. """ def __init__( self, account_url: str, diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_share_client_async.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_share_client_async.py index d942fbd17acc..33f53b127698 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_share_client_async.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_share_client_async.py @@ -82,6 +82,10 @@ class ShareClient(AsyncStorageAccountHostsMixin, ShareClientBase): :keyword str secondary_hostname: The hostname of the secondary endpoint. :keyword int max_range_size: The maximum range size used for a file upload. Defaults to 4*1024*1024. + :keyword bool enable_snapshot_virtual_directory_access: + Supported in service version 2023-08-03 and greater. Specifies whether the snapshot + virtual directory should be accessible at the root of the share mount point when NFS + is enabled. Default value is True. """ def __init__( self, account_url: str, From 68302d8231e12e299f31510a82ceaf4b29c708b1 Mon Sep 17 00:00:00 2001 From: Vincent Tran Date: Wed, 24 Apr 2024 19:10:57 -0700 Subject: [PATCH 02/15] Ported over previous work, generated, added testcases, added custom sorter C++ port --- .../azure-storage-file-share/assets.json | 2 +- .../_generated/_azure_file_storage.py | 2 +- .../fileshare/_generated/_configuration.py | 4 +- .../storage/fileshare/_generated/_patch.py | 2 + .../_generated/aio/_azure_file_storage.py | 2 +- .../_generated/aio/_configuration.py | 4 +- .../fileshare/_generated/aio/_patch.py | 2 + .../aio/operations/_directory_operations.py | 25 +++-- .../aio/operations/_file_operations.py | 43 +++++---- .../_generated/aio/operations/_patch.py | 1 + .../aio/operations/_service_operations.py | 13 ++- .../aio/operations/_share_operations.py | 52 ++++++---- .../_generated/models/_models_py3.py | 7 ++ .../fileshare/_generated/models/_patch.py | 1 + .../operations/_directory_operations.py | 43 +++++---- .../_generated/operations/_file_operations.py | 79 ++++++++------- .../fileshare/_generated/operations/_patch.py | 1 + .../operations/_service_operations.py | 19 ++-- .../operations/_share_operations.py | 96 ++++++++++++------- .../azure/storage/fileshare/_models.py | 1 + .../fileshare/_shared/authentication.py | 75 ++++++++++++++- .../tests/test_share.py | 21 ++++ .../tests/test_share_async.py | 23 +++++ 23 files changed, 360 insertions(+), 158 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/assets.json b/sdk/storage/azure-storage-file-share/assets.json index b4ad58843489..c1d136146e39 100644 --- a/sdk/storage/azure-storage-file-share/assets.json +++ b/sdk/storage/azure-storage-file-share/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/storage/azure-storage-file-share", - "Tag": "python/storage/azure-storage-file-share_1159609065" + "Tag": "python/storage/azure-storage-file-share_4e7efb08d8" } diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/_azure_file_storage.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/_azure_file_storage.py index 3c7796a01895..aac0adcdceec 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/_azure_file_storage.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/_azure_file_storage.py @@ -44,7 +44,7 @@ class AzureFileStorage: # pylint: disable=client-accepts-api-version-keyword URI. Default value is None. :type allow_source_trailing_dot: bool :keyword version: Specifies the version of the operation to use for this request. Default value - is "2024-05-04". Note that overriding this default value may result in unsupported behavior. + is "2024-08-04". Note that overriding this default value may result in unsupported behavior. :paramtype version: str :keyword file_range_write_from_url: Only update is supported: - Update: Writes the bytes downloaded from the source url into the specified range. Default value is "update". Note that diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/_configuration.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/_configuration.py index 5eb5a5f150d2..54aea0342111 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/_configuration.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/_configuration.py @@ -33,7 +33,7 @@ class AzureFileStorageConfiguration: # pylint: disable=too-many-instance-attrib URI. Default value is None. :type allow_source_trailing_dot: bool :keyword version: Specifies the version of the operation to use for this request. Default value - is "2024-05-04". Note that overriding this default value may result in unsupported behavior. + is "2024-08-04". Note that overriding this default value may result in unsupported behavior. :paramtype version: str :keyword file_range_write_from_url: Only update is supported: - Update: Writes the bytes downloaded from the source url into the specified range. Default value is "update". Note that @@ -49,7 +49,7 @@ def __init__( allow_source_trailing_dot: Optional[bool] = None, **kwargs: Any ) -> None: - version: Literal["2024-05-04"] = kwargs.pop("version", "2024-05-04") + version: Literal["2024-08-04"] = kwargs.pop("version", "2024-08-04") file_range_write_from_url: Literal["update"] = kwargs.pop("file_range_write_from_url", "update") if url is None: diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/_patch.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/_patch.py index f99e77fef986..4688ca7f8ac2 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/_patch.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/_patch.py @@ -27,5 +27,7 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md + + def patch_sdk(): pass diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/_azure_file_storage.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/_azure_file_storage.py index c58d28789cf3..46b977e4d579 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/_azure_file_storage.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/_azure_file_storage.py @@ -44,7 +44,7 @@ class AzureFileStorage: # pylint: disable=client-accepts-api-version-keyword URI. Default value is None. :type allow_source_trailing_dot: bool :keyword version: Specifies the version of the operation to use for this request. Default value - is "2024-05-04". Note that overriding this default value may result in unsupported behavior. + is "2024-08-04". Note that overriding this default value may result in unsupported behavior. :paramtype version: str :keyword file_range_write_from_url: Only update is supported: - Update: Writes the bytes downloaded from the source url into the specified range. Default value is "update". Note that diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/_configuration.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/_configuration.py index 5f4ac8b24bdd..a71a8e74cfb8 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/_configuration.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/_configuration.py @@ -33,7 +33,7 @@ class AzureFileStorageConfiguration: # pylint: disable=too-many-instance-attrib URI. Default value is None. :type allow_source_trailing_dot: bool :keyword version: Specifies the version of the operation to use for this request. Default value - is "2024-05-04". Note that overriding this default value may result in unsupported behavior. + is "2024-08-04". Note that overriding this default value may result in unsupported behavior. :paramtype version: str :keyword file_range_write_from_url: Only update is supported: - Update: Writes the bytes downloaded from the source url into the specified range. Default value is "update". Note that @@ -49,7 +49,7 @@ def __init__( allow_source_trailing_dot: Optional[bool] = None, **kwargs: Any ) -> None: - version: Literal["2024-05-04"] = kwargs.pop("version", "2024-05-04") + version: Literal["2024-08-04"] = kwargs.pop("version", "2024-08-04") file_range_write_from_url: Literal["update"] = kwargs.pop("file_range_write_from_url", "update") if url is None: diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/_patch.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/_patch.py index f99e77fef986..4688ca7f8ac2 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/_patch.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/_patch.py @@ -27,5 +27,7 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md + + def patch_sdk(): pass diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/operations/_directory_operations.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/operations/_directory_operations.py index 583cf184473f..2877ddb3fa11 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/operations/_directory_operations.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/operations/_directory_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, List, Literal, Optional, TypeVar, Union +import sys +from typing import Any, Callable, Dict, List, Literal, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -36,6 +37,10 @@ build_set_properties_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -109,7 +114,7 @@ async def create( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -205,7 +210,7 @@ async def get_properties( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -292,7 +297,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -385,7 +390,7 @@ async def set_properties( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -480,7 +485,7 @@ async def set_metadata( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -578,7 +583,7 @@ async def list_files_and_directories_segment( :rtype: ~azure.storage.fileshare.models.ListFilesAndDirectoriesSegmentResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -674,7 +679,7 @@ async def list_handles( :rtype: ~azure.storage.fileshare.models.ListHandlesResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -765,7 +770,7 @@ async def force_close_handles( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -885,7 +890,7 @@ async def rename( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/operations/_file_operations.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/operations/_file_operations.py index 406411dc60e8..8aa0012fd84a 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/operations/_file_operations.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/operations/_file_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterator, Callable, Dict, IO, Literal, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterator, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -45,6 +46,10 @@ build_upload_range_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -127,7 +132,7 @@ async def create( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -256,7 +261,7 @@ async def download( :rtype: AsyncIterator[bytes] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -457,7 +462,7 @@ async def get_properties( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -572,7 +577,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -679,7 +684,7 @@ async def set_http_headers( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -803,7 +808,7 @@ async def set_metadata( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -893,7 +898,7 @@ async def acquire_lease( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -973,7 +978,7 @@ async def release_lease( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1060,7 +1065,7 @@ async def change_lease( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1144,7 +1149,7 @@ async def break_lease( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1258,7 +1263,7 @@ async def upload_range( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1384,7 +1389,7 @@ async def upload_range_from_url( # pylint: disable=inconsistent-return-statemen :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1503,7 +1508,7 @@ async def get_range_list( :rtype: ~azure.storage.fileshare.models.ShareFileRangeList :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1614,7 +1619,7 @@ async def start_copy( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1720,7 +1725,7 @@ async def abort_copy( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1809,7 +1814,7 @@ async def list_handles( :rtype: ~azure.storage.fileshare.models.ListHandlesResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1895,7 +1900,7 @@ async def force_close_handles( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2017,7 +2022,7 @@ async def rename( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/operations/_patch.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/operations/_patch.py index f7dd32510333..49900f6ab120 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/operations/_patch.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/operations/_patch.py @@ -2,6 +2,7 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # ------------------------------------ + """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/operations/_service_operations.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/operations/_service_operations.py index 5232833a70c0..82b5d5681cc2 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/operations/_service_operations.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/operations/_service_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, List, Literal, Optional, TypeVar, Union +import sys +from typing import Any, Callable, Dict, List, Literal, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -30,6 +31,10 @@ build_set_properties_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +76,7 @@ async def set_properties( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -136,7 +141,7 @@ async def get_properties(self, timeout: Optional[int] = None, **kwargs: Any) -> :rtype: ~azure.storage.fileshare.models.StorageServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -223,7 +228,7 @@ async def list_shares_segment( :rtype: ~azure.storage.fileshare.models.ListSharesResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/operations/_share_operations.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/operations/_share_operations.py index 0734e23b452b..bb89d8fb19c1 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/operations/_share_operations.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/aio/operations/_share_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, List, Literal, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, List, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -45,6 +46,10 @@ build_set_properties_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,6 +82,7 @@ async def create( # pylint: disable=inconsistent-return-statements access_tier: Optional[Union[str, _models.ShareAccessTier]] = None, enabled_protocols: Optional[str] = None, root_squash: Optional[Union[str, _models.ShareRootSquash]] = None, + enable_snapshot_virtual_directory_access: Optional[bool] = None, **kwargs: Any ) -> None: """Creates a new share under the specified account. If the share with the same name already @@ -100,11 +106,13 @@ async def create( # pylint: disable=inconsistent-return-statements :param root_squash: Root squash to set on the share. Only valid for NFS shares. Known values are: "NoRootSquash", "RootSquash", and "AllSquash". Default value is None. :type root_squash: str or ~azure.storage.fileshare.models.ShareRootSquash + :param enable_snapshot_virtual_directory_access: Default value is None. + :type enable_snapshot_virtual_directory_access: bool :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -126,6 +134,7 @@ async def create( # pylint: disable=inconsistent-return-statements access_tier=access_tier, enabled_protocols=enabled_protocols, root_squash=root_squash, + enable_snapshot_virtual_directory_access=enable_snapshot_virtual_directory_access, restype=restype, version=self._config.version, headers=_headers, @@ -181,7 +190,7 @@ async def get_properties( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -261,6 +270,9 @@ async def get_properties( # pylint: disable=inconsistent-return-statements "str", response.headers.get("x-ms-enabled-protocols") ) response_headers["x-ms-root-squash"] = self._deserialize("str", response.headers.get("x-ms-root-squash")) + response_headers["x-ms-enable-snapshot-virtual-directory-access"] = self._deserialize( + "bool", response.headers.get("x-ms-enable-snapshot-virtual-directory-access") + ) if cls: return cls(pipeline_response, None, response_headers) # type: ignore @@ -294,7 +306,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -383,7 +395,7 @@ async def acquire_lease( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -472,7 +484,7 @@ async def release_lease( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -564,7 +576,7 @@ async def change_lease( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -653,7 +665,7 @@ async def renew_lease( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -750,7 +762,7 @@ async def break_lease( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -832,7 +844,7 @@ async def create_snapshot( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -953,7 +965,7 @@ async def create_permission( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1033,7 +1045,7 @@ async def get_permission( :rtype: ~azure.storage.fileshare.models.SharePermission :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1093,6 +1105,7 @@ async def set_properties( # pylint: disable=inconsistent-return-statements quota: Optional[int] = None, access_tier: Optional[Union[str, _models.ShareAccessTier]] = None, root_squash: Optional[Union[str, _models.ShareRootSquash]] = None, + enable_snapshot_virtual_directory_access: Optional[bool] = None, lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, **kwargs: Any ) -> None: @@ -1111,13 +1124,15 @@ async def set_properties( # pylint: disable=inconsistent-return-statements :param root_squash: Root squash to set on the share. Only valid for NFS shares. Known values are: "NoRootSquash", "RootSquash", and "AllSquash". Default value is None. :type root_squash: str or ~azure.storage.fileshare.models.ShareRootSquash + :param enable_snapshot_virtual_directory_access: Default value is None. + :type enable_snapshot_virtual_directory_access: bool :param lease_access_conditions: Parameter group. Default value is None. :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1143,6 +1158,7 @@ async def set_properties( # pylint: disable=inconsistent-return-statements access_tier=access_tier, lease_id=_lease_id, root_squash=root_squash, + enable_snapshot_virtual_directory_access=enable_snapshot_virtual_directory_access, restype=restype, comp=comp, version=self._config.version, @@ -1198,7 +1214,7 @@ async def set_metadata( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1273,7 +1289,7 @@ async def get_access_policy( :rtype: list[~azure.storage.fileshare.models.SignedIdentifier] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1354,7 +1370,7 @@ async def set_access_policy( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1438,7 +1454,7 @@ async def get_statistics( :rtype: ~azure.storage.fileshare.models.ShareStats :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1526,7 +1542,7 @@ async def restore( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/models/_models_py3.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/models/_models_py3.py index 94f5fcac3f72..181502b972ac 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/models/_models_py3.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/models/_models_py3.py @@ -1239,6 +1239,8 @@ class SharePropertiesInternal(_serialization.Model): # pylint: disable=too-many :vartype enabled_protocols: str :ivar root_squash: Known values are: "NoRootSquash", "RootSquash", and "AllSquash". :vartype root_squash: str or ~azure.storage.fileshare.models.ShareRootSquash + :ivar enable_snapshot_virtual_directory_access: + :vartype enable_snapshot_virtual_directory_access: bool """ _validation = { @@ -1266,6 +1268,7 @@ class SharePropertiesInternal(_serialization.Model): # pylint: disable=too-many "lease_duration": {"key": "LeaseDuration", "type": "str"}, "enabled_protocols": {"key": "EnabledProtocols", "type": "str"}, "root_squash": {"key": "RootSquash", "type": "str"}, + "enable_snapshot_virtual_directory_access": {"key": "EnableSnapshotVirtualDirectoryAccess", "type": "bool"}, } def __init__( @@ -1289,6 +1292,7 @@ def __init__( lease_duration: Optional[Union[str, "_models.LeaseDurationType"]] = None, enabled_protocols: Optional[str] = None, root_squash: Optional[Union[str, "_models.ShareRootSquash"]] = None, + enable_snapshot_virtual_directory_access: Optional[bool] = None, **kwargs: Any ) -> None: """ @@ -1331,6 +1335,8 @@ def __init__( :paramtype enabled_protocols: str :keyword root_squash: Known values are: "NoRootSquash", "RootSquash", and "AllSquash". :paramtype root_squash: str or ~azure.storage.fileshare.models.ShareRootSquash + :keyword enable_snapshot_virtual_directory_access: + :paramtype enable_snapshot_virtual_directory_access: bool """ super().__init__(**kwargs) self.last_modified = last_modified @@ -1351,6 +1357,7 @@ def __init__( self.lease_duration = lease_duration self.enabled_protocols = enabled_protocols self.root_squash = root_squash + self.enable_snapshot_virtual_directory_access = enable_snapshot_virtual_directory_access class ShareProtocolSettings(_serialization.Model): diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/models/_patch.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/models/_patch.py index f7dd32510333..49900f6ab120 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/models/_patch.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/models/_patch.py @@ -2,6 +2,7 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # ------------------------------------ + """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/operations/_directory_operations.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/operations/_directory_operations.py index 03bfd31171bf..52e76948e026 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/operations/_directory_operations.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/operations/_directory_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, List, Literal, Optional, TypeVar, Union +import sys +from typing import Any, Callable, Dict, List, Literal, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -26,6 +27,10 @@ from .._serialization import Serializer from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +57,7 @@ def build_create_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) restype: Literal["directory"] = kwargs.pop("restype", _params.pop("restype", "directory")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -105,7 +110,7 @@ def build_get_properties_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) restype: Literal["directory"] = kwargs.pop("restype", _params.pop("restype", "directory")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -146,7 +151,7 @@ def build_delete_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) restype: Literal["directory"] = kwargs.pop("restype", _params.pop("restype", "directory")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -192,7 +197,7 @@ def build_set_properties_request( restype: Literal["directory"] = kwargs.pop("restype", _params.pop("restype", "directory")) comp: Literal["properties"] = kwargs.pop("comp", _params.pop("comp", "properties")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -245,7 +250,7 @@ def build_set_metadata_request( restype: Literal["directory"] = kwargs.pop("restype", _params.pop("restype", "directory")) comp: Literal["metadata"] = kwargs.pop("comp", _params.pop("comp", "metadata")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -294,7 +299,7 @@ def build_list_files_and_directories_segment_request( # pylint: disable=name-to restype: Literal["directory"] = kwargs.pop("restype", _params.pop("restype", "directory")) comp: Literal["list"] = kwargs.pop("comp", _params.pop("comp", "list")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -350,7 +355,7 @@ def build_list_handles_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) comp: Literal["listhandles"] = kwargs.pop("comp", _params.pop("comp", "listhandles")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -401,7 +406,7 @@ def build_force_close_handles_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) comp: Literal["forceclosehandles"] = kwargs.pop("comp", _params.pop("comp", "forceclosehandles")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -461,7 +466,7 @@ def build_rename_request( restype: Literal["directory"] = kwargs.pop("restype", _params.pop("restype", "directory")) comp: Literal["rename"] = kwargs.pop("comp", _params.pop("comp", "rename")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -587,7 +592,7 @@ def create( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -683,7 +688,7 @@ def get_properties( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -770,7 +775,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -863,7 +868,7 @@ def set_properties( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -958,7 +963,7 @@ def set_metadata( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1056,7 +1061,7 @@ def list_files_and_directories_segment( :rtype: ~azure.storage.fileshare.models.ListFilesAndDirectoriesSegmentResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1152,7 +1157,7 @@ def list_handles( :rtype: ~azure.storage.fileshare.models.ListHandlesResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1243,7 +1248,7 @@ def force_close_handles( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1363,7 +1368,7 @@ def rename( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/operations/_file_operations.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/operations/_file_operations.py index bec5b64e3145..a26b1206aa0a 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/operations/_file_operations.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/operations/_file_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterator, Literal, Optional, TypeVar, Union +import sys +from typing import Any, Callable, Dict, IO, Iterator, Literal, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -26,6 +27,10 @@ from .._serialization import Serializer from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -60,7 +65,7 @@ def build_create_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) file_type_constant: Literal["file"] = kwargs.pop("file_type_constant", _headers.pop("x-ms-type", "file")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -131,7 +136,7 @@ def build_download_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -178,7 +183,7 @@ def build_get_properties_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -220,7 +225,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -274,7 +279,7 @@ def build_set_http_headers_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) comp: Literal["properties"] = kwargs.pop("comp", _params.pop("comp", "properties")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -344,7 +349,7 @@ def build_set_metadata_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) comp: Literal["metadata"] = kwargs.pop("comp", _params.pop("comp", "metadata")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -391,7 +396,7 @@ def build_acquire_lease_request( comp: Literal["lease"] = kwargs.pop("comp", _params.pop("comp", "lease")) action: Literal["acquire"] = kwargs.pop("action", _headers.pop("x-ms-lease-action", "acquire")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -440,7 +445,7 @@ def build_release_lease_request( comp: Literal["lease"] = kwargs.pop("comp", _params.pop("comp", "lease")) action: Literal["release"] = kwargs.pop("action", _headers.pop("x-ms-lease-action", "release")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -487,7 +492,7 @@ def build_change_lease_request( comp: Literal["lease"] = kwargs.pop("comp", _params.pop("comp", "lease")) action: Literal["change"] = kwargs.pop("action", _headers.pop("x-ms-lease-action", "change")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -535,7 +540,7 @@ def build_break_lease_request( comp: Literal["lease"] = kwargs.pop("comp", _params.pop("comp", "lease")) action: Literal["break"] = kwargs.pop("action", _headers.pop("x-ms-lease-action", "break")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -587,7 +592,7 @@ def build_upload_range_request( comp: Literal["range"] = kwargs.pop("comp", _params.pop("comp", "range")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -653,7 +658,7 @@ def build_upload_range_from_url_request( file_range_write_from_url: Literal["update"] = kwargs.pop( "file_range_write_from_url", _headers.pop("x-ms-write", "update") ) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -729,7 +734,7 @@ def build_get_range_list_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) comp: Literal["rangelist"] = kwargs.pop("comp", _params.pop("comp", "rangelist")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -790,7 +795,7 @@ def build_start_copy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -864,7 +869,7 @@ def build_abort_copy_request( copy_action_abort_constant: Literal["abort"] = kwargs.pop( "copy_action_abort_constant", _headers.pop("x-ms-copy-action", "abort") ) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -910,7 +915,7 @@ def build_list_handles_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) comp: Literal["listhandles"] = kwargs.pop("comp", _params.pop("comp", "listhandles")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -958,7 +963,7 @@ def build_force_close_handles_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) comp: Literal["forceclosehandles"] = kwargs.pop("comp", _params.pop("comp", "forceclosehandles")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -1016,7 +1021,7 @@ def build_rename_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) comp: Literal["rename"] = kwargs.pop("comp", _params.pop("comp", "rename")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -1152,7 +1157,7 @@ def create( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1281,7 +1286,7 @@ def download( :rtype: Iterator[bytes] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1482,7 +1487,7 @@ def get_properties( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1597,7 +1602,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1704,7 +1709,7 @@ def set_http_headers( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1828,7 +1833,7 @@ def set_metadata( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1918,7 +1923,7 @@ def acquire_lease( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1998,7 +2003,7 @@ def release_lease( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2085,7 +2090,7 @@ def change_lease( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2169,7 +2174,7 @@ def break_lease( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2283,7 +2288,7 @@ def upload_range( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2409,7 +2414,7 @@ def upload_range_from_url( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2528,7 +2533,7 @@ def get_range_list( :rtype: ~azure.storage.fileshare.models.ShareFileRangeList :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2639,7 +2644,7 @@ def start_copy( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2745,7 +2750,7 @@ def abort_copy( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2834,7 +2839,7 @@ def list_handles( :rtype: ~azure.storage.fileshare.models.ListHandlesResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2920,7 +2925,7 @@ def force_close_handles( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3042,7 +3047,7 @@ def rename( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/operations/_patch.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/operations/_patch.py index f7dd32510333..49900f6ab120 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/operations/_patch.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/operations/_patch.py @@ -2,6 +2,7 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # ------------------------------------ + """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/operations/_service_operations.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/operations/_service_operations.py index 187801dc381d..7923f4cc5bcc 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/operations/_service_operations.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/operations/_service_operations.py @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, List, Literal, Optional, TypeVar, Union +import sys +from typing import Any, Callable, Dict, List, Literal, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -26,6 +27,10 @@ from .._serialization import Serializer from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +47,7 @@ def build_set_properties_request( restype: Literal["service"] = kwargs.pop("restype", _params.pop("restype", "service")) comp: Literal["properties"] = kwargs.pop("comp", _params.pop("comp", "properties")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -74,7 +79,7 @@ def build_get_properties_request(url: str, *, timeout: Optional[int] = None, **k restype: Literal["service"] = kwargs.pop("restype", _params.pop("restype", "service")) comp: Literal["properties"] = kwargs.pop("comp", _params.pop("comp", "properties")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -112,7 +117,7 @@ def build_list_shares_segment_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) comp: Literal["list"] = kwargs.pop("comp", _params.pop("comp", "list")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -180,7 +185,7 @@ def set_properties( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,7 +250,7 @@ def get_properties(self, timeout: Optional[int] = None, **kwargs: Any) -> _model :rtype: ~azure.storage.fileshare.models.StorageServiceProperties :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -332,7 +337,7 @@ def list_shares_segment( :rtype: ~azure.storage.fileshare.models.ListSharesResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/operations/_share_operations.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/operations/_share_operations.py index 9f73185677b4..4f78e8fd55ff 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/operations/_share_operations.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_generated/operations/_share_operations.py @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, List, Literal, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, List, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,6 +28,10 @@ from .._serialization import Serializer from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,13 +48,14 @@ def build_create_request( access_tier: Optional[Union[str, _models.ShareAccessTier]] = None, enabled_protocols: Optional[str] = None, root_squash: Optional[Union[str, _models.ShareRootSquash]] = None, + enable_snapshot_virtual_directory_access: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -77,6 +83,10 @@ def build_create_request( _headers["x-ms-enabled-protocols"] = _SERIALIZER.header("enabled_protocols", enabled_protocols, "str") if root_squash is not None: _headers["x-ms-root-squash"] = _SERIALIZER.header("root_squash", root_squash, "str") + if enable_snapshot_virtual_directory_access is not None: + _headers["x-ms-enable-snapshot-virtual-directory-access"] = _SERIALIZER.header( + "enable_snapshot_virtual_directory_access", enable_snapshot_virtual_directory_access, "bool" + ) _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) @@ -94,7 +104,7 @@ def build_get_properties_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -134,7 +144,7 @@ def build_delete_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -179,7 +189,7 @@ def build_acquire_lease_request( comp: Literal["lease"] = kwargs.pop("comp", _params.pop("comp", "lease")) action: Literal["acquire"] = kwargs.pop("action", _headers.pop("x-ms-lease-action", "acquire")) restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -227,7 +237,7 @@ def build_release_lease_request( comp: Literal["lease"] = kwargs.pop("comp", _params.pop("comp", "lease")) action: Literal["release"] = kwargs.pop("action", _headers.pop("x-ms-lease-action", "release")) restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -273,7 +283,7 @@ def build_change_lease_request( comp: Literal["lease"] = kwargs.pop("comp", _params.pop("comp", "lease")) action: Literal["change"] = kwargs.pop("action", _headers.pop("x-ms-lease-action", "change")) restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -320,7 +330,7 @@ def build_renew_lease_request( comp: Literal["lease"] = kwargs.pop("comp", _params.pop("comp", "lease")) action: Literal["renew"] = kwargs.pop("action", _headers.pop("x-ms-lease-action", "renew")) restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -366,7 +376,7 @@ def build_break_lease_request( comp: Literal["lease"] = kwargs.pop("comp", _params.pop("comp", "lease")) action: Literal["break"] = kwargs.pop("action", _headers.pop("x-ms-lease-action", "break")) restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -407,7 +417,7 @@ def build_create_snapshot_request( restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) comp: Literal["snapshot"] = kwargs.pop("comp", _params.pop("comp", "snapshot")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -446,7 +456,7 @@ def build_create_permission_request( restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) comp: Literal["filepermission"] = kwargs.pop("comp", _params.pop("comp", "filepermission")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -487,7 +497,7 @@ def build_get_permission_request( restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) comp: Literal["filepermission"] = kwargs.pop("comp", _params.pop("comp", "filepermission")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -522,6 +532,7 @@ def build_set_properties_request( access_tier: Optional[Union[str, _models.ShareAccessTier]] = None, lease_id: Optional[str] = None, root_squash: Optional[Union[str, _models.ShareRootSquash]] = None, + enable_snapshot_virtual_directory_access: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -529,7 +540,7 @@ def build_set_properties_request( restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) comp: Literal["properties"] = kwargs.pop("comp", _params.pop("comp", "properties")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -556,6 +567,10 @@ def build_set_properties_request( _headers["x-ms-lease-id"] = _SERIALIZER.header("lease_id", lease_id, "str") if root_squash is not None: _headers["x-ms-root-squash"] = _SERIALIZER.header("root_squash", root_squash, "str") + if enable_snapshot_virtual_directory_access is not None: + _headers["x-ms-enable-snapshot-virtual-directory-access"] = _SERIALIZER.header( + "enable_snapshot_virtual_directory_access", enable_snapshot_virtual_directory_access, "bool" + ) _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) @@ -574,7 +589,7 @@ def build_set_metadata_request( restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) comp: Literal["metadata"] = kwargs.pop("comp", _params.pop("comp", "metadata")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -610,7 +625,7 @@ def build_get_access_policy_request( restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) comp: Literal["acl"] = kwargs.pop("comp", _params.pop("comp", "acl")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -645,7 +660,7 @@ def build_set_access_policy_request( restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) comp: Literal["acl"] = kwargs.pop("comp", _params.pop("comp", "acl")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -681,7 +696,7 @@ def build_get_statistics_request( restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) comp: Literal["stats"] = kwargs.pop("comp", _params.pop("comp", "stats")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -721,7 +736,7 @@ def build_restore_request( restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) comp: Literal["undelete"] = kwargs.pop("comp", _params.pop("comp", "undelete")) - version: Literal["2024-05-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-05-04")) + version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04")) accept = _headers.pop("Accept", "application/xml") # Construct URL @@ -781,6 +796,7 @@ def create( # pylint: disable=inconsistent-return-statements access_tier: Optional[Union[str, _models.ShareAccessTier]] = None, enabled_protocols: Optional[str] = None, root_squash: Optional[Union[str, _models.ShareRootSquash]] = None, + enable_snapshot_virtual_directory_access: Optional[bool] = None, **kwargs: Any ) -> None: """Creates a new share under the specified account. If the share with the same name already @@ -804,11 +820,13 @@ def create( # pylint: disable=inconsistent-return-statements :param root_squash: Root squash to set on the share. Only valid for NFS shares. Known values are: "NoRootSquash", "RootSquash", and "AllSquash". Default value is None. :type root_squash: str or ~azure.storage.fileshare.models.ShareRootSquash + :param enable_snapshot_virtual_directory_access: Default value is None. + :type enable_snapshot_virtual_directory_access: bool :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -830,6 +848,7 @@ def create( # pylint: disable=inconsistent-return-statements access_tier=access_tier, enabled_protocols=enabled_protocols, root_squash=root_squash, + enable_snapshot_virtual_directory_access=enable_snapshot_virtual_directory_access, restype=restype, version=self._config.version, headers=_headers, @@ -885,7 +904,7 @@ def get_properties( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -965,6 +984,9 @@ def get_properties( # pylint: disable=inconsistent-return-statements "str", response.headers.get("x-ms-enabled-protocols") ) response_headers["x-ms-root-squash"] = self._deserialize("str", response.headers.get("x-ms-root-squash")) + response_headers["x-ms-enable-snapshot-virtual-directory-access"] = self._deserialize( + "bool", response.headers.get("x-ms-enable-snapshot-virtual-directory-access") + ) if cls: return cls(pipeline_response, None, response_headers) # type: ignore @@ -998,7 +1020,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1087,7 +1109,7 @@ def acquire_lease( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1176,7 +1198,7 @@ def release_lease( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1268,7 +1290,7 @@ def change_lease( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1357,7 +1379,7 @@ def renew_lease( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1454,7 +1476,7 @@ def break_lease( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1536,7 +1558,7 @@ def create_snapshot( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1657,7 +1679,7 @@ def create_permission( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1737,7 +1759,7 @@ def get_permission( :rtype: ~azure.storage.fileshare.models.SharePermission :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1797,6 +1819,7 @@ def set_properties( # pylint: disable=inconsistent-return-statements quota: Optional[int] = None, access_tier: Optional[Union[str, _models.ShareAccessTier]] = None, root_squash: Optional[Union[str, _models.ShareRootSquash]] = None, + enable_snapshot_virtual_directory_access: Optional[bool] = None, lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, **kwargs: Any ) -> None: @@ -1815,13 +1838,15 @@ def set_properties( # pylint: disable=inconsistent-return-statements :param root_squash: Root squash to set on the share. Only valid for NFS shares. Known values are: "NoRootSquash", "RootSquash", and "AllSquash". Default value is None. :type root_squash: str or ~azure.storage.fileshare.models.ShareRootSquash + :param enable_snapshot_virtual_directory_access: Default value is None. + :type enable_snapshot_virtual_directory_access: bool :param lease_access_conditions: Parameter group. Default value is None. :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1847,6 +1872,7 @@ def set_properties( # pylint: disable=inconsistent-return-statements access_tier=access_tier, lease_id=_lease_id, root_squash=root_squash, + enable_snapshot_virtual_directory_access=enable_snapshot_virtual_directory_access, restype=restype, comp=comp, version=self._config.version, @@ -1902,7 +1928,7 @@ def set_metadata( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1977,7 +2003,7 @@ def get_access_policy( :rtype: list[~azure.storage.fileshare.models.SignedIdentifier] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2058,7 +2084,7 @@ def set_access_policy( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2142,7 +2168,7 @@ def get_statistics( :rtype: ~azure.storage.fileshare.models.ShareStats :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2230,7 +2256,7 @@ def restore( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_models.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_models.py index 135f28c4b89e..5a1e1c6fbbe9 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_models.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_models.py @@ -393,6 +393,7 @@ def _from_generated(cls, generated): props.protocols = [protocol.strip() for protocol in generated.properties.enabled_protocols.split(',')]\ if generated.properties.enabled_protocols else None props.root_squash = generated.properties.root_squash + props.enable_snapshot_virtual_directory_access = generated.properties.enable_snapshot_virtual_directory_access return props diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py index abbbfe88127f..81d0f39b7627 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py @@ -8,6 +8,7 @@ import re from typing import List, Tuple from urllib.parse import unquote, urlparse +from functools import cmp_to_key try: from yarl import URL @@ -26,6 +27,75 @@ logger = logging.getLogger(__name__) +table_lv0 = [ + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x71c, 0x0, 0x71f, 0x721, 0x723, 0x725, + 0x0, 0x0, 0x0, 0x72d, 0x803, 0x0, 0x0, 0x733, 0x0, 0x0, 0xd1a, 0xd1c, 0xd1e, + 0xd20, 0xd22, 0xd24, 0xd26, 0xd28, 0xd2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0xe02, 0xe09, 0xe0a, 0xe1a, 0xe21, 0xe23, 0xe25, 0xe2c, 0xe32, 0xe35, 0xe36, 0xe48, 0xe51, + 0xe70, 0xe7c, 0xe7e, 0xe89, 0xe8a, 0xe91, 0xe99, 0xe9f, 0xea2, 0xea4, 0xea6, 0xea7, 0xea9, + 0x0, 0x0, 0x0, 0x743, 0x744, 0x748, 0xe02, 0xe09, 0xe0a, 0xe1a, 0xe21, 0xe23, 0xe25, + 0xe2c, 0xe32, 0xe35, 0xe36, 0xe48, 0xe51, 0xe70, 0xe7c, 0xe7e, 0xe89, 0xe8a, 0xe91, 0xe99, + 0xe9f, 0xea2, 0xea4, 0xea6, 0xea7, 0xea9, 0x0, 0x74c, 0x0, 0x750, 0x0, +] + +table_lv2 = [ + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, + 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, +] + +table_lv4 = [ + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8012, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8212, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, +] + +def compare(lhs: str, rhs: str): + tables = [table_lv0, table_lv2, table_lv4] + curr_level, i, j, n = 0, 0, 0, len(tables) + while curr_level < n: + if curr_level == (n - 1) and i != j: + if i > j: + return -1 + elif i < j: + return 1 + else: + return 0 + + w1 = tables[curr_level][ord(lhs[i])] if i < len(lhs) else 0x1 + w2 = tables[curr_level][ord(rhs[j])] if j < len(rhs) else 0x1 + + if w1 == 0x1 and w2 == 0x1: + i, j = 0, 0 + curr_level += 1 + elif w1 == w2: + i += 1 + j += 1 + elif w1 == 0: + i += 1 + elif w2 == 0: + j += 1 + else: + if w1 < w2: + return -1 + elif w1 > w2: + return 1 + else: + return 0 + return 1 + # wraps a given exception with the desired exception type def _wrap_exception(ex, desired_type): @@ -37,7 +107,7 @@ def _wrap_exception(ex, desired_type): # This method attempts to emulate the sorting done by the service def _storage_header_sort(input_headers: List[Tuple[str, str]]) -> List[Tuple[str, str]]: # Define the custom alphabet for weights - custom_weights = "-!#$%&*.^_|~+\"\'(),/`~0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]abcdefghijklmnopqrstuvwxyz{}" + # custom_weights = "-!#$%&*.^_|~+\"\'(),/`~0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]abcdefghijklmnopqrstuvwxyz{}" # Build dict of tuples and list of keys header_dict = {} @@ -48,7 +118,8 @@ def _storage_header_sort(input_headers: List[Tuple[str, str]]) -> List[Tuple[str # Sort according to custom defined weights try: - header_keys = sorted(header_keys, key=lambda word: [custom_weights.index(c) for c in word]) + # header_keys = sorted(header_keys, key=lambda word: [custom_weights.index(c) for c in word]) + header_keys = sorted(header_keys, key=cmp_to_key(compare)) except ValueError as exc: raise ValueError("Illegal character encountered when sorting headers.") from exc diff --git a/sdk/storage/azure-storage-file-share/tests/test_share.py b/sdk/storage/azure-storage-file-share/tests/test_share.py index 60333a24b904..1d4ab78c8eb4 100644 --- a/sdk/storage/azure-storage-file-share/tests/test_share.py +++ b/sdk/storage/azure-storage-file-share/tests/test_share.py @@ -746,6 +746,27 @@ def test_list_shares_no_options(self, **kwargs): self.assertNamedItemInContainer(shares, share.share_name) self._delete_shares() + @FileSharePreparer() + @recorded_by_proxy + def test_list_shares_enable_snapshot_virtual_directory_access(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + + self._setup(storage_account_name, storage_account_key) + share = self._create_share(protocols="NFS", enable_snapshot_virtual_directory_access=False) + + # Act + list_props = list(self.fsc.list_shares()) + share_props = share.get_share_properties() + + # Assert + assert list_props[0].protocols[0] == 'NFS' + assert list_props[0].enable_snapshot_virtual_directory_access is False + + assert share_props.protocols[0] == 'NFS' + assert share_props.enable_snapshot_virtual_directory_access is False + self._delete_shares() + @FileSharePreparer() @recorded_by_proxy def test_list_shares_no_options_for_premium_account(self, **kwargs): diff --git a/sdk/storage/azure-storage-file-share/tests/test_share_async.py b/sdk/storage/azure-storage-file-share/tests/test_share_async.py index 748e75a14222..617e99835583 100644 --- a/sdk/storage/azure-storage-file-share/tests/test_share_async.py +++ b/sdk/storage/azure-storage-file-share/tests/test_share_async.py @@ -742,6 +742,29 @@ async def test_list_shares_no_options(self, **kwargs): self.assertNamedItemInContainer(shares, share.share_name) await self._delete_shares(share.share_name) + @FileSharePreparer() + @recorded_by_proxy_async + async def test_list_shares_enable_snapshot_virtual_directory_access(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + + self._setup(storage_account_name, storage_account_key) + share = await self._create_share(protocols="NFS", enable_snapshot_virtual_directory_access=False) + + # Act + list_props = [] + async for s in self.fsc.list_shares(): + list_props.append(s) + share_props = await share.get_share_properties() + + # Assert + assert list_props[0].protocols[0] == 'NFS' + assert list_props[0].enable_snapshot_virtual_directory_access is False + + assert share_props.protocols[0] == 'NFS' + assert share_props.enable_snapshot_virtual_directory_access is False + await self._delete_shares() + @FileSharePreparer() @recorded_by_proxy_async async def test_list_shares_no_options_for_premium_account(self, **kwargs): From 0f1f391e3c9fe46ad4db241b9e5c3f2b7a0d32c0 Mon Sep 17 00:00:00 2001 From: Vincent Tran Date: Wed, 24 Apr 2024 20:05:15 -0700 Subject: [PATCH 03/15] Move docstring to correct place :) on API not ctor --- .../azure/storage/fileshare/_share_client.py | 8 ++++---- .../azure/storage/fileshare/aio/_share_client_async.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_share_client.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_share_client.py index 3172d1afca37..4cb324c035a3 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_share_client.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_share_client.py @@ -86,10 +86,6 @@ class ShareClient(StorageAccountHostsMixin): # pylint: disable=too-many-public-m :keyword str secondary_hostname: The hostname of the secondary endpoint. :keyword int max_range_size: The maximum range size used for a file upload. Defaults to 4*1024*1024. - :keyword bool enable_snapshot_virtual_directory_access: - Supported in service version 2023-08-03 and greater. Specifies whether the snapshot - virtual directory should be accessible at the root of the share mount point when NFS - is enabled. Default value is True. """ def __init__( self, account_url: str, @@ -366,6 +362,10 @@ def create_share(self, **kwargs): Root squash to set on the share. Only valid for NFS shares. Possible values include: 'NoRootSquash', 'RootSquash', 'AllSquash'. :paramtype root_squash: str or ~azure.storage.fileshare.ShareRootSquash + :keyword bool enable_snapshot_virtual_directory_access: + Supported in service version 2023-08-03 and greater. Specifies whether the snapshot + virtual directory should be accessible at the root of the share mount point when NFS + is enabled. Default value is True. :returns: Share-updated property dict (Etag and last modified). :rtype: Dict[str, Any] diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_share_client_async.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_share_client_async.py index 33f53b127698..9466a2753127 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_share_client_async.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_share_client_async.py @@ -82,10 +82,6 @@ class ShareClient(AsyncStorageAccountHostsMixin, ShareClientBase): :keyword str secondary_hostname: The hostname of the secondary endpoint. :keyword int max_range_size: The maximum range size used for a file upload. Defaults to 4*1024*1024. - :keyword bool enable_snapshot_virtual_directory_access: - Supported in service version 2023-08-03 and greater. Specifies whether the snapshot - virtual directory should be accessible at the root of the share mount point when NFS - is enabled. Default value is True. """ def __init__( self, account_url: str, @@ -229,6 +225,10 @@ async def create_share(self, **kwargs): Root squash to set on the share. Only valid for NFS shares. Possible values include: 'NoRootSquash', 'RootSquash', 'AllSquash'. :paramtype root_squash: str or ~azure.storage.fileshare.ShareRootSquash + :keyword bool enable_snapshot_virtual_directory_access: + Supported in service version 2023-08-03 and greater. Specifies whether the snapshot + virtual directory should be accessible at the root of the share mount point when NFS + is enabled. Default value is True. :returns: Share-updated property dict (Etag and last modified). :rtype: Dict[str, Any] From 3acfca3d726dd065a0e85d9c412ec4811364c5fc Mon Sep 17 00:00:00 2001 From: Vincent Tran Date: Thu, 25 Apr 2024 21:31:36 -0700 Subject: [PATCH 04/15] Recordings --- sdk/storage/azure-storage-file-share/assets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/storage/azure-storage-file-share/assets.json b/sdk/storage/azure-storage-file-share/assets.json index 75c74f0f875b..7a802253416e 100644 --- a/sdk/storage/azure-storage-file-share/assets.json +++ b/sdk/storage/azure-storage-file-share/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/storage/azure-storage-file-share", - "Tag": "python/storage/azure-storage-file-share_890795be5a" + "Tag": "python/storage/azure-storage-file-share_93f0b0b7e9" } From e637ceaa45699e81c63f84e69732fbe838f31622 Mon Sep 17 00:00:00 2001 From: Vincent Tran Date: Thu, 25 Apr 2024 21:33:37 -0700 Subject: [PATCH 05/15] Lint --- .../azure/storage/fileshare/_shared/authentication.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py index 81d0f39b7627..441ad29f7c2a 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py @@ -69,7 +69,7 @@ def compare(lhs: str, rhs: str): if curr_level == (n - 1) and i != j: if i > j: return -1 - elif i < j: + if i < j: return 1 else: return 0 @@ -90,7 +90,7 @@ def compare(lhs: str, rhs: str): else: if w1 < w2: return -1 - elif w1 > w2: + if w1 > w2: return 1 else: return 0 @@ -107,7 +107,6 @@ def _wrap_exception(ex, desired_type): # This method attempts to emulate the sorting done by the service def _storage_header_sort(input_headers: List[Tuple[str, str]]) -> List[Tuple[str, str]]: # Define the custom alphabet for weights - # custom_weights = "-!#$%&*.^_|~+\"\'(),/`~0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]abcdefghijklmnopqrstuvwxyz{}" # Build dict of tuples and list of keys header_dict = {} From 827187f901f5105a112375f4b15551445472a116 Mon Sep 17 00:00:00 2001 From: Vincent Tran Date: Fri, 26 Apr 2024 11:31:55 -0700 Subject: [PATCH 06/15] Lint --- .../azure/storage/fileshare/_shared/authentication.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py index 441ad29f7c2a..b713e401e553 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py @@ -62,7 +62,7 @@ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ] -def compare(lhs: str, rhs: str): +def compare(lhs: str, rhs: str): # pylint:disable=too-many-return-statements tables = [table_lv0, table_lv2, table_lv4] curr_level, i, j, n = 0, 0, 0, len(tables) while curr_level < n: @@ -71,8 +71,7 @@ def compare(lhs: str, rhs: str): return -1 if i < j: return 1 - else: - return 0 + return 0 w1 = tables[curr_level][ord(lhs[i])] if i < len(lhs) else 0x1 w2 = tables[curr_level][ord(rhs[j])] if j < len(rhs) else 0x1 @@ -92,8 +91,7 @@ def compare(lhs: str, rhs: str): return -1 if w1 > w2: return 1 - else: - return 0 + return 0 return 1 From bd12b0d0f25db0949d8c8ecdae9793e54d580074 Mon Sep 17 00:00:00 2001 From: Vincent Tran Date: Tue, 30 Apr 2024 13:35:11 -0700 Subject: [PATCH 07/15] PR feedback --- .../azure/storage/fileshare/_models.py | 5 ++--- .../azure/storage/fileshare/_share_client.py | 5 ++--- .../azure/storage/fileshare/aio/_share_client_async.py | 5 ++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_models.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_models.py index 5a1e1c6fbbe9..141de2b503f6 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_models.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_models.py @@ -342,9 +342,8 @@ class ShareProperties(DictMixin): :ivar list(str) protocols: Indicates the protocols enabled on the share. The protocol can be either SMB or NFS. :ivar bool enable_snapshot_virtual_directory_access: - Supported in service version 2023-08-03 and greater. Specifies whether the snapshot - virtual directory should be accessible at the root of the share mount point when NFS - is enabled. if not specified, the default is True. + Specifies whether the snapshot virtual directory should be accessible at the root of the share + mount point when NFS is enabled. if not specified, the default is True. """ def __init__(self, **kwargs): diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_share_client.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_share_client.py index 4cb324c035a3..2c7c154bb703 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_share_client.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_share_client.py @@ -363,9 +363,8 @@ def create_share(self, **kwargs): Only valid for NFS shares. Possible values include: 'NoRootSquash', 'RootSquash', 'AllSquash'. :paramtype root_squash: str or ~azure.storage.fileshare.ShareRootSquash :keyword bool enable_snapshot_virtual_directory_access: - Supported in service version 2023-08-03 and greater. Specifies whether the snapshot - virtual directory should be accessible at the root of the share mount point when NFS - is enabled. Default value is True. + Specifies whether the snapshot virtual directory should be accessible at the root of the share + mount point when NFS is enabled. Default value is True. :returns: Share-updated property dict (Etag and last modified). :rtype: Dict[str, Any] diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_share_client_async.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_share_client_async.py index 9466a2753127..2fc1c179aa9e 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_share_client_async.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_share_client_async.py @@ -226,9 +226,8 @@ async def create_share(self, **kwargs): Only valid for NFS shares. Possible values include: 'NoRootSquash', 'RootSquash', 'AllSquash'. :paramtype root_squash: str or ~azure.storage.fileshare.ShareRootSquash :keyword bool enable_snapshot_virtual_directory_access: - Supported in service version 2023-08-03 and greater. Specifies whether the snapshot - virtual directory should be accessible at the root of the share mount point when NFS - is enabled. Default value is True. + Specifies whether the snapshot virtual directory should be accessible at the root of the share + mount point when NFS is enabled. Default value is True. :returns: Share-updated property dict (Etag and last modified). :rtype: Dict[str, Any] From 6ef56279cbb19f6ebfeca72d7b903d75d5f1da49 Mon Sep 17 00:00:00 2001 From: Vincent Tran Date: Fri, 3 May 2024 16:41:38 -0700 Subject: [PATCH 08/15] Propagate new sorting header sorting to other packages, add in explicit test for previously failing test case in Blob --- sdk/storage/azure-storage-blob/assets.json | 2 +- .../storage/blob/_shared/authentication.py | 66 +++++++++++++++++-- .../tests/test_blob_access_conditions.py | 41 ++++++++++++ .../test_blob_access_conditions_async.py | 65 ++++++++++++++++++ .../filedatalake/_shared/authentication.py | 66 +++++++++++++++++-- .../fileshare/_shared/authentication.py | 27 +++----- .../storage/queue/_shared/authentication.py | 66 +++++++++++++++++-- 7 files changed, 301 insertions(+), 32 deletions(-) diff --git a/sdk/storage/azure-storage-blob/assets.json b/sdk/storage/azure-storage-blob/assets.json index c7ffdc341154..feaccf431cb2 100644 --- a/sdk/storage/azure-storage-blob/assets.json +++ b/sdk/storage/azure-storage-blob/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/storage/azure-storage-blob", - "Tag": "python/storage/azure-storage-blob_ba57356b0e" + "Tag": "python/storage/azure-storage-blob_f9158b580e" } diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/authentication.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/authentication.py index abbbfe88127f..9d2b6dc2bfcb 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/authentication.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/authentication.py @@ -8,6 +8,7 @@ import re from typing import List, Tuple from urllib.parse import unquote, urlparse +from functools import cmp_to_key try: from yarl import URL @@ -27,6 +28,66 @@ logger = logging.getLogger(__name__) +table_lv0 = [ + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x71c, 0x0, 0x71f, 0x721, 0x723, 0x725, + 0x0, 0x0, 0x0, 0x72d, 0x803, 0x0, 0x0, 0x733, 0x0, 0x0, 0xd1a, 0xd1c, 0xd1e, + 0xd20, 0xd22, 0xd24, 0xd26, 0xd28, 0xd2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0xe02, 0xe09, 0xe0a, 0xe1a, 0xe21, 0xe23, 0xe25, 0xe2c, 0xe32, 0xe35, 0xe36, 0xe48, 0xe51, + 0xe70, 0xe7c, 0xe7e, 0xe89, 0xe8a, 0xe91, 0xe99, 0xe9f, 0xea2, 0xea4, 0xea6, 0xea7, 0xea9, + 0x0, 0x0, 0x0, 0x743, 0x744, 0x748, 0xe02, 0xe09, 0xe0a, 0xe1a, 0xe21, 0xe23, 0xe25, + 0xe2c, 0xe32, 0xe35, 0xe36, 0xe48, 0xe51, 0xe70, 0xe7c, 0xe7e, 0xe89, 0xe8a, 0xe91, 0xe99, + 0xe9f, 0xea2, 0xea4, 0xea6, 0xea7, 0xea9, 0x0, 0x74c, 0x0, 0x750, 0x0, +] + +table_lv4 = [ + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8012, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8212, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, +] + +def compare(lhs: str, rhs: str) -> int: # pylint:disable=too-many-return-statements + tables = [table_lv0, table_lv4] + curr_level, i, j, n = 0, 0, 0, len(tables) + lhs_len = len(lhs) + rhs_len = len(rhs) + while curr_level < n: + if curr_level == (n - 1) and i != j: + if i > j: + return -1 + if i < j: + return 1 + return 0 + + w1 = tables[curr_level][ord(lhs[i])] if i < lhs_len else 0x1 + w2 = tables[curr_level][ord(rhs[j])] if j < rhs_len else 0x1 + + if w1 == 0x1 and w2 == 0x1: + i = 0 + j = 0 + curr_level += 1 + elif w1 == w2: + i += 1 + j += 1 + elif w1 == 0: + i += 1 + elif w2 == 0: + j += 1 + else: + if w1 < w2: + return -1 + if w1 > w2: + return 1 + return 0 + return 1 + + # wraps a given exception with the desired exception type def _wrap_exception(ex, desired_type): msg = "" @@ -36,8 +97,6 @@ def _wrap_exception(ex, desired_type): # This method attempts to emulate the sorting done by the service def _storage_header_sort(input_headers: List[Tuple[str, str]]) -> List[Tuple[str, str]]: - # Define the custom alphabet for weights - custom_weights = "-!#$%&*.^_|~+\"\'(),/`~0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]abcdefghijklmnopqrstuvwxyz{}" # Build dict of tuples and list of keys header_dict = {} @@ -46,9 +105,8 @@ def _storage_header_sort(input_headers: List[Tuple[str, str]]) -> List[Tuple[str header_dict[k] = v header_keys.append(k) - # Sort according to custom defined weights try: - header_keys = sorted(header_keys, key=lambda word: [custom_weights.index(c) for c in word]) + header_keys = sorted(header_keys, key=cmp_to_key(compare)) except ValueError as exc: raise ValueError("Illegal character encountered when sorting headers.") from exc diff --git a/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions.py b/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions.py index 18fbae7ef491..c4aba5e31a80 100644 --- a/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions.py +++ b/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions.py @@ -3124,4 +3124,45 @@ def test_header_metadata_sort_in_upload_blob(self, **kwargs): # Act blob_client.upload_blob(data, length=len(data), metadata=metadata) + @BlobPreparer() + @recorded_by_proxy + def test_header_metadata_sort_in_upload_blob_translation(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + + self._setup() + data = b'hello world' + bsc = BlobServiceClient(self.account_url(storage_account_name, "blob"), storage_account_key) + try: + container_client = bsc.create_container(self.container_name) + except: + container_client = bsc.get_container_client(self.container_name) + blob_client = container_client.get_blob_client('blob1') + + # Hand-picked metadata examples that sorted incorrectly with our previous implementation. + metadata = { + 'test': 'val', + 'test-': 'val', + 'test--': 'val', + 'test-_': 'val', + 'test_-': 'val', + 'test__': 'val', + 'test-a': 'val', + 'test-A': 'val', + 'test-_A': 'val', + 'test_a': 'val', + 'test_Z': 'val', + 'test_a_': 'val', + 'test_a-': 'val', + 'test_a-_': 'val', + } + + # Act + # If we hit invalid metadata error, that means we have successfully sorted headers properly to pass auth error + with pytest.raises(HttpResponseError) as e: + blob_client.upload_blob(data, length=len(data), metadata=metadata) + + # Assert + assert StorageErrorCode.invalid_metadata == e.value.error_code + # ------------------------------------------------------------------------------ diff --git a/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions_async.py b/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions_async.py index 2b21f444f00c..ac2a864851ed 100644 --- a/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions_async.py +++ b/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions_async.py @@ -3092,4 +3092,69 @@ async def test_header_metadata_sort_in_upload_blob(self, **kwargs): # Act await blob_client.upload_blob(data, length=len(data), metadata=metadata) + @BlobPreparer() + @recorded_by_proxy_async + async def test_header_metadata_sort_in_upload_blob(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + + self._setup() + data = b'hello world' + bsc = BlobServiceClient(self.account_url(storage_account_name, "blob"), storage_account_key) + try: + container_client = await bsc.create_container(self.container_name) + except: + container_client = bsc.get_container_client(self.container_name) + blob_client = container_client.get_blob_client('blob1') + + # Hand-picked metadata examples as Python & service don't sort '_' with the same weight + metadata = {'a0': 'a', 'a1': 'a', 'a2': 'a', 'a3': 'a', 'a4': 'a', 'a5': 'a', 'a6': 'a', 'a7': 'a', 'a8': 'a', + 'a9': 'a', '_': 'a', '_a': 'a', 'a_': 'a', '__': 'a', '_a_': 'a', 'b': 'a', 'c': 'a', 'y': 'a', + 'z': 'z_', '_z': 'a', '_F': 'a', 'F': 'a', 'F_': 'a', '_F_': 'a', '__F': 'a', '__a': 'a', 'a__': 'a' + } + + # Act + await blob_client.upload_blob(data, length=len(data), metadata=metadata) + + @BlobPreparer() + @recorded_by_proxy_async + async def test_header_metadata_sort_in_upload_blob_translation(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + + self._setup() + data = b'hello world' + bsc = BlobServiceClient(self.account_url(storage_account_name, "blob"), storage_account_key) + try: + container_client = await bsc.create_container(self.container_name) + except: + container_client = bsc.get_container_client(self.container_name) + blob_client = container_client.get_blob_client('blob1') + + # Hand-picked metadata examples that sorted incorrectly with our previous implementation. + metadata = { + 'test': 'val', + 'test-': 'val', + 'test--': 'val', + 'test-_': 'val', + 'test_-': 'val', + 'test__': 'val', + 'test-a': 'val', + 'test-A': 'val', + 'test-_A': 'val', + 'test_a': 'val', + 'test_Z': 'val', + 'test_a_': 'val', + 'test_a-': 'val', + 'test_a-_': 'val', + } + + # Act + # If we hit invalid metadata error, that means we have successfully sorted headers properly to pass auth error + with pytest.raises(HttpResponseError) as e: + await blob_client.upload_blob(data, length=len(data), metadata=metadata) + + # Assert + assert StorageErrorCode.invalid_metadata == e.value.error_code + # ------------------------------------------------------------------------------ diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/authentication.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/authentication.py index abbbfe88127f..9d2b6dc2bfcb 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/authentication.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/authentication.py @@ -8,6 +8,7 @@ import re from typing import List, Tuple from urllib.parse import unquote, urlparse +from functools import cmp_to_key try: from yarl import URL @@ -27,6 +28,66 @@ logger = logging.getLogger(__name__) +table_lv0 = [ + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x71c, 0x0, 0x71f, 0x721, 0x723, 0x725, + 0x0, 0x0, 0x0, 0x72d, 0x803, 0x0, 0x0, 0x733, 0x0, 0x0, 0xd1a, 0xd1c, 0xd1e, + 0xd20, 0xd22, 0xd24, 0xd26, 0xd28, 0xd2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0xe02, 0xe09, 0xe0a, 0xe1a, 0xe21, 0xe23, 0xe25, 0xe2c, 0xe32, 0xe35, 0xe36, 0xe48, 0xe51, + 0xe70, 0xe7c, 0xe7e, 0xe89, 0xe8a, 0xe91, 0xe99, 0xe9f, 0xea2, 0xea4, 0xea6, 0xea7, 0xea9, + 0x0, 0x0, 0x0, 0x743, 0x744, 0x748, 0xe02, 0xe09, 0xe0a, 0xe1a, 0xe21, 0xe23, 0xe25, + 0xe2c, 0xe32, 0xe35, 0xe36, 0xe48, 0xe51, 0xe70, 0xe7c, 0xe7e, 0xe89, 0xe8a, 0xe91, 0xe99, + 0xe9f, 0xea2, 0xea4, 0xea6, 0xea7, 0xea9, 0x0, 0x74c, 0x0, 0x750, 0x0, +] + +table_lv4 = [ + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8012, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8212, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, +] + +def compare(lhs: str, rhs: str) -> int: # pylint:disable=too-many-return-statements + tables = [table_lv0, table_lv4] + curr_level, i, j, n = 0, 0, 0, len(tables) + lhs_len = len(lhs) + rhs_len = len(rhs) + while curr_level < n: + if curr_level == (n - 1) and i != j: + if i > j: + return -1 + if i < j: + return 1 + return 0 + + w1 = tables[curr_level][ord(lhs[i])] if i < lhs_len else 0x1 + w2 = tables[curr_level][ord(rhs[j])] if j < rhs_len else 0x1 + + if w1 == 0x1 and w2 == 0x1: + i = 0 + j = 0 + curr_level += 1 + elif w1 == w2: + i += 1 + j += 1 + elif w1 == 0: + i += 1 + elif w2 == 0: + j += 1 + else: + if w1 < w2: + return -1 + if w1 > w2: + return 1 + return 0 + return 1 + + # wraps a given exception with the desired exception type def _wrap_exception(ex, desired_type): msg = "" @@ -36,8 +97,6 @@ def _wrap_exception(ex, desired_type): # This method attempts to emulate the sorting done by the service def _storage_header_sort(input_headers: List[Tuple[str, str]]) -> List[Tuple[str, str]]: - # Define the custom alphabet for weights - custom_weights = "-!#$%&*.^_|~+\"\'(),/`~0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]abcdefghijklmnopqrstuvwxyz{}" # Build dict of tuples and list of keys header_dict = {} @@ -46,9 +105,8 @@ def _storage_header_sort(input_headers: List[Tuple[str, str]]) -> List[Tuple[str header_dict[k] = v header_keys.append(k) - # Sort according to custom defined weights try: - header_keys = sorted(header_keys, key=lambda word: [custom_weights.index(c) for c in word]) + header_keys = sorted(header_keys, key=cmp_to_key(compare)) except ValueError as exc: raise ValueError("Illegal character encountered when sorting headers.") from exc diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py index b713e401e553..5e24a7cab6e0 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py @@ -40,17 +40,6 @@ 0xe9f, 0xea2, 0xea4, 0xea6, 0xea7, 0xea9, 0x0, 0x74c, 0x0, 0x750, 0x0, ] -table_lv2 = [ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, - 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -] - table_lv4 = [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, @@ -62,9 +51,11 @@ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ] -def compare(lhs: str, rhs: str): # pylint:disable=too-many-return-statements - tables = [table_lv0, table_lv2, table_lv4] +def compare(lhs: str, rhs: str) -> int: # pylint:disable=too-many-return-statements + tables = [table_lv0, table_lv4] curr_level, i, j, n = 0, 0, 0, len(tables) + lhs_len = len(lhs) + rhs_len = len(rhs) while curr_level < n: if curr_level == (n - 1) and i != j: if i > j: @@ -73,11 +64,12 @@ def compare(lhs: str, rhs: str): # pylint:disable=too-many-return-statements return 1 return 0 - w1 = tables[curr_level][ord(lhs[i])] if i < len(lhs) else 0x1 - w2 = tables[curr_level][ord(rhs[j])] if j < len(rhs) else 0x1 + w1 = tables[curr_level][ord(lhs[i])] if i < lhs_len else 0x1 + w2 = tables[curr_level][ord(rhs[j])] if j < rhs_len else 0x1 if w1 == 0x1 and w2 == 0x1: - i, j = 0, 0 + i = 0 + j = 0 curr_level += 1 elif w1 == w2: i += 1 @@ -104,7 +96,6 @@ def _wrap_exception(ex, desired_type): # This method attempts to emulate the sorting done by the service def _storage_header_sort(input_headers: List[Tuple[str, str]]) -> List[Tuple[str, str]]: - # Define the custom alphabet for weights # Build dict of tuples and list of keys header_dict = {} @@ -113,9 +104,7 @@ def _storage_header_sort(input_headers: List[Tuple[str, str]]) -> List[Tuple[str header_dict[k] = v header_keys.append(k) - # Sort according to custom defined weights try: - # header_keys = sorted(header_keys, key=lambda word: [custom_weights.index(c) for c in word]) header_keys = sorted(header_keys, key=cmp_to_key(compare)) except ValueError as exc: raise ValueError("Illegal character encountered when sorting headers.") from exc diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/authentication.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/authentication.py index abbbfe88127f..9d2b6dc2bfcb 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/authentication.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/authentication.py @@ -8,6 +8,7 @@ import re from typing import List, Tuple from urllib.parse import unquote, urlparse +from functools import cmp_to_key try: from yarl import URL @@ -27,6 +28,66 @@ logger = logging.getLogger(__name__) +table_lv0 = [ + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x71c, 0x0, 0x71f, 0x721, 0x723, 0x725, + 0x0, 0x0, 0x0, 0x72d, 0x803, 0x0, 0x0, 0x733, 0x0, 0x0, 0xd1a, 0xd1c, 0xd1e, + 0xd20, 0xd22, 0xd24, 0xd26, 0xd28, 0xd2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0xe02, 0xe09, 0xe0a, 0xe1a, 0xe21, 0xe23, 0xe25, 0xe2c, 0xe32, 0xe35, 0xe36, 0xe48, 0xe51, + 0xe70, 0xe7c, 0xe7e, 0xe89, 0xe8a, 0xe91, 0xe99, 0xe9f, 0xea2, 0xea4, 0xea6, 0xea7, 0xea9, + 0x0, 0x0, 0x0, 0x743, 0x744, 0x748, 0xe02, 0xe09, 0xe0a, 0xe1a, 0xe21, 0xe23, 0xe25, + 0xe2c, 0xe32, 0xe35, 0xe36, 0xe48, 0xe51, 0xe70, 0xe7c, 0xe7e, 0xe89, 0xe8a, 0xe91, 0xe99, + 0xe9f, 0xea2, 0xea4, 0xea6, 0xea7, 0xea9, 0x0, 0x74c, 0x0, 0x750, 0x0, +] + +table_lv4 = [ + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8012, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8212, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, +] + +def compare(lhs: str, rhs: str) -> int: # pylint:disable=too-many-return-statements + tables = [table_lv0, table_lv4] + curr_level, i, j, n = 0, 0, 0, len(tables) + lhs_len = len(lhs) + rhs_len = len(rhs) + while curr_level < n: + if curr_level == (n - 1) and i != j: + if i > j: + return -1 + if i < j: + return 1 + return 0 + + w1 = tables[curr_level][ord(lhs[i])] if i < lhs_len else 0x1 + w2 = tables[curr_level][ord(rhs[j])] if j < rhs_len else 0x1 + + if w1 == 0x1 and w2 == 0x1: + i = 0 + j = 0 + curr_level += 1 + elif w1 == w2: + i += 1 + j += 1 + elif w1 == 0: + i += 1 + elif w2 == 0: + j += 1 + else: + if w1 < w2: + return -1 + if w1 > w2: + return 1 + return 0 + return 1 + + # wraps a given exception with the desired exception type def _wrap_exception(ex, desired_type): msg = "" @@ -36,8 +97,6 @@ def _wrap_exception(ex, desired_type): # This method attempts to emulate the sorting done by the service def _storage_header_sort(input_headers: List[Tuple[str, str]]) -> List[Tuple[str, str]]: - # Define the custom alphabet for weights - custom_weights = "-!#$%&*.^_|~+\"\'(),/`~0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]abcdefghijklmnopqrstuvwxyz{}" # Build dict of tuples and list of keys header_dict = {} @@ -46,9 +105,8 @@ def _storage_header_sort(input_headers: List[Tuple[str, str]]) -> List[Tuple[str header_dict[k] = v header_keys.append(k) - # Sort according to custom defined weights try: - header_keys = sorted(header_keys, key=lambda word: [custom_weights.index(c) for c in word]) + header_keys = sorted(header_keys, key=cmp_to_key(compare)) except ValueError as exc: raise ValueError("Illegal character encountered when sorting headers.") from exc From 536d637e6776782311d5737c87bfaee47cdb17ac Mon Sep 17 00:00:00 2001 From: Vincent Tran Date: Tue, 14 May 2024 11:23:38 -0700 Subject: [PATCH 09/15] Fix test recordings --- sdk/storage/azure-storage-blob/assets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/storage/azure-storage-blob/assets.json b/sdk/storage/azure-storage-blob/assets.json index feaccf431cb2..f83761242371 100644 --- a/sdk/storage/azure-storage-blob/assets.json +++ b/sdk/storage/azure-storage-blob/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/storage/azure-storage-blob", - "Tag": "python/storage/azure-storage-blob_f9158b580e" + "Tag": "python/storage/azure-storage-blob_6ddae21536" } From 940b5721b60a5545502a4843e6bc6476f15e6967 Mon Sep 17 00:00:00 2001 From: Vincent Tran Date: Tue, 14 May 2024 12:24:32 -0700 Subject: [PATCH 10/15] Fix recordings again --- sdk/storage/azure-storage-blob/assets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/storage/azure-storage-blob/assets.json b/sdk/storage/azure-storage-blob/assets.json index f83761242371..9943346d65ba 100644 --- a/sdk/storage/azure-storage-blob/assets.json +++ b/sdk/storage/azure-storage-blob/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/storage/azure-storage-blob", - "Tag": "python/storage/azure-storage-blob_6ddae21536" + "Tag": "python/storage/azure-storage-blob_729418a751" } From 9c0c5e7c6ed3c6290a3016bac00b4a95aed27641 Mon Sep 17 00:00:00 2001 From: Vincent Tran Date: Tue, 14 May 2024 13:56:44 -0700 Subject: [PATCH 11/15] Recordings again.. --- sdk/storage/azure-storage-blob/assets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/storage/azure-storage-blob/assets.json b/sdk/storage/azure-storage-blob/assets.json index 9943346d65ba..26c9cbaab4af 100644 --- a/sdk/storage/azure-storage-blob/assets.json +++ b/sdk/storage/azure-storage-blob/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/storage/azure-storage-blob", - "Tag": "python/storage/azure-storage-blob_729418a751" + "Tag": "python/storage/azure-storage-blob_cf0fe15e9f" } From 7b4f68c2eb059d7edeba835315a565c2a8f761b7 Mon Sep 17 00:00:00 2001 From: Vincent Tran Date: Tue, 14 May 2024 15:11:15 -0700 Subject: [PATCH 12/15] 1 more recording --- sdk/storage/azure-storage-blob/assets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/storage/azure-storage-blob/assets.json b/sdk/storage/azure-storage-blob/assets.json index 26c9cbaab4af..fce9d1a7c338 100644 --- a/sdk/storage/azure-storage-blob/assets.json +++ b/sdk/storage/azure-storage-blob/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/storage/azure-storage-blob", - "Tag": "python/storage/azure-storage-blob_cf0fe15e9f" + "Tag": "python/storage/azure-storage-blob_275000b78a" } From d13a9a1e0341c15a2fa93268a89acc285ace4ead Mon Sep 17 00:00:00 2001 From: Vincent Tran Date: Tue, 14 May 2024 17:44:30 -0700 Subject: [PATCH 13/15] Now fix file-share recordings.. --- sdk/storage/azure-storage-file-share/assets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/storage/azure-storage-file-share/assets.json b/sdk/storage/azure-storage-file-share/assets.json index c084ac07ee98..357e2cce5096 100644 --- a/sdk/storage/azure-storage-file-share/assets.json +++ b/sdk/storage/azure-storage-file-share/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/storage/azure-storage-file-share", - "Tag": "python/storage/azure-storage-file-share_a600655193" + "Tag": "python/storage/azure-storage-file-share_78435f7193" } From c595b3d85cefa3ddb98777299655bd76ed011fa0 Mon Sep 17 00:00:00 2001 From: Vincent Tran Date: Tue, 21 May 2024 11:45:28 -0700 Subject: [PATCH 14/15] Fix typo in copy-paste chart --- .../azure/storage/blob/_shared/authentication.py | 2 +- .../azure/storage/filedatalake/_shared/authentication.py | 2 +- .../azure/storage/fileshare/_shared/authentication.py | 2 +- .../azure/storage/queue/_shared/authentication.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/authentication.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/authentication.py index 9d2b6dc2bfcb..8d25232c31b1 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/authentication.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/authentication.py @@ -32,7 +32,7 @@ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x71c, 0x0, 0x71f, 0x721, 0x723, 0x725, - 0x0, 0x0, 0x0, 0x72d, 0x803, 0x0, 0x0, 0x733, 0x0, 0x0, 0xd1a, 0xd1c, 0xd1e, + 0x0, 0x0, 0x0, 0x72d, 0x803, 0x0, 0x0, 0x733, 0x0, 0xd03, 0xd1a, 0xd1c, 0xd1e, 0xd20, 0xd22, 0xd24, 0xd26, 0xd28, 0xd2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe02, 0xe09, 0xe0a, 0xe1a, 0xe21, 0xe23, 0xe25, 0xe2c, 0xe32, 0xe35, 0xe36, 0xe48, 0xe51, 0xe70, 0xe7c, 0xe7e, 0xe89, 0xe8a, 0xe91, 0xe99, 0xe9f, 0xea2, 0xea4, 0xea6, 0xea7, 0xea9, diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/authentication.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/authentication.py index 9d2b6dc2bfcb..8d25232c31b1 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/authentication.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/authentication.py @@ -32,7 +32,7 @@ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x71c, 0x0, 0x71f, 0x721, 0x723, 0x725, - 0x0, 0x0, 0x0, 0x72d, 0x803, 0x0, 0x0, 0x733, 0x0, 0x0, 0xd1a, 0xd1c, 0xd1e, + 0x0, 0x0, 0x0, 0x72d, 0x803, 0x0, 0x0, 0x733, 0x0, 0xd03, 0xd1a, 0xd1c, 0xd1e, 0xd20, 0xd22, 0xd24, 0xd26, 0xd28, 0xd2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe02, 0xe09, 0xe0a, 0xe1a, 0xe21, 0xe23, 0xe25, 0xe2c, 0xe32, 0xe35, 0xe36, 0xe48, 0xe51, 0xe70, 0xe7c, 0xe7e, 0xe89, 0xe8a, 0xe91, 0xe99, 0xe9f, 0xea2, 0xea4, 0xea6, 0xea7, 0xea9, diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py index 5e24a7cab6e0..bb1a89d7efe4 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py @@ -31,7 +31,7 @@ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x71c, 0x0, 0x71f, 0x721, 0x723, 0x725, - 0x0, 0x0, 0x0, 0x72d, 0x803, 0x0, 0x0, 0x733, 0x0, 0x0, 0xd1a, 0xd1c, 0xd1e, + 0x0, 0x0, 0x0, 0x72d, 0x803, 0x0, 0x0, 0x733, 0x0, 0xd03, 0xd1a, 0xd1c, 0xd1e, 0xd20, 0xd22, 0xd24, 0xd26, 0xd28, 0xd2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe02, 0xe09, 0xe0a, 0xe1a, 0xe21, 0xe23, 0xe25, 0xe2c, 0xe32, 0xe35, 0xe36, 0xe48, 0xe51, 0xe70, 0xe7c, 0xe7e, 0xe89, 0xe8a, 0xe91, 0xe99, 0xe9f, 0xea2, 0xea4, 0xea6, 0xea7, 0xea9, diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/authentication.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/authentication.py index 9d2b6dc2bfcb..8d25232c31b1 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/authentication.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/authentication.py @@ -32,7 +32,7 @@ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x71c, 0x0, 0x71f, 0x721, 0x723, 0x725, - 0x0, 0x0, 0x0, 0x72d, 0x803, 0x0, 0x0, 0x733, 0x0, 0x0, 0xd1a, 0xd1c, 0xd1e, + 0x0, 0x0, 0x0, 0x72d, 0x803, 0x0, 0x0, 0x733, 0x0, 0xd03, 0xd1a, 0xd1c, 0xd1e, 0xd20, 0xd22, 0xd24, 0xd26, 0xd28, 0xd2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe02, 0xe09, 0xe0a, 0xe1a, 0xe21, 0xe23, 0xe25, 0xe2c, 0xe32, 0xe35, 0xe36, 0xe48, 0xe51, 0xe70, 0xe7c, 0xe7e, 0xe89, 0xe8a, 0xe91, 0xe99, 0xe9f, 0xea2, 0xea4, 0xea6, 0xea7, 0xea9, From 58856aa82125debd3c628829b0f3edba219b7a3b Mon Sep 17 00:00:00 2001 From: Vincent Tran Date: Wed, 29 May 2024 12:14:48 -0700 Subject: [PATCH 15/15] Fix comparator logic slightly, fix premium tests + re-record --- .../azure/storage/blob/_shared/authentication.py | 2 +- .../azure/storage/filedatalake/_shared/authentication.py | 2 +- sdk/storage/azure-storage-file-share/assets.json | 2 +- .../azure/storage/fileshare/_shared/authentication.py | 2 +- sdk/storage/azure-storage-file-share/tests/test_share.py | 6 +++--- .../azure-storage-file-share/tests/test_share_async.py | 6 +++--- .../azure/storage/queue/_shared/authentication.py | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/authentication.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/authentication.py index 8d25232c31b1..e4d5ed730846 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/authentication.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/authentication.py @@ -85,7 +85,7 @@ def compare(lhs: str, rhs: str) -> int: # pylint:disable=too-many-return-statem if w1 > w2: return 1 return 0 - return 1 + return 0 # wraps a given exception with the desired exception type diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/authentication.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/authentication.py index 8d25232c31b1..e4d5ed730846 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/authentication.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/authentication.py @@ -85,7 +85,7 @@ def compare(lhs: str, rhs: str) -> int: # pylint:disable=too-many-return-statem if w1 > w2: return 1 return 0 - return 1 + return 0 # wraps a given exception with the desired exception type diff --git a/sdk/storage/azure-storage-file-share/assets.json b/sdk/storage/azure-storage-file-share/assets.json index 357e2cce5096..f31202404fee 100644 --- a/sdk/storage/azure-storage-file-share/assets.json +++ b/sdk/storage/azure-storage-file-share/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/storage/azure-storage-file-share", - "Tag": "python/storage/azure-storage-file-share_78435f7193" + "Tag": "python/storage/azure-storage-file-share_e105feb7fb" } diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py index bb1a89d7efe4..7f01527560b6 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py @@ -84,7 +84,7 @@ def compare(lhs: str, rhs: str) -> int: # pylint:disable=too-many-return-statem if w1 > w2: return 1 return 0 - return 1 + return 0 # wraps a given exception with the desired exception type diff --git a/sdk/storage/azure-storage-file-share/tests/test_share.py b/sdk/storage/azure-storage-file-share/tests/test_share.py index 21a822d6948f..335185e62b97 100644 --- a/sdk/storage/azure-storage-file-share/tests/test_share.py +++ b/sdk/storage/azure-storage-file-share/tests/test_share.py @@ -755,10 +755,10 @@ def test_list_shares_no_options(self, **kwargs): @FileSharePreparer() @recorded_by_proxy def test_list_shares_enable_snapshot_virtual_directory_access(self, **kwargs): - storage_account_name = kwargs.pop("storage_account_name") - storage_account_key = kwargs.pop("storage_account_key") + premium_storage_file_account_name = kwargs.pop("premium_storage_file_account_name") + premium_storage_file_account_key = kwargs.pop("premium_storage_file_account_key") - self._setup(storage_account_name, storage_account_key) + self._setup(premium_storage_file_account_name, premium_storage_file_account_key) share = self._create_share(protocols="NFS", enable_snapshot_virtual_directory_access=False) # Act diff --git a/sdk/storage/azure-storage-file-share/tests/test_share_async.py b/sdk/storage/azure-storage-file-share/tests/test_share_async.py index 961f2c3a5c32..3691ab2e7ec6 100644 --- a/sdk/storage/azure-storage-file-share/tests/test_share_async.py +++ b/sdk/storage/azure-storage-file-share/tests/test_share_async.py @@ -752,10 +752,10 @@ async def test_list_shares_no_options(self, **kwargs): @FileSharePreparer() @recorded_by_proxy_async async def test_list_shares_enable_snapshot_virtual_directory_access(self, **kwargs): - storage_account_name = kwargs.pop("storage_account_name") - storage_account_key = kwargs.pop("storage_account_key") + premium_storage_file_account_name = kwargs.pop("premium_storage_file_account_name") + premium_storage_file_account_key = kwargs.pop("premium_storage_file_account_key") - self._setup(storage_account_name, storage_account_key) + self._setup(premium_storage_file_account_name, premium_storage_file_account_key) share = await self._create_share(protocols="NFS", enable_snapshot_virtual_directory_access=False) # Act diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/authentication.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/authentication.py index 8d25232c31b1..e4d5ed730846 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/authentication.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/authentication.py @@ -85,7 +85,7 @@ def compare(lhs: str, rhs: str) -> int: # pylint:disable=too-many-return-statem if w1 > w2: return 1 return 0 - return 1 + return 0 # wraps a given exception with the desired exception type