forked from basespace/basespace-python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.py
More file actions
57 lines (47 loc) · 1.79 KB
/
User.py
File metadata and controls
57 lines (47 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from BaseSpacePy.api.BaseSpaceException import ModelNotInitializedException
class User(object):
def __init__(self):
self.swaggerTypes = {
'Name': 'str',
'Email': 'str',
'DateLastActive': 'datetime',
'GravatarUrl': 'str',
'HrefProjects': 'str',
'DateCreated': 'datetime',
'Id': 'str',
'Href': 'str',
'HrefRuns': 'str'
}
def __str__(self):
return self.Name
def __repr__(self):
return str(self)
def isInit(self):
'''
Tests if the User instance has been initialized.
:raises ModelNotInitializedException: if the Id variable is not set
:return True on success
'''
err = 'The User object has not been initialized yet'
try:
if not self.Id:
raise ModelNotInitializedException(err)
except AttributeError:
raise ModelNotInitializedException(err)
return True
def getProjects(self, api, queryPars=None):
'''
Returns a list of the accessible Projects for the user
:param api: An instance of BaseSpaceAPI
:param queryPars: An (optional) object of type QueryParameters for custom sorting and filtering
'''
self.isInit()
return api.getProjectByUser(queryPars=queryPars)
def getRuns(self, api, queryPars=None):
'''
Returns a list of the accessible Runs for the user
:param api: An instance of BaseSpaceAPI
:param queryPars: An (optional) object of type QueryParameters for custom sorting and filtering
'''
self.isInit()
return api.getAccessibleRunsByUser(queryPars=queryPars)