summaryrefslogtreecommitdiff
path: root/database/prefab.py
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-04-04 17:00:31 +0200
committerGitHub <noreply@github.com>2022-04-04 17:00:31 +0200
commit38769373c7e89783d33849283586bfa0b62e8251 (patch)
tree4fda128ee6b30018c1aa14c584cc53ade80e67f7 /database/prefab.py
parent6021aa4278bebb34bf5603ead4b5daeabcdc4c19 (diff)
parent527ae2230f5c2dd22f496f45d5d8e3bd4acdb854 (diff)
merge: Migrate to Quarkus-based web API
This pull request changes the web API to a Quarkus-based version. Currently, the OpenDC web API is written in Python (using Flask). Although Python is a powerful language to develop web services, having another language next to Kotlin/Java and JavaScript introduces some challenges. For instance, the web API and UI lack integration with our Gradle-based build pipeline and require additional steps from the developer to start working with. Furthermore, deploying OpenDC requires having Python installed in addition to the JVM. By converting the web API into a Quarkus application, we can enjoy further integration with our Gradle-based build pipeline and simplify the development/deployment process of OpenDC, by requiring only the JVM and Node to work with OpenDC. ## Implementation Notes :hammer_and_pick: * Move build dependencies into version catalog * Design unified communication protocol * Add Quarkus API implementation * Add new web client implementation * Update runner to use new web client * Fix compatibility with React.js UI * Remove Python build steps from CI pipeline * Update Docker deployment for new web API * Remove obsolete database configuration ## External Dependencies :four_leaf_clover: * Quarkus ## Breaking API Changes :warning: * The new web API only supports SQL-based databases for storing user-data, as opposed to MongoDB currently. We intend to use H2 for development and Postgres for production.
Diffstat (limited to 'database/prefab.py')
-rwxr-xr-xdatabase/prefab.py112
1 files changed, 0 insertions, 112 deletions
diff --git a/database/prefab.py b/database/prefab.py
deleted file mode 100755
index b993c7f0..00000000
--- a/database/prefab.py
+++ /dev/null
@@ -1,112 +0,0 @@
-#!/usr/bin/env python3
-#Change shebang to /usr/bin/python3 before using with docker
-# encoding: utf-8
-"""
-prefab
-
-CLI frontend for viewing, modifying and creating prefabs in OpenDC.
-
-"""
-import sys
-import prefabs
-
-def usage():
- print("Usage: prefab add <prefab>: imports a prefab from JSON")
- print(" list: lists all (public) prefabs")
- print(" export <prefab> [json|yaml]: exports the specified prefab to the specified filetype (with JSON used by default)")
- print(" clone <prefab> [new prefab name]: clones the specified prefab, giving the new prefab a name if specified")
- print(" remove <prefab>: removes the specified prefab from the database")
-
-def interactive(): #interactive CLI mode: recommended
- print("OpenDC Prefab CLI")
- running = True
- while(exit):
- print(">", end=" ")
- try:
- command = input()
- command = command.split()
- except EOFError as e:
- print("exit")
- print("bye!")
- exit()
- except KeyboardInterrupt as KI:
- print("\nbye!")
- exit()
- if(len(command) >= 1):
- if(command[0] == "exit"):
- print("bye!")
- exit()
- elif(command[0] == "list"): # decrypt
- prefabs.list()
- elif(command[0] == "help"): # decrypt
- usage()
- elif(command[0] == "add"):
- if(len(command) == 3):
- prefabs.add(command[1], command[2])
- else:
- prefabs.add(command[1], None)
- elif(command[0] == "clone"):
- if(len(command) == 3):
- prefabs.clone(command[1], command[2])
- else:
- prefabs.clone(command[1], None)
- elif(command[0] == "export"):
- #print(sys.argv[2])
- prefabs.export(command[1], "json")
- elif(command[0] == "remove"):
- print("WARNING: Doing so will permanently remove the specified prefab. \nThis action CANNOT be undone. Please type the name of the prefab to confirm deletion.")
- confirm = input()
- if confirm == command[1]:
- prefabs.remove(command[1])
- print(f'Prefab {command[1]} has been removed.')
- else:
- print("Confirmation failed. The prefab has not been removed.")
- else:
- print("prefabs: try 'help' for more information\n")
- else:
- print("prefabs: try 'help' for more information\n")
-
-
-def main():
- if(len(sys.argv) >= 2):
- if(sys.argv[1] == "list"): # decrypt
- prefabs.list()
- exit()
- #elif(sys.argv[1] == "-e"): # encrypt
- # encrypt(sys.argv[2], sys.argv[3], sys.argv[4])
- #elif(sys.argv[1] == "-v"): # verify
- # verify(sys.argv[2], sys.argv[3], sys.argv[4])
- elif(sys.argv[1] == "help"): # decrypt
- usage()
- exit()
- elif(sys.argv[1] == "add"):
- if(sys.argv[3]):
- prefabs.add(sys.argv[2], sys.argv[3])
- else:
- prefabs.add(sys.argv[2])
- exit()
- elif(sys.argv[1] == "export"):
- #print(sys.argv[2])
- prefabs.export(sys.argv[2], "json")
- exit()
- elif(sys.argv[1] == "remove"):
- print("WARNING: Doing so will permanently remove the specified prefab. \nThis action CANNOT be undone. Please type the name of the prefab to confirm deletion.")
- confirm = input()
- if confirm == sys.argv[2]:
- prefabs.remove(sys.argv[2])
- print(f'Prefab {sys.argv[2]} has been removed.')
- else:
- print("Confirmation failed. The prefab has not been removed.")
- exit()
- else:
- print("prefabs: try 'prefabs help' for more information\n")
- elif(len(sys.argv) == 1):
- interactive()
-
- else:
- # print "Incorrect number of arguments!\n"
- print("prefabs: try 'prefabs help' for more information\n")
-
-
-if __name__ == "__main__":
- main()