-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction_list.py
50 lines (40 loc) · 1.63 KB
/
action_list.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
42
43
44
45
46
47
48
49
50
import os
import hmac
from flask import Response
def authenticate(request):
if request.method != 'POST':
r = '|ERROR| Request must be POST'; print (r)
return Response(r, status=401, mimetype='application/json')
elif 'authorization' not in request.headers:
r = '|ERROR| Request does not have auth token'; print (r)
return Response(r, status=400, mimetype='application/json')
else:
expected_auth_header = 'Token token="{}"'.format(os.environ.get('header'))
submitted_auth = request.headers['authorization']
if hmac.compare_digest(expected_auth_header,submitted_auth):
return Response(status=200, mimetype='application/json')
else:
r = '|ERROR| Incorrect token'; print (r)
return Response(r, status=403, mimetype='application/json')
def action_list(request):
auth = authenticate(request)
if auth.status_code != 200:
return auth
"""Return a list of actions"""
return {
"label": "Send Tabbed Dashboards with Tabby!",
"integrations": [
{
"name": "Tabby",
"label": "Tabby",
"description": "Write dashboard tiles to a tabbed excel sheet.",
"form_url":"https://URLGOESHERE.cloudfunctions.net/action_form",
"supported_action_types": ["dashboard"],
"supported_download_settings": ["url"],
"supported_formats": ["csv_zip"],
"supported_formattings": ["unformatted"],
"url": "https://URLGOESHERE.cloudfunctions.net/action_execute",
"icon_data_uri":URIGOESHERE
}
]
}