GetHistogramsResponse.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * Copyright (C) Alibaba Cloud Computing
  4. * All rights reserved
  5. */
  6. require_once realpath(dirname(__FILE__) . '/Response.php');
  7. require_once realpath(dirname(__FILE__) . '/Histogram.php');
  8. /**
  9. * The response of the GetHistograms API from log service.
  10. *
  11. * @author log service dev
  12. */
  13. class Aliyun_Log_Models_GetHistogramsResponse extends Aliyun_Log_Models_Response {
  14. /**
  15. * @var string histogram query status(Complete or InComplete)
  16. */
  17. private $progress;
  18. /**
  19. * @var integer logs' count that current query hits
  20. */
  21. private $count;
  22. /**
  23. * @var array Aliyun_Log_Models_Histogram array, histograms on the requested time range: [from, to)
  24. */
  25. private $histograms; // List<Aliyun_Log_Models_Histogram>
  26. /**
  27. * Aliyun_Log_Models_GetHistogramsResponse constructor
  28. *
  29. * @param array $resp
  30. * GetHistogramsResponse HTTP response body
  31. * @param array $header
  32. * GetHistogramsResponse HTTP response header
  33. */
  34. public function __construct($resp, $header) {
  35. parent::__construct ( $header );
  36. $this->progress = $header ['x-log-progress'];
  37. $this->count = $header ['x-log-count'];
  38. $this->histograms = array ();
  39. foreach ( $resp as $data )
  40. $this->histograms [] = new Aliyun_Log_Models_Histogram ( $data ['from'], $data ['to'], $data ['count'], $data ['progress'] );
  41. }
  42. /**
  43. * Check if the histogram is completed
  44. *
  45. * @return bool true if this histogram is completed
  46. */
  47. public function isCompleted() {
  48. return $this->progress == 'Complete';
  49. }
  50. /**
  51. * Get total logs' count that current query hits
  52. *
  53. * @return integer total logs' count that current query hits
  54. */
  55. public function getTotalCount() {
  56. return $this->count;
  57. }
  58. /**
  59. * Get histograms on the requested time range: [from, to)
  60. *
  61. * @return array Aliyun_Log_Models_Histogram array, histograms on the requested time range
  62. */
  63. public function getHistograms() {
  64. return $this->histograms;
  65. }
  66. }