GetLogsResponse.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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__) . '/QueriedLog.php');
  8. /**
  9. * The response of the GetLog API from log service.
  10. *
  11. * @author log service dev
  12. */
  13. class Aliyun_Log_Models_GetLogsResponse extends Aliyun_Log_Models_Response {
  14. /**
  15. * @var integer log number
  16. */
  17. private $count;
  18. /**
  19. * @var string logs query status(Complete or InComplete)
  20. */
  21. private $progress;
  22. /**
  23. * @var array Aliyun_Log_Models_QueriedLog array, all log data
  24. */
  25. private $logs;
  26. /**
  27. * Aliyun_Log_Models_GetLogsResponse constructor
  28. *
  29. * @param array $resp
  30. * GetLogs HTTP response body
  31. * @param array $header
  32. * GetLogs HTTP response header
  33. */
  34. public function __construct($resp, $header) {
  35. parent::__construct ( $header );
  36. $this->count = $header['x-log-count'];
  37. $this->progress = $header ['x-log-progress'];
  38. $this->logs = array ();
  39. foreach ( $resp as $data ) {
  40. $contents = $data;
  41. $time = $data ['__time__'];
  42. $source = $data ['__source__'];
  43. unset ( $contents ['__time__'] );
  44. unset ( $contents ['__source__'] );
  45. $this->logs [] = new Aliyun_Log_Models_QueriedLog ( $time, $source, $contents );
  46. }
  47. }
  48. /**
  49. * Get log number from the response
  50. *
  51. * @return integer log number
  52. */
  53. public function getCount() {
  54. return $this->count;
  55. }
  56. /**
  57. * Check if the get logs query is completed
  58. *
  59. * @return bool true if this logs query is completed
  60. */
  61. public function isCompleted() {
  62. return $this->progress == 'Complete';
  63. }
  64. /**
  65. * Get all logs from the response
  66. *
  67. * @return array Aliyun_Log_Models_QueriedLog array, all log data
  68. */
  69. public function getLogs() {
  70. return $this->logs;
  71. }
  72. }