Azure DataLake Gen1 python SDK用于删除目录上的递归Acl



我想在AzureData lake Gen1中递归地删除acl。

我可以看到Gen2的客户端api。

但是我找不到gen1的任何客户端api。

可以使用python吗?

下面的代码来自Microsoft官方文档这是DataLake Gen2

def remove_permission_recursively(is_default_scope):
try:
file_system_client = service_client.get_file_system_client(file_system="my-container")
directory_client = file_system_client.get_directory_client("my-parent-directory")
acl = 'user:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
if is_default_scope:
acl = 'default:user:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
directory_client.remove_access_control_recursive(acl=acl)
except Exception as e:
print(e)

我们有Python SDK在Azure Data Lake Storage Gen1上执行文件系统操作。

这里我们需要安装以下模块:

pip install azure-mgmt-resource
pip install azure-mgmt-datalake-store
pip install azure-datalake-store

我们有微软的相关文档来解释我们如何使用DLS Gen1处理Azure上的文件系统操作。

此外,我们有以下方法可以帮助我们处理ACL:

remove_acl(self, path)
remove_acl_entries(self, path, acl_spec, recursive=False, number_of_sub_process=None)
remove_default_acl(self, path)

为了递归地使用它们,我们有一个布尔类型的形参,用来指定是否可以递归地删除ACL。

有关这些方法的更多详细信息,请参阅GitHub azure-data -store-python文档。

下面是remove_acl_entries()的详细函数:

def remove_acl_entries(self, path, acl_spec, recursive=False, number_of_sub_process=None):
"""
Remove existing, named, Access Control List (ACL) entries on a file or folder.
If the entry does not exist already it is ignored.
Default entries cannot be removed this way, please use remove_default_acl for that.
Unnamed entries cannot be removed in this way, please use remove_acl for that.
Note: this is by default not recursive, and applies only to the file or folder specified.
Parameters
----------
path: str
Location to remove the ACL entries.
acl_spec: str
The ACL specification to remove from the ACL at the path in the format (note that the permission portion is missing)
'[default:]user|group|other:[entity id or UPN],[default:]user|group|other:[entity id or UPN],...'
recursive: bool
Specifies whether to remove ACLs recursively or not
"""
if recursive:
multi_processor_change_acl(adl=self, path=path, method_name="rem_acl", acl_spec=acl_spec,
number_of_sub_process=number_of_sub_process)
else:
self._acl_call('REMOVEACLENTRIES', path, acl_spec, invalidate_cache=True)

相关内容

  • 没有找到相关文章