@@ -715,9 +715,28 @@ def get_teams(self, team_filter='', product_filter=''):
715715 return [False , self .lasterr ]
716716 ret = [t for t in res .json ()['teams' ] if team_filter in t ['name' ]]
717717 if product_filter :
718- ret = [t for t in ret if product_filter in t ['products' ]]
718+ ret = [t for t in ret if product_filter in t ['products' ]]
719719 return [True , ret ]
720720
721+ def get_team_by_id (self , id ):
722+ '''**Description**
723+ Return the team with the specified team ID, if it is present.
724+
725+ **Arguments**
726+ - **id**: the ID of the team to return
727+
728+ **Success Return Value**
729+ The requested team.
730+
731+ **Example**
732+ `examples/user_team_mgmt.py <https://github.com/draios/python-sdc-client/blob/master/examples/user_team_mgmt.py>`_
733+ '''
734+ res = self .http .get (self .url + '/api/teams/' + str (id ), headers = self .hdrs , verify = self .ssl_verify )
735+ if not self ._checkResponse (res ):
736+ return [False , self .lasterr ]
737+
738+ return [True , res .json ()['team' ]]
739+
721740 def get_team (self , name ):
722741 '''**Description**
723742 Return the team with the specified team name, if it is present.
@@ -731,13 +750,18 @@ def get_team(self, name):
731750 **Example**
732751 `examples/user_team_mgmt.py <https://github.com/draios/python-sdc-client/blob/master/examples/user_team_mgmt.py>`_
733752 '''
734- ok , res = self .get_teams (name )
753+ res = self .http .get (self .url + '/api/v2/teams/light/name/' + str (name ), headers = self .hdrs , verify = self .ssl_verify )
754+ if not self ._checkResponse (res ):
755+ return [False , self .lasterr ]
756+
757+ light_team = res .json ()['team' ]
758+
759+ ok , team_with_memberships = self .get_team_by_id (light_team ['id' ])
760+
735761 if not ok :
736- return ok , res
737- for team in res :
738- if team ['name' ] == name :
739- return [True , team ]
740- return [False , 'Could not find team' ]
762+ return [False , self .lasterr ]
763+
764+ return [True , team_with_memberships ]
741765
742766 def get_team_ids (self , teams ):
743767 res = self .http .get (self .url + '/api/teams' , headers = self .hdrs , verify = self .ssl_verify )
0 commit comments