-
Notifications
You must be signed in to change notification settings - Fork 965
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3fa1c51
commit 7b87954
Showing
4 changed files
with
237 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
namespace Elasticsearch\Endpoints\Tasks; | ||
|
||
use Elasticsearch\Common\Exceptions; | ||
use Elasticsearch\Endpoints\AbstractEndpoint; | ||
|
||
/** | ||
* Class Cancel | ||
* | ||
* @category Elasticsearch | ||
* @package Elasticsearch\Endpoints\Tasks | ||
* @author Zachary Tong <[email protected]> | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2 | ||
* @link http://elasticsearch.org | ||
*/ | ||
class Cancel extends AbstractEndpoint | ||
{ | ||
private $taskId; | ||
|
||
/** | ||
* @param string $taskId | ||
* | ||
* @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException | ||
* @return $this | ||
*/ | ||
public function setTaskId($taskId) | ||
{ | ||
if (isset($taskId) !== true) { | ||
return $this; | ||
} | ||
|
||
$this->taskId = $taskId; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @throws \Elasticsearch\Common\Exceptions\RuntimeException | ||
* @return string | ||
*/ | ||
protected function getURI() | ||
{ | ||
if (isset($this->id) === true) { | ||
return "/_tasks/{$this->taskId}/_cancel"; | ||
} | ||
|
||
return "/_tasks/_cancel"; | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
protected function getParamWhitelist() | ||
{ | ||
return array( | ||
'node_id', | ||
'actions', | ||
'parent_node', | ||
'parent_task', | ||
); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
protected function getMethod() | ||
{ | ||
return 'POST'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace Elasticsearch\Endpoints\Tasks; | ||
|
||
use Elasticsearch\Common\Exceptions; | ||
use Elasticsearch\Endpoints\AbstractEndpoint; | ||
|
||
/** | ||
* Class Get | ||
* | ||
* @category Elasticsearch | ||
* @package Elasticsearch\Endpoints\Tasks | ||
* @author Zachary Tong <[email protected]> | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2 | ||
* @link http://elasticsearch.org | ||
*/ | ||
class Get extends AbstractEndpoint | ||
{ | ||
private $taskId; | ||
|
||
/** | ||
* @param string $taskId | ||
* | ||
* @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException | ||
* @return $this | ||
*/ | ||
public function setTaskId($taskId) | ||
{ | ||
if (isset($taskId) !== true) { | ||
return $this; | ||
} | ||
|
||
$this->taskId = $taskId; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @throws \Elasticsearch\Common\Exceptions\RuntimeException | ||
* @return string | ||
*/ | ||
protected function getURI() | ||
{ | ||
if (isset($this->id) === true) { | ||
return "/_tasks/{$this->taskId}"; | ||
} | ||
|
||
return "/_tasks"; | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
protected function getParamWhitelist() | ||
{ | ||
return array( | ||
'node_id', | ||
'actions', | ||
'detailed', | ||
'parent_node', | ||
'parent_task', | ||
'wait_for_completion', | ||
'group_by' | ||
); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
protected function getMethod() | ||
{ | ||
return 'GET'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
namespace Elasticsearch\Namespaces; | ||
use Elasticsearch\Endpoints\Tasks\Cancel; | ||
use Elasticsearch\Endpoints\Tasks\Get; | ||
|
||
|
||
/** | ||
* Class TasksNamespace | ||
* | ||
* @category Elasticsearch | ||
* @package Elasticsearch\Namespaces\TasksNamespace | ||
* @author Zachary Tong <[email protected]> | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2 | ||
* @link http://elasticsearch.org | ||
*/ | ||
class TasksNamespace extends AbstractNamespace | ||
{ | ||
/** | ||
* $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 | ||
* ['actions'] = (list) A comma-separated list of actions that should be cancelled. Leave empty to cancel all. | ||
* ['parent_node'] = (string) Cancel tasks with specified parent node | ||
* ['parent_task'] = (string) Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all. | ||
* ['detailed'] = (bool) Return detailed task information (default: false) | ||
* ['wait_for_completion'] = (bool) Wait for the matching tasks to complete (default: false) | ||
* ['group_by'] = (enum) Group tasks by nodes or parent/child relationships | ||
* | ||
* @param $params array Associative array of parameters | ||
* | ||
* @return array | ||
*/ | ||
public function get($params = array()) | ||
{ | ||
$id = $this->extractArgument($params, 'id'); | ||
|
||
/** @var callback $endpointBuilder */ | ||
$endpointBuilder = $this->endpoints; | ||
|
||
/** @var Get $endpoint */ | ||
$endpoint = $endpointBuilder('Tasks\Get'); | ||
$endpoint->setTaskId($id) | ||
->setParams($params); | ||
$response = $endpoint->performRequest(); | ||
|
||
return $endpoint->resultOrFuture($response); | ||
} | ||
|
||
/** | ||
* $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 | ||
* ['actions'] = (list) A comma-separated list of actions that should be cancelled. Leave empty to cancel all. | ||
* ['parent_node'] = (string) Cancel tasks with specified parent node | ||
* ['parent_task'] = (string) Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all. | ||
* | ||
* @param $params array Associative array of parameters | ||
* | ||
* @return array | ||
*/ | ||
public function cancel($params = array()) | ||
{ | ||
$id = $this->extractArgument($params, 'id'); | ||
|
||
/** @var callback $endpointBuilder */ | ||
$endpointBuilder = $this->endpoints; | ||
|
||
/** @var Cancel $endpoint */ | ||
$endpoint = $endpointBuilder('Tasks\Cancel'); | ||
$endpoint->setTaskId($id) | ||
->setParams($params); | ||
$response = $endpoint->performRequest(); | ||
|
||
return $endpoint->resultOrFuture($response); | ||
} | ||
|
||
|
||
} |