diff --git a/src/Endpoints/Indices.php b/src/Endpoints/Indices.php index 6b229c1ee..c44b663d1 100644 --- a/src/Endpoints/Indices.php +++ b/src/Endpoints/Indices.php @@ -425,13 +425,13 @@ public function deleteAlias(array $params = []) /** - * Deletes the data lifecycle of the selected data streams. + * Deletes the data stream lifecycle of the selected data streams. * * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams-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 + * name: list, // (REQUIRED) A comma-separated list of data streams of which the data stream 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 @@ -1070,7 +1070,7 @@ public function getAlias(array $params = []) /** - * Returns the data lifecycle of the selected data streams. + * Returns the data stream lifecycle of the selected data streams. * * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams-get-lifecycle.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release @@ -1552,7 +1552,7 @@ public function putAlias(array $params = []) /** - * Updates the data lifecycle of the selected data streams. + * Updates the data stream lifecycle of the selected data streams. * * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams-put-lifecycle.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release @@ -1567,7 +1567,7 @@ public function putAlias(array $params = []) * 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 + * body: array, // The data stream lifecycle configuration that consist of the data retention * } $params * * @throws MissingParameterException if a required parameter is missing @@ -1850,6 +1850,7 @@ public function refresh(array $params = []) * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) * allow_no_indices: boolean, // Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) * expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both. + * resource: string, // changed resource to reload analyzers from if applicable * 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) @@ -1870,7 +1871,7 @@ public function reloadSearchAnalyzers(array $params = []) $url = '/' . $this->encode($params['index']) . '/_reload_search_analyzers'; $method = empty($params['body']) ? 'GET' : 'POST'; - $url = $this->addQueryString($url, $params, ['ignore_unavailable','allow_no_indices','expand_wildcards','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['ignore_unavailable','allow_no_indices','expand_wildcards','resource','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; diff --git a/src/Endpoints/QueryRuleset.php b/src/Endpoints/QueryRuleset.php index 008eb5540..ef2857cec 100644 --- a/src/Endpoints/QueryRuleset.php +++ b/src/Endpoints/QueryRuleset.php @@ -100,6 +100,41 @@ public function get(array $params = []) } + /** + * Lists query rulesets. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/list-query-rulesets.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * from: int, // Starting offset (default: 0) + * size: int, // specifies a max number of results to get (default: 100) + * 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 = '/_query_rules'; + $method = 'GET'; + + $url = $this->addQueryString($url, $params, ['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 or updates a query ruleset. * diff --git a/src/Endpoints/Security.php b/src/Endpoints/Security.php index f6d64d3ee..8c7536587 100644 --- a/src/Endpoints/Security.php +++ b/src/Endpoints/Security.php @@ -389,7 +389,6 @@ public function createApiKey(array $params = []) * Creates a cross-cluster API key for API key based remote cluster access. * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-cross-cluster-api-key.html - * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) @@ -1118,6 +1117,39 @@ public function getServiceCredentials(array $params = []) } + /** + * Retrieve settings for the security system indices + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-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 = '/_security/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)); + } + + /** * Creates a bearer token for access without requiring basic authentication. * @@ -2017,7 +2049,6 @@ public function updateApiKey(array $params = []) * Updates attributes of an existing cross-cluster API key. * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-update-cross-cluster-api-key.html - * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ * id: string, // (REQUIRED) The ID of the cross-cluster API key to update @@ -2051,6 +2082,41 @@ public function updateCrossClusterApiKey(array $params = []) } + /** + * Update settings for the security system index + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-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 settings for each index, if any + * } $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 = '/_security/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)); + } + + /** * Update application specific data for the user profile of the given unique ID. * diff --git a/src/Endpoints/SynonymRule.php b/src/Endpoints/SynonymRule.php deleted file mode 100644 index dcd4d638f..000000000 --- a/src/Endpoints/SynonymRule.php +++ /dev/null @@ -1,68 +0,0 @@ -checkRequiredParameters(['synonyms_set','synonym_rule','body'], $params); - $url = '/_synonyms/' . $this->encode($params['synonyms_set']) . '/' . $this->encode($params['synonym_rule']); - $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/Endpoints/Synonyms.php b/src/Endpoints/Synonyms.php index e81fe973d..2256b4f09 100644 --- a/src/Endpoints/Synonyms.php +++ b/src/Endpoints/Synonyms.php @@ -31,11 +31,11 @@ class Synonyms extends AbstractEndpoint /** * Deletes a synonym set * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-synonyms.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-synonyms-set.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * synonyms_set: string, // (REQUIRED) The name of the synonyms set to be deleted + * id: string, // (REQUIRED) The id of the synonyms set 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) @@ -50,10 +50,10 @@ class Synonyms extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function delete(array $params = []) + public function deleteSynonym(array $params = []) { - $this->checkRequiredParameters(['synonyms_set'], $params); - $url = '/_synonyms/' . $this->encode($params['synonyms_set']); + $this->checkRequiredParameters(['id'], $params); + $url = '/_synonyms/' . $this->encode($params['id']); $method = 'DELETE'; $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); @@ -64,14 +64,52 @@ public function delete(array $params = []) } + /** + * Deletes a synonym rule in a synonym set + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-synonym-rule.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * set_id: string, // (REQUIRED) The id of the synonym set to be updated + * rule_id: string, // (REQUIRED) The id of the synonym rule 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 deleteSynonymRule(array $params = []) + { + $this->checkRequiredParameters(['set_id','rule_id'], $params); + $url = '/_synonyms/' . $this->encode($params['set_id']) . '/' . $this->encode($params['rule_id']); + $method = 'DELETE'; + + $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 synonym set * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-synonyms.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-synonyms-set.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * synonyms_set: string, // (REQUIRED) The name of the synonyms set to be retrieved + * id: string, // (REQUIRED) The name of the synonyms set to be retrieved * from: int, // Starting offset * size: int, // specifies a max number of results to get * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) @@ -88,10 +126,83 @@ public function delete(array $params = []) * * @return Elasticsearch|Promise */ - public function get(array $params = []) + public function getSynonym(array $params = []) + { + $this->checkRequiredParameters(['id'], $params); + $url = '/_synonyms/' . $this->encode($params['id']); + $method = 'GET'; + + $url = $this->addQueryString($url, $params, ['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)); + } + + + /** + * Retrieves a synonym rule from a synonym set + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-synonym-rule.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * set_id: string, // (REQUIRED) The id of the synonym set to retrieve the synonym rule from + * rule_id: string, // (REQUIRED) The id of the synonym rule to retrieve + * 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 getSynonymRule(array $params = []) + { + $this->checkRequiredParameters(['set_id','rule_id'], $params); + $url = '/_synonyms/' . $this->encode($params['set_id']) . '/' . $this->encode($params['rule_id']); + $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 summary of all defined synonym sets + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/list-synonyms-sets.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * from: int, // Starting offset + * 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 getSynonymsSets(array $params = []) { - $this->checkRequiredParameters(['synonyms_set'], $params); - $url = '/_synonyms/' . $this->encode($params['synonyms_set']); + $url = '/_synonyms'; $method = 'GET'; $url = $this->addQueryString($url, $params, ['from','size','pretty','human','error_trace','source','filter_path']); @@ -105,11 +216,11 @@ public function get(array $params = []) /** * Creates or updates a synonyms set * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-synonyms.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-synonyms-set.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * synonyms_set: string, // (REQUIRED) The name of the synonyms set to be created or updated + * id: string, // (REQUIRED) The id of the synonyms set 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) @@ -125,10 +236,49 @@ public function get(array $params = []) * * @return Elasticsearch|Promise */ - public function put(array $params = []) + public function putSynonym(array $params = []) + { + $this->checkRequiredParameters(['id','body'], $params); + $url = '/_synonyms/' . $this->encode($params['id']); + $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)); + } + + + /** + * Creates or updates a synonym rule in a synonym set + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-synonym-rule.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * set_id: string, // (REQUIRED) The id of the synonym set to be updated with the synonym rule + * rule_id: string, // (REQUIRED) The id of the synonym rule to be updated or created + * 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) Synonym rule + * } $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 putSynonymRule(array $params = []) { - $this->checkRequiredParameters(['synonyms_set','body'], $params); - $url = '/_synonyms/' . $this->encode($params['synonyms_set']); + $this->checkRequiredParameters(['set_id','rule_id','body'], $params); + $url = '/_synonyms/' . $this->encode($params['set_id']) . '/' . $this->encode($params['rule_id']); $method = 'PUT'; $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); diff --git a/src/Endpoints/SynonymsSets.php b/src/Endpoints/SynonymsSets.php deleted file mode 100644 index b341604ff..000000000 --- a/src/Endpoints/SynonymsSets.php +++ /dev/null @@ -1,64 +0,0 @@ -addQueryString($url, $params, ['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)); - } -} diff --git a/src/Traits/NamespaceTrait.php b/src/Traits/NamespaceTrait.php index 2e9463a2c..dee8b3c51 100644 --- a/src/Traits/NamespaceTrait.php +++ b/src/Traits/NamespaceTrait.php @@ -46,9 +46,7 @@ use Elastic\Elasticsearch\Endpoints\Snapshot; use Elastic\Elasticsearch\Endpoints\Sql; use Elastic\Elasticsearch\Endpoints\Ssl; -use Elastic\Elasticsearch\Endpoints\SynonymRule; use Elastic\Elasticsearch\Endpoints\Synonyms; -use Elastic\Elasticsearch\Endpoints\SynonymsSets; use Elastic\Elasticsearch\Endpoints\Tasks; use Elastic\Elasticsearch\Endpoints\TextStructure; use Elastic\Elasticsearch\Endpoints\Transform; @@ -334,15 +332,6 @@ public function ssl(): Ssl } - public function synonymRule(): SynonymRule - { - if (!isset($this->namespace['SynonymRule'])) { - $this->namespace['SynonymRule'] = new SynonymRule($this); - } - return $this->namespace['SynonymRule']; - } - - public function synonyms(): Synonyms { if (!isset($this->namespace['Synonyms'])) { @@ -352,15 +341,6 @@ public function synonyms(): Synonyms } - public function synonymsSets(): SynonymsSets - { - if (!isset($this->namespace['SynonymsSets'])) { - $this->namespace['SynonymsSets'] = new SynonymsSets($this); - } - return $this->namespace['SynonymsSets']; - } - - public function tasks(): Tasks { if (!isset($this->namespace['Tasks'])) {