20
20
__copyright__ = "Copyright 2017-2018, LoginRadius"
21
21
22
22
__status__ = "Production"
23
- __version__ = "3.1 .0"
23
+ __version__ = "3.2 .0"
24
24
25
25
26
26
accountEndpoint = "identity/v2/manage/account/"
@@ -37,45 +37,47 @@ def __init__(self, lr_object):
37
37
self ._lr_object = lr_object
38
38
39
39
def create (self , payload , fields = '*' ):
40
- """Create Account( POST )"""
40
+ # Account Create (POST)
41
41
headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
42
42
params = 'fields=' + fields
43
43
url = self ._lr_object .SECURE_API_URL + accountEndpoint + "?" + params
44
44
return self ._lr_object ._post_json (url , payload , headers )
45
45
46
46
def update (self , uid , payload , isNullSupport = False , fields = '*' ):
47
- """Update Account( POST )"""
47
+ # Account Update (PUT)
48
48
headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
49
- params = 'nullsupport=' + isNullSupport + "&fields=" + fields
49
+ params = 'nullsupport=' + str ( isNullSupport ) + "&fields=" + fields
50
50
url = self ._lr_object .SECURE_API_URL + accountEndpoint + uid + "?" + params
51
51
return self ._lr_object ._put_json (url , payload , headers )
52
52
53
53
def remove (self , uid ):
54
- """ Account Delete( DELETE )"""
54
+ # Account Delete (DEL)
55
55
headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
56
56
url = self ._lr_object .SECURE_API_URL + accountEndpoint + uid
57
57
return self ._lr_object ._delete_json (url , {}, headers )
58
58
59
59
def generateSott (self , timediff = '10' ):
60
- """Account generate sott( GET )"""
60
+ # Generate SOTT ( GET)
61
61
headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
62
62
params = 'timedifference=' + timediff
63
63
url = self ._lr_object .SECURE_API_URL + accountEndpoint + "sott" + "?" + params
64
64
return self ._lr_object ._get_json (url , {}, headers )
65
65
66
66
def setPassword (self , uid , password ):
67
- """ Account Set Password( PUT )"""
67
+ # Account Set Password ( PUT)
68
68
headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
69
69
payload = {"password" : password }
70
- url = self ._lr_object .SECURE_API_URL + accountEndpoint + uid + "/password" + "?" + params
70
+ url = self ._lr_object .SECURE_API_URL + accountEndpoint + uid + "/password"
71
71
return self ._lr_object ._put_json (url , payload , headers )
72
72
73
73
def getPassword (self , uid ):
74
+ # Account Password (GET)
74
75
headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
75
76
url = self ._lr_object .SECURE_API_URL + accountEndpoint + uid + "/password"
76
77
return self ._lr_object ._get_json (url , {}, headers )
77
78
78
79
def invalidateVerificationEmail (self , uid , verificationUrl = '' , emailTemplate = '' ):
80
+ # Account Invalidate Verification Email (PUT)
79
81
headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
80
82
params = 'verificationUrl=' + verificationUrl + "&emailTemplate=" + emailTemplate
81
83
url = self ._lr_object .SECURE_API_URL + accountEndpoint + uid + "/invalidateemail" + "?" + params
@@ -99,62 +101,52 @@ def getDeletedAccountByUid(self, uid):
99
101
url = self ._lr_object .SECURE_API_URL + archivedEndpoint
100
102
return self ._lr_object ._get_json (url , payload , headers )
101
103
102
- def assignRole (self , uid , payload ):
103
- """Put Assign Role( PUT )"""
104
- headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
105
- url = self ._lr_object .SECURE_API_URL + accountEndpoint + uid + "/role"
106
- return self ._lr_object ._put_json (url , payload , headers )
107
-
108
- def getRoleByUid (self , uid ):
109
- headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
110
- url = self ._lr_object .SECURE_API_URL + accountEndpoint + uid + "/role"
111
- return self ._lr_object ._get_json (url , {}, headers )
112
-
113
104
def updateSecurityQuestion (self , uid , payload ):
105
+ # Account Update Security Question Configuration (PUT)
114
106
headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
115
107
url = self ._lr_object .SECURE_API_URL + accountEndpoint + uid
116
108
return self ._lr_object ._put_json (url , payload , headers )
117
109
118
110
def getForgotPasswordToken (self , email ):
111
+ # Forgot Password Token (POST)
119
112
payload = {"email" :email }
120
113
headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
121
114
url = self ._lr_object .SECURE_API_URL + accountEndpoint + "forgot/token"
122
115
return self ._lr_object ._post_json (url , payload , headers )
123
116
124
117
def getEmailVerificationToken (self , email ):
118
+ # Email Verification Token (POST)
125
119
payload = {"email" :email }
126
120
headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
127
121
url = self ._lr_object .SECURE_API_URL + accountEndpoint + "verify/token"
128
122
return self ._lr_object ._post_json (url , payload , headers )
129
123
130
124
def getAccessToken (self , uid ):
125
+ # Access Token based on UID or User impersonation API (GET)
131
126
headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
132
- payload = { " uid" : uid }
133
- url = self ._lr_object .SECURE_API_URL + accountEndpoint + "access_token"
134
- return self ._lr_object ._get_json (url , payload , headers )
127
+ params = ' uid=' + uid
128
+ url = self ._lr_object .SECURE_API_URL + accountEndpoint + "access_token" + "?" + params
129
+ return self ._lr_object ._get_json (url , {} , headers )
135
130
136
131
def getIdentities (self , email , fields = '*' ):
132
+ # Account Identities by Email (GET)
137
133
headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
138
134
params = 'email=' + email + "&fields=" + fields
139
135
url = self ._lr_object .SECURE_API_URL + accountEndpoint + "identities" + "?" + params
140
136
return self ._lr_object ._get_json (url , {}, headers )
141
137
142
138
def resetPhoneIdVerification (self , uid ):
139
+ # Reset phone ID verification (PUT)
143
140
headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
144
141
url = self ._lr_object .SECURE_API_URL + accountEndpoint + uid + "/invalidatephone"
145
142
return self ._lr_object ._put_json (url , {}, headers )
146
143
147
- def getBackupCodeByUid (self , uid ):
148
- headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
149
- payload = {"uid" :uid }
150
- url = self ._lr_object .SECURE_API_URL + accountEndpoint + "2fa/backupcode"
151
- return self ._lr_object ._get_json (url , payload , headers )
152
-
153
- def resetBackupCodeByUid (self , uid ):
154
- headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
155
- payload = {"uid" :uid }
156
- url = self ._lr_object .SECURE_API_URL + accountEndpoint + "2fa/backupcode/reset"
157
- return self ._lr_object ._get_json (url , payload , headers )
144
+ def removeEmail (self , uid , email ):
145
+ # Account Email Delete (DEL)
146
+ payload = {'email' :email }
147
+ headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
148
+ url = self ._lr_object .SECURE_API_URL + accountEndpoint + uid + '/email'
149
+ return self ._lr_object ._delete_json (url , payload , headers )
158
150
159
151
160
152
class Profile :
@@ -163,24 +155,28 @@ def __init__(self, lr_object):
163
155
self ._lr_object = lr_object
164
156
165
157
def getByEmail (self , email , fields = '*' ):
158
+ # Account Profiles by Email (GET)
166
159
headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
167
160
params = 'email=' + email + "&fields=" + fields
168
161
url = self ._lr_object .SECURE_API_URL + accountEndpoint + "?" + params
169
162
return self ._lr_object ._get_json (url , {}, headers )
170
163
171
164
def getByUsername (self , username , fields = '*' ):
165
+ # Account Profiles by Username (GET)
172
166
headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
173
167
params = 'username=' + username + "&fields=" + fields
174
168
url = self ._lr_object .SECURE_API_URL + accountEndpoint + "?" + params
175
169
return self ._lr_object ._get_json (url , {}, headers )
176
170
177
171
def getByPhone (self , phone , fields = '*' ):
172
+ # Account Profile by Phone ID (GET)
178
173
headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
179
174
params = 'phone=' + phone + "&fields=" + fields
180
175
url = self ._lr_object .SECURE_API_URL + accountEndpoint + "?" + params
181
176
return self ._lr_object ._get_json (url , {}, headers )
182
177
183
178
def getByUid (self , uid , fields = '*' ):
179
+ # Account Profiles by UID (GET)
184
180
headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
185
181
params = "fields=" + fields
186
182
url = self ._lr_object .SECURE_API_URL + accountEndpoint + uid + "?" + params
@@ -192,38 +188,61 @@ def __init__(self, lr_object):
192
188
self ._lr_object = lr_object
193
189
194
190
def removeAuthByUid (self , uid , authenticator ):
191
+ # MFA Reset Google Authenticator By UID (DEL) & MFA Reset SMS Authenticator By UID (DEL)
195
192
payload = {}
196
193
payload [authenticator ] = True
197
194
headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
198
195
params = 'uid=' + uid
199
196
url = self ._lr_object .SECURE_API_URL + accountEndpoint + "2FA/authenticator?" + params
200
197
return self ._lr_object ._delete_json (url , payload , headers )
201
198
199
+ def getBackupCodeByUid (self , uid ):
200
+ # MFA Backup Code by UID (GET)
201
+ headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
202
+ payload = {"uid" :uid }
203
+ url = self ._lr_object .SECURE_API_URL + accountEndpoint + "2fa/backupcode"
204
+ return self ._lr_object ._get_json (url , payload , headers )
205
+
206
+ def resetBackupCodeByUid (self , uid ):
207
+ # MFA Reset Backup Code by UID (GET)
208
+ headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
209
+ payload = {"uid" :uid }
210
+ url = self ._lr_object .SECURE_API_URL + accountEndpoint + "2fa/backupcode/reset"
211
+ return self ._lr_object ._get_json (url , payload , headers )
212
+
202
213
class RegistrationData :
203
214
204
215
def __init__ (self , lr_object ):
205
216
self ._lr_object = lr_object
206
217
207
218
def addRegistrationData (self , payload ):
219
+ # Add Registration Data (POST)
208
220
headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
209
221
url = self ._lr_object .SECURE_API_URL + registrationDataEndpoint + "registrationdata"
210
222
return self ._lr_object ._post_json (url , payload , headers )
211
223
212
224
def getRegistrationDataServer (self , datasourcetype , parentid = '' , skip = '' , limit = '' ):
225
+ # Get Registration Data (GET)
213
226
headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
214
227
params = 'parentid=' + parentid + '&skip=' + skip + '&limit=' + limit
215
228
url = self ._lr_object .SECURE_API_URL + registrationDataEndpoint + "registrationdata/" + datasourcetype + "?" + params
216
229
return self ._lr_object ._get_json (url , {}, headers )
217
230
218
231
def updateRegistrationData (self , recordid , payload ):
219
- """ Update Registration Data( PUT )"""
232
+ # Update Registration Data ( PUT)
220
233
headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
221
234
url = self ._lr_object .SECURE_API_URL + registrationDataEndpoint + "registrationdata/" + recordid
222
235
return self ._lr_object ._put_json (url , payload , headers )
223
236
224
237
def deleteRegistrationData (self , recordid ):
225
- """ Delete Registration Data( delete )"""
238
+ # Delete Registration Data (DEL)
226
239
headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
227
240
url = self ._lr_object .SECURE_API_URL + registrationDataEndpoint + "registrationdata/" + recordid
228
241
return self ._lr_object ._delete_json (url , {}, headers )
242
+
243
+ def deleteAllRecordsByDatasource (self , datasourcetype ):
244
+ # Delete All Records by Datasource (DEL)
245
+ headers = {'apikey' : self ._lr_object ._get_api_key (), 'apisecret' : self ._lr_object ._get_api_secret ()}
246
+ url = self ._lr_object .SECURE_API_URL + registrationDataEndpoint + "registrationdata/type/" + datasourcetype
247
+ return self ._lr_object ._delete_json (url , {}, headers )
229
248
0 commit comments