<?php
/**
* Elasticsearch PHP Client
*
* @link https://github.com/elastic/elasticsearch-php
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license https://opensource.org/licenses/MIT MIT License
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the MIT License.
* See the LICENSE file in the project root for more information.
*/
declare(strict_types=1);
namespace Elastic\Elasticsearch\Endpoints;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
class Eql extends AbstractEndpoint
{
/**
* Deletes an async EQL search by ID. If the search is still running, the search request will be cancelled. Otherwise, the saved search results are deleted.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html
*
* @param array{
* id: string, // (REQUIRED) The async search ID
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function delete(array $params = [])
{
$this->checkRequiredParameters(['id'], $params);
$url = '/_eql/search/' . $this->encode($params['id']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns async results from previously executed Event Query Language (EQL) search
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html
*
* @param array{
* id: string, // (REQUIRED) The async search ID
* wait_for_completion_timeout: time, // Specify the time that the request should block waiting for the final response
* keep_alive: time, // Update the time interval in which the results (partial or final) for this search will be available
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function get(array $params = [])
{
$this->checkRequiredParameters(['id'], $params);
$url = '/_eql/search/' . $this->encode($params['id']);
$method = 'GET';
$url = $this->addQueryString($url, $params, ['wait_for_completion_timeout','keep_alive','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns the status of a previously submitted async or stored Event Query Language (EQL) search
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html
*
* @param array{
* id: string, // (REQUIRED) The async search ID
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getStatus(array $params = [])
{
$this->checkRequiredParameters(['id'], $params);
$url = '/_eql/search/status/' . $this->encode($params['id']);
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
/**
* Returns results matching a query expressed in Event Query Language (EQL)
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html
*
* @param array{
* index: string, // (REQUIRED) The name of the index to scope the operation
* wait_for_completion_timeout: time, // Specify the time that the request should block waiting for the final response
* keep_on_completion: boolean, // Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false)
* keep_alive: time, // Update the time interval in which the results (partial or final) for this search will be available
* pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
* human: boolean, // Return human readable values for statistics. (DEFAULT: true)
* error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
* source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path: list, // A comma-separated list of filters used to reduce the response.
* body: array, // (REQUIRED) Eql request body. Use the `query` to limit the query scope.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function search(array $params = [])
{
$this->checkRequiredParameters(['index','body'], $params);
$url = '/' . $this->encode($params['index']) . '/_eql/search';
$method = empty($params['body']) ? 'GET' : 'POST';
$url = $this->addQueryString($url, $params, ['wait_for_completion_timeout','keep_on_completion','keep_alive','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null));
}
}