Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions sdk/storage/azure-storage-file-datalake/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
include *.md
include azure/__init__.py
include azure/storage/__init__.py
include LICENSE
include azure/storage/filedatalake/_generated/py.typed
recursive-include tests *.py
recursive-include samples *.py *.md
include azure/storage/filedatalake/py.typed
include azure/__init__.py
include azure/storage/__init__.py
include azure/storage/filedatalake/__init__.py
6 changes: 6 additions & 0 deletions sdk/storage/azure-storage-file-datalake/_metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"apiVersion": "2026-02-06",
"apiVersions": {
"Storage.DataLake": "2026-02-06"
}
}
69 changes: 69 additions & 0 deletions sdk/storage/azure-storage-file-datalake/apiview-properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"CrossLanguagePackageId": "Storage.DataLake",
"CrossLanguageDefinitionId": {
"azure.storage.filedatalake._generated.models.AclFailedEntry": "Storage.DataLake.AclFailedEntry",
"azure.storage.filedatalake._generated.models.BlobHierarchyListSegment": "Storage.DataLake.BlobHierarchyListSegment",
"azure.storage.filedatalake._generated.models.BlobItemInternal": "Storage.DataLake.BlobItemInternal",
"azure.storage.filedatalake._generated.models.BlobPrefix": "Storage.DataLake.BlobPrefix",
"azure.storage.filedatalake._generated.models.BlobPropertiesInternal": "Storage.DataLake.BlobPropertiesInternal",
"azure.storage.filedatalake._generated.models.FileSystemItem": "Storage.DataLake.FileSystemItem",
"azure.storage.filedatalake._generated.models.FileSystemList": "Storage.DataLake.FileSystemList",
"azure.storage.filedatalake._generated.models.ListBlobsHierarchySegmentResponse": "Storage.DataLake.ListBlobsHierarchySegmentResponse",
"azure.storage.filedatalake._generated.models.PathItem": "Storage.DataLake.PathItem",
"azure.storage.filedatalake._generated.models.PathList": "Storage.DataLake.PathList",
"azure.storage.filedatalake._generated.models.SetAccessControlRecursiveResponse": "Storage.DataLake.SetAccessControlRecursiveResponse",
"azure.storage.filedatalake._generated.models.StorageError": "Storage.DataLake.StorageError",
"azure.storage.filedatalake._generated.models.StorageErrorBody": "Storage.DataLake.StorageErrorBody",
"azure.storage.filedatalake._generated.models.AccountResourceType": "Storage.DataLake.AccountResourceType",
"azure.storage.filedatalake._generated.models.FileSystemResourceType": "Storage.DataLake.FileSystemResourceType",
"azure.storage.filedatalake._generated.models.ListBlobsIncludeItem": "Storage.DataLake.ListBlobsIncludeItem",
"azure.storage.filedatalake._generated.models.ListBlobsShowOnly": "Storage.DataLake.ListBlobsShowOnly",
"azure.storage.filedatalake._generated.models.PathResourceType": "Storage.DataLake.PathResourceType",
"azure.storage.filedatalake._generated.models.PathRenameMode": "Storage.DataLake.PathRenameMode",
"azure.storage.filedatalake._generated.models.EncryptionAlgorithmType": "Storage.DataLake.EncryptionAlgorithmType",
"azure.storage.filedatalake._generated.models.PathExpiryOptions": "Storage.DataLake.PathExpiryOptions",
"azure.storage.filedatalake._generated.models.PathUpdateAction": "Storage.DataLake.PathUpdateAction",
"azure.storage.filedatalake._generated.models.PathSetAccessControlRecursiveMode": "Storage.DataLake.PathSetAccessControlRecursiveMode",
"azure.storage.filedatalake._generated.models.PathLeaseAction": "Storage.DataLake.PathLeaseAction",
"azure.storage.filedatalake._generated.models.PathGetPropertiesAction": "Storage.DataLake.PathGetPropertiesAction",
"azure.storage.filedatalake._generated.models.LeaseAction": "Storage.DataLake.LeaseAction",
"azure.storage.filedatalake._generated.operations.ServiceOperations.list_file_systems": "Storage.DataLake.Service.listFileSystems",
"azure.storage.filedatalake._generated.aio.operations.ServiceOperations.list_file_systems": "Storage.DataLake.Service.listFileSystems",
"azure.storage.filedatalake._generated.operations.FileSystemOperations.create": "Storage.DataLake.FileSystem.create",
"azure.storage.filedatalake._generated.aio.operations.FileSystemOperations.create": "Storage.DataLake.FileSystem.create",
"azure.storage.filedatalake._generated.operations.FileSystemOperations.set_properties": "Storage.DataLake.FileSystem.setProperties",
"azure.storage.filedatalake._generated.aio.operations.FileSystemOperations.set_properties": "Storage.DataLake.FileSystem.setProperties",
"azure.storage.filedatalake._generated.operations.FileSystemOperations.get_properties": "Storage.DataLake.FileSystem.getProperties",
"azure.storage.filedatalake._generated.aio.operations.FileSystemOperations.get_properties": "Storage.DataLake.FileSystem.getProperties",
"azure.storage.filedatalake._generated.operations.FileSystemOperations.delete": "Storage.DataLake.FileSystem.delete",
"azure.storage.filedatalake._generated.aio.operations.FileSystemOperations.delete": "Storage.DataLake.FileSystem.delete",
"azure.storage.filedatalake._generated.operations.FileSystemOperations.list_paths": "Storage.DataLake.FileSystem.listPaths",
"azure.storage.filedatalake._generated.aio.operations.FileSystemOperations.list_paths": "Storage.DataLake.FileSystem.listPaths",
"azure.storage.filedatalake._generated.operations.FileSystemOperations.list_blob_hierarchy_segment": "Storage.DataLake.FileSystem.listBlobHierarchySegment",
"azure.storage.filedatalake._generated.aio.operations.FileSystemOperations.list_blob_hierarchy_segment": "Storage.DataLake.FileSystem.listBlobHierarchySegment",
"azure.storage.filedatalake._generated.operations.PathOperations.create": "Storage.DataLake.Path.create",
"azure.storage.filedatalake._generated.aio.operations.PathOperations.create": "Storage.DataLake.Path.create",
"azure.storage.filedatalake._generated.operations.PathOperations.update": "Storage.DataLake.Path.update",
"azure.storage.filedatalake._generated.aio.operations.PathOperations.update": "Storage.DataLake.Path.update",
"azure.storage.filedatalake._generated.operations.PathOperations.lease": "Storage.DataLake.Path.lease",
"azure.storage.filedatalake._generated.aio.operations.PathOperations.lease": "Storage.DataLake.Path.lease",
"azure.storage.filedatalake._generated.operations.PathOperations.read": "Storage.DataLake.Path.read",
"azure.storage.filedatalake._generated.aio.operations.PathOperations.read": "Storage.DataLake.Path.read",
"azure.storage.filedatalake._generated.operations.PathOperations.get_properties": "Storage.DataLake.Path.getProperties",
"azure.storage.filedatalake._generated.aio.operations.PathOperations.get_properties": "Storage.DataLake.Path.getProperties",
"azure.storage.filedatalake._generated.operations.PathOperations.delete": "Storage.DataLake.Path.delete",
"azure.storage.filedatalake._generated.aio.operations.PathOperations.delete": "Storage.DataLake.Path.delete",
"azure.storage.filedatalake._generated.operations.PathOperations.set_access_control": "Storage.DataLake.Path.setAccessControl",
"azure.storage.filedatalake._generated.aio.operations.PathOperations.set_access_control": "Storage.DataLake.Path.setAccessControl",
"azure.storage.filedatalake._generated.operations.PathOperations.set_access_control_recursive": "Storage.DataLake.Path.setAccessControlRecursive",
"azure.storage.filedatalake._generated.aio.operations.PathOperations.set_access_control_recursive": "Storage.DataLake.Path.setAccessControlRecursive",
"azure.storage.filedatalake._generated.operations.PathOperations.flush_data": "Storage.DataLake.Path.flushData",
"azure.storage.filedatalake._generated.aio.operations.PathOperations.flush_data": "Storage.DataLake.Path.flushData",
"azure.storage.filedatalake._generated.operations.PathOperations.append_data": "Storage.DataLake.Path.appendData",
"azure.storage.filedatalake._generated.aio.operations.PathOperations.append_data": "Storage.DataLake.Path.appendData",
"azure.storage.filedatalake._generated.operations.PathOperations.set_expiry": "Storage.DataLake.Path.setExpiry",
"azure.storage.filedatalake._generated.aio.operations.PathOperations.set_expiry": "Storage.DataLake.Path.setExpiry",
"azure.storage.filedatalake._generated.operations.PathOperations.undelete": "Storage.DataLake.Path.undelete",
"azure.storage.filedatalake._generated.aio.operations.PathOperations.undelete": "Storage.DataLake.Path.undelete"
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
# pylint: disable=docstring-keyword-should-match-keyword-only

import functools
from typing import (
Any, cast, Dict, Optional, Union,
TYPE_CHECKING
)
from typing import Any, cast, Dict, Optional, Union, TYPE_CHECKING
from urllib.parse import quote, unquote
from typing_extensions import Self

Expand Down Expand Up @@ -84,22 +81,29 @@ class DataLakeDirectoryClient(PathClient):
"""The hostname of the primary endpoint."""

def __init__(
self, account_url: str,
self,
account_url: str,
file_system_name: str,
directory_name: str,
credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
**kwargs: Any
credential: Optional[
Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]
] = None, # pylint: disable=line-too-long
**kwargs: Any,
) -> None:
super(DataLakeDirectoryClient, self).__init__(account_url, file_system_name, path_name=directory_name,
credential=credential, **kwargs)
super(DataLakeDirectoryClient, self).__init__(
account_url, file_system_name, path_name=directory_name, credential=credential, **kwargs
)

@classmethod
def from_connection_string(
cls, conn_str: str,
cls,
conn_str: str,
file_system_name: str,
directory_name: str,
credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
**kwargs: Any
credential: Optional[
Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]
] = None, # pylint: disable=line-too-long
**kwargs: Any,
) -> Self:
"""
Create DataLakeDirectoryClient from a Connection String.
Expand Down Expand Up @@ -135,15 +139,18 @@ def from_connection_string(
:return: A DataLakeDirectoryClient.
:rtype: ~azure.storage.filedatalake.DataLakeDirectoryClient
"""
account_url, _, credential = parse_connection_str(conn_str, credential, 'dfs')
account_url, _, credential = parse_connection_str(conn_str, credential, "dfs")
return cls(
account_url, file_system_name=file_system_name, directory_name=directory_name,
credential=credential, **kwargs)
account_url,
file_system_name=file_system_name,
directory_name=directory_name,
credential=credential,
**kwargs,
)

@distributed_trace
def create_directory(
self, metadata: Optional[Dict[str, str]] = None,
**kwargs: Any
self, metadata: Optional[Dict[str, str]] = None, **kwargs: Any
) -> Dict[str, Union[str, "datetime"]]:
"""
Create a new directory.
Expand Down Expand Up @@ -227,7 +234,7 @@ def create_directory(
:dedent: 8
:caption: Create directory.
"""
return self._create('directory', metadata=metadata, **kwargs)
return self._create("directory", metadata=metadata, **kwargs)

@distributed_trace
def delete_directory(self, **kwargs: Any) -> None:
Expand Down Expand Up @@ -332,11 +339,11 @@ def get_directory_properties(self, **kwargs: Any) -> DirectoryProperties:
:dedent: 4
:caption: Getting the properties for a file/directory.
"""
upn = kwargs.pop('upn', None)
upn = kwargs.pop("upn", None)
if upn:
headers = kwargs.pop('headers', {})
headers['x-ms-upn'] = str(upn)
kwargs['headers'] = headers
headers = kwargs.pop("headers", {})
headers["x-ms-upn"] = str(upn)
kwargs["headers"] = headers
return cast(DirectoryProperties, self._get_path_properties(cls=deserialize_dir_properties, **kwargs))

@distributed_trace
Expand Down Expand Up @@ -425,21 +432,26 @@ def rename_directory(self, new_name: str, **kwargs: Any) -> "DataLakeDirectoryCl
:caption: Rename the source directory.
"""
new_file_system, new_path, new_dir_sas = _parse_rename_path(
new_name, self.file_system_name, self._query_str, self._raw_credential)
new_name, self.file_system_name, self._query_str, self._raw_credential
)

new_directory_client = DataLakeDirectoryClient(
f"{self.scheme}://{self.primary_hostname}", new_file_system, directory_name=new_path,
credential=self._raw_credential or new_dir_sas, _hosts=self._hosts, _configuration=self._config,
_pipeline=self._pipeline)
f"{self.scheme}://{self.primary_hostname}",
new_file_system,
directory_name=new_path,
credential=self._raw_credential or new_dir_sas,
_hosts=self._hosts,
_configuration=self._config,
_pipeline=self._pipeline,
)
new_directory_client._rename_path( # pylint: disable=protected-access
f'/{quote(unquote(self.file_system_name))}/{quote(unquote(self.path_name))}{self._query_str}', **kwargs)
f"/{quote(unquote(self.file_system_name))}/{quote(unquote(self.path_name))}{self._query_str}", **kwargs
)
return new_directory_client

@distributed_trace
def create_sub_directory(
self, sub_directory: Union[DirectoryProperties, str],
metadata: Optional[Dict[str, str]] = None,
**kwargs: Any
self, sub_directory: Union[DirectoryProperties, str], metadata: Optional[Dict[str, str]] = None, **kwargs: Any
) -> "DataLakeDirectoryClient":
"""
Create a subdirectory and return the subdirectory client to be interacted with.
Expand Down Expand Up @@ -524,8 +536,7 @@ def create_sub_directory(

@distributed_trace
def delete_sub_directory( # pylint: disable=delete-operation-wrong-return-type
self, sub_directory: Union[DirectoryProperties, str],
**kwargs: Any
self, sub_directory: Union[DirectoryProperties, str], **kwargs: Any
) -> "DataLakeDirectoryClient":
"""
Marks the specified subdirectory for deletion.
Expand Down Expand Up @@ -661,13 +672,14 @@ def create_file(self, file: Union[FileProperties, str], **kwargs: Any) -> DataLa

@distributed_trace
def get_paths(
self, *,
self,
*,
recursive: bool = True,
max_results: Optional[int] = None,
upn: Optional[bool] = None,
start_from: Optional[str] = None,
timeout: Optional[int] = None,
**kwargs: Any
**kwargs: Any,
) -> ItemPaged["PathProperties"]:
"""Returns a generator to list the paths under specified file system and directory.
The generator will lazily follow the continuation tokens returned by the service.
Expand Down Expand Up @@ -702,15 +714,16 @@ def get_paths(
url = f"{self.scheme}://{hostname}/{quote(self.file_system_name)}"
client = self._build_generated_client(url)
command = functools.partial(
client.file_system.list_paths,
path=self.path_name,
begin_from=start_from,
timeout=timeout,
**kwargs
client.file_system.list_paths, path=self.path_name, begin_from=start_from, timeout=timeout, **kwargs
)
return ItemPaged(
command, recursive, path=self.path_name, max_results=max_results,
upn=upn, page_iterator_class=PathPropertiesPaged, **kwargs
command,
recursive,
path=self.path_name,
max_results=max_results,
upn=upn,
page_iterator_class=PathPropertiesPaged,
**kwargs,
)

def get_file_client(self, file: Union[FileProperties, str]) -> DataLakeFileClient:
Expand All @@ -726,18 +739,24 @@ def get_file_client(self, file: Union[FileProperties, str]) -> DataLakeFileClien
:rtype: ~azure.storage.filedatalake.DataLakeFileClient
"""
if isinstance(file, FileProperties):
file_path = file.get('name')
file_path = file.get("name")
else:
file_path = self.path_name + '/' + str(file)
file_path = self.path_name + "/" + str(file)

_pipeline = Pipeline(
transport=TransportWrapper(self._pipeline._transport), # pylint: disable = protected-access
policies=self._pipeline._impl_policies # pylint: disable = protected-access
transport=TransportWrapper(self._pipeline._transport), # pylint: disable = protected-access
policies=self._pipeline._impl_policies, # pylint: disable = protected-access
)
return DataLakeFileClient(
self.url, self.file_system_name, file_path=file_path, credential=self._raw_credential,
self.url,
self.file_system_name,
file_path=file_path,
credential=self._raw_credential,
api_version=self.api_version,
_hosts=self._hosts, _configuration=self._config, _pipeline=_pipeline)
_hosts=self._hosts,
_configuration=self._config,
_pipeline=_pipeline,
)

def get_sub_directory_client(self, sub_directory: Union[DirectoryProperties, str]) -> "DataLakeDirectoryClient":
"""Get a client to interact with the specified subdirectory of the current directory.
Expand All @@ -752,15 +771,21 @@ def get_sub_directory_client(self, sub_directory: Union[DirectoryProperties, str
:rtype: ~azure.storage.filedatalake.DataLakeDirectoryClient
"""
if isinstance(sub_directory, DirectoryProperties):
subdir_path = sub_directory.get('name')
subdir_path = sub_directory.get("name")
else:
subdir_path = self.path_name + '/' + str(sub_directory)
subdir_path = self.path_name + "/" + str(sub_directory)

_pipeline = Pipeline(
transport=TransportWrapper(self._pipeline._transport), # pylint: disable=protected-access
policies=self._pipeline._impl_policies # pylint: disable=protected-access
transport=TransportWrapper(self._pipeline._transport), # pylint: disable=protected-access
policies=self._pipeline._impl_policies, # pylint: disable=protected-access
)
return DataLakeDirectoryClient(
self.url, self.file_system_name, directory_name=subdir_path, credential=self._raw_credential,
self.url,
self.file_system_name,
directory_name=subdir_path,
credential=self._raw_credential,
api_version=self.api_version,
_hosts=self._hosts, _configuration=self._config, _pipeline=_pipeline)
_hosts=self._hosts,
_configuration=self._config,
_pipeline=_pipeline,
)
Loading
Loading