This repository has been archived by the owner on Jan 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnotification_flask_listener.py
64 lines (48 loc) · 1.8 KB
/
notification_flask_listener.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
Flask Listener
"""
import json
from flask import Flask, request
from Modules.app_promote import promote_app
from Modules.app_publish_review import email_on_publish_to_review
# Configuration
with open("static/config.json") as f:
CONFIG = json.load(f)
f.close()
LOCAL_SERVER = "localhost"
PORT = CONFIG["port"]
app = Flask(__name__, static_url_path="")
app.url_map.strict_slashes = False
# any app update event will trigger this function
@app.route("/app/update/promote", methods=["POST"])
def app_update_promote():
"""
Function to promote an app to another Qlik Sense site on certain app updates
"""
response_json = request.get_json()
app_id = response_json[0]["objectID"]
originator_node_id = response_json[0]["originatorNodeID"]
originator_host_name = response_json[0]["originatorHostName"]
return promote_app("updated", app_id, originator_node_id, originator_host_name)
@app.route("/app/update/reloaded", methods=["POST"])
def app_update_reloaded():
"""
Function to promote an app to another Qlik Sense site on app reloads
"""
response_json = request.get_json()
app_id = response_json[0]["objectID"]
originator_node_id = response_json[0]["originatorNodeID"]
originator_host_name = response_json[0]["originatorHostName"]
return promote_app("reloaded", app_id, originator_node_id, originator_host_name)
@app.route("/app/publish/review", methods=["POST"])
def app_publish_review():
"""
Function that is triggered when an app is published to the stream
configured as the "review"
Function triggers an email alert to target address
"""
response_json = request.get_json()
app_id = response_json[0]["objectID"]
return email_on_publish_to_review(app_id)
if __name__ == "__main__":
app.run(host=LOCAL_SERVER, port=PORT)