@@ -520,31 +520,43 @@ def _drive_item_loaded():
520
520
_create_and_add_query (parent )
521
521
return return_type
522
522
523
- def move (self , name = None , parent = None ):
523
+ def move (self , name = None , parent = None , conflict_behavior = ConflictBehavior .Fail ):
524
+ # type: (str, ItemReference|"DriveItem", str) -> "DriveItem"
524
525
"""To move a DriveItem to a new parent item, your app requests to update the parentReference of the DriveItem
525
526
to move.
526
527
527
- return_type = ClientResult(self.context, str())
528
+ :param str name: The new name for the move. If this isn't provided, the same name will be used as the
529
+ original.
530
+ :param ItemReference or DriveItem or None parent: Reference to the
531
+ parent item the move will be created in.
532
+ :param str conflict_behavior: query parameter to customize the behavior when a conflict occurs.
533
+ """
528
534
529
- def _create_and_add_query(parent_reference):
535
+ return_type = DriveItem (self .context )
536
+ self .children .add_child (return_type )
537
+
538
+ def _move (parent_reference ):
539
+ # type: (ItemReference) -> None
530
540
payload = {"name" : name , "parentReference" : parent_reference }
531
541
532
542
def _construct_request (request ):
533
543
# type: (RequestOptions) -> None
534
544
request .method = HttpMethod .Patch
545
+ request .url += "?@microsoft.graph.conflictBehavior={0}" .format (
546
+ conflict_behavior
547
+ )
535
548
536
- self.context.before_execute(_construct_request)
537
549
qry = ServiceOperationQuery (self , "" , None , payload , None , return_type )
538
- self.context.add_query(qry)
550
+ self .context .add_query (qry ). before_execute ( _construct_request )
539
551
540
552
if isinstance (parent , DriveItem ):
541
553
542
554
def _drive_item_loaded ():
543
- _create_and_add_query (ItemReference(_id=parent.id))
555
+ _move (ItemReference (_id = parent .id ))
544
556
545
557
parent .ensure_property ("parentReference" , _drive_item_loaded )
546
558
else :
547
- _create_and_add_query (parent)
559
+ _move (parent )
548
560
return return_type
549
561
550
562
def rename (self , new_name ):
0 commit comments