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

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):
# ------------------------
# 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
Keyword arguments:
usage -- return usage information for user (boolean)
In case of success return user information (json parsed format).
Otherwise raise an AstakosClientException.
"""
# Send request
auth_path = self.api_authenticate
if usage:
auth_path += "?usage=1"
return self._call_astakos(auth_path)
return self._call_astakos(self.api_authenticate)
# ----------------------------------
# do a POST to ``API_USERCATALOGS`` (or ``API_SERVICE_USERCATALOGS``)
......
......@@ -74,10 +74,9 @@ retry=0, use_pool=False, pool_size=8, logger=None\ **)**
This class provides the following methods:
**get_user_info(**\ usage=False\ **)**
It returns a dict with the corresponding user's info. If usage is set
to 'True' more information about user's resources will be returned. In
case of error, it raises an AstakosClientException exception.
**get_user_info()**
It returns a dict with the corresponding user's info. In case of
error, it raises an AstakosClientException exception.
**get_usernames(**\ uuids\ **)**
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,
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:
return None
client = AstakosClient(token, astakos_auth_url,
retry=2, use_pool=True, logger=logger)
try:
return client.get_user_info(usage=True)
return client.get_user_info()
except Unauthorized:
return None
def get_user(request, astakos_auth_url, fallback_token=None,
usage=False, logger=None):
def get_user(request, astakos_auth_url, fallback_token=None, logger=None):
request.user = None
request.user_uniq = None
# Try to find token in a parameter or in a request header.
user = user_for_token(
request.GET.get('X-Auth-Token'), astakos_auth_url,
usage, logger)
request.GET.get('X-Auth-Token'), astakos_auth_url, logger)
if not user:
user = user_for_token(
request.META.get('HTTP_X_AUTH_TOKEN'), astakos_auth_url,
usage, logger)
request.META.get('HTTP_X_AUTH_TOKEN'), astakos_auth_url, logger)
if not user:
user = user_for_token(
fallback_token, astakos_auth_url, usage, logger)
fallback_token, astakos_auth_url, logger)
if not user:
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