From 0f3fc78c4602b3a70b4e54efbffa155bdea437d8 Mon Sep 17 00:00:00 2001 From: gifrerenom <lluis.gifre@cttc.es> Date: Wed, 12 Feb 2025 17:09:54 +0000 Subject: [PATCH] Pre-merge code cleanup --- .../nbi_plugins/camara_qod/Resources.py | 29 ++++++++----------- .../nbi_plugins/camara_qod/Tools.py | 2 +- .../nbi_plugins/camara_qod/__init__.py | 13 ++++----- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/nbi/service/rest_server/nbi_plugins/camara_qod/Resources.py b/src/nbi/service/rest_server/nbi_plugins/camara_qod/Resources.py index 253823545..cd89c02fb 100644 --- a/src/nbi/service/rest_server/nbi_plugins/camara_qod/Resources.py +++ b/src/nbi/service/rest_server/nbi_plugins/camara_qod/Resources.py @@ -1,4 +1,4 @@ -# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) +# Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -11,31 +11,26 @@ # 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.json import jsonify -from flask_restful import Resource, request -from enum import Enum -import grpc._channel -from qos_profile.client.QoSProfileClient import QoSProfileClient -from werkzeug.exceptions import UnsupportedMediaType -from common.proto.context_pb2 import QoSProfileId, Uuid,Empty -from common.proto.qos_profile_pb2 import QoDConstraintsRequest + + +import copy, grpc, grpc._channel, logging from typing import Dict from uuid import uuid4 -import grpc, logging -import copy, deepmerge, json, logging -from typing import Dict +from flask.json import jsonify from flask_restful import Resource, request -from werkzeug.exceptions import UnsupportedMediaType +from common.proto.context_pb2 import QoSProfileId, Uuid,Empty from common.Constants import DEFAULT_CONTEXT_NAME from context.client.ContextClient import ContextClient +from qos_profile.client.QoSProfileClient import QoSProfileClient from service.client.ServiceClient import ServiceClient from .Tools import ( - format_grpc_to_json, grpc_context_id, grpc_service_id, QOD_2_service, service_2_qod,grpc_message_to_qos_table_data,create_qos_profile_from_json + format_grpc_to_json, grpc_context_id, grpc_service_id, + QOD_2_service, service_2_qod, grpc_message_to_qos_table_data, + create_qos_profile_from_json ) +LOGGER = logging.getLogger(__name__) -LOGGER = logging.getLogger(__name__) -#Initiate the QoSProfileClient class _Resource(Resource): def __init__(self) -> None: super().__init__() @@ -43,7 +38,7 @@ class _Resource(Resource): self.client = ContextClient() self.service_client = ServiceClient() -#ProfileList Endpoint for posting +#ProfileList Endpoint for posting class ProfileList(_Resource): def post(self): if not request.is_json: diff --git a/src/nbi/service/rest_server/nbi_plugins/camara_qod/Tools.py b/src/nbi/service/rest_server/nbi_plugins/camara_qod/Tools.py index feec71cb6..e0d19efff 100644 --- a/src/nbi/service/rest_server/nbi_plugins/camara_qod/Tools.py +++ b/src/nbi/service/rest_server/nbi_plugins/camara_qod/Tools.py @@ -1,4 +1,4 @@ -# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) +# Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/src/nbi/service/rest_server/nbi_plugins/camara_qod/__init__.py b/src/nbi/service/rest_server/nbi_plugins/camara_qod/__init__.py index ab4fe2bbd..19c452955 100644 --- a/src/nbi/service/rest_server/nbi_plugins/camara_qod/__init__.py +++ b/src/nbi/service/rest_server/nbi_plugins/camara_qod/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) +# Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,18 +13,17 @@ # limitations under the License. from nbi.service.rest_server.RestServer import RestServer -from .Resources import ProfileList, ProfileDetail, qodinfo, qodinfoId +from .Resources import ProfileList, ProfileDetail, QodInfo, QodInfoID URL_PREFIX = '/camara/qod/v0' # Use 'path' type since some identifiers might contain char '/' and Flask is unable to recognize them in 'string' type. RESOURCES = [ # (endpoint_name, resource_class, resource_url) - # TODO: Add appropriate endpoints - ('camara.qod_session_info', qodinfo, '/sessions'), - ('camara.qod_info_session_id', qodinfoId, '/sessions/<sessionId>'), - ('camara.qod.profile_list',ProfileList,'/profiles'), - ('camara.qod.profile_detail',ProfileDetail,'/profiles/<string:qos_profile_id>'), + ('camara.qod_session_info', QodInfo, '/sessions'), + ('camara.qod_info_session_id', QodInfoID, '/sessions/<sessionId>'), + ('camara.qod.profile_list', ProfileList, '/profiles'), + ('camara.qod.profile_detail', ProfileDetail, '/profiles/<string:qos_profile_id>'), ] def register_camara_qod(rest_server : RestServer): -- GitLab