Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Storage] [STG 97] Exposed mode_copy_mode and owner_copy_mode in start_copy_from_url #38931

Open
wants to merge 7 commits into
base: feature/storage-stg97
Choose a base branch
from
2 changes: 1 addition & 1 deletion sdk/storage/azure-storage-file-share/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -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_8af5942fd9"
"Tag": "python/storage/azure-storage-file-share_4047c4afa8"
}
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,20 @@ def start_copy_from_url(self, source_url: str, **kwargs: Any) -> Dict[str, Any]:
NFS only. The owning group of the file.
:keyword str file_mode:
NFS only. The file mode of the file.
:keyword mode_copy_mode:
NFS only. Applicable only when the copy source is a File. Determines the copy behavior
of the mode bits of the file. Possible values are:

source - The mode on the destination file is copied from the source file.
override - The mode on the destination file is determined via the file_mode keyword.
:paramtype mode_copy_mode: Literal['source', 'override']
:keyword owner_copy_mode:
NFS only. Applicable only when the copy source is a File. Determines the copy behavior
of the owner and group of the file. Possible values are:

source - The owner and group on the destination file is copied from the source file.
override - The owner and group on the destination file is determined via the owner and group keywords.
:paramtype owner_copy_mode: Literal['source', 'override']
:keyword int timeout:
Sets the server-side timeout for the operation in seconds. For more details see
https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-file-service-operations.
Expand All @@ -749,8 +763,8 @@ def start_copy_from_url(self, source_url: str, **kwargs: Any) -> Dict[str, Any]:
owner = kwargs.pop('owner', None)
group = kwargs.pop('group', None)
file_mode = kwargs.pop('file_mode', None)
file_mode_copy_mode = 'override' if file_mode else None
file_owner_copy_mode = 'override' if owner or group else None
file_mode_copy_mode = kwargs.pop('mode_copy_mode', None)
file_owner_copy_mode = kwargs.pop('owner_copy_mode', None)
headers = kwargs.pop('headers', {})
headers.update(add_metadata_headers(metadata))
kwargs.update(get_smb_properties(kwargs))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def _create_xml_node(tag, prefix=None, ns=None):
return ET.Element(tag)


class Model(object):
class Model:
"""Mixin for all client request body/response body models to support
serialization and deserialization.
"""
Expand Down Expand Up @@ -563,7 +563,7 @@ def _decode_attribute_map_key(key):
return key.replace("\\.", ".")


class Serializer(object): # pylint: disable=too-many-public-methods
class Serializer: # pylint: disable=too-many-public-methods
"""Request object model serializer."""

basic_types = {str: "str", int: "int", bool: "bool", float: "float"}
Expand Down Expand Up @@ -1441,7 +1441,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument
return children[0]


class Deserializer(object):
class Deserializer:
"""Response object model deserializer.

:param dict classes: Class type dictionary for deserializing complex types.
Expand Down Expand Up @@ -1683,17 +1683,21 @@ def _instantiate_model(self, response, attrs, additional_properties=None):
subtype = getattr(response, "_subtype_map", {})
try:
readonly = [
k for k, v in response._validation.items() if v.get("readonly") # pylint: disable=protected-access
k
for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore
if v.get("readonly")
]
const = [
k for k, v in response._validation.items() if v.get("constant") # pylint: disable=protected-access
k
for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore
if v.get("constant")
]
kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const}
response_obj = response(**kwargs)
for attr in readonly:
setattr(response_obj, attr, attrs.get(attr))
if additional_properties:
response_obj.additional_properties = additional_properties
response_obj.additional_properties = additional_properties # type: ignore
return response_obj
except TypeError as err:
msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ async def create(
None.
:type file_mode: str
:param nfs_file_type: Optional, NFS only. Type of the file or directory. Known values are:
"Regular", "Directory", and "Symlink". Default value is None.
"Regular", "Directory", and "SymLink". Default value is None.
:type nfs_file_type: str or ~azure.storage.fileshare.models.NfsFileType
:param file_http_headers: Parameter group. Default value is None.
:type file_http_headers: ~azure.storage.fileshare.models.FileHTTPHeaders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class NfsFileType(str, Enum, metaclass=CaseInsensitiveEnumMeta):

REGULAR = "Regular"
DIRECTORY = "Directory"
SYMLINK = "Symlink"
SYM_LINK = "SymLink"


class OwnerCopyMode(str, Enum, metaclass=CaseInsensitiveEnumMeta):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,7 @@ def create( # pylint: disable=inconsistent-return-statements
None.
:type file_mode: str
:param nfs_file_type: Optional, NFS only. Type of the file or directory. Known values are:
"Regular", "Directory", and "Symlink". Default value is None.
"Regular", "Directory", and "SymLink". Default value is None.
:type nfs_file_type: str or ~azure.storage.fileshare.models.NfsFileType
:param file_http_headers: Parameter group. Default value is None.
:type file_http_headers: ~azure.storage.fileshare.models.FileHTTPHeaders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,20 @@ async def start_copy_from_url(self, source_url: str, **kwargs: Any) -> Dict[str,
NFS only. The owning group of the file.
:keyword str file_mode:
NFS only. The file mode of the file.
:keyword mode_copy_mode:
NFS only. Applicable only when the copy source is a File. Determines the copy behavior
of the mode bits of the file. Possible values are:

source - The mode on the destination file is copied from the source file.
override - The mode on the destination file is determined via the file_mode keyword.
:paramtype mode_copy_mode: Literal['source', 'override']
:keyword owner_copy_mode:
NFS only. Applicable only when the copy source is a File. Determines the copy behavior
of the owner and group of the file. Possible values are:

source - The owner and group on the destination file is copied from the source file.
override - The owner and group on the destination file is determined via the owner and group keywords.
:paramtype owner_copy_mode: Literal['source', 'override']
:keyword int timeout:
Sets the server-side timeout for the operation in seconds. For more details see
https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-file-service-operations.
Expand All @@ -744,8 +758,8 @@ async def start_copy_from_url(self, source_url: str, **kwargs: Any) -> Dict[str,
owner = kwargs.pop('owner', None)
group = kwargs.pop('group', None)
file_mode = kwargs.pop('file_mode', None)
file_mode_copy_mode = 'override' if file_mode else None
file_owner_copy_mode = 'override' if owner or group else None
file_mode_copy_mode = kwargs.pop('mode_copy_mode', None)
file_owner_copy_mode = kwargs.pop('owner_copy_mode', None)
headers = kwargs.pop("headers", {})
headers.update(add_metadata_headers(metadata))
kwargs.update(get_smb_properties(kwargs))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,13 @@ def test_old_api_copy_file_succeeds(self, **kwargs):
file_name = self._get_file_reference()

source_client = share.get_file_client(file_name)
source_client.upload_file(self.short_byte_data)
source_client.upload_file(
self.short_byte_data,
file_attributes='none',
file_creation_time='now',
file_last_write_time='now',
file_permission='inherit'
)
source_prop = source_client.get_file_properties()

file_client = ShareFileClient(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,13 @@ async def test_old_api_copy_file_succeeds(self, **kwargs):
file_name = self._get_file_reference()

source_client = share.get_file_client(file_name)
await source_client.upload_file(self.short_byte_data)
await source_client.upload_file(
self.short_byte_data,
file_attributes='none',
file_creation_time='now',
file_last_write_time='now',
file_permission='inherit'
)
source_prop = await source_client.get_file_properties()

file_client = ShareFileClient(
Expand Down
Loading
Loading