Fix ocloudvirtualresource api typo
[pti/o2.git] / o2dms / api / ocloud_vresource_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 DmsLcmNfOCloudVResourceDTO
19 from o2dms.api import dms_lcm_nfdeployment_vres as 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 # LCM services #
32 @api_dms_lcm_v1\
33     .route("/<deploymentManagerID>/O2dms_DeploymentLifecycle/"
34            "NfDeployment/<nfDeploymentId>/NfOCloudVirtualResource")
35 @api_dms_lcm_v1\
36     .param('deploymentManagerID', 'ID of the Deployment Manager')
37 @api_dms_lcm_v1.param('nfDeploymentId',
38                       'ID of the NfDeployment')
39 @api_dms_lcm_v1.response(404, 'DMS LCM not found')
40 class DmsLcmNfOCloudVResListRouter(Resource):
41
42     model = DmsLcmNfOCloudVResourceDTO.NfOCloudVResource_get
43
44     @api_dms_lcm_v1.doc('Get a list of NfOCloudVirtualResource')
45     @api_dms_lcm_v1.marshal_list_with(model)
46     def get(self, nfDeploymentId, deploymentManagerID):
47         bus = MessageBus.get_instance()
48         return dms_lcm_view.lcm_nfocloudvresource_list(
49             nfDeploymentId, bus.uow)
50
51
52 @api_dms_lcm_v1\
53     .route("/<deploymentManagerID>/O2dms_DeploymentLifecycle/"
54            "NfDeployment/<nfDeploymentId>/"
55            "NfOCloudVirtualResource/<nfOCloudVirtualResourceId>")
56 @api_dms_lcm_v1\
57     .param('deploymentManagerID', 'ID of the deployment manager')
58 @api_dms_lcm_v1.param('nfDeploymentId',
59                       'ID of the NfDeployment')
60 @api_dms_lcm_v1.param('nfOCloudVirtualResourceId',
61                       'ID of the NfOCloudVirtualResource')
62 @api_dms_lcm_v1.response(404, 'DMS LCM not found')
63 class DmsLcmNfOCloudVResGetRouter(Resource):
64
65     model = DmsLcmNfOCloudVResourceDTO.NfOCloudVResource_get
66
67     @api_dms_lcm_v1.doc('Get a NfOCloudVirtualResource')
68     @api_dms_lcm_v1.marshal_with(model)
69     def get(self, nfOCloudVirtualResourceId,
70             nfDeploymentId, deploymentManagerID):
71         bus = MessageBus.get_instance()
72         result = dms_lcm_view\
73             .lcm_nfocloudvresource_one(nfOCloudVirtualResourceId, bus.uow)
74         if result is not None:
75             return result
76         api_dms_lcm_v1.abort(
77             404, "NfOCloudVirtualResource {} doesn't exist".format(
78                 nfOCloudVirtualResourceId))