Source code for aliyun.log.gethistogramsresponse

#!/usr/bin/env python
#encoding: utf-8

# Copyright (C) Alibaba Cloud Computing
# All rights reserved.

from logresponse import LogResponse
from histogram import Histogram

[docs]class GetHistogramsResponse(LogResponse): """ The response of the GetHistograms API from log. :type resp: dict :param resp: GetHistogramsResponse HTTP response body :type header: dict :param header: GetHistogramsResponse HTTP response header """ def __init__(self, resp, header): LogResponse.__init__(self, header) self.progress = header['x-log-progress'] self.count = header['x-log-count'] self.histograms = [] for data in resp : status = Histogram(data['from'], data['to'], data['count'], data['progress']) self.histograms.append(status)
[docs] def is_completed(self): """ Check if the histogram is completed :return: bool, true if this histogram is completed """ return self.progress=='Complete'
[docs] def get_total_count(self): """ Get total logs' count that current query hits :return: int, total logs' count that current query hits """ return self.count
[docs] def get_histograms(self): """ Get histograms on the requested time range: [from, to) :return: Histogram list, histograms on the requested time range: [from, to) """ return self.histograms
[docs] def log_print(self): print 'GetHistogramsResponse:' print 'headers:', self.get_all_headers() print 'progress:', self.progress print 'count:', self.count print '\nhistograms class:\n' for data in self.histograms: data.log_print() print