@@ -715,9 +715,28 @@ def get_teams(self, team_filter='', product_filter=''):
715
715
return [False , self .lasterr ]
716
716
ret = [t for t in res .json ()['teams' ] if team_filter in t ['name' ]]
717
717
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' ]]
719
719
return [True , ret ]
720
720
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
+
721
740
def get_team (self , name ):
722
741
'''**Description**
723
742
Return the team with the specified team name, if it is present.
@@ -731,13 +750,18 @@ def get_team(self, name):
731
750
**Example**
732
751
`examples/user_team_mgmt.py <https://github.com/draios/python-sdc-client/blob/master/examples/user_team_mgmt.py>`_
733
752
'''
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
+
735
761
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 ]
741
765
742
766
def get_team_ids (self , teams ):
743
767
res = self .http .get (self .url + '/api/teams' , headers = self .hdrs , verify = self .ssl_verify )
0 commit comments