Skip to content

Commit

Permalink
Merge pull request #52 from UWIT-IAM/netid-1189
Browse files Browse the repository at this point in the history
Add nws query to get supported NetIDs
  • Loading branch information
krlowe authored Nov 22, 2019
2 parents 7c61006 + 8732569 commit 054a917
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions resttools/nws.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ def get_netid_pwinfo(self, netid):

return self._pwinfo_from_json(response.data)

def get_netid_supported(self, netid):
"""
Returns a list of Supportees for the netid
"""
url = "%s/uwnetid/%s/supported" % (self._base_url, quote_plus(netid))
response = self.dao.getURL(url, self._headers({"Accept": "application/json"}))

if response.status != 200:
raise DataFailureException(url, response.status, response.data)

return self._supportees_from_json(response.data)

def set_netid_pw(self, netid, password, auth, action=None):
"""
Sets password for netid
Expand Down Expand Up @@ -90,6 +102,11 @@ def _pwinfo_from_json(self, data):
else:
return None

def _supportees_from_json(self, data):
supportobj = json.loads(data)
supportees = supportobj.get('supportedList', [])
return supportees

def _headers(self, headers):
# could auto-add headers here
return headers
Expand Down

0 comments on commit 054a917

Please sign in to comment.