Commit c607acab authored by Antonio Gines Buendia Lopez's avatar Antonio Gines Buendia Lopez
Browse files

Separate NBI Resources for pathcompextended

Resources do not support duplication of methods (get / , get /uid) so separation into resourceX and resourceXDetails was made
parent e4f5b603
Loading
Loading
Loading
Loading
+22 −15
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
import logging
from flask_restful import Resource, request
from flask.json import jsonify
from pathcompextended.client.PathCompClient import PathCompExtendedClient
# from pathcompextended.client.PathCompClient import PathCompExtendedClient

LOGGER = logging.getLogger(__name__)

@@ -23,7 +23,8 @@ LOGGER = logging.getLogger(__name__)
class _Resource(Resource):
    def __init__(self) -> None:
        super().__init__()
        self.pathcompextended_client = PathCompExtendedClient()
        # TODO: when pce is built
        # self.pathcompextended_client = PathCompExtendedClient()


class Index(_Resource):
@@ -38,17 +39,19 @@ class NetworkContext(_Resource):
        # TODO: call the gRPC operations and return real result
        return jsonify({'message': 'Not implemented yet'})

    def get(self, id: str):
        LOGGER.info(f"Operation GET /network-context/{id}")
        # TODO: call the gRPC operations
        return jsonify({'message': 'Not implemented yet'})

    def post(self):
        payload = request.json
        LOGGER.info(f"Operation POST /network-context")
        # TODO: call the gRPC operations
        return jsonify({'message': 'Not implemented yet'})


class NetworkContextDetails(_Resource):
    def get(self, id: str):
        LOGGER.info(f"Operation GET /network-context/{id}")
        # TODO: call the gRPC operations
        return jsonify({'message': 'Not implemented yet'})

    def delete(self, id: str):
        LOGGER.info(f"Operation DELETE /network-context/{id}")
        # TODO: call the gRPC operations
@@ -68,13 +71,15 @@ class TransportOpticalSlice(_Resource):
        # TODO: implement
        return jsonify({'message': 'Not implemented yet'})

    def get(self, id: str):
        LOGGER.info(f"Operation GET /transport-optical-slice/{id}")
    def post(self):
        LOGGER.info("Operation POST /transport-optical-slice")
        # TODO: implement
        return jsonify({'message': 'Not implemented yet'})

    def post(self):
        LOGGER.info("Operation POST /transport-optical-slice")

class TransportOpticalSliceDetails(_Resource):
    def get(self, id: str):
        LOGGER.info(f"Operation GET /transport-optical-slice/{id}")
        # TODO: implement
        return jsonify({'message': 'Not implemented yet'})

@@ -90,13 +95,15 @@ class TransportNetworkSliceL3(_Resource):
        # TODO: implement
        return jsonify({'message': 'Not implemented yet'})

    def get(self, id: str):
        LOGGER.info(f"Operation GET /transport-network-slice-l3/{id}")
    def post(self):
        LOGGER.info("Operation POST /transport-network-slice-l3")
        # TODO: implement
        return jsonify({'message': 'Not implemented yet'})

    def post(self):
        LOGGER.info("Operation POST /transport-network-slice-l3")

class TransportNetworkSliceL3Details(_Resource):
    def get(self, id: str):
        LOGGER.info(f"Operation GET /transport-network-slice-l3/{id}")
        # TODO: implement
        return jsonify({'message': 'Not implemented yet'})

+7 −4
Original line number Diff line number Diff line
@@ -16,9 +16,12 @@ from nbi.service.NbiApplication import NbiApplication
from .Resources import (
    Index,
    NetworkContext,
    NetworkContextDetails,
    Health,
    TransportOpticalSlice,
    TransportNetworkSliceL3
    TransportOpticalSliceDetails,
    TransportNetworkSliceL3,
    TransportNetworkSliceL3Details
)

URL_PREFIX = '/pathcompextended'
@@ -35,7 +38,7 @@ def register_pathcompextended(nbi_app : NbiApplication):
        endpoint='pathcompextended.network_context'
    )
    nbi_app.add_rest_api_resource(
        NetworkContext,
        NetworkContextDetails,
        URL_PREFIX + '/network-context/<path:id>',
        endpoint='pathcompextended.network_context_by_id'
    )
@@ -50,7 +53,7 @@ def register_pathcompextended(nbi_app : NbiApplication):
        endpoint='pathcompextended.transport_optical_slice'
    )
    nbi_app.add_rest_api_resource(
        TransportOpticalSlice,
        TransportOpticalSliceDetails,
        URL_PREFIX + '/transport-optical-slice/<path:id>',
        endpoint='pathcompextended.transport_optical_slice_by_id'
    )
@@ -60,7 +63,7 @@ def register_pathcompextended(nbi_app : NbiApplication):
        endpoint='pathcompextended.transport_network_slice_l3'
    )
    nbi_app.add_rest_api_resource(
        TransportNetworkSliceL3,
        TransportNetworkSliceL3Details,
        URL_PREFIX + '/transport-network-slice-l3/<path:id>',
        endpoint='pathcompextended.transport_network_slice_l3_by_id'
    )