![](/img/trans.png)
[英]How to create resources in azure data lake gen1 with java sdk?
[英]Azure DataLake Gen1 python SDK for removing recursive Acl on directories
我想在 AzureData lake Gen1 中遞歸刪除 acl。
我可以看到 Gen2 的客戶端 API。
但我找不到 gen1 的任何客戶端 Apis。
可以使用 python 嗎?
以下代碼來自微軟官方文檔This is for 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
我們有關於此的 Microsoft 文檔來解釋我們如何使用 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)
為了以遞歸方式使用它們,我們有一個 Boolean 類型的參數,我們可以在其中指定我們是否可以遞歸地刪除 ACL。
有關這些方法的更多詳細信息,請參閱 GitHub azure-datalake-store-python文檔。
以下是 remove_acl_entries() 的 function 的詳細信息:
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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.