diff options
author | laili <lai.li@zte.com.cn> | 2018-08-22 16:37:43 +0800 |
---|---|---|
committer | laili <lai.li@zte.com.cn> | 2018-08-22 16:37:43 +0800 |
commit | 1de6ed4cb85b1c6c189098f55c5101449491bb8d (patch) | |
tree | 081ca4d1d168ac7c9d703e7b8e97d8ff0832fe3b | |
parent | 79873dd43fc6d55584dc9bbb08b018781eb85a71 (diff) |
Ns descriptor related stuffs.
Add the view for query of an individual nsd.
Change-Id: I9d036a7b872227c8e162612e425d573d882a0276
Issue-ID: VFC-1037
Signed-off-by: laili <lai.li@zte.com.cn>
-rw-r--r-- | catalog/packages/views/ns_descriptor_views.py | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/catalog/packages/views/ns_descriptor_views.py b/catalog/packages/views/ns_descriptor_views.py index a8364eda..eb673aba 100644 --- a/catalog/packages/views/ns_descriptor_views.py +++ b/catalog/packages/views/ns_descriptor_views.py @@ -20,7 +20,7 @@ from rest_framework import status from rest_framework.decorators import api_view from rest_framework.response import Response -from catalog.packages.biz.ns_descriptor import create, query_multiple +from catalog.packages.biz.ns_descriptor import create, query_multiple, query_single from catalog.packages.serializers.create_nsd_info_request import \ CreateNsdInfoRequestSerializer from catalog.packages.serializers.nsd_info import NsdInfoSerializer @@ -29,17 +29,40 @@ from catalog.pub.exceptions import CatalogException logger = logging.getLogger(__name__) - +""" @swagger_auto_schema( responses={ # status.HTTP_200_OK: Serializer(), status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error" } ) -# @api_view(http_method_names=['GET']) -def ns_info_rd(request): - # TODO - return None +""" + + +@swagger_auto_schema( + method='GET', + operation_description="Query an individual NS descriptor resource", + request_body=no_body, + responses={ + status.HTTP_200_OK: NsdInfoSerializer(), + status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error" + } +) +@api_view(http_method_names=['GET']) +def ns_info_rd(request, nsdInfoId): + if request.method == 'GET': + try: + data = query_single(nsdInfoId) + nsd_info = NsdInfoSerializer(data=data) + if not nsd_info.is_valid(): + raise CatalogException + return Response(data=nsd_info.data, status=status.HTTP_200_OK) + except CatalogException: + logger.error(traceback.format_exc()) + return Response( + data={'error': 'Query of an individual NS descriptor resource failed.'}, + status=status.HTTP_500_INTERNAL_SERVER_ERROR + ) @swagger_auto_schema( |