-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
32 lines (25 loc) · 1 KB
/
main.py
File metadata and controls
32 lines (25 loc) · 1 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
import os
from core import action_hub, app
from api_types import ActionList
import logging
logger = logging.getLogger(__name__)
logger.info('Custom Action Hub started')
fast_hub_info = {
'info': 'The following applications have been installed. Note that these are not used directly via this webpage. Actions are accessed via the Looker Action Hub.',
'actions': [],
}
actions_list = []
available_actions = [module[:-3] for module in os.listdir('actions') if module[-3:] == '.py']
for action in available_actions:
logger.info(f'Importing Action: {action}')
definition = __import__('.'.join(['actions', action]), globals(), locals(), ['definition']).definition
actions_list.append(definition)
fast_hub_info['actions'].append(action)
@app.get('/')
def root():
"""Simple homepage with JSON response only."""
return fast_hub_info
@app.post('/')
def list_actions():
"""Returns an ActionList with all actions available from this ActionHub"""
return ActionList(integrations=actions_list)