1 # Copyright (C) 2021 Wind River Systems, Inc.
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 # from flask import jsonify
16 from flask_restx import Resource
18 from o2common.config import config
19 from o2dms.views.dms_dto import DmsLcmNfOCloudVResourceDTO
20 from o2dms.views import dms_lcm_view, api_dms_lcm_v1
21 from o2common.service.messagebus import MessageBus
23 apibase = config.get_o2dms_api_base()
28 .route("/<deploymentManagerID>/O2dms_DeploymentLifecycle/"
29 "NfDeployment/<nfDeploymentId>/NfOCloudVirtualResource")
31 .param('deploymentManagerID', 'ID of the Deployment Manager')
32 @api_dms_lcm_v1.param('nfDeploymentId',
33 'ID of the NfDeployment')
34 @api_dms_lcm_v1.response(404, 'DMS LCM not found')
35 class DmsLcmNfOCloudVResListRouter(Resource):
37 model = DmsLcmNfOCloudVResourceDTO.NfOCloudVResource_get
39 @api_dms_lcm_v1.doc('Get a list of NfOCloudVirtualResource')
40 @api_dms_lcm_v1.marshal_list_with(model)
41 def get(self, nfDeploymentId, deploymentManagerID):
42 bus = MessageBus.get_instance()
43 return dms_lcm_view.lcm_nfocloudvresource_list(
44 nfDeploymentId, bus.uow)
48 .route("/<deploymentManagerID>/O2dms_DeploymentLifecycle/"
49 "NfDeployment/<nfDeploymentId>/"
50 "NfOCloudVirtualResource/<nfOCloudVirtualResourceId>")
52 .param('deploymentManagerID', 'ID of the deployment manager')
53 @api_dms_lcm_v1.param('nfDeploymentId',
54 'ID of the NfDeployment')
55 @api_dms_lcm_v1.param('nfOCloudVirtualResourceId',
56 'ID of the NfOCloudVirtualResource')
57 @api_dms_lcm_v1.response(404, 'DMS LCM not found')
58 class DmsLcmNfOCloudVResGetRouter(Resource):
60 model = DmsLcmNfOCloudVResourceDTO.NfOCloudVResource_get
62 @api_dms_lcm_v1.doc('Get a NfOCloudVirtualResource')
63 @api_dms_lcm_v1.marshal_with(model)
64 def get(self, nfOCloudVirtualResourceId,
65 nfDeploymentId, deploymentManagerID):
66 bus = MessageBus.get_instance()
67 result = dms_lcm_view\
68 .lcm_nfocloudvresource_one(nfOCloudVirtualResourceId, bus.uow)
69 if result is not None:
72 404, "NfOCloudVirtualResource {} doesn't exist".format(
73 nfOCloudVirtualResourceId))