@@ -493,22 +493,50 @@ class DropboxTeam(_DropboxTransport, DropboxTeamBase):
493
493
token. Methods of this class are meant to act on the team, but there is
494
494
also an :meth:`as_user` method for assuming a team member's identity.
495
495
"""
496
+ def as_admin (self , team_member_id ):
497
+ """
498
+ Allows a team credential to assume the identity of an administrator on the team
499
+ and perform operations on any team-owned content.
500
+
501
+ :param str team_member_id: team member id of administrator to perform actions with
502
+ :return: A :class:`Dropbox` object that can be used to query on behalf
503
+ of this admin of the team.
504
+ :rtype: Dropbox
505
+ """
506
+ return self ._get_dropbox_client_with_select_header ('Dropbox-API-Select-Admin' ,
507
+ team_member_id )
496
508
497
509
def as_user (self , team_member_id ):
498
510
"""
499
511
Allows a team credential to assume the identity of a member of the
500
512
team.
501
513
514
+ :param str team_member_id: team member id of team member to perform actions with
502
515
:return: A :class:`Dropbox` object that can be used to query on behalf
503
516
of this member of the team.
504
517
:rtype: Dropbox
505
518
"""
519
+ return self ._get_dropbox_client_with_select_header ('Dropbox-API-Select-User' ,
520
+ team_member_id )
521
+
522
+ def _get_dropbox_client_with_select_header (self , select_header_name , team_member_id ):
523
+ """
524
+ Get Dropbox client with modified headers
525
+
526
+ :param str select_header_name: Header name used to select users
527
+ :param str team_member_id: team member id of team member to perform actions with
528
+ :return: A :class:`Dropbox` object that can be used to query on behalf
529
+ of a member or admin of the team
530
+ :rtype: Dropbox
531
+ """
532
+
506
533
new_headers = self ._headers .copy () if self ._headers else {}
507
- new_headers ['Dropbox-API-Select-User' ] = team_member_id
534
+ new_headers [select_header_name ] = team_member_id
508
535
return Dropbox (
509
536
self ._oauth2_access_token ,
510
537
max_retries_on_error = self ._max_retries_on_error ,
511
538
max_retries_on_rate_limit = self ._max_retries_on_rate_limit ,
539
+ timeout = self ._timeout ,
512
540
user_agent = self ._raw_user_agent ,
513
541
session = self ._session ,
514
542
headers = new_headers ,
0 commit comments