"src/git@git.aps.anl.gov:hammonds/dm-docs.git" did not exist on "4a126a60ae034679f9cd8c4ef8e9edeeb6a1ac01"
Forked from
DM / dm-docs
261 commits behind, 167 commits ahead of the upstream repository.
-
sveseli authored
add first functional DS web service with user, experiment and auth controllers that allow retrieving user and experiment information from the db, start/stop experiment, and principal authorization; added corresponding API and CLI classes; added storage manager skeleton
sveseli authoredadd first functional DS web service with user, experiment and auth controllers that allow retrieving user and experiment information from the db, start/stop experiment, and principal authorization; added corresponding API and CLI classes; added storage manager skeleton
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
userRestApi.py 1.46 KiB
#!/usr/bin/env python
import os
import urllib
from dm.common.utility.encoder import Encoder
from dm.common.exceptions.dmException import DmException
from dm.common.exceptions.invalidRequest import InvalidRequest
from dm.common.objects.userInfo import UserInfo
from dsRestApi import DsRestApi
class UserRestApi(DsRestApi):
def __init__(self, username=None, password=None, host=None, port=None, protocol=None):
DsRestApi.__init__(self, username, password, host, port, protocol)
@DsRestApi.execute
def getUsers(self):
url = '%s/users' % (self.getContextRoot())
responseData = self.sendSessionRequest(url=url, method='GET')
return self.toDmObjectList(responseData, UserInfo)
@DsRestApi.execute
def getUserById(self, id):
if id is None:
raise InvalidRequest('User id must be provided.')
url = '%s/users/%s' % (self.getContextRoot(), id)
responseData = self.sendSessionRequest(url=url, method='GET')
return UserInfo(responseData)
@DsRestApi.execute
def getUserByUsername(self, username):
if username is None:
raise InvalidRequest('Username must be provided.')
url = '%s/usersByUsername/%s' % (self.getContextRoot(), username)
responseData = self.sendSessionRequest(url=url, method='GET')
return UserInfo(responseData)
#######################################################################
# Testing.
if __name__ == '__main__':
pass