Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions altaAudit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
################## Asmbly Neon API Integrations ###################
# Neon API docs - https://developer.neoncrm.com/api-v2/ #
#################################################################

import openPathUtil
import neonUtil
import logging
import argparse


def getParserArgs():
parser = argparse.ArgumentParser(
prog='Alta User Audit',
description='Help find users who have an entry in the Alta database, but are not supported by an entry in Neon.',
)
parser.add_argument('-v', '--verbose', action='store_true')
args = parser.parse_args()
return args


def getLogger(verbose=True):
logLevel = logging.DEBUG if verbose else logging.INFO
logging.basicConfig(
format='%(asctime)s %(levelname)-8s %(message)s',
level=logLevel,
datefmt='%Y-%m-%d %H:%M:%S')
return logging.getLogger(__name__)


def main():
args = getParserArgs()
log = getLogger(args.verbose)

# Get the list of users from the Alta database
altaUsers = openPathUtil.getAllUsersMock()
neonUsers = neonUtil.getRealAccountsMock()

# Find all users in Alta who _are not_ in Neon
extraAltaUsers = []
for uid, user in altaUsers.items():
match = False
log.debug(f'Checking for Alta user {uid}')
for nuid, neonUser in neonUsers.items():
log.debug(f'Comparing Alta user {uid} to Neon user {nuid}')
opid = neonUser.get('OpenPathID')
log.debug(f'Neon user {nuid} has OpenPathID {opid}')
if opid and int(uid) == int(opid):
match = True
log.debug(f'Alta user {uid} is Neon user {neonUser.get("fullName")} ({nuid})')
continue
else:
log.debug('No match')
if not match:
log.debug('No match found for {uid}')
extraAltaUsers.append(uid)

if len(extraAltaUsers) == 0:
log.info('All users in Alta are supported by a Neon entry')
else:
log.info('The following Alta users are not found in Neon:')
for uid in extraAltaUsers:
log.info(f'{uid}: {altaUsers[uid]}')


if __name__ == '__main__':
main()
17 changes: 17 additions & 0 deletions neonUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,23 @@ def getRealAccounts():
return neonAccountDict


####################################################################
# MOCK: Get all staf and current/past members from Neon, incuding detailed subscription info
####################################################################
def getRealAccountsMock():
return {
'12af34e5': { # What does this value look like? Int/hex/string?
'OpenPathID': '4321',
'validMembership': True,
'fullName': 'Cam Herringshaw',
},
'12a34': {
'OpenPathID': '1234',
'fullName': 'Test User',
},
}


####################################################################
# Helper function: is this Neon account marked with any type
####################################################################
Expand Down
14 changes: 14 additions & 0 deletions openPathUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@ def getAllUsers():
return opUsers


####################################################################
# MOCK: Return a fake list of users
####################################################################
def getAllUsersMock():
return {
4321: {
'id': 4321,
},
12345: {
'id': 12345,
},
}


####################################################################
# Get a single OpenPath user by OpenPath ID
####################################################################
Expand Down