# under the License.
##
-version = '7.0.0.post11'
-version_date = '2019-02-04'
+version = '7.0.1.post17'
+version_date = '2019-03-31'
# Obtain installed package version. Ignore if error, e.g. pkg_resources not installed
try:
Get complete information on an topic
:param session: contains "username", "admin", "force", "public", "project_id", "set_project"
- :param _id: server internal id
+ :param _id: server internal id or username
:return: dictionary, raise exception if not found.
"""
# Allow _id to be a name or uuid
if len(users) == 1:
return users[0]
elif len(users) > 1:
- raise EngineException("Too many users found", HTTPStatus.CONFLICT)
+ raise EngineException("Too many users found for '{}'".format(_id), HTTPStatus.CONFLICT)
else:
- raise EngineException("User not found", HTTPStatus.NOT_FOUND)
+ raise EngineException("User '{}' not found".format(_id), HTTPStatus.NOT_FOUND)
def edit(self, session, _id, indata=None, kwargs=None, content=None):
"""
"Alfonso Tierno <alfonso.tiernosepulveda@telefoncia.com"
__date__ = "$06-jun-2019 11:16:08$"
+import logging
+import re
+
from osm_nbi.authconn import Authconn, AuthException # , AuthconnOperationException
from osm_common.dbbase import DbException
from osm_nbi.base_topic import BaseTopic
-
-import logging
-import re
+from osm_nbi.validation import is_valid_uuid
from time import time, sleep
from http import HTTPStatus
from uuid import uuid4
"""
Get user list.
- :param filter_q: dictionary to filter user list by name (username is also admited) and/or _id
+ :param filter_q: dictionary to filter user list by:
+ name (username is also admitted). If a user id is equal to the filter name, it is also provided
+ other
:return: returns a list of users.
"""
filt = filter_q or {}
- if "name" in filt:
- filt["username"] = filt["name"]
- del filt["name"]
+ if "name" in filt: # backward compatibility
+ filt["username"] = filt.pop("name")
+ if filt.get("username") and is_valid_uuid(filt["username"]):
+ # username cannot be a uuid. If this is the case, change from username to _id
+ filt["_id"] = filt.pop("username")
users = self.db.get_list("users", filt)
project_id_name = {}
role_id_name = {}