X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=o2ims%2Fviews%2Focloud_route.py;fp=o2ims%2Fviews%2Focloud_route.py;h=1341b212b5f83690cfa81074554b3da043cb05b3;hb=38646c684a13536146ecf16a35e6e33d614b29e9;hp=0000000000000000000000000000000000000000;hpb=cbe50abd06ae2160acd8b48e39d8c6b96325f3c1;p=pti%2Fo2.git diff --git a/o2ims/views/ocloud_route.py b/o2ims/views/ocloud_route.py new file mode 100644 index 0000000..1341b21 --- /dev/null +++ b/o2ims/views/ocloud_route.py @@ -0,0 +1,132 @@ +# Copyright (C) 2021 Wind River Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from flask import jsonify + +from o2ims import config +from o2ims.views import ocloud_view + + +apibase = config.get_o2ims_api_base() + + +def configure_routes(app, bus): + + # ---------- OClouds ---------- # + @app.route(apibase, methods=["GET"]) + def oclouds(): + result = ocloud_view.oclouds(bus.uow) + return jsonify(result), 200 + + # ---------- ResourceTypes ---------- # + + @app.route(apibase + "/resourceTypes", methods=["GET"]) + def resource_types(): + result = ocloud_view.resource_types(bus.uow) + return jsonify(result), 200 + + @app.route(apibase + "/resourceTypes", methods=["POST", "PUT", "PATCH", + "DELETE"]) + def resource_types_not_allow(): + return "Method Not Allowed", 405 + + @app.route(apibase + "/resourceTypes/", methods=["GET"]) + def resource_types_one(resourceTypeID): + result = ocloud_view.resource_type_one(resourceTypeID, bus.uow) + if result is None: + return "", 200 + return jsonify(result), 200 + + @app.route(apibase + "/resourceTypes/", + methods=["POST", "PUT", "PATCH", "DELETE"]) + def resource_types_one_not_allow(resourceTypeID): + return "Method Not Allowed", 405 + + # ---------- ResourcePools ---------- # + + @app.route(apibase + "/resourcePools", methods=["GET"]) + def resource_pools(): + result = ocloud_view.resource_pools(bus.uow) + return jsonify(result), 200 + + @app.route(apibase + "/resourcePools", methods=["POST", "PUT", "PATCH", + "DELETE"]) + def resource_pools_not_allow(): + return "Method Not Allowed", 405 + + @app.route(apibase + "/resourcePools/", methods=["GET"]) + def resource_pools_one(resourcePoolID): + result = ocloud_view.resource_pool_one(resourcePoolID, bus.uow) + if result is None: + return "", 200 + return jsonify(result), 200 + + @app.route(apibase + "/resourcePools/", + methods=["POST", "PUT", "PATCH", "DELETE"]) + def resource_pools_one_not_allow(resourcePoolID): + return "Method Not Allowed", 405 + + # ---------- Resources ---------- # + + @app.route(apibase + "/resourcePools//resources", + methods=["GET"]) + def resources(resourcePoolID): + result = ocloud_view.resources(resourcePoolID, bus.uow) + return jsonify(result), 200 + + @app.route(apibase + "/resourcePools//resources", + methods=["POST", "PUT", "PATCH", "DELETE"]) + def resource_not_allow(resourcePoolID): + return "Method Not Allowed", 405 + + @app.route(apibase + + "/resourcePools//resources/", + methods=["GET"]) + def resources_one(resourcePoolID, resourceID): + result = ocloud_view.resource_one(resourceID, bus.uow) + if result is None: + return "", 200 + return jsonify(result), 200 + + @app.route(apibase + + "/resourcePools//resources/", + methods=["POST", "PUT", "PATCH", "DELETE"]) + def resource_one_not_allow(resourcePoolID, resourceID): + return "Method Not Allowed", 405 + + # ---------- DeploymentManagers ---------- # + + @app.route(apibase + "/deploymentManagers", methods=["GET"]) + def deployment_managers(): + result = ocloud_view.deployment_managers(bus.uow) + return jsonify(result), 200 + + @app.route(apibase + "/deploymentManagers", + methods=["POST", "PUT", "PATCH", "DELETE"]) + def deployment_managers_not_allow(): + return "Method Not Allowed", 405 + + @app.route(apibase + "/deploymentManagers/", + methods=["GET"]) + def deployment_manager_one(deploymentManagerID): + result = ocloud_view.deployment_manager_one( + deploymentManagerID, bus.uow) + if result is None: + return "", 200 + return jsonify(result), 200 + + @app.route(apibase + "/deploymentManagers/", + methods=["POST", "PUT", "PATCH", "DELETE"]) + def deployment_manager_one_not_allow(deploymentManagerID): + return "Method Not Allowed", 405