Skip to content

Commit 21dc3d1

Browse files
committed
[STG78][FileShare]List Files v2 (#19017)
* [STG78][FileShare]List Files v2 * fix pylint
1 parent 2e97f30 commit 21dc3d1

12 files changed

+1787
-63
lines changed

sdk/storage/azure-storage-file-share/azure/storage/fileshare/_directory_client.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,19 @@ def list_directories_and_files(self, name_starts_with=None, **kwargs):
335335
:param str name_starts_with:
336336
Filters the results to return only entities whose names
337337
begin with the specified prefix.
338+
:keyword list[str] include:
339+
Include this parameter to specify one or more datasets to include in the response.
340+
Possible str values are "timestamps", "Etag", "Attributes", "PermissionKey".
341+
342+
.. versionadded:: 12.6.0
343+
This keyword argument was introduced in API version '2020-10-02'.
344+
345+
:keyword bool include_extended_info:
346+
If this is set to true, file id will be returned in listed results.
347+
348+
.. versionadded:: 12.6.0
349+
This keyword argument was introduced in API version '2020-10-02'.
350+
338351
:keyword int timeout:
339352
The timeout parameter is expressed in seconds.
340353
:returns: An auto-paging iterable of dict-like DirectoryProperties and FileProperties

sdk/storage/azure-storage-file-share/azure/storage/fileshare/_models.py

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,8 @@ class DirectoryProperties(DictMixin):
549549
:vartype creation_time: str or ~datetime.datetime
550550
:ivar last_write_time: Last write time for the file.
551551
:vartype last_write_time: str or ~datetime.datetime
552+
:ivar last_access_time: Last access time for the file.
553+
:vartype last_access_time: ~datetime.datetime
552554
:ivar file_attributes:
553555
The file system attributes for files and directories.
554556
:vartype file_attributes: str or :class:`~azure.storage.fileshare.NTFSAttributes`
@@ -572,19 +574,26 @@ def __init__(self, **kwargs):
572574
self.change_time = _parse_datetime_from_str(kwargs.get('x-ms-file-change-time'))
573575
self.creation_time = _parse_datetime_from_str(kwargs.get('x-ms-file-creation-time'))
574576
self.last_write_time = _parse_datetime_from_str(kwargs.get('x-ms-file-last-write-time'))
577+
self.last_access_time = None
575578
self.file_attributes = kwargs.get('x-ms-file-attributes')
576579
self.permission_key = kwargs.get('x-ms-file-permission-key')
577580
self.file_id = kwargs.get('x-ms-file-id')
578581
self.parent_id = kwargs.get('x-ms-file-parent-id')
582+
self.is_directory = True
579583

580584
@classmethod
581585
def _from_generated(cls, generated):
582586
props = cls()
583587
props.name = generated.name
588+
props.file_id = generated.file_id
589+
props.file_attributes = generated.attributes
584590
props.last_modified = generated.properties.last_modified
591+
props.creation_time = generated.properties.creation_time
592+
props.last_access_time = generated.properties.last_access_time
593+
props.last_write_time = generated.properties.last_write_time
594+
props.change_time = generated.properties.change_time
585595
props.etag = generated.properties.etag
586-
props.server_encrypted = generated.properties.server_encrypted
587-
props.metadata = generated.metadata
596+
props.permission_key = generated.permission_key
588597
return props
589598

590599

@@ -643,8 +652,8 @@ def _extract_data_cb(self, get_next_return):
643652
self.prefix = self._response.prefix
644653
self.marker = self._response.marker
645654
self.results_per_page = self._response.max_results
646-
self.current_page = [_wrap_item(i) for i in self._response.segment.directory_items]
647-
self.current_page.extend([_wrap_item(i) for i in self._response.segment.file_items])
655+
self.current_page = [DirectoryProperties._from_generated(i) for i in self._response.segment.directory_items] # pylint: disable = protected-access
656+
self.current_page.extend([FileProperties._from_generated(i) for i in self._response.segment.file_items]) # pylint: disable = protected-access
648657
return self._response.next_marker or None, self.current_page
649658

650659

@@ -703,18 +712,27 @@ def __init__(self, **kwargs):
703712
self.change_time = _parse_datetime_from_str(kwargs.get('x-ms-file-change-time'))
704713
self.creation_time = _parse_datetime_from_str(kwargs.get('x-ms-file-creation-time'))
705714
self.last_write_time = _parse_datetime_from_str(kwargs.get('x-ms-file-last-write-time'))
715+
self.last_access_time = None
706716
self.file_attributes = kwargs.get('x-ms-file-attributes')
707717
self.permission_key = kwargs.get('x-ms-file-permission-key')
708718
self.file_id = kwargs.get('x-ms-file-id')
709719
self.parent_id = kwargs.get('x-ms-file-parent-id')
720+
self.is_directory = False
710721

711722
@classmethod
712723
def _from_generated(cls, generated):
713724
props = cls()
714725
props.name = generated.name
715-
props.content_length = generated.properties.content_length
716-
props.metadata = generated.properties.metadata
717-
props.lease = LeaseProperties._from_generated(generated) # pylint: disable=protected-access
726+
props.file_id = generated.file_id
727+
props.etag = generated.properties.etag
728+
props.file_attributes = generated.attributes
729+
props.last_modified = generated.properties.last_modified
730+
props.creation_time = generated.properties.creation_time
731+
props.last_access_time = generated.properties.last_access_time
732+
props.last_write_time = generated.properties.last_write_time
733+
props.change_time = generated.properties.change_time
734+
props.size = generated.properties.content_length
735+
props.permission_key = generated.permission_key
718736
return props
719737

720738

sdk/storage/azure-storage-file-share/azure/storage/fileshare/_share_client.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,19 @@ def list_directories_and_files(
778778
An opaque continuation token. This value can be retrieved from the
779779
next_marker field of a previous generator object. If specified,
780780
this generator will begin returning results from this point.
781+
:keyword list[str] include:
782+
Include this parameter to specify one or more datasets to include in the response.
783+
Possible str values are "timestamps", "Etag", "Attributes", "PermissionKey".
784+
785+
.. versionadded:: 12.6.0
786+
This keyword argument was introduced in API version '2020-10-02'.
787+
788+
:keyword bool include_extended_info:
789+
If this is set to true, file id will be returned in listed results.
790+
791+
.. versionadded:: 12.6.0
792+
This keyword argument was introduced in API version '2020-10-02'.
793+
781794
:keyword int timeout:
782795
The timeout parameter is expressed in seconds.
783796
:returns: An auto-paging iterable of dict-like DirectoryProperties and FileProperties

sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_directory_client_async.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,19 @@ def list_directories_and_files(self, name_starts_with=None, **kwargs):
215215
:param str name_starts_with:
216216
Filters the results to return only entities whose names
217217
begin with the specified prefix.
218+
:keyword list[str] include:
219+
Include this parameter to specify one or more datasets to include in the response.
220+
Possible str values are "timestamps", "Etag", "Attributes", "PermissionKey".
221+
222+
.. versionadded:: 12.6.0
223+
This keyword argument was introduced in API version '2020-10-02'.
224+
225+
:keyword bool include_extended_info:
226+
If this is set to true, file id will be returned in listed results.
227+
228+
.. versionadded:: 12.6.0
229+
This keyword argument was introduced in API version '2020-10-02'.
230+
218231
:keyword int timeout:
219232
The timeout parameter is expressed in seconds.
220233
:returns: An auto-paging iterable of dict-like DirectoryProperties and FileProperties

sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from .._shared.response_handlers import return_context_and_deserialized, process_storage_error
1313
from .._generated.models import DirectoryItem
14-
from .._models import Handle, ShareProperties
14+
from .._models import Handle, ShareProperties, DirectoryProperties, FileProperties
1515

1616

1717
def _wrap_item(item):
@@ -173,6 +173,6 @@ async def _extract_data_cb(self, get_next_return):
173173
self.prefix = self._response.prefix
174174
self.marker = self._response.marker
175175
self.results_per_page = self._response.max_results
176-
self.current_page = [_wrap_item(i) for i in self._response.segment.directory_items]
177-
self.current_page.extend([_wrap_item(i) for i in self._response.segment.file_items])
176+
self.current_page = [DirectoryProperties._from_generated(i) for i in self._response.segment.directory_items] # pylint: disable = protected-access
177+
self.current_page.extend([FileProperties._from_generated(i) for i in self._response.segment.file_items]) # pylint: disable = protected-access
178178
return self._response.next_marker or None, self.current_page

sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_share_client_async.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,19 @@ def list_directories_and_files( # type: ignore
638638
An opaque continuation token. This value can be retrieved from the
639639
next_marker field of a previous generator object. If specified,
640640
this generator will begin returning results from this point.
641+
:keyword list[str] include:
642+
Include this parameter to specify one or more datasets to include in the response.
643+
Possible str values are "timestamps", "Etag", "Attributes", "PermissionKey".
644+
645+
.. versionadded:: 12.6.0
646+
This keyword argument was introduced in API version '2020-10-02'.
647+
648+
:keyword bool include_extended_info:
649+
If this is set to true, file id will be returned in listed results.
650+
651+
.. versionadded:: 12.6.0
652+
This keyword argument was introduced in API version '2020-10-02'.
653+
641654
:keyword int timeout:
642655
The timeout parameter is expressed in seconds.
643656
:returns: An auto-paging iterable of dict-like DirectoryProperties and FileProperties
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- application/xml
7+
Accept-Encoding:
8+
- gzip, deflate
9+
Connection:
10+
- keep-alive
11+
Content-Length:
12+
- '0'
13+
User-Agent:
14+
- azsdk-python-storage-file-share/12.5.0b1 Python/3.7.3 (Windows-10-10.0.19041-SP0)
15+
x-ms-date:
16+
- Tue, 01 Jun 2021 06:07:31 GMT
17+
x-ms-version:
18+
- '2020-10-02'
19+
method: PUT
20+
uri: https://storagename.file.core.windows.net/utshare228d1d46?restype=share
21+
response:
22+
body:
23+
string: ''
24+
headers:
25+
content-length:
26+
- '0'
27+
date:
28+
- Tue, 01 Jun 2021 06:07:31 GMT
29+
etag:
30+
- '"0x8D924C38B034DA7"'
31+
last-modified:
32+
- Tue, 01 Jun 2021 06:07:31 GMT
33+
server:
34+
- Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0
35+
x-ms-version:
36+
- '2020-10-02'
37+
status:
38+
code: 201
39+
message: Created
40+
- request:
41+
body: null
42+
headers:
43+
Accept:
44+
- application/xml
45+
Accept-Encoding:
46+
- gzip, deflate
47+
Connection:
48+
- keep-alive
49+
Content-Length:
50+
- '0'
51+
User-Agent:
52+
- azsdk-python-storage-file-share/12.5.0b1 Python/3.7.3 (Windows-10-10.0.19041-SP0)
53+
x-ms-date:
54+
- Tue, 01 Jun 2021 06:07:31 GMT
55+
x-ms-file-attributes:
56+
- none
57+
x-ms-file-creation-time:
58+
- now
59+
x-ms-file-last-write-time:
60+
- now
61+
x-ms-file-permission:
62+
- inherit
63+
x-ms-version:
64+
- '2020-10-02'
65+
method: PUT
66+
uri: https://storagename.file.core.windows.net/utshare228d1d46/dir1?restype=directory
67+
response:
68+
body:
69+
string: ''
70+
headers:
71+
content-length:
72+
- '0'
73+
date:
74+
- Tue, 01 Jun 2021 06:07:31 GMT
75+
etag:
76+
- '"0x8D924C38B172120"'
77+
last-modified:
78+
- Tue, 01 Jun 2021 06:07:32 GMT
79+
server:
80+
- Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0
81+
x-ms-file-attributes:
82+
- Directory
83+
x-ms-file-change-time:
84+
- '2021-06-01T06:07:32.0407328Z'
85+
x-ms-file-creation-time:
86+
- '2021-06-01T06:07:32.0407328Z'
87+
x-ms-file-id:
88+
- '13835128424026341376'
89+
x-ms-file-last-write-time:
90+
- '2021-06-01T06:07:32.0407328Z'
91+
x-ms-file-parent-id:
92+
- '0'
93+
x-ms-file-permission-key:
94+
- 17860367565182308406*11459378189709739967
95+
x-ms-request-server-encrypted:
96+
- 'true'
97+
x-ms-version:
98+
- '2020-10-02'
99+
status:
100+
code: 201
101+
message: Created
102+
- request:
103+
body: null
104+
headers:
105+
Accept:
106+
- application/xml
107+
Accept-Encoding:
108+
- gzip, deflate
109+
Connection:
110+
- keep-alive
111+
Content-Length:
112+
- '0'
113+
User-Agent:
114+
- azsdk-python-storage-file-share/12.5.0b1 Python/3.7.3 (Windows-10-10.0.19041-SP0)
115+
x-ms-date:
116+
- Tue, 01 Jun 2021 06:07:32 GMT
117+
x-ms-file-attributes:
118+
- none
119+
x-ms-file-creation-time:
120+
- now
121+
x-ms-file-last-write-time:
122+
- now
123+
x-ms-file-permission:
124+
- inherit
125+
x-ms-version:
126+
- '2020-10-02'
127+
method: PUT
128+
uri: https://storagename.file.core.windows.net/utshare228d1d46/dir1%2Fsubdir1?restype=directory
129+
response:
130+
body:
131+
string: ''
132+
headers:
133+
content-length:
134+
- '0'
135+
date:
136+
- Tue, 01 Jun 2021 06:07:31 GMT
137+
etag:
138+
- '"0x8D924C38B2B4909"'
139+
last-modified:
140+
- Tue, 01 Jun 2021 06:07:32 GMT
141+
server:
142+
- Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0
143+
x-ms-file-attributes:
144+
- Directory
145+
x-ms-file-change-time:
146+
- '2021-06-01T06:07:32.1728265Z'
147+
x-ms-file-creation-time:
148+
- '2021-06-01T06:07:32.1728265Z'
149+
x-ms-file-id:
150+
- '11529285414812647424'
151+
x-ms-file-last-write-time:
152+
- '2021-06-01T06:07:32.1728265Z'
153+
x-ms-file-parent-id:
154+
- '13835128424026341376'
155+
x-ms-file-permission-key:
156+
- 17860367565182308406*11459378189709739967
157+
x-ms-request-server-encrypted:
158+
- 'true'
159+
x-ms-version:
160+
- '2020-10-02'
161+
status:
162+
code: 201
163+
message: Created
164+
- request:
165+
body: null
166+
headers:
167+
Accept:
168+
- application/xml
169+
Accept-Encoding:
170+
- gzip, deflate
171+
Connection:
172+
- keep-alive
173+
User-Agent:
174+
- azsdk-python-storage-file-share/12.5.0b1 Python/3.7.3 (Windows-10-10.0.19041-SP0)
175+
x-ms-date:
176+
- Tue, 01 Jun 2021 06:07:32 GMT
177+
x-ms-file-extended-info:
178+
- 'true'
179+
x-ms-version:
180+
- '2020-10-02'
181+
method: GET
182+
uri: https://storagename.file.core.windows.net/utshare228d1d46/dir1?restype=directory&comp=list
183+
response:
184+
body:
185+
string: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><EnumerationResults
186+
ServiceEndpoint=\"https://storagename.file.core.windows.net/\" ShareName=\"utshare228d1d46\"
187+
DirectoryPath=\"dir1\"><DirectoryId>13835128424026341376</DirectoryId><Entries><Directory><Name>subdir1</Name><FileId>11529285414812647424</FileId><Properties
188+
/></Directory></Entries><NextMarker /></EnumerationResults>"
189+
headers:
190+
content-type:
191+
- application/xml
192+
date:
193+
- Tue, 01 Jun 2021 06:07:31 GMT
194+
server:
195+
- Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0
196+
transfer-encoding:
197+
- chunked
198+
x-ms-version:
199+
- '2020-10-02'
200+
status:
201+
code: 200
202+
message: OK
203+
version: 1

0 commit comments

Comments
 (0)