From 8732569623c0395b8fdcdda692dab4015c917fa6 Mon Sep 17 00:00:00 2001 From: Ken Lowe Date: Thu, 21 Nov 2019 17:35:34 -0800 Subject: [PATCH] Add nws query to get supported NetIDs --- resttools/nws.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/resttools/nws.py b/resttools/nws.py index e939c05..6a99699 100644 --- a/resttools/nws.py +++ b/resttools/nws.py @@ -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 @@ -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