-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_apis.py
45 lines (35 loc) · 1.68 KB
/
admin_apis.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
import database
def get_all_deployments():
return database.get_all_deployments()
def get_deployment(deployment_name):
return database.get_deployment_by_name(deployment_name)
def get_deployment_stats(deployment_name):
res = database.get_deployment_stats(deployment_name)
unique_res = database.get_unique_deployment_stats(deployment_name)
return {'step_wise_stats': res, 'step_wise_unique_stats': unique_res}
def add_deployment(data):
deployment_name = data["deployment_name"]
user_start_message = data["user_start_message"]
instance_name = data["instance_name"]
comments = data["comments"]
script = data["script"]
result_name = database.get_deployment_by_name(deployment_name)
result_start_msg = database.get_deployment_by_user_start_message(user_start_message)
if result_name or result_start_msg:
return {"error": "deployment name or start message already exists!"}
else:
database.insert_deployment(deployment_name, instance_name, script, user_start_message, comments)
return {"msg": "success"}
def edit_deployment(data):
deployment_name = data["deployment_name"]
user_start_message = data["user_start_message"]
instance_name = data["instance_name"]
comments = data["comments"]
script = data["script"]
result_name = database.get_deployment_by_name(deployment_name)
if not result_name:
return {"error": "deployment does not exist"}
else:
database.insert_deployment_snapshot(deployment_name, instance_name, script, user_start_message, comments)
database.update_deployment(deployment_name, instance_name, script, user_start_message, comments)
return {"msg": "success"}