Loading src/nbi/service/rest_server/nbi_plugins/etsi_bwm/Resources.py +14 −6 Original line number Diff line number Diff line Loading @@ -13,12 +13,15 @@ # limitations under the License. import copy, deepmerge, json, logging from typing import Dict from flask_restful import Resource, request from werkzeug.exceptions import UnsupportedMediaType from common.Constants import DEFAULT_CONTEXT_NAME from context.client.ContextClient import ContextClient from flask_restful import Resource, request from service.client.ServiceClient import ServiceClient from .Tools import ( format_grpc_to_json, grpc_context_id, grpc_service_id, bwInfo_2_service, service_2_bwInfo) format_grpc_to_json, grpc_context_id, grpc_service_id, bwInfo_2_service, service_2_bwInfo ) LOGGER = logging.getLogger(__name__) Loading @@ -37,15 +40,20 @@ class BwInfo(_Resource): return bw_allocations def post(self): bwinfo = request.get_json() service = bwInfo_2_service(self.client, bwinfo) if not request.is_json: raise UnsupportedMediaType('JSON payload is required') request_data: Dict = request.get_json() service = bwInfo_2_service(self.client, request_data) stripped_service = copy.deepcopy(service) stripped_service.ClearField('service_endpoint_ids') stripped_service.ClearField('service_constraints') stripped_service.ClearField('service_config') try: response = format_grpc_to_json(self.service_client.CreateService(stripped_service)) response = format_grpc_to_json(self.service_client.UpdateService(service)) except Exception as e: # pylint: disable=broad-except return e return response Loading src/nbi/service/rest_server/nbi_plugins/etsi_bwm/Tools.py +1 −1 Original line number Diff line number Diff line Loading @@ -20,10 +20,10 @@ from common.proto.context_pb2 import ( Service, Constraint, Constraint_SLA_Capacity, ConfigRule, ConfigRule_Custom, ConfigActionEnum ) from common.tools.grpc.ConfigRules import update_config_rule_custom from common.tools.grpc.Tools import grpc_message_to_json from common.tools.object_factory.Context import json_context_id from common.tools.object_factory.Service import json_service_id from common.tools.grpc.ConfigRules import update_config_rule_custom LOGGER = logging.getLogger(__name__) Loading Loading
src/nbi/service/rest_server/nbi_plugins/etsi_bwm/Resources.py +14 −6 Original line number Diff line number Diff line Loading @@ -13,12 +13,15 @@ # limitations under the License. import copy, deepmerge, json, logging from typing import Dict from flask_restful import Resource, request from werkzeug.exceptions import UnsupportedMediaType from common.Constants import DEFAULT_CONTEXT_NAME from context.client.ContextClient import ContextClient from flask_restful import Resource, request from service.client.ServiceClient import ServiceClient from .Tools import ( format_grpc_to_json, grpc_context_id, grpc_service_id, bwInfo_2_service, service_2_bwInfo) format_grpc_to_json, grpc_context_id, grpc_service_id, bwInfo_2_service, service_2_bwInfo ) LOGGER = logging.getLogger(__name__) Loading @@ -37,15 +40,20 @@ class BwInfo(_Resource): return bw_allocations def post(self): bwinfo = request.get_json() service = bwInfo_2_service(self.client, bwinfo) if not request.is_json: raise UnsupportedMediaType('JSON payload is required') request_data: Dict = request.get_json() service = bwInfo_2_service(self.client, request_data) stripped_service = copy.deepcopy(service) stripped_service.ClearField('service_endpoint_ids') stripped_service.ClearField('service_constraints') stripped_service.ClearField('service_config') try: response = format_grpc_to_json(self.service_client.CreateService(stripped_service)) response = format_grpc_to_json(self.service_client.UpdateService(service)) except Exception as e: # pylint: disable=broad-except return e return response Loading
src/nbi/service/rest_server/nbi_plugins/etsi_bwm/Tools.py +1 −1 Original line number Diff line number Diff line Loading @@ -20,10 +20,10 @@ from common.proto.context_pb2 import ( Service, Constraint, Constraint_SLA_Capacity, ConfigRule, ConfigRule_Custom, ConfigActionEnum ) from common.tools.grpc.ConfigRules import update_config_rule_custom from common.tools.grpc.Tools import grpc_message_to_json from common.tools.object_factory.Context import json_context_id from common.tools.object_factory.Service import json_service_id from common.tools.grpc.ConfigRules import update_config_rule_custom LOGGER = logging.getLogger(__name__) Loading