Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions sdcclient/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,9 +715,28 @@ def get_teams(self, team_filter='', product_filter=''):
return [False, self.lasterr]
ret = [t for t in res.json()['teams'] if team_filter in t['name']]
if product_filter:
ret = [t for t in ret if product_filter in t['products']]
ret = [t for t in ret if product_filter in t['products']]
return [True, ret]

def get_team_by_id(self, id):
'''**Description**
Return the team with the specified team ID, if it is present.

**Arguments**
- **id**: the ID of the team to return

**Success Return Value**
The requested team.

**Example**
`examples/user_team_mgmt.py <https://github.com/draios/python-sdc-client/blob/master/examples/user_team_mgmt.py>`_
'''
res = self.http.get(self.url + '/api/teams/' + str(id), headers=self.hdrs, verify=self.ssl_verify)
if not self._checkResponse(res):
return [False, self.lasterr]

return [True, res.json()['team']]

def get_team(self, name):
'''**Description**
Return the team with the specified team name, if it is present.
Expand All @@ -731,13 +750,18 @@ def get_team(self, name):
**Example**
`examples/user_team_mgmt.py <https://github.com/draios/python-sdc-client/blob/master/examples/user_team_mgmt.py>`_
'''
ok, res = self.get_teams(name)
res = self.http.get(self.url + '/api/v2/teams/light/name/' + str(name), headers=self.hdrs, verify=self.ssl_verify)
if not self._checkResponse(res):
return [False, self.lasterr]

light_team = res.json()['team']

ok, team_with_memberships = self.get_team_by_id(light_team['id'])

if not ok:
return ok, res
for team in res:
if team['name'] == name:
return [True, team]
return [False, 'Could not find team']
return [False, self.lasterr]

return [True, team_with_memberships]

def get_team_ids(self, teams):
res = self.http.get(self.url + '/api/teams', headers=self.hdrs, verify=self.ssl_verify)
Expand Down