-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcountry.py
More file actions
executable file
·46 lines (31 loc) · 1.02 KB
/
country.py
File metadata and controls
executable file
·46 lines (31 loc) · 1.02 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
#!/usr/bin/python3
import requests
import openpyxl
import time
#CONSTANTS
API_URL = 'https://api.veracode.com/api/authn/v2/'
def extract_json(search_term):
parameters = {
'fullText': 'true',
'fields': 'Account;Login Name;User Name;Email Address;Custom ID;Title;Login Enabled;Created;Is Active;Is saml User;Is Platform User;Has Elearning Role;Last Login;Roles;Teams'
}
response = requests.get(API_URL + search_term, params=parameters)
json = response.json()
if response.status_code != 200:
return 'error'
return json[0]
def write_account():
filename = 'test_account.xlsx'
wb = openpyxl.load_workbook(filename)
ws = wb.active
wc = ws['A']
i = 1
for cell in wc[1:]:
i += 1
account_details = extract_json(cell.value)
time.sleep(10)
ws['B' + str(i)] = account_details['Account']
ws['C' + str(i)] = account_details['Login Name']
ws['D' + str(i)] = account_details['User Name']
wb.save(filename)
write_account()