async def test_list_paths_using_file_sys_delegation_sas_async( self, datalake_storage_account_name, datalake_storage_account_key): self._setUp(datalake_storage_account_name, datalake_storage_account_key) url = self._get_account_url(datalake_storage_account_name) token_credential = self.generate_oauth_token() dsc = DataLakeServiceClient(url, token_credential) file_system_name = self._get_file_system_reference() directory_client_name = '/' directory_client = (await dsc.create_file_system(file_system_name)).get_directory_client(directory_client_name) random_guid = uuid.uuid4() await directory_client.set_access_control(owner=random_guid, permissions='0777') delegation_key = await dsc.get_user_delegation_key(datetime.utcnow(), datetime.utcnow() + timedelta(hours=1)) token = generate_file_system_sas( dsc.account_name, file_system_name, delegation_key, permission=DirectorySasPermissions(list=True), expiry=datetime.utcnow() + timedelta(hours=1), agent_object_id=random_guid ) sas_directory_client = FileSystemClient(self.dsc.url, file_system_name, credential=token) paths = list() async for path in sas_directory_client.get_paths(): paths.append(path) self.assertEqual(0, 0)
async def look_up_parquet_files(egress_folder_path: str, filesystem_client: FileSystemClient, directory_client: DataLakeDirectoryClient): """ Args: egress_folder_path: Path (without guid prefix) to folder in which parquet files are placed. Example "year=2021/month=01" Returns: List with paths to parquet files in egress_folder_path (without guid prefix). """ guid = directory_client.path_name path_with_guid = f'{guid}/{egress_folder_path}' paths_in_directory = filesystem_client.get_paths(path=path_with_guid) try: parquet_paths_with_guid = [ path.name async for path in paths_in_directory if path.name.endswith('.parquet') ] except ResourceNotFoundError: return [] # Remove guid from paths parquet_paths = [p.split('/', 1)[1] for p in parquet_paths_with_guid] return parquet_paths