Cancel.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace Elasticsearch\Endpoints\Tasks;
  3. use Elasticsearch\Common\Exceptions;
  4. use Elasticsearch\Endpoints\AbstractEndpoint;
  5. /**
  6. * Class Cancel
  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 Cancel 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->id) === true) {
  38. return "/_tasks/{$this->taskId}/_cancel";
  39. }
  40. return "/_tasks/_cancel";
  41. }
  42. /**
  43. * @return string[]
  44. */
  45. public function getParamWhitelist()
  46. {
  47. return array(
  48. 'node_id',
  49. 'actions',
  50. 'parent_node',
  51. 'parent_task',
  52. );
  53. }
  54. /**
  55. * @return string
  56. */
  57. public function getMethod()
  58. {
  59. return 'POST';
  60. }
  61. }