From 32265f67a9422c842faadc54e963f4cb1ada481c Mon Sep 17 00:00:00 2001 From: Mark Tripod <66480604+MarkTripod-Duo@users.noreply.github.com> Date: Wed, 21 Feb 2024 09:53:53 -0500 Subject: [PATCH] chore: remove example log files and update admin API credential inputs (#255) --- examples/Admin/report_user_activity.py | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/examples/Admin/report_user_activity.py b/examples/Admin/report_user_activity.py index 534d617..d5e61a3 100755 --- a/examples/Admin/report_user_activity.py +++ b/examples/Admin/report_user_activity.py @@ -8,42 +8,38 @@ from six.moves import input argv_iter = iter(sys.argv[1:]) -def get_next_arg(prompt): + + +def get_next_input(prompt): + """Collect user input from terminal and return it.""" try: return next(argv_iter) except StopIteration: return input(prompt) + def human_time(time: int) -> str: """Translate unix time into human readable string""" if time is None: date_str = 'Never' else: - date_str = datetime.fromtimestamp(time, timezone.utc).strftime("%Y-%m-%m %H:%M:%S") + date_str = datetime.fromtimestamp(time, timezone.utc).strftime("%Y-%m-%m %H:%M:%S") return date_str # Configuration and information about objects to create. -""" admin_api = duo_client.Admin( - ikey=get_next_input('Admin API integration key ("DI..."): '), - skey=get_next_input('integration secret key: '), - host=get_next_input('API hostname ("api-....duosecurity.com"): '), -) -""" + ikey=get_next_input('Admin API integration key ("DI..."): '), + skey=get_next_input('integration secret key: '), + host=get_next_input('API hostname ("api-....duosecurity.com"): '), ) -admin_api = duo_client.Admin( - ikey='DIW9XT14VIIAH3L427I8', - skey='8iQEKjOCxjjvwYKFZ77ztkcd60c7aToMlf8zZiDs', - host='api-731c6826.duosecurity.com' -) # Retrieve user info from API: users = admin_api.get_users() print(f'{"Username":^30} {"Last Login":^20} {"User Enrolled"}') -print(f'{"="*30} {"="*20} {"="*15}') +print(f'{"=" * 30} {"=" * 20} {"=" * 15}') for user in users: line_out = f"{user['username']:30} " line_out += f"{human_time(user['last_login']):20} " line_out += f" {user['is_enrolled']} " - print(line_out) \ No newline at end of file + print(line_out)