@@ -3407,7 +3407,7 @@ def undelete_blob(self, container_name, blob_name, timeout=None):
3407
3407
3408
3408
# ----------------------------Methods related to directory manipulations---------------------------- #
3409
3409
3410
- def create_directory (self , container_name , directory_path , proposed_lease_id = None , lease_id = None , metadata = None ,
3410
+ def create_directory (self , container_name , directory_path , lease_id = None , metadata = None ,
3411
3411
posix_permissions = None , posix_umask = None , timeout = None ):
3412
3412
"""
3413
3413
Create a directory which can contain other directories or blobs.
@@ -3416,10 +3416,7 @@ def create_directory(self, container_name, directory_path, proposed_lease_id=Non
3416
3416
Name of existing container.
3417
3417
:param str directory_path:
3418
3418
Path of the directory to be created. Ex: 'dirfoo/dirbar'.
3419
- :param str proposed_lease_id:
3420
- Proposed lease ID, in a GUID string format. The Blob service
3421
- returns 400 (Invalid request) if the proposed lease ID is not
3422
- in the correct format.
3419
+ The service will create parent directories if they do not exist yet.
3423
3420
:param str lease_id:
3424
3421
Required if the directory to be overwritten has an active lease.
3425
3422
:param metadata:
@@ -3459,16 +3456,15 @@ def create_directory(self, container_name, directory_path, proposed_lease_id=Non
3459
3456
'timeout' : _int_to_str (timeout ),
3460
3457
}
3461
3458
request .headers = {
3462
- 'x-ms-proposed-lease-id' : _to_str (proposed_lease_id ),
3463
3459
'x-ms-lease-id' : _to_str (lease_id ),
3464
3460
'x-ms-permissions' : _to_str (posix_permissions ),
3465
3461
'x-ms-umask' : _to_str (posix_umask ),
3466
3462
}
3467
- # TODO add test cases for lease and metadata
3463
+ # TODO add test cases for lease
3468
3464
_add_file_or_directory_properties_header (metadata , request )
3469
3465
return self ._perform_request (request , parser = _parse_base_properties )
3470
3466
3471
- def delete_directory (self , container_name , directory_path , fail_not_exist = False , recursive = True , marker = None ,
3467
+ def delete_directory (self , container_name , directory_path , fail_not_exist = False , recursive = False , marker = None ,
3472
3468
lease_id = None , if_modified_since = None , if_unmodified_since = None , if_match = None ,
3473
3469
if_none_match = None , timeout = None ):
3474
3470
"""
@@ -3551,22 +3547,28 @@ def delete_directory(self, container_name, directory_path, fail_not_exist=False,
3551
3547
3552
3548
def rename_path (self , container_name , new_path , source_path ,
3553
3549
mode = None , marker = None , lease_id = None , source_lease_id = None ,
3554
- metadata = None , source_if_modified_since = None , source_if_unmodified_since = None ,
3550
+ source_if_modified_since = None , source_if_unmodified_since = None ,
3555
3551
source_if_match = None , source_if_none_match = None , timeout = None ):
3556
3552
"""
3557
3553
Rename a blob or directory(which can contain other directories or blobs).
3558
3554
3559
3555
:param str container_name:
3560
3556
Name of existing container.
3561
3557
:param str new_path:
3562
- New path for source_path. Ex: 'dirfoo/dirsubfoo'.
3558
+ New path for source_path. Ex: 'topdir1/dirsubfoo'.
3559
+ Note that the path should be an absolute path under the container.
3563
3560
:param str source_path:
3564
- Path to be renamed. Ex: 'dirfoo/dirbar'.
3561
+ Path to be renamed. Ex: 'topdir1/dirbar'.
3562
+ Note that the path should be an absolute path under the container.
3565
3563
:param mode:
3566
3564
Optional. Valid only when namespace is enabled.
3567
3565
This parameter determines the behavior of the rename operation.
3568
3566
The value must be "legacy" or "posix", and the default value will be "posix".
3569
- A "posix" rename is done atomically; a "legacy" rename is done in batches and could return a marker.
3567
+ Legacy: if the destination of the move is an existing directory and that directory is empty,
3568
+ the source will overwrite the destination. If the directory is not empty, the move will fail.
3569
+ Posix: if the destination of the move is an existing empty directory,
3570
+ destination will be overwritten. Otherwise, the source will be moved into the destination directory.
3571
+ If the destination is an existing file, the file will be overwritten.
3570
3572
:param marker:
3571
3573
Optional. When renaming a directory, the number of paths that are renamed with each invocation is limited.
3572
3574
If the number of paths to be renamed exceeds this limit,
@@ -3578,12 +3580,6 @@ def rename_path(self, container_name, new_path, source_path,
3578
3580
:param str source_lease_id:
3579
3581
Optional. A lease ID for the source_path.
3580
3582
The source_path must have an active lease and the lease ID must match.
3581
- :param metadata:
3582
- Optional. A dict with name_value pairs to associate with the path as metadata.
3583
- Example:{'Category':'test'}.
3584
- If metadata is specified, it will overwrite the existing metadata;
3585
- otherwise, the existing metadata will be preserved.
3586
- :type metadata: dict(str, str)
3587
3583
:param datetime source_if_modified_since:
3588
3584
Optional. A date and time value. Specify this header to perform the rename operation
3589
3585
only if the source has been modified since the specified date and time.
@@ -3625,8 +3621,6 @@ def rename_path(self, container_name, new_path, source_path,
3625
3621
'x-ms-source-if-match' : _to_str (source_if_match ),
3626
3622
'x-ms-source-if-none-match' : _to_str (source_if_none_match ),
3627
3623
}
3628
- # TODO add test cases for lease and metadata
3629
- _add_file_or_directory_properties_header (metadata , request )
3630
3624
return self ._perform_request (request , parser = _parse_continuation_token )
3631
3625
3632
3626
def get_path_access_control (self , container_name , path , user_principle_names = False ,
0 commit comments