-
Notifications
You must be signed in to change notification settings - Fork 280
Expand file tree
/
Copy pathuser.py
More file actions
119 lines (95 loc) · 2.63 KB
/
user.py
File metadata and controls
119 lines (95 loc) · 2.63 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import ctypes
from .. import _binaryninjacore as core
from . import remote, util
class User:
"""
Class representing a remote User
"""
def __init__(self, handle: core.BNCollaborationUserHandle):
self._handle = ctypes.cast(handle, core.BNCollaborationUserHandle)
def __del__(self):
if core is not None:
core.BNFreeCollaborationUser(self._handle)
def __eq__(self, other):
if not isinstance(other, User):
return False
return self.id == other.id
@property
def remote(self) -> 'remote.Remote':
"""
Owning Remote
:return: Remote object
"""
value = core.BNCollaborationUserGetRemote(self._handle)
if value is None:
raise RuntimeError(util._last_error())
return remote.Remote(handle=value)
@property
def url(self) -> str:
"""
Web api endpoint URL
:return: URL string
"""
return core.BNCollaborationUserGetUrl(self._handle)
@property
def id(self) -> str:
"""
Unique id
:return: Id string
"""
return core.BNCollaborationUserGetId(self._handle)
@property
def username(self) -> str:
"""
User's login username
:return: Username string
"""
return core.BNCollaborationUserGetUsername(self._handle)
@username.setter
def username(self, value: str):
"""
Set user's username. You will need to push the user to update the Remote
:param value: New username
:raises RuntimeError: If there was an error
"""
if not core.BNCollaborationUserSetUsername(self._handle, value):
raise RuntimeError(util._last_error())
@property
def email(self) -> str:
"""
User's email address
:return: Email string
"""
return core.BNCollaborationUserGetEmail(self._handle)
@email.setter
def email(self, value: str):
"""
Set user's email. You will need to push the user to update the Remote
:param value: New email address
:raises RuntimeError: If there was an error
"""
if not core.BNCollaborationUserSetEmail(self._handle, value):
raise RuntimeError(util._last_error())
@property
def last_login(self) -> str:
"""
String representing the last date the user logged in
:return: Last login string
"""
return core.BNCollaborationUserGetLastLogin(self._handle)
@property
def is_active(self) -> bool:
"""
If the user account is active and can log in
:return: If account is active
"""
return core.BNCollaborationUserIsActive(self._handle)
@is_active.setter
def is_active(self, value: bool):
"""
Enable/disable a user account. You will need to push the user to update the Remote
:param value: New active value
:raises RuntimeError: If there was an error
"""
if not core.BNCollaborationUserSetIsActive(self._handle, value):
raise RuntimeError(util._last_error())