IngestNamespace.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. namespace Elasticsearch\Namespaces;
  3. use Elasticsearch\Endpoints\Ingest\Pipeline\Delete;
  4. use Elasticsearch\Endpoints\Ingest\Pipeline\Get;
  5. use Elasticsearch\Endpoints\Ingest\Pipeline\ProcessorGrok;
  6. use Elasticsearch\Endpoints\Ingest\Pipeline\Put;
  7. use Elasticsearch\Endpoints\Ingest\Simulate;
  8. /**
  9. * Class IngestNamespace
  10. *
  11. * @category Elasticsearch
  12. * @package Elasticsearch\Namespaces\IngestNamespace
  13. * @author Zachary Tong <zach@elastic.co>
  14. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
  15. * @link http://elastic.co
  16. */
  17. class IngestNamespace extends AbstractNamespace
  18. {
  19. /**
  20. * $params['master_timeout'] = (time) Explicit operation timeout for connection to master node
  21. * ['timeout'] = (time) Explicit operation timeout
  22. *
  23. * @param $params array Associative array of parameters
  24. *
  25. * @return array
  26. */
  27. public function deletePipeline($params = array())
  28. {
  29. $id = $this->extractArgument($params, 'id');
  30. /** @var callback $endpointBuilder */
  31. $endpointBuilder = $this->endpoints;
  32. /** @var Delete $endpoint */
  33. $endpoint = $endpointBuilder('Ingest\Pipeline\Delete');
  34. $endpoint->setID($id);
  35. $endpoint->setParams($params);
  36. return $this->performRequest($endpoint);
  37. }
  38. /**
  39. * $params['master_timeout'] = (time) Explicit operation timeout for connection to master node
  40. *
  41. * @param $params array Associative array of parameters
  42. *
  43. * @return array
  44. */
  45. public function getPipeline($params = array())
  46. {
  47. $id = $this->extractArgument($params, 'id');
  48. /** @var callback $endpointBuilder */
  49. $endpointBuilder = $this->endpoints;
  50. /** @var Get $endpoint */
  51. $endpoint = $endpointBuilder('Ingest\Pipeline\Get');
  52. $endpoint->setID($id);
  53. $endpoint->setParams($params);
  54. return $this->performRequest($endpoint);
  55. }
  56. /**
  57. * $params['master_timeout'] = (time) Explicit operation timeout for connection to master node
  58. * ['timeout'] = (time) Explicit operation timeout
  59. *
  60. * @param $params array Associative array of parameters
  61. *
  62. * @return array
  63. */
  64. public function putPipeline($params = array())
  65. {
  66. $body = $this->extractArgument($params, 'body');
  67. $id = $this->extractArgument($params, 'id');
  68. /** @var callback $endpointBuilder */
  69. $endpointBuilder = $this->endpoints;
  70. /** @var Put $endpoint */
  71. $endpoint = $endpointBuilder('Ingest\Pipeline\Put');
  72. $endpoint->setID($id)
  73. ->setBody($body)
  74. ->setParams($params);
  75. return $this->performRequest($endpoint);
  76. }
  77. /**
  78. * $params['verbose'] = (bool) Verbose mode. Display data output for each processor in executed pipeline
  79. *
  80. * @param $params array Associative array of parameters
  81. *
  82. * @return array
  83. */
  84. public function simulate($params = array())
  85. {
  86. $body = $this->extractArgument($params, 'body');
  87. $id = $this->extractArgument($params, 'id');
  88. /** @var callback $endpointBuilder */
  89. $endpointBuilder = $this->endpoints;
  90. /** @var Simulate $endpoint */
  91. $endpoint = $endpointBuilder('Ingest\Simulate');
  92. $endpoint->setID($id)
  93. ->setBody($body)
  94. ->setParams($params);
  95. return $this->performRequest($endpoint);
  96. }
  97. /**
  98. * $params[]
  99. *
  100. * @param $params array Associative array of parameters
  101. *
  102. * @return array
  103. */
  104. public function processorGrok($params = [])
  105. {
  106. /** @var callback $endpointBuilder */
  107. $endpointBuilder = $this->endpoints;
  108. /** @var ProcessorGrok $endpoint */
  109. $endpoint = $endpointBuilder('Ingest\ProcessorGrok');
  110. return $this->performRequest($endpoint);
  111. }
  112. }