def expired_hostnames(self, request, *args, **kwargs): """ get the a list of all 'expired' hostnames for this project """ try: data = self.get_object().get_expired_hostnames() page = self.paginate_queryset(data) if page is not None: serializer = HostnameSerializer(page, many=True) return self.get_paginated_response(serializer.data) serializer = HostnameSerializer(data, many=True) return Response(serializer.data) except Exception as err: return Response({'messages': err}, status.HTTP_400_BAD_REQUEST)
def hostnames(self, request, *args, **kwargs): """ get the a list of all hostnames for this owner """ try: data = self.get_object().get_hostnames() page = self.paginate_queryset(data) if page is not None: serializer = HostnameSerializer(page, many=True) return self.get_paginated_response(serializer.data) serializer = HostnameSerializer(data, many=True) return Response(serializer.data) except Exception as err: return Response( {'messages': 'no data available for requested owner'}, status.HTTP_400_BAD_REQUEST)