Get.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace Elasticsearch\Endpoints\Tasks;
  3. use Elasticsearch\Common\Exceptions;
  4. use Elasticsearch\Endpoints\AbstractEndpoint;
  5. /**
  6. * Class Get
  7. *
  8. * @category Elasticsearch
  9. * @package Elasticsearch\Endpoints\Tasks
  10. * @author Zachary Tong <zach@elastic.co>
  11. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
  12. * @link http://elastic.co
  13. */
  14. class Get extends AbstractEndpoint
  15. {
  16. private $taskId;
  17. /**
  18. * @param string $taskId
  19. *
  20. * @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException
  21. * @return $this
  22. */
  23. public function setTaskId($taskId)
  24. {
  25. if (isset($taskId) !== true) {
  26. return $this;
  27. }
  28. $this->taskId = $taskId;
  29. return $this;
  30. }
  31. /**
  32. * @throws \Elasticsearch\Common\Exceptions\RuntimeException
  33. * @return string
  34. */
  35. public function getURI()
  36. {
  37. if (isset($this->taskId) === true) {
  38. return "/_tasks/{$this->taskId}";
  39. }
  40. return "/_tasks";
  41. }
  42. /**
  43. * @return string[]
  44. */
  45. public function getParamWhitelist()
  46. {
  47. return array(
  48. 'wait_for_completion'
  49. );
  50. }
  51. /**
  52. * @return string
  53. */
  54. public function getMethod()
  55. {
  56. return 'GET';
  57. }
  58. }