Commit 6e3e3c40 authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis
Browse files

astakosclient: Usage request parameter deprecated

Astakos' Authenticate Api Method has deprecated the `usage' request
parameter. Remove it from AstakosClient.
parent 14629f7f
...@@ -249,21 +249,14 @@ class AstakosClient(object): ...@@ -249,21 +249,14 @@ class AstakosClient(object):
# ------------------------ # ------------------------
# do a GET to ``API_AUTHENTICATE`` # do a GET to ``API_AUTHENTICATE``
def get_user_info(self, usage=False): def get_user_info(self):
"""Authenticate user and get user's info as a dictionary """Authenticate user and get user's info as a dictionary
Keyword arguments:
usage -- return usage information for user (boolean)
In case of success return user information (json parsed format). In case of success return user information (json parsed format).
Otherwise raise an AstakosClientException. Otherwise raise an AstakosClientException.
""" """
# Send request return self._call_astakos(self.api_authenticate)
auth_path = self.api_authenticate
if usage:
auth_path += "?usage=1"
return self._call_astakos(auth_path)
# ---------------------------------- # ----------------------------------
# do a POST to ``API_USERCATALOGS`` (or ``API_SERVICE_USERCATALOGS``) # do a POST to ``API_USERCATALOGS`` (or ``API_SERVICE_USERCATALOGS``)
......
...@@ -74,10 +74,9 @@ retry=0, use_pool=False, pool_size=8, logger=None\ **)** ...@@ -74,10 +74,9 @@ retry=0, use_pool=False, pool_size=8, logger=None\ **)**
This class provides the following methods: This class provides the following methods:
**get_user_info(**\ usage=False\ **)** **get_user_info()**
It returns a dict with the corresponding user's info. If usage is set It returns a dict with the corresponding user's info. In case of
to 'True' more information about user's resources will be returned. In error, it raises an AstakosClientException exception.
case of error, it raises an AstakosClientException exception.
**get_usernames(**\ uuids\ **)** **get_usernames(**\ uuids\ **)**
Given a list of UUIDs it returns a uuid_catalog, that is a dictionary Given a list of UUIDs it returns a uuid_catalog, that is a dictionary
......
...@@ -38,33 +38,30 @@ from astakosclient.errors import (Unauthorized, NoUUID, NoUserName, ...@@ -38,33 +38,30 @@ from astakosclient.errors import (Unauthorized, NoUUID, NoUserName,
AstakosClientException) AstakosClientException)
def user_for_token(token, astakos_auth_url, usage=False, logger=None): def user_for_token(token, astakos_auth_url, logger=None):
if token is None: if token is None:
return None return None
client = AstakosClient(token, astakos_auth_url, client = AstakosClient(token, astakos_auth_url,
retry=2, use_pool=True, logger=logger) retry=2, use_pool=True, logger=logger)
try: try:
return client.get_user_info(usage=True) return client.get_user_info()
except Unauthorized: except Unauthorized:
return None return None
def get_user(request, astakos_auth_url, fallback_token=None, def get_user(request, astakos_auth_url, fallback_token=None, logger=None):
usage=False, logger=None):
request.user = None request.user = None
request.user_uniq = None request.user_uniq = None
# Try to find token in a parameter or in a request header. # Try to find token in a parameter or in a request header.
user = user_for_token( user = user_for_token(
request.GET.get('X-Auth-Token'), astakos_auth_url, request.GET.get('X-Auth-Token'), astakos_auth_url, logger)
usage, logger)
if not user: if not user:
user = user_for_token( user = user_for_token(
request.META.get('HTTP_X_AUTH_TOKEN'), astakos_auth_url, request.META.get('HTTP_X_AUTH_TOKEN'), astakos_auth_url, logger)
usage, logger)
if not user: if not user:
user = user_for_token( user = user_for_token(
fallback_token, astakos_auth_url, usage, logger) fallback_token, astakos_auth_url, logger)
if not user: if not user:
return None return None
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment