update get network structre
[vfc/gvnfm/vnfres.git] / res / res / resources / views / get_networks_view.py
diff --git a/res/res/resources/views/get_networks_view.py b/res/res/resources/views/get_networks_view.py
new file mode 100644 (file)
index 0000000..ef07b06
--- /dev/null
@@ -0,0 +1,34 @@
+# Copyright @ 2020 China Mobile (SuZhou) Software Technology Co.,Ltd.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+#         http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
+import logging\r
+\r
+from rest_framework import status\r
+from rest_framework.views import APIView\r
+from drf_yasg.utils import swagger_auto_schema\r
+from res.resources.serializers import NetworkInfoSerializer\r
+from res.resources.views.base_view import view_safe_call_with_log\r
+from res.biz.networks_get import GetNetworksService\r
+logger = logging.getLogger(__name__)\r
+\r
+\r
+class GetNetworksView(APIView):\r
+    @swagger_auto_schema(\r
+        responses={\r
+            status.HTTP_200_OK: NetworkInfoSerializer(),\r
+            status.HTTP_500_INTERNAL_SERVER_ERROR: 'internal error'\r
+        }\r
+    )\r
+    @view_safe_call_with_log(logger=logger)\r
+    def get(self, request, vnf_instance_id):\r
+        return GetNetworksService().get_networks(vnf_instance_id)\r