Integrate nfdeployment api with event handler
[pti/o2.git] / o2dms / api / dms_route.py
1 # Copyright (C) 2021 Wind River Systems, Inc.
2 #
3 #  Licensed under the Apache License, Version 2.0 (the "License");
4 #  you may not use this file except in compliance with the License.
5 #  You may obtain a copy of the License at
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
9 #  Unless required by applicable law or agreed to in writing, software
10 #  distributed under the License is distributed on an "AS IS" BASIS,
11 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 #  See the License for the specific language governing permissions and
13 #  limitations under the License.
14
15 # from flask import jsonify
16 from flask_restx import Resource
17
18 from o2dms.api.dms_dto import DmsDTO
19 from o2dms.api import dms_lcm_view
20 from o2dms.api.dms_api_ns import api_dms_lcm_v1
21
22 from o2common.service.messagebus import MessageBus
23 from o2common.helper import o2logging
24 logger = o2logging.get_logger(__name__)
25
26
27 def configure_api_route():
28     pass
29
30
31 # ----------  DeploymentManagers ---------- #
32 @api_dms_lcm_v1.route("/<deploymentManagerID>")
33 @api_dms_lcm_v1.param('deploymentManagerID', 'ID of the deployment manager')
34 @api_dms_lcm_v1.response(404, 'Deployment manager not found')
35 class DmsGetRouter(Resource):
36
37     model = DmsDTO.dms_get
38
39     @api_dms_lcm_v1.doc('Get deployment manager')
40     @api_dms_lcm_v1.marshal_with(model)
41     def get(self, deploymentManagerID):
42         logger.debug("get o2dms info:{}".format(
43             deploymentManagerID
44         ))
45         bus = MessageBus.get_instance()
46         result = dms_lcm_view.deployment_manager_one(
47             deploymentManagerID, bus.uow)
48         if result is not None:
49             return result
50         api_dms_lcm_v1.abort(404, "Deployment manager {} doesn't exist".format(
51             deploymentManagerID))