aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFu Jinhua <fu.jinhua@zte.com.cn>2018-08-23 00:29:57 +0000
committerGerrit Code Review <gerrit@onap.org>2018-08-23 00:29:57 +0000
commitd38f1909567699fc5cb02ca2d82288d5f50577c5 (patch)
treefe927de68ccf68a9efdb29b5bae5bf118c22807c
parent4c5c678a59a411885ee8ace449caae5be1639d96 (diff)
parent17e5ab17a74dc19cb4dde033c17b8b67e30aef89 (diff)
Merge "Ns descriptor related stuffs."
-rw-r--r--catalog/packages/views/ns_descriptor_views.py31
1 files changed, 21 insertions, 10 deletions
diff --git a/catalog/packages/views/ns_descriptor_views.py b/catalog/packages/views/ns_descriptor_views.py
index eb673aba..455b01ae 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, query_single
+from catalog.packages.biz.ns_descriptor import create, query_multiple, query_single, delete_single
from catalog.packages.serializers.create_nsd_info_request import \
CreateNsdInfoRequestSerializer
from catalog.packages.serializers.nsd_info import NsdInfoSerializer
@@ -29,26 +29,26 @@ from catalog.pub.exceptions import CatalogException
logger = logging.getLogger(__name__)
-"""
+
@swagger_auto_schema(
+ method='GET',
+ operation_description="Query an individual NS descriptor resource",
+ request_body=no_body,
responses={
- # status.HTTP_200_OK: Serializer(),
+ status.HTTP_200_OK: NsdInfoSerializer(),
status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error"
}
)
-"""
-
-
@swagger_auto_schema(
- method='GET',
- operation_description="Query an individual NS descriptor resource",
+ method='DELETE',
+ operation_description="Delete an individual NS descriptor resource",
request_body=no_body,
responses={
- status.HTTP_200_OK: NsdInfoSerializer(),
+ status.HTTP_204_NO_CONTENT: {},
status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error"
}
)
-@api_view(http_method_names=['GET'])
+@api_view(http_method_names=['GET', 'DELETE'])
def ns_info_rd(request, nsdInfoId):
if request.method == 'GET':
try:
@@ -64,6 +64,17 @@ def ns_info_rd(request, nsdInfoId):
status=status.HTTP_500_INTERNAL_SERVER_ERROR
)
+ if request.method == 'DELETE':
+ try:
+ data = delete_single(nsdInfoId)
+ return Response(data={}, status=status.HTTP_204_NO_CONTENT)
+ except CatalogException:
+ logger.error(traceback.format_exc())
+ return Response(
+ data={'error': 'Deletion of an individual NS descriptor resource failed.'},
+ status=status.HTTP_500_INTERNAL_SERVER_ERROR
+ )
+
@swagger_auto_schema(
method='POST',