Skip to content

Commit

Permalink
chore: remove example log files and update admin API credential inputs (
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkTripod-Duo authored Feb 21, 2024
1 parent c25fc29 commit 32265f6
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions examples/Admin/report_user_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
print(line_out)

0 comments on commit 32265f6

Please sign in to comment.