Commit 033f710d authored by Ristylou Dolar's avatar Ristylou Dolar

Modified Application, Endpoint and Service retrieve method

parent 510a53e5
......@@ -94,23 +94,23 @@ class ApplicationViewSet(viewsets.ModelViewSet):
def retrieve(self, request, *args, **kwargs):
try:
id = self.kwargs['pk']
queryset = Application.objects.filter(id=id)
serializer = self.get_serializer(queryset, many=True)
if not queryset.exists():
message = status_message_response(404, 'failed',
'No record found', [])
return Response(message, status=status.HTTP_404_NOT_FOUND)
else:
message = status_message_response(
instance = Application.objects.get(id=id)
serializer = self.get_serializer(instance)
message = status_message_response(
200, 'success',
'Application retrieved', serializer.data
)
return Response(message, status=status.HTTP_200_OK)
return Response(message, status=status.HTTP_200_OK)
except Application.DoesNotExist:
message = status_message_response(404, 'failed',
'No record found', [])
return Response(message, status=status.HTTP_404_NOT_FOUND)
except Exception as e:
message = status_message_response(
500, 'failed',
500, 'failed',
'Request was not able to process' + str(e), []
)
return Response(message,
......
......@@ -80,24 +80,23 @@ class APIEndpointViewSet(viewsets.ModelViewSet):
def retrieve(self, request, *args, **kwargs):
try:
id = self.kwargs['pk']
queryset = APIEndpoint.objects.filter(id=id)
serializer = self.get_serializer(queryset, many=True)
instance = APIEndpoint.objects.get(id=id)
serializer = self.get_serializer(instance)
message = status_message_response(
200, 'success',
'Endpoint retrieved', serializer.data
)
return Response(message, status=status.HTTP_200_OK)
if not queryset.exists():
message = status_message_response(
404, 'failed', 'No record found', []
)
return Response(message, status=status.HTTP_404_NOT_FOUND)
else:
message = status_message_response(
200, 'success',
'Endpoint retrieved', serializer.data
)
return Response(message, status=status.HTTP_200_OK)
except APIEndpoint.DoesNotExist:
message = status_message_response(404, 'failed',
'No record found', [])
return Response(message, status=status.HTTP_404_NOT_FOUND)
except Exception as e:
message = status_message_response(
500, 'failed',
500, 'failed',
'Request was not able to process' + str(e), []
)
return Response(message,
......
......@@ -76,24 +76,23 @@ class APIServiceViewSet(viewsets.ModelViewSet):
def retrieve(self, request, *args, **kwargs):
try:
id = self.kwargs['pk']
queryset = APIService.objects.filter(id=id)
serializer = self.get_serializer(queryset, many=True)
instance = APIService.objects.get(id=id)
serializer = self.get_serializer(instance)
message = status_message_response(
200, 'success',
'Service retrieved', serializer.data
)
return Response(message, status=status.HTTP_200_OK)
if not queryset.exists():
message = status_message_response(
404, 'failed', 'No record found', []
)
return Response(message, status=status.HTTP_404_NOT_FOUND)
else:
message = status_message_response(
200, 'success',
'Service retrieved', serializer.data
)
return Response(message, status=status.HTTP_200_OK)
except APIService.DoesNotExist:
message = status_message_response(404, 'failed',
'No record found', [])
return Response(message, status=status.HTTP_404_NOT_FOUND)
except Exception as e:
message = status_message_response(
500, 'failed',
500, 'failed',
'Request was not able to process' + str(e), []
)
return Response(message,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment