summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFu Jinhua <fu.jinhua@zte.com.cn>2018-03-06 06:50:24 +0000
committerGerrit Code Review <gerrit@onap.org>2018-03-06 06:50:24 +0000
commit52bd7e6f949a52c066d41ac10a5210c50d4ef320 (patch)
tree3f787ce1e2181a63a21b7498ee3071c42bb5a4ef
parent7c1f31143d6fe8db3f732389953db2405318bf6f (diff)
parent6eb6242f4c2ffca859b83b05b0f4e32282ef73ef (diff)
Merge "Add vnf Grant swagger generate logic"
-rw-r--r--lcm/v2/views.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/lcm/v2/views.py b/lcm/v2/views.py
index 4b0a9499..19f6740a 100644
--- a/lcm/v2/views.py
+++ b/lcm/v2/views.py
@@ -12,15 +12,35 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
+import traceback
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework import status
+from drf_yasg.utils import swagger_auto_schema
+
+from lcm.v2.serializers import GrantRequestSerializer
+from lcm.v2.serializers import GrantSerializer
logger = logging.getLogger(__name__)
class VnfGrantView(APIView):
+ @swagger_auto_schema(
+ request_body=GrantRequestSerializer(),
+ responses={
+ status.HTTP_201_CREATED: GrantSerializer(),
+ status.HTTP_500_INTERNAL_SERVER_ERROR: "Inner error"
+ }
+ )
def post(self, request):
logger.debug("VnfGrantView Post: %s" % request.data)
+ try:
+ req_serializer = GrantRequestSerializer(data=request.data)
+ if not req_serializer.is_valid():
+ raise Exception(req_serializer.errors)
+ except Exception as e:
+ logger.error(traceback.format_exc())
+ logger.error("Exception in VnfGrant: %s", e.message)
+ return Response(data={'error': e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
return Response(data={}, status=status.HTTP_201_CREATED)