From 53663e73479bb749369aab94d80dabac55e57321 Mon Sep 17 00:00:00 2001 From: Enrico Zimuel Date: Tue, 23 May 2023 14:56:33 +0200 Subject: [PATCH] Added 8.8 endpoints --- src/Endpoints/Cat.php | 2 +- src/Endpoints/Cluster.php | 3 +- src/Endpoints/Indices.php | 167 ++++++++++++- src/Endpoints/Logstash.php | 14 +- src/Endpoints/Ml.php | 6 +- src/Endpoints/SearchApplication.php | 363 ++++++++++++++++++++++++++++ src/Endpoints/Transform.php | 3 +- src/Endpoints/Watcher.php | 68 ++++++ src/Traits/ClientEndpointsTrait.php | 3 +- src/Traits/NamespaceTrait.php | 10 + 10 files changed, 623 insertions(+), 16 deletions(-) create mode 100644 src/Endpoints/SearchApplication.php diff --git a/src/Endpoints/Cat.php b/src/Endpoints/Cat.php index a33023c4e..34943761f 100644 --- a/src/Endpoints/Cat.php +++ b/src/Endpoints/Cat.php @@ -120,7 +120,7 @@ public function allocation(array $params = []) /** * Returns information about existing component_templates templates. * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-compoentn-templates.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-component-templates.html * * @param array{ * name: string, // A pattern that returned component template names must match diff --git a/src/Endpoints/Cluster.php b/src/Endpoints/Cluster.php index 983265558..7fd01b48a 100644 --- a/src/Endpoints/Cluster.php +++ b/src/Endpoints/Cluster.php @@ -181,6 +181,7 @@ public function existsComponentTemplate(array $params = []) * name: list, // The comma separated names of the component templates * master_timeout: time, // Explicit operation timeout for connection to master node * local: boolean, // Return local information, do not retrieve the state from master node (default: false) + * include_defaults: boolean, // Return all default configurations for the component template (default: false) * 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) @@ -203,7 +204,7 @@ public function getComponentTemplate(array $params = []) $url = '/_component_template'; $method = 'GET'; } - $url = $this->addQueryString($url, $params, ['master_timeout','local','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','local','include_defaults','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; diff --git a/src/Endpoints/Indices.php b/src/Endpoints/Indices.php index e711f9349..174e933fe 100644 --- a/src/Endpoints/Indices.php +++ b/src/Endpoints/Indices.php @@ -424,6 +424,45 @@ public function deleteAlias(array $params = []) } + /** + * Deletes the data lifecycle of the selected data streams. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/dlm-delete-lifecycle.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * name: list, // (REQUIRED) A comma-separated list of data streams of which the data lifecycle will be deleted; use `*` to get all data streams + * expand_wildcards: enum, // Whether wildcard expressions should get expanded to open or closed indices (default: open) + * timeout: time, // Explicit timestamp for the document + * master_timeout: time, // Specify timeout for connection to master + * 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 deleteDataLifecycle(array $params = []) + { + $this->checkRequiredParameters(['name'], $params); + $url = '/_data_stream/' . $this->encode($params['name']) . '/_lifecycle'; + $method = 'DELETE'; + + $url = $this->addQueryString($url, $params, ['expand_wildcards','timeout','master_timeout','pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + } + + /** * Deletes a data stream. * @@ -775,6 +814,44 @@ public function existsTemplate(array $params = []) } + /** + * Retrieves information about the index's current DLM lifecycle, such as any potential encountered error, time since creation etc. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/dlm-explain-lifecycle.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * index: string, // (REQUIRED) The name of the index to explain + * include_defaults: boolean, // indicates if the API should return the default values the system uses for the index's lifecycle + * master_timeout: time, // Specify timeout for connection to master + * 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 explainDataLifecycle(array $params = []) + { + $this->checkRequiredParameters(['index'], $params); + $url = '/' . $this->encode($params['index']) . '/_lifecycle/explain'; + $method = 'GET'; + + $url = $this->addQueryString($url, $params, ['include_defaults','master_timeout','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 field usage stats for each field of an index * @@ -992,6 +1069,44 @@ public function getAlias(array $params = []) } + /** + * Returns the data lifecycle of the selected data streams. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/dlm-get-lifecycle.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * name: list, // (REQUIRED) A comma-separated list of data streams to get; use `*` to get all data streams + * expand_wildcards: enum, // Whether wildcard expressions should get expanded to open or closed indices (default: open) + * include_defaults: boolean, // Return all relevant default configurations for the data stream (default: false) + * 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 getDataLifecycle(array $params = []) + { + $this->checkRequiredParameters(['name'], $params); + $url = '/_data_stream/' . $this->encode($params['name']) . '/_lifecycle'; + $method = 'GET'; + + $url = $this->addQueryString($url, $params, ['expand_wildcards','include_defaults','pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + } + + /** * Returns data streams. * @@ -1000,6 +1115,7 @@ public function getAlias(array $params = []) * @param array{ * name: list, // A comma-separated list of data streams to get; use `*` to get all data streams * expand_wildcards: enum, // Whether wildcard expressions should get expanded to open or closed indices (default: open) + * include_defaults: boolean, // Return all relevant default configurations for the data stream (default: false) * 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) @@ -1022,7 +1138,7 @@ public function getDataStream(array $params = []) $url = '/_data_stream'; $method = 'GET'; } - $url = $this->addQueryString($url, $params, ['expand_wildcards','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['expand_wildcards','include_defaults','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -1085,6 +1201,7 @@ public function getFieldMapping(array $params = []) * flat_settings: boolean, // Return settings in flat format (default: false) * master_timeout: time, // Explicit operation timeout for connection to master node * local: boolean, // Return local information, do not retrieve the state from master node (default: false) + * include_defaults: boolean, // Return all relevant default configurations for the index template (default: false) * 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) @@ -1107,7 +1224,7 @@ public function getIndexTemplate(array $params = []) $url = '/_index_template'; $method = 'GET'; } - $url = $this->addQueryString($url, $params, ['flat_settings','master_timeout','local','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['flat_settings','master_timeout','local','include_defaults','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -1434,6 +1551,46 @@ public function putAlias(array $params = []) } + /** + * Updates the data lifecycle of the selected data streams. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/dlm-put-lifecycle.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * name: list, // (REQUIRED) A comma-separated list of data streams whose lifecycle will be updated; use `*` to set the lifecycle to all data streams + * expand_wildcards: enum, // Whether wildcard expressions should get expanded to open or closed indices (default: open) + * timeout: time, // Explicit timestamp for the document + * master_timeout: time, // Specify timeout for connection to master + * 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, // The data lifecycle configuration that consist of the data retention + * } $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 putDataLifecycle(array $params = []) + { + $this->checkRequiredParameters(['name'], $params); + $url = '/_data_stream/' . $this->encode($params['name']) . '/_lifecycle'; + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['expand_wildcards','timeout','master_timeout','pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + } + + /** * Creates or updates an index template. * @@ -1937,6 +2094,7 @@ public function shrink(array $params = []) * create: boolean, // Whether the index template we optionally defined in the body should only be dry-run added if new or can also replace an existing one * cause: string, // User defined reason for dry-run creating the new template for simulation purposes * master_timeout: time, // Specify timeout for connection to master + * include_defaults: boolean, // Return all relevant default configurations for this index template simulation (default: false) * 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) @@ -1958,7 +2116,7 @@ public function simulateIndexTemplate(array $params = []) $url = '/_index_template/_simulate_index/' . $this->encode($params['name']); $method = 'POST'; - $url = $this->addQueryString($url, $params, ['create','cause','master_timeout','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['create','cause','master_timeout','include_defaults','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', @@ -1977,6 +2135,7 @@ public function simulateIndexTemplate(array $params = []) * create: boolean, // Whether the index template we optionally defined in the body should only be dry-run added if new or can also replace an existing one * cause: string, // User defined reason for dry-run creating the new template for simulation purposes * master_timeout: time, // Specify timeout for connection to master + * include_defaults: boolean, // Return all relevant default configurations for this template simulation (default: false) * 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) @@ -2000,7 +2159,7 @@ public function simulateTemplate(array $params = []) $url = '/_index_template/_simulate'; $method = 'POST'; } - $url = $this->addQueryString($url, $params, ['create','cause','master_timeout','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['create','cause','master_timeout','include_defaults','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', diff --git a/src/Endpoints/Logstash.php b/src/Endpoints/Logstash.php index 7e83ae369..1dbae86f4 100644 --- a/src/Endpoints/Logstash.php +++ b/src/Endpoints/Logstash.php @@ -69,7 +69,7 @@ public function deletePipeline(array $params = []) * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/logstash-api-get-pipeline.html * * @param array{ - * id: string, // (REQUIRED) A comma-separated list of Pipeline IDs + * id: string, // A comma-separated list of Pipeline IDs * 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) @@ -77,7 +77,6 @@ public function deletePipeline(array $params = []) * 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 @@ -86,10 +85,13 @@ public function deletePipeline(array $params = []) */ public function getPipeline(array $params = []) { - $this->checkRequiredParameters(['id'], $params); - $url = '/_logstash/pipeline/' . $this->encode($params['id']); - $method = 'GET'; - + if (isset($params['id'])) { + $url = '/_logstash/pipeline/' . $this->encode($params['id']); + $method = 'GET'; + } else { + $url = '/_logstash/pipeline'; + $method = 'GET'; + } $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', diff --git a/src/Endpoints/Ml.php b/src/Endpoints/Ml.php index 47bba93de..665844db8 100644 --- a/src/Endpoints/Ml.php +++ b/src/Endpoints/Ml.php @@ -2036,6 +2036,7 @@ public function putJob(array $params = []) * @param array{ * model_id: string, // (REQUIRED) The ID of the trained models to store * defer_definition_decompression: boolean, // If set to `true` and a `compressed_definition` is provided, the request defers definition decompression and skips relevant validations. + * wait_for_completion: boolean, // Whether to wait for all child operations(e.g. model download) to complete, before returning or not. Default to false * 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) @@ -2057,7 +2058,7 @@ public function putTrainedModel(array $params = []) $url = '/_ml/trained_models/' . $this->encode($params['model_id']); $method = 'PUT'; - $url = $this->addQueryString($url, $params, ['defer_definition_decompression','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['defer_definition_decompression','wait_for_completion','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', @@ -2375,6 +2376,7 @@ public function startDatafeed(array $params = []) * @param array{ * model_id: string, // (REQUIRED) The unique identifier of the trained model. * cache_size: string, // A byte-size value for configuring the inference cache size. For example, 20mb. + * deployment_id: string, // The Id of the new deployment. Defaults to the model_id if not set. * number_of_allocations: int, // The total number of allocations this model is assigned across machine learning nodes. * threads_per_allocation: int, // The number of threads used by each model allocation during inference. * priority: string, // The deployment priority. @@ -2401,7 +2403,7 @@ public function startTrainedModelDeployment(array $params = []) $url = '/_ml/trained_models/' . $this->encode($params['model_id']) . '/deployment/_start'; $method = 'POST'; - $url = $this->addQueryString($url, $params, ['cache_size','number_of_allocations','threads_per_allocation','priority','queue_capacity','timeout','wait_for','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['cache_size','deployment_id','number_of_allocations','threads_per_allocation','priority','queue_capacity','timeout','wait_for','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', diff --git a/src/Endpoints/SearchApplication.php b/src/Endpoints/SearchApplication.php new file mode 100644 index 000000000..9aa2d2044 --- /dev/null +++ b/src/Endpoints/SearchApplication.php @@ -0,0 +1,363 @@ +checkRequiredParameters(['name'], $params); + $url = '/_application/search_application/' . $this->encode($params['name']); + $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)); + } + + + /** + * Delete a behavioral analytics collection. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-analytics-collection.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * name: string, // (REQUIRED) The name of the analytics collection to be deleted + * 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 deleteBehavioralAnalytics(array $params = []) + { + $this->checkRequiredParameters(['name'], $params); + $url = '/_application/analytics/' . $this->encode($params['name']); + $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 the details about a search application. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-search-application.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * name: string, // (REQUIRED) The name of the search application + * 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(['name'], $params); + $url = '/_application/search_application/' . $this->encode($params['name']); + $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 the existing behavioral analytics collections. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/list-analytics-collection.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * name: list, // A comma-separated list of analytics collections to limit the returned information + * 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 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 getBehavioralAnalytics(array $params = []) + { + if (isset($params['name'])) { + $url = '/_application/analytics/' . $this->encode($params['name']); + $method = 'GET'; + } else { + $url = '/_application/analytics'; + $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 the existing search applications. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/list-search-applications.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * q: string, // Query in the Lucene query string syntax + * from: int, // Starting offset (default: 0) + * size: int, // specifies a max number of results to get + * 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 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 list(array $params = []) + { + $url = '/_application/search_application'; + $method = 'GET'; + + $url = $this->addQueryString($url, $params, ['q','from','size','pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + } + + + /** + * Creates a behavioral analytics event for existing collection. + * + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * collection_name: string, // (REQUIRED) The name of behavioral analytics collection + * event_type: string, // (REQUIRED) Behavioral analytics event type. Available: page_view, search, search_click + * debug: boolean, // If true, returns event information that will be stored + * 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) The event definition + * } $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 postBehavioralAnalyticsEvent(array $params = []) + { + $this->checkRequiredParameters(['collection_name','event_type','body'], $params); + $url = '/_application/analytics/' . $this->encode($params['collection_name']) . '/event/' . $this->encode($params['event_type']); + $method = 'POST'; + + $url = $this->addQueryString($url, $params, ['debug','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)); + } + + + /** + * Creates or updates a search application. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-search-application.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * name: string, // (REQUIRED) The name of the search application to be created or updated + * create: boolean, // If true, requires that a search application with the specified resource_id does not already exist. (default: false) + * 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) The search application configuration, including `indices` + * } $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 put(array $params = []) + { + $this->checkRequiredParameters(['name','body'], $params); + $url = '/_application/search_application/' . $this->encode($params['name']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['create','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)); + } + + + /** + * Creates a behavioral analytics collection. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-analytics-collection.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * name: string, // (REQUIRED) The name of the analytics collection to be created or updated + * 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 putBehavioralAnalytics(array $params = []) + { + $this->checkRequiredParameters(['name'], $params); + $url = '/_application/analytics/' . $this->encode($params['name']); + $method = 'PUT'; + + $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)); + } + + + /** + * Perform a search against a search application + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-application-search.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * name: string, // (REQUIRED) The name of the search application to be searched + * 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, // Search parameters, including template parameters that override defaults + * } $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(['name'], $params); + $url = '/_application/search_application/' . $this->encode($params['name']) . '/_search'; + $method = empty($params['body']) ? 'GET' : 'POST'; + + $url = $this->addQueryString($url, $params, ['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)); + } +} diff --git a/src/Endpoints/Transform.php b/src/Endpoints/Transform.php index a809fe099..660457db9 100644 --- a/src/Endpoints/Transform.php +++ b/src/Endpoints/Transform.php @@ -36,6 +36,7 @@ class Transform extends AbstractEndpoint * @param array{ * transform_id: string, // (REQUIRED) The id of the transform to delete * force: boolean, // When `true`, the transform is deleted regardless of its current state. The default value is `false`, meaning that the transform must be `stopped` before it can be deleted. + * delete_dest_index: boolean, // When `true`, the destination index is deleted together with the transform. The default value is `false`, meaning that the destination index will not be deleted. * timeout: time, // Controls the time to wait for the transform deletion * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) * human: boolean, // Return human readable values for statistics. (DEFAULT: true) @@ -57,7 +58,7 @@ public function deleteTransform(array $params = []) $url = '/_transform/' . $this->encode($params['transform_id']); $method = 'DELETE'; - $url = $this->addQueryString($url, $params, ['force','timeout','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['force','delete_dest_index','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; diff --git a/src/Endpoints/Watcher.php b/src/Endpoints/Watcher.php index c1dafe5a7..810cc15cb 100644 --- a/src/Endpoints/Watcher.php +++ b/src/Endpoints/Watcher.php @@ -213,6 +213,39 @@ public function executeWatch(array $params = []) } + /** + * Retrieve settings for the watcher system index + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-get-settings.html + * + * @param array{ + * 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 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 getSettings(array $params = []) + { + $url = '/_watcher/settings'; + $method = 'GET'; + + $url = $this->addQueryString($url, $params, ['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)); + } + + /** * Retrieves a watch by its ID. * @@ -423,4 +456,39 @@ public function stop(array $params = []) ]; return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); } + + + /** + * Update settings for the watcher system index + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-update-settings.html + * + * @param array{ + * 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) An object with the new index settings + * } $params + * + * @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 updateSettings(array $params = []) + { + $this->checkRequiredParameters(['body'], $params); + $url = '/_watcher/settings'; + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['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)); + } } diff --git a/src/Traits/ClientEndpointsTrait.php b/src/Traits/ClientEndpointsTrait.php index 875a53bd1..dd09540e7 100644 --- a/src/Traits/ClientEndpointsTrait.php +++ b/src/Traits/ClientEndpointsTrait.php @@ -1576,6 +1576,7 @@ public function scroll(array $params = []) * pre_filter_shard_size: number, // A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. * rest_total_hits_as_int: boolean, // Indicates whether hits.total should be rendered as an integer or an object in the rest search response * min_compatible_shard_node: string, // The minimum compatible version that all shards involved in search should have for this request to be successful + * include_named_queries_score: boolean, // Indicates whether hit.matched_queries should be rendered as a map that includes the name of the matched query associated with its score (true) or as an array containing the name of the matched queries (false) * 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) @@ -1599,7 +1600,7 @@ public function search(array $params = []) $url = '/_search'; $method = empty($params['body']) ? 'GET' : 'POST'; } - $url = $this->addQueryString($url, $params, ['analyzer','analyze_wildcard','ccs_minimize_roundtrips','default_operator','df','explain','stored_fields','docvalue_fields','from','force_synthetic_source','ignore_unavailable','ignore_throttled','allow_no_indices','expand_wildcards','lenient','preference','q','routing','scroll','search_type','size','sort','_source','_source_excludes','_source_includes','terminate_after','stats','suggest_field','suggest_mode','suggest_size','suggest_text','timeout','track_scores','track_total_hits','allow_partial_search_results','typed_keys','version','seq_no_primary_term','request_cache','batched_reduce_size','max_concurrent_shard_requests','pre_filter_shard_size','rest_total_hits_as_int','min_compatible_shard_node','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['analyzer','analyze_wildcard','ccs_minimize_roundtrips','default_operator','df','explain','stored_fields','docvalue_fields','from','force_synthetic_source','ignore_unavailable','ignore_throttled','allow_no_indices','expand_wildcards','lenient','preference','q','routing','scroll','search_type','size','sort','_source','_source_excludes','_source_includes','terminate_after','stats','suggest_field','suggest_mode','suggest_size','suggest_text','timeout','track_scores','track_total_hits','allow_partial_search_results','typed_keys','version','seq_no_primary_term','request_cache','batched_reduce_size','max_concurrent_shard_requests','pre_filter_shard_size','rest_total_hits_as_int','min_compatible_shard_node','include_named_queries_score','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', diff --git a/src/Traits/NamespaceTrait.php b/src/Traits/NamespaceTrait.php index f26043872..f460e3c06 100644 --- a/src/Traits/NamespaceTrait.php +++ b/src/Traits/NamespaceTrait.php @@ -37,6 +37,7 @@ use Elastic\Elasticsearch\Endpoints\Monitoring; use Elastic\Elasticsearch\Endpoints\Nodes; use Elastic\Elasticsearch\Endpoints\Rollup; +use Elastic\Elasticsearch\Endpoints\SearchApplication; use Elastic\Elasticsearch\Endpoints\SearchableSnapshots; use Elastic\Elasticsearch\Endpoints\Security; use Elastic\Elasticsearch\Endpoints\Shutdown; @@ -248,6 +249,15 @@ public function rollup(): Rollup } + public function searchApplication(): SearchApplication + { + if (!isset($this->namespace['SearchApplication'])) { + $this->namespace['SearchApplication'] = new SearchApplication($this); + } + return $this->namespace['SearchApplication']; + } + + public function searchableSnapshots(): SearchableSnapshots { if (!isset($this->namespace['SearchableSnapshots'])) {