1212from azure .storage .blob import ResourceTypes as BlobResourceTypes
1313from azure .storage .blob import UserDelegationKey as BlobUserDelegationKey
1414from azure .storage .blob import ContentSettings as BlobContentSettings
15- from azure .storage .blob import ContainerSasPermissions , BlobSasPermissions
1615from azure .storage .blob import AccessPolicy as BlobAccessPolicy
1716from azure .storage .blob import DelimitedTextDialect as BlobDelimitedTextDialect
1817from azure .storage .blob import DelimitedJsonDialect as BlobDelimitedJSON
@@ -294,7 +293,7 @@ def __init__(self, read=False, write=False, delete=False, list=False, # pylint:
294293 )
295294
296295
297- class FileSystemSasPermissions (ContainerSasPermissions ):
296+ class FileSystemSasPermissions (object ):
298297 """FileSystemSasPermissions class to be used with the
299298 :func:`~azure.storage.filedatalake.generate_file_system_sas` function.
300299
@@ -308,14 +307,57 @@ class FileSystemSasPermissions(ContainerSasPermissions):
308307 List paths in the file system.
309308 """
310309
311- def __init__ (self , read = False , write = False , delete = False , list = False # pylint: disable=redefined-builtin
312- ):
313- super (FileSystemSasPermissions , self ).__init__ (
314- read = read , write = write , delete = delete , list = list
315- )
316-
310+ def __init__ (self , read = False , write = False , delete = False , list = False , # pylint: disable=redefined-builtin
311+ ** kwargs ):
312+ self .read = read
313+ self .write = write
314+ self .delete = delete
315+ self .list = list
316+ self .move = kwargs .pop ('move' , None )
317+ self .execute = kwargs .pop ('execute' , None )
318+ self .manage_ownership = kwargs .pop ('manage_ownership' , None )
319+ self .manage_access_control = kwargs .pop ('manage_access_control' , None )
320+ self ._str = (('r' if self .read else '' ) +
321+ ('w' if self .write else '' ) +
322+ ('d' if self .delete else '' ) +
323+ ('l' if self .list else '' ) +
324+ ('m' if self .move else '' ) +
325+ ('e' if self .execute else '' ) +
326+ ('o' if self .manage_ownership else '' ) +
327+ ('p' if self .manage_access_control else '' ))
328+
329+ def __str__ (self ):
330+ return self ._str
317331
318- class DirectorySasPermissions (BlobSasPermissions ):
332+ @classmethod
333+ def from_string (cls , permission ):
334+ """Create a FileSystemSasPermissions from a string.
335+
336+ To specify read, write, or delete permissions you need only to
337+ include the first letter of the word in the string. E.g. For read and
338+ write permissions, you would provide a string "rw".
339+
340+ :param str permission: The string which dictates the read, add, create,
341+ write, or delete permissions.
342+ :return: A FileSystemSasPermissions object
343+ :rtype: ~azure.storage.fildatalake.FileSystemSasPermissions
344+ """
345+ p_read = 'r' in permission
346+ p_write = 'w' in permission
347+ p_delete = 'd' in permission
348+ p_list = 'l' in permission
349+ p_move = 'm' in permission
350+ p_execute = 'e' in permission
351+ p_manage_ownership = 'o' in permission
352+ p_manage_access_control = 'p' in permission
353+
354+ parsed = cls (read = p_read , write = p_write , delete = p_delete ,
355+ list = p_list , move = p_move , execute = p_execute , manage_ownership = p_manage_ownership ,
356+ manage_access_control = p_manage_access_control )
357+ return parsed
358+
359+
360+ class DirectorySasPermissions (object ):
319361 """DirectorySasPermissions class to be used with the
320362 :func:`~azure.storage.filedatalake.generate_directory_sas` function.
321363
@@ -327,17 +369,77 @@ class DirectorySasPermissions(BlobSasPermissions):
327369 Create or write content, properties, metadata. Lease the directory.
328370 :param bool delete:
329371 Delete the directory.
372+ :keyword bool list:
373+ List any files in the directory. Implies Execute.
374+ :keyword bool move:
375+ Move any file in the directory to a new location.
376+ Note the move operation can optionally be restricted to the child file or directory owner or
377+ the parent directory owner if the saoid parameter is included in the token and the sticky bit is set
378+ on the parent directory.
379+ :keyword bool execute:
380+ Get the status (system defined properties) and ACL of any file in the directory.
381+ If the caller is the owner, set access control on any file in the directory.
382+ :keyword bool manage_ownership:
383+ Allows the user to set owner, owning group, or act as the owner when renaming or deleting a file or directory
384+ within a folder that has the sticky bit set.
385+ :keyword bool manage_access_control:
386+ Allows the user to set permissions and POSIX ACLs on files and directories.
330387 """
331388
332389 def __init__ (self , read = False , create = False , write = False ,
333- delete = False ):
334- super (DirectorySasPermissions , self ).__init__ (
335- read = read , create = create , write = write ,
336- delete = delete
337- )
390+ delete = False , ** kwargs ):
391+ self .read = read
392+ self .create = create
393+ self .write = write
394+ self .delete = delete
395+ self .list = kwargs .pop ('list' , None )
396+ self .move = kwargs .pop ('move' , None )
397+ self .execute = kwargs .pop ('execute' , None )
398+ self .manage_ownership = kwargs .pop ('manage_ownership' , None )
399+ self .manage_access_control = kwargs .pop ('manage_access_control' , None )
400+ self ._str = (('r' if self .read else '' ) +
401+ ('c' if self .create else '' ) +
402+ ('w' if self .write else '' ) +
403+ ('d' if self .delete else '' ) +
404+ ('l' if self .list else '' ) +
405+ ('m' if self .move else '' ) +
406+ ('e' if self .execute else '' ) +
407+ ('o' if self .manage_ownership else '' ) +
408+ ('p' if self .manage_access_control else '' ))
409+
410+ def __str__ (self ):
411+ return self ._str
338412
339-
340- class FileSasPermissions (BlobSasPermissions ):
413+ @classmethod
414+ def from_string (cls , permission ):
415+ """Create a DirectorySasPermissions from a string.
416+
417+ To specify read, create, write, or delete permissions you need only to
418+ include the first letter of the word in the string. E.g. For read and
419+ write permissions, you would provide a string "rw".
420+
421+ :param str permission: The string which dictates the read, add, create,
422+ write, or delete permissions.
423+ :return: A DirectorySasPermissions object
424+ :rtype: ~azure.storage.filedatalake.DirectorySasPermissions
425+ """
426+ p_read = 'r' in permission
427+ p_create = 'c' in permission
428+ p_write = 'w' in permission
429+ p_delete = 'd' in permission
430+ p_list = 'l' in permission
431+ p_move = 'm' in permission
432+ p_execute = 'e' in permission
433+ p_manage_ownership = 'o' in permission
434+ p_manage_access_control = 'p' in permission
435+
436+ parsed = cls (read = p_read , create = p_create , write = p_write , delete = p_delete ,
437+ list = p_list , move = p_move , execute = p_execute , manage_ownership = p_manage_ownership ,
438+ manage_access_control = p_manage_access_control )
439+ return parsed
440+
441+
442+ class FileSasPermissions (object ):
341443 """FileSasPermissions class to be used with the
342444 :func:`~azure.storage.filedatalake.generate_file_sas` function.
343445
@@ -350,14 +452,69 @@ class FileSasPermissions(BlobSasPermissions):
350452 Create or write content, properties, metadata. Lease the file.
351453 :param bool delete:
352454 Delete the file.
353- """
455+ :keyword bool move:
456+ Move any file in the directory to a new location.
457+ Note the move operation can optionally be restricted to the child file or directory owner or
458+ the parent directory owner if the saoid parameter is included in the token and the sticky bit is set
459+ on the parent directory.
460+ :keyword bool execute:
461+ Get the status (system defined properties) and ACL of any file in the directory.
462+ If the caller is the owner, set access control on any file in the directory.
463+ :keyword bool manage_ownership:
464+ Allows the user to set owner, owning group, or act as the owner when renaming or deleting a file or directory
465+ within a folder that has the sticky bit set.
466+ :keyword bool manage_access_control:
467+ Allows the user to set permissions and POSIX ACLs on files and directories.
468+ """
469+
470+ def __init__ (self , read = False , create = False , write = False , delete = False , ** kwargs ):
471+ self .read = read
472+ self .create = create
473+ self .write = write
474+ self .delete = delete
475+ self .list = list
476+ self .move = kwargs .pop ('move' , None )
477+ self .execute = kwargs .pop ('execute' , None )
478+ self .manage_ownership = kwargs .pop ('manage_ownership' , None )
479+ self .manage_access_control = kwargs .pop ('manage_access_control' , None )
480+ self ._str = (('r' if self .read else '' ) +
481+ ('c' if self .create else '' ) +
482+ ('w' if self .write else '' ) +
483+ ('d' if self .delete else '' ) +
484+ ('m' if self .move else '' ) +
485+ ('e' if self .execute else '' ) +
486+ ('o' if self .manage_ownership else '' ) +
487+ ('p' if self .manage_access_control else '' ))
488+
489+ def __str__ (self ):
490+ return self ._str
354491
355- def __init__ (self , read = False , create = False , write = False ,
356- delete = False ):
357- super (FileSasPermissions , self ).__init__ (
358- read = read , create = create , write = write ,
359- delete = delete
360- )
492+ @classmethod
493+ def from_string (cls , permission ):
494+ """Create a FileSasPermissions from a string.
495+
496+ To specify read, write, or delete permissions you need only to
497+ include the first letter of the word in the string. E.g. For read and
498+ write permissions, you would provide a string "rw".
499+
500+ :param str permission: The string which dictates the read, add, create,
501+ write, or delete permissions.
502+ :return: A FileSasPermissions object
503+ :rtype: ~azure.storage.fildatalake.FileSasPermissions
504+ """
505+ p_read = 'r' in permission
506+ p_create = 'c' in permission
507+ p_write = 'w' in permission
508+ p_delete = 'd' in permission
509+ p_move = 'm' in permission
510+ p_execute = 'e' in permission
511+ p_manage_ownership = 'o' in permission
512+ p_manage_access_control = 'p' in permission
513+
514+ parsed = cls (read = p_read , create = p_create , write = p_write , delete = p_delete ,
515+ move = p_move , execute = p_execute , manage_ownership = p_manage_ownership ,
516+ manage_access_control = p_manage_access_control )
517+ return parsed
361518
362519
363520class AccessPolicy (BlobAccessPolicy ):
0 commit comments