def get(self, request, format=None):
        # XXX: Hack. Should be removed after zabbix refactoring
        if not ZABBIX_ENABLED:
            raise Http404()

        usage_stats = []

        aggregate_model_name = request.query_params.get('aggregate', 'customer')
        if aggregate_model_name not in self.aggregate_models.keys():
            return Response(
                'Get parameter "aggregate" can take only this values: %s' % ', '.join(self.aggregate_models.keys()),
                status=status.HTTP_400_BAD_REQUEST)

        # This filters out the things we group by (aka aggregate root) to those that can be seen
        # by currently logged in user.
        aggregate_queryset = self._get_aggregate_queryset(request, aggregate_model_name)

        if 'uuid' in request.query_params:
            aggregate_queryset = aggregate_queryset.filter(uuid__in=request.query_params.getlist('uuid'))

        # This filters out the vm Instances to those that can be seen
        # by currently logged in user. This is done within each aggregate root separately.
        visible_instances = filter_queryset_for_user(models.Instance.objects.all(), request.user)

        for aggregate_object in aggregate_queryset:
            # Narrow down the instance scope to aggregate root.
            instances = visible_instances.filter(
                **self._get_aggregate_filter(aggregate_model_name, aggregate_object))
            if instances:
                hour = 60 * 60
                data = {
                    'start_timestamp': request.query_params.get('from', int(time.time() - hour)),
                    'end_timestamp': request.query_params.get('to', int(time.time())),
                    'segments_count': request.query_params.get('datapoints', 6),
                    'item': request.query_params.get('item'),
                }

                serializer = serializers.UsageStatsSerializer(data=data)
                serializer.is_valid(raise_exception=True)

                stats = serializer.get_stats(instances)
                usage_stats.append({'name': aggregate_object.name, 'datapoints': stats})
            else:
                usage_stats.append({'name': aggregate_object.name, 'datapoints': []})
        return Response(usage_stats, status=status.HTTP_200_OK)
dataset/ETHPy150Open opennode/nodeconductor/nodeconductor/iaas/views.py/UsageStatsView.get/original