Skip to content

Commit 1fc96ec

Browse files
[Storage] [Named Keywords] ADLS Package (#42974)
1 parent 3345f63 commit 1fc96ec

22 files changed

+2422
-44
lines changed

sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_directory_client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ def from_connection_string(
126126
:param directory_name:
127127
The name of directory to interact with. The directory is under file system.
128128
:type directory_name: str
129+
:keyword str api_version:
130+
The Storage API version to use for requests. Default value is the most recent service version that is
131+
compatible with the current SDK. Setting to an older version may result in reduced feature compatibility.
129132
:keyword str audience: The audience to use when requesting tokens for Azure Active Directory
130133
authentication. Only has an effect when credential is of type TokenCredential. The value could be
131134
https://storage.azure.com/ (default) or https://<account>.blob.core.windows.net.
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
# -------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for
4+
# license information.
5+
# --------------------------------------------------------------------------
6+
# pylint: skip-file
7+
8+
from datetime import datetime
9+
from typing import (
10+
Any,
11+
Dict,
12+
Optional,
13+
Union,
14+
)
15+
from types import TracebackType
16+
from typing_extensions import Self
17+
18+
from azure.core import MatchConditions
19+
from azure.core.credentials import AzureNamedKeyCredential, AzureSasCredential, TokenCredential
20+
from azure.core.paging import ItemPaged
21+
from azure.core.tracing.decorator import distributed_trace
22+
from ._data_lake_lease import DataLakeLeaseClient
23+
from ._data_lake_file_client import DataLakeFileClient
24+
from ._models import ContentSettings, CustomerProvidedEncryptionKey, DirectoryProperties, FileProperties, PathProperties
25+
from ._path_client import PathClient
26+
27+
class DataLakeDirectoryClient(PathClient):
28+
url: str
29+
primary_endpoint: str
30+
primary_hostname: str
31+
def __init__(
32+
self,
33+
account_url: str,
34+
file_system_name: str,
35+
directory_name: str,
36+
credential: Optional[
37+
Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, TokenCredential]
38+
] = None,
39+
*,
40+
api_version: Optional[str] = None,
41+
audience: Optional[str] = None,
42+
**kwargs: Any
43+
) -> None: ...
44+
def __enter__(self) -> Self: ...
45+
def __exit__(
46+
self, typ: Optional[type[BaseException]], exc: Optional[BaseException], tb: Optional[TracebackType]
47+
) -> None: ...
48+
def close(self) -> None: ...
49+
@classmethod
50+
def from_connection_string(
51+
cls,
52+
conn_str: str,
53+
file_system_name: str,
54+
directory_name: str,
55+
credential: Optional[
56+
Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, TokenCredential]
57+
] = None,
58+
*,
59+
api_version: Optional[str] = None,
60+
audience: Optional[str] = None,
61+
**kwargs: Any
62+
) -> Self: ...
63+
@distributed_trace
64+
def create_directory(
65+
self,
66+
metadata: Optional[Dict[str, str]] = None,
67+
*,
68+
content_settings: Optional[ContentSettings] = None,
69+
lease: Optional[Union[DataLakeLeaseClient, str]] = None,
70+
umask: Optional[str] = None,
71+
owner: Optional[str] = None,
72+
group: Optional[str] = None,
73+
acl: Optional[str] = None,
74+
lease_id: Optional[str] = None,
75+
lease_duration: Optional[int] = None,
76+
permissions: Optional[str] = None,
77+
if_modified_since: Optional[datetime] = None,
78+
if_unmodified_since: Optional[datetime] = None,
79+
etag: Optional[str] = None,
80+
match_condition: Optional[MatchConditions] = None,
81+
cpk: Optional[CustomerProvidedEncryptionKey] = None,
82+
timeout: Optional[int] = None,
83+
**kwargs: Any
84+
) -> Dict[str, Union[str, datetime]]: ...
85+
@distributed_trace
86+
def delete_directory(
87+
self,
88+
*,
89+
lease: Optional[Union[DataLakeLeaseClient, str]] = None,
90+
if_modified_since: Optional[datetime] = None,
91+
if_unmodified_since: Optional[datetime] = None,
92+
etag: Optional[str] = None,
93+
match_condition: Optional[MatchConditions] = None,
94+
timeout: Optional[int] = None,
95+
**kwargs: Any
96+
) -> None: ...
97+
@distributed_trace
98+
def get_directory_properties(
99+
self,
100+
*,
101+
lease: Optional[Union[DataLakeLeaseClient, str]] = None,
102+
if_modified_since: Optional[datetime] = None,
103+
if_unmodified_since: Optional[datetime] = None,
104+
etag: Optional[str] = None,
105+
match_condition: Optional[MatchConditions] = None,
106+
cpk: Optional[CustomerProvidedEncryptionKey] = None,
107+
upn: Optional[bool] = None,
108+
timeout: Optional[int] = None,
109+
**kwargs: Any
110+
) -> DirectoryProperties: ...
111+
@distributed_trace
112+
def exists(self, *, timeout: Optional[int] = None, **kwargs: Any) -> bool: ...
113+
@distributed_trace
114+
def rename_directory(
115+
self,
116+
new_name: str,
117+
*,
118+
source_lease: Optional[Union[DataLakeLeaseClient, str]] = None,
119+
lease: Optional[Union[DataLakeLeaseClient, str]] = None,
120+
if_modified_since: Optional[datetime] = None,
121+
if_unmodified_since: Optional[datetime] = None,
122+
etag: Optional[str] = None,
123+
match_condition: Optional[MatchConditions] = None,
124+
source_if_modified_since: Optional[datetime] = None,
125+
source_if_unmodified_since: Optional[datetime] = None,
126+
source_etag: Optional[str] = None,
127+
source_match_condition: Optional[MatchConditions] = None,
128+
timeout: Optional[int] = None,
129+
**kwargs: Any
130+
) -> "DataLakeDirectoryClient": ...
131+
@distributed_trace
132+
def create_sub_directory(
133+
self,
134+
sub_directory: Union[DirectoryProperties, str],
135+
metadata: Optional[Dict[str, str]] = None,
136+
*,
137+
content_settings: Optional[ContentSettings] = None,
138+
lease: Optional[Union[DataLakeLeaseClient, str]] = None,
139+
umask: Optional[str] = None,
140+
owner: Optional[str] = None,
141+
group: Optional[str] = None,
142+
acl: Optional[str] = None,
143+
lease_id: Optional[str] = None,
144+
lease_duration: Optional[int] = None,
145+
permissions: Optional[str] = None,
146+
if_modified_since: Optional[datetime] = None,
147+
if_unmodified_since: Optional[datetime] = None,
148+
etag: Optional[str] = None,
149+
match_condition: Optional[MatchConditions] = None,
150+
cpk: Optional[CustomerProvidedEncryptionKey] = None,
151+
timeout: Optional[int] = None,
152+
**kwargs: Any
153+
) -> "DataLakeDirectoryClient": ...
154+
@distributed_trace
155+
def delete_sub_directory(
156+
self,
157+
sub_directory: Union[DirectoryProperties, str],
158+
*,
159+
lease: Optional[Union[DataLakeLeaseClient, str]] = None,
160+
if_modified_since: Optional[datetime] = None,
161+
if_unmodified_since: Optional[datetime] = None,
162+
etag: Optional[str] = None,
163+
match_condition: Optional[MatchConditions] = None,
164+
timeout: Optional[int] = None,
165+
**kwargs: Any
166+
) -> "DataLakeDirectoryClient": ...
167+
@distributed_trace
168+
def create_file(
169+
self,
170+
file: Union[FileProperties, str],
171+
*,
172+
content_settings: Optional[ContentSettings] = None,
173+
metadata: Optional[Dict[str, str]] = None,
174+
lease: Optional[Union[DataLakeLeaseClient, str]] = None,
175+
umask: Optional[str] = None,
176+
owner: Optional[str] = None,
177+
group: Optional[str] = None,
178+
acl: Optional[str] = None,
179+
lease_id: Optional[str] = None,
180+
lease_duration: Optional[int] = None,
181+
expires_on: Optional[Union[datetime, int]] = None,
182+
permissions: Optional[str] = None,
183+
if_modified_since: Optional[datetime] = None,
184+
if_unmodified_since: Optional[datetime] = None,
185+
etag: Optional[str] = None,
186+
match_condition: Optional[MatchConditions] = None,
187+
cpk: Optional[CustomerProvidedEncryptionKey] = None,
188+
timeout: Optional[int] = None,
189+
**kwargs: Any
190+
) -> DataLakeFileClient: ...
191+
@distributed_trace
192+
def get_paths(
193+
self,
194+
*,
195+
recursive: bool = True,
196+
max_results: Optional[int] = None,
197+
upn: Optional[bool] = None,
198+
timeout: Optional[int] = None,
199+
**kwargs: Any
200+
) -> ItemPaged[PathProperties]: ...
201+
def get_file_client(self, file: Union[FileProperties, str]) -> DataLakeFileClient: ...
202+
def get_sub_directory_client(self, sub_directory: Union[DirectoryProperties, str]) -> "DataLakeDirectoryClient": ...

sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_file_client.py

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ def from_connection_string(
128128
~azure.core.credentials.AzureSasCredential or
129129
~azure.core.credentials.TokenCredential or
130130
str or Dict[str, str] or None
131+
:keyword str api_version:
132+
The Storage API version to use for requests. Default value is the most recent service version that is
133+
compatible with the current SDK. Setting to an older version may result in reduced feature compatibility.
131134
:keyword str audience: The audience to use when requesting tokens for Azure Active Directory
132135
authentication. Only has an effect when credential is of type TokenCredential. The value could be
133136
https://storage.azure.com/ (default) or https://<account>.blob.core.windows.net.
@@ -217,14 +220,14 @@ def create_file(
217220
:keyword ~azure.storage.filedatalake.CustomerProvidedEncryptionKey cpk:
218221
Encrypts the data on the service-side with the given key.
219222
Use of customer-provided keys must be done over HTTPS.
223+
:keyword str encryption_context:
224+
Specifies the encryption context to set on the file.
220225
:keyword int timeout:
221226
Sets the server-side timeout for the operation in seconds. For more details see
222227
https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
223228
This value is not tracked or validated on the client. To configure client-side network timesouts
224229
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-file-datalake
225230
#other-client--per-operation-configuration>`_.
226-
:keyword str encryption_context:
227-
Specifies the encryption context to set on the file.
228231
:returns: A dictionary of response headers.
229232
:rtype: Dict[str, Union[str, ~datetime.datetime]]
230233
@@ -407,11 +410,11 @@ def upload_data(
407410
The default permission is 0777 for a directory and 0666 for a file. The default umask is 0027.
408411
The umask must be specified in 4-digit octal notation (e.g. 0766).
409412
:keyword str permissions: Optional and only valid if Hierarchical Namespace
410-
is enabled for the account. Sets POSIX access permissions for the file
411-
owner, the file owning group, and others. Each class may be granted
412-
read, write, or execute permission. The sticky bit is also supported.
413-
Both symbolic (rwxrw-rw-) and 4-digit octal notation (e.g. 0766) are
414-
supported.
413+
is enabled for the account. Sets POSIX access permissions for the file
414+
owner, the file owning group, and others. Each class may be granted
415+
read, write, or execute permission. The sticky bit is also supported.
416+
Both symbolic (rwxrw-rw-) and 4-digit octal notation (e.g. 0766) are
417+
supported.
415418
:keyword ~datetime.datetime if_modified_since:
416419
A DateTime value. Azure expects the date value passed in to be UTC.
417420
If timezone is included, any non-UTC datetimes will be converted to UTC.
@@ -441,13 +444,6 @@ def upload_data(
441444
:keyword ~azure.storage.filedatalake.CustomerProvidedEncryptionKey cpk:
442445
Encrypts the data on the service-side with the given key.
443446
Use of customer-provided keys must be done over HTTPS.
444-
:keyword int timeout:
445-
Sets the server-side timeout for the operation in seconds. For more details see
446-
https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
447-
This value is not tracked or validated on the client. To configure client-side network timesouts
448-
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-file-datalake
449-
#other-client--per-operation-configuration>`_. This method may make multiple calls to the service and
450-
the timeout will apply to each call individually.
451447
:keyword int max_concurrency:
452448
Maximum number of parallel connections to use when transferring the file in chunks.
453449
This option does not affect the underlying connection pool, and may
@@ -462,6 +458,13 @@ def upload_data(
462458
function(current: int, total: int) where current is the number of bytes transferred
463459
so far, and total is the total size of the download.
464460
:paramtype progress_hook: ~typing.Callable[[int, int], None]
461+
:keyword int timeout:
462+
Sets the server-side timeout for the operation in seconds. For more details see
463+
https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
464+
This value is not tracked or validated on the client. To configure client-side network timesouts
465+
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-file-datalake
466+
#other-client--per-operation-configuration>`_. This method may make multiple calls to the service and
467+
the timeout will apply to each call individually.
465468
:returns: A dictionary of response headers.
466469
:rtype: Dict[str, Any]
467470
"""
@@ -523,6 +526,13 @@ def append_data(
523526
:keyword ~azure.storage.filedatalake.CustomerProvidedEncryptionKey cpk:
524527
Encrypts the data on the service-side with the given key.
525528
Use of customer-provided keys must be done over HTTPS.
529+
:keyword int timeout:
530+
Sets the server-side timeout for the operation in seconds. For more details see
531+
https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
532+
This value is not tracked or validated on the client. To configure client-side network timesouts
533+
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-file-datalake
534+
#other-client--per-operation-configuration>`_. This method may make multiple calls to the service and
535+
the timeout will apply to each call individually.
526536
:returns: A dictionary of response headers.
527537
:rtype: Dict[str, Any]
528538
@@ -552,7 +562,7 @@ def flush_data(
552562
retain_uncommitted_data: Optional[bool] = False,
553563
**kwargs: Any
554564
) -> Dict[str, Any]:
555-
""" Commit the previous appended data.
565+
"""Commit the previous appended data.
556566
557567
:param int offset: offset is equal to the length of the file after commit
558568
the previous appended data.
@@ -578,7 +588,7 @@ def flush_data(
578588
been closed). If "false" a change notification is raised indicating
579589
the file has changed. The default is false. This query parameter is
580590
set to true by the Hadoop ABFS driver to indicate that the file stream
581-
has been closed."
591+
has been closed.
582592
:keyword ~datetime.datetime if_modified_since:
583593
A DateTime value. Azure expects the date value passed in to be UTC.
584594
If timezone is included, any non-UTC datetimes will be converted to UTC.
@@ -620,6 +630,13 @@ def flush_data(
620630
:keyword ~azure.storage.filedatalake.CustomerProvidedEncryptionKey cpk:
621631
Encrypts the data on the service-side with the given key.
622632
Use of customer-provided keys must be done over HTTPS.
633+
:keyword int timeout:
634+
Sets the server-side timeout for the operation in seconds. For more details see
635+
https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
636+
This value is not tracked or validated on the client. To configure client-side network timesouts
637+
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-file-datalake
638+
#other-client--per-operation-configuration>`_. This method may make multiple calls to the service and
639+
the timeout will apply to each call individually.
623640
:returns: A dictionary of response headers.
624641
:rtype: Dict[str, Any]
625642

0 commit comments

Comments
 (0)