@@ -469,6 +469,7 @@ def convert(self, format_name):
469
469
return self .get_content (format_name )
470
470
471
471
def copy (self , name = None , parent = None , conflict_behavior = ConflictBehavior .Fail ):
472
+ # type: (str, ItemReference|"DriveItem", str) -> ClientResult[str]
472
473
"""Asynchronously creates a copy of an driveItem (including any children), under a new parent item or with a
473
474
new name.
474
475
@@ -480,44 +481,40 @@ def copy(self, name=None, parent=None, conflict_behavior=ConflictBehavior.Fail):
480
481
481
482
Returns location for details about how to monitor the progress of the copy, upon accepting the request.
482
483
"""
483
- return_type = ClientResult (self .context ) # type: ClientResult[ str]
484
+ return_type = ClientResult (self .context , str ())
484
485
485
- def _create_request (request ):
486
- # type: (RequestOptions) -> None
487
- request .url += "?@microsoft.graph.conflictBehavior={0}" .format (
488
- conflict_behavior
489
- )
486
+ def _copy (parent_reference ):
487
+ # type: (ItemReference) -> None
488
+
489
+ def _create_request (request ):
490
+ # type: (RequestOptions) -> None
491
+ request .url += "?@microsoft.graph.conflictBehavior={0}" .format (
492
+ conflict_behavior
493
+ )
494
+
495
+ def _process_response (resp ):
496
+ # type: (requests.Response) -> None
497
+ resp .raise_for_status ()
498
+ location = resp .headers .get ("Location" , None )
499
+ if location is None :
500
+ return
501
+ return_type .set_property ("__value" , location )
490
502
491
- def _process_response (resp ):
492
- # type: (requests.Response) -> None
493
- resp .raise_for_status ()
494
- location = resp .headers .get ("Location" , None )
495
- if location is None :
496
- return
497
- return_type .set_property ("__value" , location )
498
-
499
- def _create_and_add_query (parent_reference ):
500
- """
501
- :param office365.onedrive.listitems.item_reference.ItemReference or None parent_reference: Reference to the
502
- parent item the copy will be created in.
503
- """
504
503
payload = {"name" : name , "parentReference" : parent_reference }
505
- self .context .before_execute (_create_request )
506
- self .context .after_execute (_process_response )
507
504
qry = ServiceOperationQuery (self , "copy" , None , payload , None , return_type )
508
- self .context .add_query (qry )
505
+ self .context .add_query (qry ). before_execute ( _create_request ). after_execute ( _process_response )
509
506
510
507
if isinstance (parent , DriveItem ):
511
508
512
509
def _drive_item_loaded ():
513
510
parent_reference = ItemReference (
514
511
drive_id = parent .parent_reference .driveId , _id = parent .id
515
512
)
516
- _create_and_add_query (parent_reference )
513
+ _copy (parent_reference )
517
514
518
515
parent .ensure_property ("parentReference" , _drive_item_loaded )
519
516
else :
520
- _create_and_add_query (parent )
517
+ _copy (parent )
521
518
return return_type
522
519
523
520
def move (self , name = None , parent = None , conflict_behavior = ConflictBehavior .Fail ):
@@ -668,7 +665,7 @@ def permanent_delete(self):
668
665
return self
669
666
670
667
def restore (self , parent_reference = None , name = None ):
671
- # type: (ItemReference or None , str or None ) -> DriveItem
668
+ # type: (Optional[ ItemReference] , str) -> " DriveItem"
672
669
"""
673
670
Restore a driveItem that has been deleted and is currently in the recycle bin.
674
671
NOTE: This functionality is currently only available for OneDrive Personal.
0 commit comments