@@ -162,6 +162,8 @@ def list_members(self) -> List[TeamMember]:
162162 """
163163 List all of the members in the current team.
164164
165+ Requires admin privileges.
166+
165167 Returns
166168 -------
167169 List[TeamMember]
@@ -172,37 +174,81 @@ def list_members(self) -> List[TeamMember]:
172174 version = self ._api_version )["users" ]
173175 return [TeamMember (user = User .build (m ), team = self , actions = m ["actions" ]) for m in members ]
174176
175- def remove_user (self , user_id : Union [str , UUID ]) -> bool :
177+ def get_member (self , user_id : Union [str , UUID , User ]) -> TeamMember :
176178 """
177- Remove a User from a Team.
179+ Get a particular member in the current team.
180+
181+ May require admin privileges depending on which user is being requested.
178182
179183 Parameters
180184 ----------
181185 user_id: str or uuid
182186 The id of the user to remove from the team
183187
188+ Returns
189+ -------
190+ TeamMember
191+ The requested team member
192+
193+ """
194+ if isinstance (user_id , User ):
195+ user_id = user_id .uid
196+ path = self ._path () + format_escaped_url ('/users/{user_id}' , user_id = user_id )
197+ member = self .session .get_resource (path = path , version = self ._api_version )["user" ]
198+ return TeamMember (user = User .build (member ), team = self , actions = member ["actions" ])
199+
200+ def me (self ) -> TeamMember :
201+ """
202+ Get the member for the current user.
203+
204+ Returns
205+ -------
206+ TeamMember
207+ The TeamMember object representing the current user
208+
209+ """
210+ me = UserCollection (self .session ).me ()
211+ return self .get_member (me )
212+
213+ def remove_user (self , user_id : Union [str , UUID , User ]) -> bool :
214+ """
215+ Remove a User from a Team.
216+
217+ Requires admin privileges.
218+
219+ Parameters
220+ ----------
221+ user_id: User, str or uuid
222+ The id of the user to remove from the team
223+
184224 Returns
185225 -------
186226 bool
187227 Returns ``True`` if user successfully removed
188228
189229 """
230+ if isinstance (user_id , User ):
231+ user_id = user_id .uid
190232 self .session .checked_post (self ._path () + "/users/batch-remove" ,
191233 json = {"ids" : [str (user_id )]}, version = self ._api_version )
192234 return True # note: only get here if checked_post doesn't raise error
193235
194- def add_user (self , user_id : Union [str , UUID ], * ,
236+ def add_user (self ,
237+ user_id : Union [str , UUID , User ],
238+ * ,
195239 actions : Optional [List [TEAM_ACTIONS ]] = None ) -> bool :
196240 """
197241 Add a User to a Team.
198242
243+ Requires admin privileges.
244+
199245 If no actions are specified, adds User with ``READ`` action to the Team.
200246
201247 Use the `update_user_action` method to change a User's actions.
202248
203249 Parameters
204250 ----------
205- user_id: str or uuid
251+ user_id: User, str or uuid
206252 The id of the user to add to the team
207253 actions: list of TEAM_ACTIONS
208254 The actions to give the new user in this team
@@ -215,18 +261,24 @@ def add_user(self, user_id: Union[str, UUID], *,
215261 Returns ``True`` if user successfully added
216262
217263 """
264+ if isinstance (user_id , User ):
265+ user_id = user_id .uid
218266 if actions is None :
219267 actions = [READ ]
220268 return self .update_user_action (user_id , actions = actions )
221269
222- def update_user_action (self , user_id : Union [str , UUID ], * ,
270+ def update_user_action (self ,
271+ user_id : Union [str , UUID , User ],
272+ * ,
223273 actions : List [TEAM_ACTIONS ]) -> bool :
224274 """
225275 Overwrites a User's action permissions in the Team.
226276
277+ Requires admin privileges.
278+
227279 Parameters
228280 ----------
229- user_id: str or uuid
281+ user_id: User, str or uuid
230282 The id of the user to add to the team
231283 actions: list of TEAM_ACTIONS
232284 The actions to give the new user in this team
@@ -238,21 +290,26 @@ def update_user_action(self, user_id: Union[str, UUID], *,
238290 Returns ``True`` if user successfully added
239291
240292 """
293+ if isinstance (user_id , User ):
294+ user_id = user_id .uid
241295 self .session .checked_put (self ._path () + "/users" , version = self ._api_version ,
242296 json = {'id' : str (user_id ), "actions" : actions })
243297 return True
244298
245- def share (self , * ,
299+ def share (self ,
300+ * ,
246301 resource : Resource ,
247- target_team_id : Union [str , UUID ]) -> bool :
302+ target_team_id : Union [str , UUID , "Team" ]) -> bool :
248303 """
249304 Share a resource with another team.
250305
306+ Requires SHARE action.
307+
251308 Parameters
252309 ----------
253310 resource: Resource
254311 The resource owned by this team, which will be shared
255- target_team_id: Union[str, UUID]
312+ target_team_id: Union[str, UUID, Team ]
256313 The id of the team with which to share the resource
257314
258315 Returns
@@ -261,6 +318,8 @@ def share(self, *,
261318 Returns ``True`` if resource successfully shared
262319
263320 """
321+ if isinstance (target_team_id , Team ):
322+ target_team_id = target_team_id .uid
264323 resource_access = resource .access_control_dict ()
265324 payload = {
266325 "resource_type" : resource_access ["type" ],
@@ -271,15 +330,17 @@ def share(self, *,
271330 version = self ._api_version , json = payload )
272331 return True
273332
274- def un_share (self , * , resource : Resource , target_team_id : Union [str , UUID ]) -> bool :
333+ def un_share (self , * , resource : Resource , target_team_id : Union [str , UUID , "Team" ]) -> bool :
275334 """
276335 Revoke the share of a particular resource to a secondary team.
277336
337+ Requires SHARE action.
338+
278339 Parameters
279340 ----------
280341 resource: Resource
281342 The resource owned by this team, which will be un-shared
282- target_team_id: Union[str, UUID]
343+ target_team_id: Union[str, UUID, Team ]
283344 The id of the team which should not have access to the resource
284345
285346 Returns
@@ -288,6 +349,8 @@ def un_share(self, *, resource: Resource, target_team_id: Union[str, UUID]) -> b
288349 Returns ``True`` if resource successfully un-shared
289350
290351 """
352+ if isinstance (target_team_id , Team ):
353+ target_team_id = target_team_id .uid
291354 resource_type = resource .access_control_dict ()["type" ]
292355 resource_id = resource .access_control_dict ()["id" ]
293356 self .session .checked_delete (
0 commit comments