Skip to content

Commit

Permalink
Added the blacklist retrieval functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar Carballal Prego committed Jul 24, 2015
1 parent c89c727 commit 47d6a76
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions ntokloapi/blacklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import json

try:
# Try to load first the Python 3 version
from urllib.parse import urlencode
Expand Down Expand Up @@ -112,3 +114,34 @@ def remove(self, productid=[]):
return r.status_code
except Exception as e:
raise RequestError(e)

def list(self):

"""List the blacklisted products on an application.
This funciton will list all the blacklisted products on a specific
application given as a querystring.
Args:
appid (str): Application ID as a string.
Raises:
RequestError: In case the request couldn't be made or failed.
Returns:
JSON Object: JSON Object with the lsit of blacklisted elements.
.. versionadded:: 0.1
"""

method = "GET"
uri = "/products/blacklist"
url = "{}{}".format(self.api_endpoint, uri)
auth_token = self.get_token(uri, method)
self.headers['Authorization'] = auth_token

try:
r = self.session.get(url, headers=self.headers)
return json.loads(r.text)
except Exception as e:
raise RequestError(e)

0 comments on commit 47d6a76

Please sign in to comment.