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
@@ -306,16 +305,72 @@ class FileSystemSasPermissions(ContainerSasPermissions):
306305 Delete the file system.
307306 :param bool list:
308307 List paths in the file system.
308+ :keyword bool move:
309+ Move any file in the directory to a new location.
310+ Note the move operation can optionally be restricted to the child file or directory owner or
311+ the parent directory owner if the saoid parameter is included in the token and the sticky bit is set
312+ on the parent directory.
313+ :keyword bool execute:
314+ Get the status (system defined properties) and ACL of any file in the directory.
315+ If the caller is the owner, set access control on any file in the directory.
316+ :keyword bool manage_ownership:
317+ Allows the user to set owner, owning group, or act as the owner when renaming or deleting a file or directory
318+ within a folder that has the sticky bit set.
319+ :keyword bool manage_access_control:
320+ Allows the user to set permissions and POSIX ACLs on files and directories.
309321 """
310322
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-
323+ def __init__ (self , read = False , write = False , delete = False , list = False , # pylint: disable=redefined-builtin
324+ ** kwargs ):
325+ self .read = read
326+ self .write = write
327+ self .delete = delete
328+ self .list = list
329+ self .move = kwargs .pop ('move' , None )
330+ self .execute = kwargs .pop ('execute' , None )
331+ self .manage_ownership = kwargs .pop ('manage_ownership' , None )
332+ self .manage_access_control = kwargs .pop ('manage_access_control' , None )
333+ self ._str = (('r' if self .read else '' ) +
334+ ('w' if self .write else '' ) +
335+ ('d' if self .delete else '' ) +
336+ ('l' if self .list else '' ) +
337+ ('m' if self .move else '' ) +
338+ ('e' if self .execute else '' ) +
339+ ('o' if self .manage_ownership else '' ) +
340+ ('p' if self .manage_access_control else '' ))
341+
342+ def __str__ (self ):
343+ return self ._str
317344
318- class DirectorySasPermissions (BlobSasPermissions ):
345+ @classmethod
346+ def from_string (cls , permission ):
347+ """Create a FileSystemSasPermissions from a string.
348+
349+ To specify read, write, or delete permissions you need only to
350+ include the first letter of the word in the string. E.g. For read and
351+ write permissions, you would provide a string "rw".
352+
353+ :param str permission: The string which dictates the read, add, create,
354+ write, or delete permissions.
355+ :return: A FileSystemSasPermissions object
356+ :rtype: ~azure.storage.fildatalake.FileSystemSasPermissions
357+ """
358+ p_read = 'r' in permission
359+ p_write = 'w' in permission
360+ p_delete = 'd' in permission
361+ p_list = 'l' in permission
362+ p_move = 'm' in permission
363+ p_execute = 'e' in permission
364+ p_manage_ownership = 'o' in permission
365+ p_manage_access_control = 'p' in permission
366+
367+ parsed = cls (read = p_read , write = p_write , delete = p_delete ,
368+ list = p_list , move = p_move , execute = p_execute , manage_ownership = p_manage_ownership ,
369+ manage_access_control = p_manage_access_control )
370+ return parsed
371+
372+
373+ class DirectorySasPermissions (object ):
319374 """DirectorySasPermissions class to be used with the
320375 :func:`~azure.storage.filedatalake.generate_directory_sas` function.
321376
@@ -327,17 +382,77 @@ class DirectorySasPermissions(BlobSasPermissions):
327382 Create or write content, properties, metadata. Lease the directory.
328383 :param bool delete:
329384 Delete the directory.
385+ :keyword bool list:
386+ List any files in the directory. Implies Execute.
387+ :keyword bool move:
388+ Move any file in the directory to a new location.
389+ Note the move operation can optionally be restricted to the child file or directory owner or
390+ the parent directory owner if the saoid parameter is included in the token and the sticky bit is set
391+ on the parent directory.
392+ :keyword bool execute:
393+ Get the status (system defined properties) and ACL of any file in the directory.
394+ If the caller is the owner, set access control on any file in the directory.
395+ :keyword bool manage_ownership:
396+ Allows the user to set owner, owning group, or act as the owner when renaming or deleting a file or directory
397+ within a folder that has the sticky bit set.
398+ :keyword bool manage_access_control:
399+ Allows the user to set permissions and POSIX ACLs on files and directories.
330400 """
331401
332402 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- )
403+ delete = False , ** kwargs ):
404+ self .read = read
405+ self .create = create
406+ self .write = write
407+ self .delete = delete
408+ self .list = kwargs .pop ('list' , None )
409+ self .move = kwargs .pop ('move' , None )
410+ self .execute = kwargs .pop ('execute' , None )
411+ self .manage_ownership = kwargs .pop ('manage_ownership' , None )
412+ self .manage_access_control = kwargs .pop ('manage_access_control' , None )
413+ self ._str = (('r' if self .read else '' ) +
414+ ('c' if self .create else '' ) +
415+ ('w' if self .write else '' ) +
416+ ('d' if self .delete else '' ) +
417+ ('l' if self .list else '' ) +
418+ ('m' if self .move else '' ) +
419+ ('e' if self .execute else '' ) +
420+ ('o' if self .manage_ownership else '' ) +
421+ ('p' if self .manage_access_control else '' ))
422+
423+ def __str__ (self ):
424+ return self ._str
338425
339-
340- class FileSasPermissions (BlobSasPermissions ):
426+ @classmethod
427+ def from_string (cls , permission ):
428+ """Create a DirectorySasPermissions from a string.
429+
430+ To specify read, create, write, or delete permissions you need only to
431+ include the first letter of the word in the string. E.g. For read and
432+ write permissions, you would provide a string "rw".
433+
434+ :param str permission: The string which dictates the read, add, create,
435+ write, or delete permissions.
436+ :return: A DirectorySasPermissions object
437+ :rtype: ~azure.storage.filedatalake.DirectorySasPermissions
438+ """
439+ p_read = 'r' in permission
440+ p_create = 'c' in permission
441+ p_write = 'w' in permission
442+ p_delete = 'd' in permission
443+ p_list = 'l' in permission
444+ p_move = 'm' in permission
445+ p_execute = 'e' in permission
446+ p_manage_ownership = 'o' in permission
447+ p_manage_access_control = 'p' in permission
448+
449+ parsed = cls (read = p_read , create = p_create , write = p_write , delete = p_delete ,
450+ list = p_list , move = p_move , execute = p_execute , manage_ownership = p_manage_ownership ,
451+ manage_access_control = p_manage_access_control )
452+ return parsed
453+
454+
455+ class FileSasPermissions (object ):
341456 """FileSasPermissions class to be used with the
342457 :func:`~azure.storage.filedatalake.generate_file_sas` function.
343458
@@ -350,14 +465,69 @@ class FileSasPermissions(BlobSasPermissions):
350465 Create or write content, properties, metadata. Lease the file.
351466 :param bool delete:
352467 Delete the file.
353- """
468+ :keyword bool move:
469+ Move any file in the directory to a new location.
470+ Note the move operation can optionally be restricted to the child file or directory owner or
471+ the parent directory owner if the saoid parameter is included in the token and the sticky bit is set
472+ on the parent directory.
473+ :keyword bool execute:
474+ Get the status (system defined properties) and ACL of any file in the directory.
475+ If the caller is the owner, set access control on any file in the directory.
476+ :keyword bool manage_ownership:
477+ Allows the user to set owner, owning group, or act as the owner when renaming or deleting a file or directory
478+ within a folder that has the sticky bit set.
479+ :keyword bool manage_access_control:
480+ Allows the user to set permissions and POSIX ACLs on files and directories.
481+ """
482+
483+ def __init__ (self , read = False , create = False , write = False , delete = False , ** kwargs ):
484+ self .read = read
485+ self .create = create
486+ self .write = write
487+ self .delete = delete
488+ self .list = list
489+ self .move = kwargs .pop ('move' , None )
490+ self .execute = kwargs .pop ('execute' , None )
491+ self .manage_ownership = kwargs .pop ('manage_ownership' , None )
492+ self .manage_access_control = kwargs .pop ('manage_access_control' , None )
493+ self ._str = (('r' if self .read else '' ) +
494+ ('c' if self .create else '' ) +
495+ ('w' if self .write else '' ) +
496+ ('d' if self .delete else '' ) +
497+ ('m' if self .move else '' ) +
498+ ('e' if self .execute else '' ) +
499+ ('o' if self .manage_ownership else '' ) +
500+ ('p' if self .manage_access_control else '' ))
501+
502+ def __str__ (self ):
503+ return self ._str
354504
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- )
505+ @classmethod
506+ def from_string (cls , permission ):
507+ """Create a FileSasPermissions from a string.
508+
509+ To specify read, write, or delete permissions you need only to
510+ include the first letter of the word in the string. E.g. For read and
511+ write permissions, you would provide a string "rw".
512+
513+ :param str permission: The string which dictates the read, add, create,
514+ write, or delete permissions.
515+ :return: A FileSasPermissions object
516+ :rtype: ~azure.storage.fildatalake.FileSasPermissions
517+ """
518+ p_read = 'r' in permission
519+ p_create = 'c' in permission
520+ p_write = 'w' in permission
521+ p_delete = 'd' in permission
522+ p_move = 'm' in permission
523+ p_execute = 'e' in permission
524+ p_manage_ownership = 'o' in permission
525+ p_manage_access_control = 'p' in permission
526+
527+ parsed = cls (read = p_read , create = p_create , write = p_write , delete = p_delete ,
528+ move = p_move , execute = p_execute , manage_ownership = p_manage_ownership ,
529+ manage_access_control = p_manage_access_control )
530+ return parsed
361531
362532
363533class AccessPolicy (BlobAccessPolicy ):
0 commit comments