Skip to content

Commit

Permalink
[STG78][FileShare]List Files v2 (#19017)
Browse files Browse the repository at this point in the history
* [STG78][FileShare]List Files v2

* fix pylint
  • Loading branch information
xiafu-msft committed Jul 27, 2021
1 parent 2e97f30 commit 21dc3d1
Show file tree
Hide file tree
Showing 12 changed files with 1,787 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,19 @@ def list_directories_and_files(self, name_starts_with=None, **kwargs):
:param str name_starts_with:
Filters the results to return only entities whose names
begin with the specified prefix.
:keyword list[str] include:
Include this parameter to specify one or more datasets to include in the response.
Possible str values are "timestamps", "Etag", "Attributes", "PermissionKey".
.. versionadded:: 12.6.0
This keyword argument was introduced in API version '2020-10-02'.
:keyword bool include_extended_info:
If this is set to true, file id will be returned in listed results.
.. versionadded:: 12.6.0
This keyword argument was introduced in API version '2020-10-02'.
:keyword int timeout:
The timeout parameter is expressed in seconds.
:returns: An auto-paging iterable of dict-like DirectoryProperties and FileProperties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,8 @@ class DirectoryProperties(DictMixin):
:vartype creation_time: str or ~datetime.datetime
:ivar last_write_time: Last write time for the file.
:vartype last_write_time: str or ~datetime.datetime
:ivar last_access_time: Last access time for the file.
:vartype last_access_time: ~datetime.datetime
:ivar file_attributes:
The file system attributes for files and directories.
:vartype file_attributes: str or :class:`~azure.storage.fileshare.NTFSAttributes`
Expand All @@ -572,19 +574,26 @@ def __init__(self, **kwargs):
self.change_time = _parse_datetime_from_str(kwargs.get('x-ms-file-change-time'))
self.creation_time = _parse_datetime_from_str(kwargs.get('x-ms-file-creation-time'))
self.last_write_time = _parse_datetime_from_str(kwargs.get('x-ms-file-last-write-time'))
self.last_access_time = None
self.file_attributes = kwargs.get('x-ms-file-attributes')
self.permission_key = kwargs.get('x-ms-file-permission-key')
self.file_id = kwargs.get('x-ms-file-id')
self.parent_id = kwargs.get('x-ms-file-parent-id')
self.is_directory = True

@classmethod
def _from_generated(cls, generated):
props = cls()
props.name = generated.name
props.file_id = generated.file_id
props.file_attributes = generated.attributes
props.last_modified = generated.properties.last_modified
props.creation_time = generated.properties.creation_time
props.last_access_time = generated.properties.last_access_time
props.last_write_time = generated.properties.last_write_time
props.change_time = generated.properties.change_time
props.etag = generated.properties.etag
props.server_encrypted = generated.properties.server_encrypted
props.metadata = generated.metadata
props.permission_key = generated.permission_key
return props


Expand Down Expand Up @@ -643,8 +652,8 @@ def _extract_data_cb(self, get_next_return):
self.prefix = self._response.prefix
self.marker = self._response.marker
self.results_per_page = self._response.max_results
self.current_page = [_wrap_item(i) for i in self._response.segment.directory_items]
self.current_page.extend([_wrap_item(i) for i in self._response.segment.file_items])
self.current_page = [DirectoryProperties._from_generated(i) for i in self._response.segment.directory_items] # pylint: disable = protected-access
self.current_page.extend([FileProperties._from_generated(i) for i in self._response.segment.file_items]) # pylint: disable = protected-access
return self._response.next_marker or None, self.current_page


Expand Down Expand Up @@ -703,18 +712,27 @@ def __init__(self, **kwargs):
self.change_time = _parse_datetime_from_str(kwargs.get('x-ms-file-change-time'))
self.creation_time = _parse_datetime_from_str(kwargs.get('x-ms-file-creation-time'))
self.last_write_time = _parse_datetime_from_str(kwargs.get('x-ms-file-last-write-time'))
self.last_access_time = None
self.file_attributes = kwargs.get('x-ms-file-attributes')
self.permission_key = kwargs.get('x-ms-file-permission-key')
self.file_id = kwargs.get('x-ms-file-id')
self.parent_id = kwargs.get('x-ms-file-parent-id')
self.is_directory = False

@classmethod
def _from_generated(cls, generated):
props = cls()
props.name = generated.name
props.content_length = generated.properties.content_length
props.metadata = generated.properties.metadata
props.lease = LeaseProperties._from_generated(generated) # pylint: disable=protected-access
props.file_id = generated.file_id
props.etag = generated.properties.etag
props.file_attributes = generated.attributes
props.last_modified = generated.properties.last_modified
props.creation_time = generated.properties.creation_time
props.last_access_time = generated.properties.last_access_time
props.last_write_time = generated.properties.last_write_time
props.change_time = generated.properties.change_time
props.size = generated.properties.content_length
props.permission_key = generated.permission_key
return props


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,19 @@ def list_directories_and_files(
An opaque continuation token. This value can be retrieved from the
next_marker field of a previous generator object. If specified,
this generator will begin returning results from this point.
:keyword list[str] include:
Include this parameter to specify one or more datasets to include in the response.
Possible str values are "timestamps", "Etag", "Attributes", "PermissionKey".
.. versionadded:: 12.6.0
This keyword argument was introduced in API version '2020-10-02'.
:keyword bool include_extended_info:
If this is set to true, file id will be returned in listed results.
.. versionadded:: 12.6.0
This keyword argument was introduced in API version '2020-10-02'.
:keyword int timeout:
The timeout parameter is expressed in seconds.
:returns: An auto-paging iterable of dict-like DirectoryProperties and FileProperties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,19 @@ def list_directories_and_files(self, name_starts_with=None, **kwargs):
:param str name_starts_with:
Filters the results to return only entities whose names
begin with the specified prefix.
:keyword list[str] include:
Include this parameter to specify one or more datasets to include in the response.
Possible str values are "timestamps", "Etag", "Attributes", "PermissionKey".
.. versionadded:: 12.6.0
This keyword argument was introduced in API version '2020-10-02'.
:keyword bool include_extended_info:
If this is set to true, file id will be returned in listed results.
.. versionadded:: 12.6.0
This keyword argument was introduced in API version '2020-10-02'.
:keyword int timeout:
The timeout parameter is expressed in seconds.
:returns: An auto-paging iterable of dict-like DirectoryProperties and FileProperties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from .._shared.response_handlers import return_context_and_deserialized, process_storage_error
from .._generated.models import DirectoryItem
from .._models import Handle, ShareProperties
from .._models import Handle, ShareProperties, DirectoryProperties, FileProperties


def _wrap_item(item):
Expand Down Expand Up @@ -173,6 +173,6 @@ async def _extract_data_cb(self, get_next_return):
self.prefix = self._response.prefix
self.marker = self._response.marker
self.results_per_page = self._response.max_results
self.current_page = [_wrap_item(i) for i in self._response.segment.directory_items]
self.current_page.extend([_wrap_item(i) for i in self._response.segment.file_items])
self.current_page = [DirectoryProperties._from_generated(i) for i in self._response.segment.directory_items] # pylint: disable = protected-access
self.current_page.extend([FileProperties._from_generated(i) for i in self._response.segment.file_items]) # pylint: disable = protected-access
return self._response.next_marker or None, self.current_page
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,19 @@ def list_directories_and_files( # type: ignore
An opaque continuation token. This value can be retrieved from the
next_marker field of a previous generator object. If specified,
this generator will begin returning results from this point.
:keyword list[str] include:
Include this parameter to specify one or more datasets to include in the response.
Possible str values are "timestamps", "Etag", "Attributes", "PermissionKey".
.. versionadded:: 12.6.0
This keyword argument was introduced in API version '2020-10-02'.
:keyword bool include_extended_info:
If this is set to true, file id will be returned in listed results.
.. versionadded:: 12.6.0
This keyword argument was introduced in API version '2020-10-02'.
:keyword int timeout:
The timeout parameter is expressed in seconds.
:returns: An auto-paging iterable of dict-like DirectoryProperties and FileProperties
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
interactions:
- request:
body: null
headers:
Accept:
- application/xml
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '0'
User-Agent:
- azsdk-python-storage-file-share/12.5.0b1 Python/3.7.3 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Tue, 01 Jun 2021 06:07:31 GMT
x-ms-version:
- '2020-10-02'
method: PUT
uri: https://storagename.file.core.windows.net/utshare228d1d46?restype=share
response:
body:
string: ''
headers:
content-length:
- '0'
date:
- Tue, 01 Jun 2021 06:07:31 GMT
etag:
- '"0x8D924C38B034DA7"'
last-modified:
- Tue, 01 Jun 2021 06:07:31 GMT
server:
- Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0
x-ms-version:
- '2020-10-02'
status:
code: 201
message: Created
- request:
body: null
headers:
Accept:
- application/xml
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '0'
User-Agent:
- azsdk-python-storage-file-share/12.5.0b1 Python/3.7.3 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Tue, 01 Jun 2021 06:07:31 GMT
x-ms-file-attributes:
- none
x-ms-file-creation-time:
- now
x-ms-file-last-write-time:
- now
x-ms-file-permission:
- inherit
x-ms-version:
- '2020-10-02'
method: PUT
uri: https://storagename.file.core.windows.net/utshare228d1d46/dir1?restype=directory
response:
body:
string: ''
headers:
content-length:
- '0'
date:
- Tue, 01 Jun 2021 06:07:31 GMT
etag:
- '"0x8D924C38B172120"'
last-modified:
- Tue, 01 Jun 2021 06:07:32 GMT
server:
- Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0
x-ms-file-attributes:
- Directory
x-ms-file-change-time:
- '2021-06-01T06:07:32.0407328Z'
x-ms-file-creation-time:
- '2021-06-01T06:07:32.0407328Z'
x-ms-file-id:
- '13835128424026341376'
x-ms-file-last-write-time:
- '2021-06-01T06:07:32.0407328Z'
x-ms-file-parent-id:
- '0'
x-ms-file-permission-key:
- 17860367565182308406*11459378189709739967
x-ms-request-server-encrypted:
- 'true'
x-ms-version:
- '2020-10-02'
status:
code: 201
message: Created
- request:
body: null
headers:
Accept:
- application/xml
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '0'
User-Agent:
- azsdk-python-storage-file-share/12.5.0b1 Python/3.7.3 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Tue, 01 Jun 2021 06:07:32 GMT
x-ms-file-attributes:
- none
x-ms-file-creation-time:
- now
x-ms-file-last-write-time:
- now
x-ms-file-permission:
- inherit
x-ms-version:
- '2020-10-02'
method: PUT
uri: https://storagename.file.core.windows.net/utshare228d1d46/dir1%2Fsubdir1?restype=directory
response:
body:
string: ''
headers:
content-length:
- '0'
date:
- Tue, 01 Jun 2021 06:07:31 GMT
etag:
- '"0x8D924C38B2B4909"'
last-modified:
- Tue, 01 Jun 2021 06:07:32 GMT
server:
- Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0
x-ms-file-attributes:
- Directory
x-ms-file-change-time:
- '2021-06-01T06:07:32.1728265Z'
x-ms-file-creation-time:
- '2021-06-01T06:07:32.1728265Z'
x-ms-file-id:
- '11529285414812647424'
x-ms-file-last-write-time:
- '2021-06-01T06:07:32.1728265Z'
x-ms-file-parent-id:
- '13835128424026341376'
x-ms-file-permission-key:
- 17860367565182308406*11459378189709739967
x-ms-request-server-encrypted:
- 'true'
x-ms-version:
- '2020-10-02'
status:
code: 201
message: Created
- request:
body: null
headers:
Accept:
- application/xml
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- azsdk-python-storage-file-share/12.5.0b1 Python/3.7.3 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Tue, 01 Jun 2021 06:07:32 GMT
x-ms-file-extended-info:
- 'true'
x-ms-version:
- '2020-10-02'
method: GET
uri: https://storagename.file.core.windows.net/utshare228d1d46/dir1?restype=directory&comp=list
response:
body:
string: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><EnumerationResults
ServiceEndpoint=\"https://storagename.file.core.windows.net/\" ShareName=\"utshare228d1d46\"
DirectoryPath=\"dir1\"><DirectoryId>13835128424026341376</DirectoryId><Entries><Directory><Name>subdir1</Name><FileId>11529285414812647424</FileId><Properties
/></Directory></Entries><NextMarker /></EnumerationResults>"
headers:
content-type:
- application/xml
date:
- Tue, 01 Jun 2021 06:07:31 GMT
server:
- Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0
transfer-encoding:
- chunked
x-ms-version:
- '2020-10-02'
status:
code: 200
message: OK
version: 1
Loading

0 comments on commit 21dc3d1

Please sign in to comment.