示例#1
0
文件: views.py 项目: cshamis/scale
    def get(self, request):
        '''Retrieves the metrics types and returns it in JSON form

        :param request: the HTTP GET request
        :type request: :class:`rest_framework.request.Request`
        :rtype: :class:`rest_framework.response.Response`
        :returns: the HTTP response to send back to the user
        '''
        metrics_types = registry.get_metrics_types()
        page = rest_util.perform_paging(request, metrics_types)
        serializer = MetricsTypeListSerializer(page, context={'request': request})
        return Response(serializer.data, status=status.HTTP_200_OK)
示例#2
0
文件: views.py 项目: wong-j/scale
    def list(self, request):
        """Retrieves the metrics types and returns it in JSON form

        :param request: the HTTP GET request
        :type request: :class:`rest_framework.request.Request`
        :rtype: :class:`rest_framework.response.Response`
        :returns: the HTTP response to send back to the user
        """
        metrics_types = registry.get_metrics_types()

        page = self.paginate_queryset(metrics_types)
        serializer = self.get_serializer(page, many=True)
        return self.get_paginated_response(serializer.data)
示例#3
0
文件: views.py 项目: AppliedIS/scale
    def list(self, request):
        """Retrieves the metrics types and returns it in JSON form

        :param request: the HTTP GET request
        :type request: :class:`rest_framework.request.Request`
        :rtype: :class:`rest_framework.response.Response`
        :returns: the HTTP response to send back to the user
        """
        metrics_types = registry.get_metrics_types()

        page = self.paginate_queryset(metrics_types)
        serializer = self.get_serializer(page, many=True)
        return self.get_paginated_response(serializer.data)
示例#4
0
文件: views.py 项目: marketboy/scale
class MetricsView(ListAPIView):
    """This view is the endpoint for retrieving available types of metrics."""
    queryset = registry.get_metrics_types()
    serializer_class = MetricsTypeSerializer

    def list(self, request):
        """Retrieves the metrics types and returns it in JSON form

        :param request: the HTTP GET request
        :type request: :class:`rest_framework.request.Request`
        :rtype: :class:`rest_framework.response.Response`
        :returns: the HTTP response to send back to the user
        """

        if request.version == 'v6':
            return self.list_v6(request)
        elif request.version == 'v7':
            return self.list_v6(request)

        raise Http404()

    def list_v6(self, request):
        """Gets v6 metrics types

        :param request: the HTTP GET request
        :type request: :class:`rest_framework.request.Request`
        :rtype: :class:`rest_framework.response.Response`
        :returns: the HTTP response to send back to the user
        """

        return self.list_impl(request)

    def list_impl(self, request):
        """Retrieves the metrics types and returns it in JSON form

        :param request: the HTTP GET request
        :type request: :class:`rest_framework.request.Request`
        :rtype: :class:`rest_framework.response.Response`
        :returns: the HTTP response to send back to the user
        """

        metrics_types = registry.get_metrics_types()

        page = self.paginate_queryset(metrics_types)
        serializer = self.get_serializer(page, many=True)
        return self.get_paginated_response(serializer.data)