forked from ebeuerle/export_users_csv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunner.py
More file actions
31 lines (25 loc) · 1018 Bytes
/
runner.py
File metadata and controls
31 lines (25 loc) · 1018 Bytes
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
import lib
import json
class UserExport():
def __init__(self):
self.config = lib.ConfigHelper()
self.csv_writer = lib.CsvWriter()
self.rl_sess = lib.RLSession(self.config.rl_user,self.config.rl_pass,self.config.rl_cust)
self.output = [["displayName", "email", "enabled", "firstName", "lastName", "roleType"]]
def build(self):
self.url = "https://api.redlock.io/user"
self.rl_sess.authenticate_client()
response = self.rl_sess.client.get(self.url)
#write out the top of csv to file
self.csv_writer.write(self.output)
json_response = response.json()
for userdata in json_response:
data = [userdata["displayName"],userdata["email"],userdata["enabled"],userdata["firstName"],userdata["lastName"],userdata["roleType"]]
self.csv_writer.append([data])
def run(self):
self.build()
def main():
rl_userexport = UserExport()
rl_userexport.run()
if __name__ == "__main__":
main()