-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunpause.py
41 lines (31 loc) · 1.27 KB
/
unpause.py
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
from actionkit.api.user import AKUserAPI
from pywell.entry_points import run_from_cli, run_from_lambda
from pywell.get_psql_results import get_psql_results
DESCRIPTION = 'Unpause AK users based on DB query.'
ARG_DEFINITIONS = {
'AK_BASEURL': 'ActionKit Base URL.',
'AK_USER': 'ActionKit API username.',
'AK_PASSWORD': 'ActionKit API password.',
'AK_IMPORT_PAGE': 'ActionKit import page name.',
'DB_HOST': 'Database host IP or hostname.',
'DB_PORT': 'Database port number.',
'DB_USER': 'Database user.',
'DB_PASS': 'Database password.',
'DB_NAME': 'Database name.',
'DB_QUERY': 'Query to get user IDs.'
}
REQUIRED_ARGS = [
'AK_BASEURL', 'AK_USER', 'AK_PASSWORD', 'AK_IMPORT_PAGE', 'DB_HOST',
'DB_PORT', 'DB_USER', 'DB_PASS', 'DB_NAME', 'DB_QUERY'
]
def unpause(args):
user_ids = [row.get('user_id') for row in get_psql_results(args)]
api = AKUserAPI(args)
api.bulk_upload_rows(
args.AK_IMPORT_PAGE, ['user_id'], [[user_id] for user_id in user_ids]
)
return user_ids
def aws_lambda(event, context):
return run_from_lambda(unpause, DESCRIPTION, ARG_DEFINITIONS, REQUIRED_ARGS, event, 'ak-unpause')
if __name__ == '__main__':
run_from_cli(unpause, DESCRIPTION, ARG_DEFINITIONS, REQUIRED_ARGS, 'ak-unpause')