TasksNamespace.php 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace Elasticsearch\Namespaces;
  3. use Elasticsearch\Endpoints\Tasks\Cancel;
  4. use Elasticsearch\Endpoints\Tasks\Get;
  5. /**
  6. * Class TasksNamespace
  7. *
  8. * @category Elasticsearch
  9. * @package Elasticsearch\Namespaces\TasksNamespace
  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 TasksNamespace extends AbstractNamespace
  15. {
  16. /**
  17. * $params['wait_for_completion'] = (bool) Wait for the matching tasks to complete (default: false)
  18. *
  19. * @param $params array Associative array of parameters
  20. *
  21. * @return array
  22. */
  23. public function get($params = array())
  24. {
  25. $id = $this->extractArgument($params, 'task_id');
  26. /** @var callback $endpointBuilder */
  27. $endpointBuilder = $this->endpoints;
  28. /** @var Get $endpoint */
  29. $endpoint = $endpointBuilder('Tasks\Get');
  30. $endpoint->setTaskId($id)
  31. ->setParams($params);
  32. return $this->performRequest($endpoint);
  33. }
  34. /**
  35. * $params['node_id'] = (list) A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
  36. * ['actions'] = (list) A comma-separated list of actions that should be cancelled. Leave empty to cancel all.
  37. * ['parent_node'] = (string) Cancel tasks with specified parent node
  38. * ['parent_task'] = (string) Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all.
  39. * ['detailed'] = (bool) Return detailed task information (default: false)
  40. * ['wait_for_completion'] = (bool) Wait for the matching tasks to complete (default: false)
  41. * ['group_by'] = (enum) Group tasks by nodes or parent/child relationships
  42. *
  43. * @param $params array Associative array of parameters
  44. *
  45. * @return array
  46. */
  47. public function tasksList($params = array())
  48. {
  49. /** @var callback $endpointBuilder */
  50. $endpointBuilder = $this->endpoints;
  51. /** @var Get $endpoint */
  52. $endpoint = $endpointBuilder('Tasks\TasksList');
  53. $endpoint->setParams($params);
  54. return $this->performRequest($endpoint);
  55. }
  56. /**
  57. * $params['node_id'] = (list) A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
  58. * ['actions'] = (list) A comma-separated list of actions that should be cancelled. Leave empty to cancel all.
  59. * ['parent_node'] = (string) Cancel tasks with specified parent node
  60. * ['parent_task'] = (string) Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all.
  61. *
  62. * @param $params array Associative array of parameters
  63. *
  64. * @return array
  65. */
  66. public function cancel($params = array())
  67. {
  68. $id = $this->extractArgument($params, 'id');
  69. /** @var callback $endpointBuilder */
  70. $endpointBuilder = $this->endpoints;
  71. /** @var Cancel $endpoint */
  72. $endpoint = $endpointBuilder('Tasks\Cancel');
  73. $endpoint->setTaskId($id)
  74. ->setParams($params);
  75. return $this->performRequest($endpoint);
  76. }
  77. }