Add framework and apiserver
[pti/o2.git] / src / o2ims / entrypoints / flask_application.py
diff --git a/src/o2ims/entrypoints/flask_application.py b/src/o2ims/entrypoints/flask_application.py
new file mode 100644 (file)
index 0000000..933301c
--- /dev/null
@@ -0,0 +1,29 @@
+# Copyright (C) 2021 Wind River Systems, Inc.\r
+#\r
+#  Licensed under the Apache License, Version 2.0 (the "License");\r
+#  you may not use this file except in compliance with the License.\r
+#  You may obtain a copy of the License at\r
+#\r
+#      http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+#  Unless required by applicable law or agreed to in writing, software\r
+#  distributed under the License is distributed on an "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+#  See the License for the specific language governing permissions and\r
+#  limitations under the License.\r
+\r
+from datetime import datetime\r
+from flask import Flask, jsonify, request\r
+from o2ims.domain import commands\r
+from o2ims.service.handlers import InvalidResourceType\r
+from o2ims import bootstrap, config\r
+from o2ims.views import ocloud_view\r
+\r
+app = Flask(__name__)\r
+bus = bootstrap.bootstrap()\r
+apibase = config.get_o2ims_api_base()\r
+\r
+@app.route(apibase, methods=["GET"])\r
+def oclouds():\r
+    result = ocloud_view.oclouds(bus.uow)\r
+    return jsonify(result), 200\r