diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 3e23889ed..ff804dfd7 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -5,7 +5,7 @@ steps: env: PHP_VERSION: "{{ matrix.php }}" TEST_SUITE: "{{ matrix.suite }}" - STACK_VERSION: 8.12-SNAPSHOT + STACK_VERSION: 8.13.0-SNAPSHOT matrix: setup: suite: diff --git a/src/Endpoints/AsyncSearch.php b/src/Endpoints/AsyncSearch.php index b11a52059..46cb8bf22 100644 --- a/src/Endpoints/AsyncSearch.php +++ b/src/Endpoints/AsyncSearch.php @@ -108,6 +108,7 @@ public function get(array $params = []) * * @param array{ * id: string, // (REQUIRED) The async search ID + * keep_alive: time, // Specify 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) @@ -128,7 +129,7 @@ public function status(array $params = []) $url = '/_async_search/status/' . $this->encode($params['id']); $method = 'GET'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['keep_alive','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; diff --git a/src/Endpoints/Connector.php b/src/Endpoints/Connector.php index fbd8fcd44..e7cc61b7e 100644 --- a/src/Endpoints/Connector.php +++ b/src/Endpoints/Connector.php @@ -182,7 +182,11 @@ public function lastSync(array $params = []) * * @param array{ * from: int, // Starting offset (default: 0) - * size: int, // specifies a max number of results to get (default: 100) + * size: int, // Specifies a max number of results to get (default: 100) + * index_name: list, // A comma-separated list of connector index names to fetch connector documents for + * connector_name: list, // A comma-separated list of connector names to fetch connector documents for + * service_type: list, // A comma-separated list of connector service types to fetch connector documents for + * query: string, // A search string for querying connectors, filtering results by matching against connector names, descriptions, and index names * 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) @@ -201,7 +205,7 @@ public function list(array $params = []) $url = '/_connector'; $method = 'GET'; - $url = $this->addQueryString($url, $params, ['from','size','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['from','size','index_name','connector_name','service_type','query','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; @@ -283,6 +287,44 @@ public function put(array $params = []) } + /** + * Updates the API key id and/or API key secret id fields in the connector document. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-api-key-id-api.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * connector_id: string, // (REQUIRED) The unique identifier of the connector to be 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. + * body: array, // (REQUIRED) An object containing the connector's API key id and/or Connector Secret document id for that API key. + * } $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 updateApiKeyId(array $params = []) + { + $this->checkRequiredParameters(['connector_id','body'], $params); + $url = '/_connector/' . $this->encode($params['connector_id']) . '/_api_key_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)); + } + + /** * Updates the connector configuration. * @@ -397,6 +439,44 @@ public function updateFiltering(array $params = []) } + /** + * Updates the index name of the connector. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-index-name-api.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * connector_id: string, // (REQUIRED) The unique identifier of the connector to be 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. + * body: array, // (REQUIRED) An object containing the connector's index name. + * } $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 updateIndexName(array $params = []) + { + $this->checkRequiredParameters(['connector_id','body'], $params); + $url = '/_connector/' . $this->encode($params['connector_id']) . '/_index_name'; + $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)); + } + + /** * Updates the name and/or description fields in the connector document. * @@ -435,6 +515,44 @@ public function updateName(array $params = []) } + /** + * Updates the is_native flag of the connector. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/connector-apis.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * connector_id: string, // (REQUIRED) The unique identifier of the connector to be 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. + * body: array, // (REQUIRED) An object containing the connector's is_native flag + * } $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 updateNative(array $params = []) + { + $this->checkRequiredParameters(['connector_id','body'], $params); + $url = '/_connector/' . $this->encode($params['connector_id']) . '/_native'; + $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)); + } + + /** * Updates the pipeline field in the connector document. * @@ -509,4 +627,80 @@ public function updateScheduling(array $params = []) ]; return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); } + + + /** + * Updates the service type of the connector. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-service-type-api.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * connector_id: string, // (REQUIRED) The unique identifier of the connector to be 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. + * body: array, // (REQUIRED) An object containing the connector's service type. + * } $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 updateServiceType(array $params = []) + { + $this->checkRequiredParameters(['connector_id','body'], $params); + $url = '/_connector/' . $this->encode($params['connector_id']) . '/_service_type'; + $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)); + } + + + /** + * Updates the status of the connector. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-status-api.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * connector_id: string, // (REQUIRED) The unique identifier of the connector to be 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. + * body: array, // (REQUIRED) An object containing the connector's status. + * } $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 updateStatus(array $params = []) + { + $this->checkRequiredParameters(['connector_id','body'], $params); + $url = '/_connector/' . $this->encode($params['connector_id']) . '/_status'; + $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/ConnectorSyncJob.php b/src/Endpoints/ConnectorSyncJob.php index 7d05fd64c..b46cf9ecf 100644 --- a/src/Endpoints/ConnectorSyncJob.php +++ b/src/Endpoints/ConnectorSyncJob.php @@ -221,6 +221,7 @@ public function get(array $params = []) * size: int, // specifies a max number of results to get (default: 100) * status: string, // Sync job status, which sync jobs are fetched for * connector_id: string, // Id of the connector to fetch the sync jobs for + * job_type: list, // A comma-separated list of job types * 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) @@ -239,7 +240,7 @@ public function list(array $params = []) $url = '/_connector/_sync_job'; $method = 'GET'; - $url = $this->addQueryString($url, $params, ['from','size','status','connector_id','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['from','size','status','connector_id','job_type','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; diff --git a/src/Endpoints/Esql.php b/src/Endpoints/Esql.php index c19392459..19ddac353 100644 --- a/src/Endpoints/Esql.php +++ b/src/Endpoints/Esql.php @@ -28,6 +28,83 @@ */ class Esql extends AbstractEndpoint { + /** + * Executes an ESQL request asynchronously + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/esql-async-query-api.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * format: string, // a short version of the Accept header, e.g. json, yaml + * delimiter: string, // The character to use between values within a CSV row. Only valid for the csv format. + * drop_null_columns: boolean, // Should entirely null columns be removed from the results? Their name and type will be returning in a new `all_columns` section. + * 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) Use the `query` element to start a query. Use `columnar` to format the answer. + * } $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 asyncQuery(array $params = []) + { + $this->checkRequiredParameters(['body'], $params); + $url = '/_query/async'; + $method = 'POST'; + + $url = $this->addQueryString($url, $params, ['format','delimiter','drop_null_columns','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 the results of a previously submitted async query request given its ID. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/esql-async-query-get-api.html + * + * @param array{ + * id: string, // (REQUIRED) The async query ID + * wait_for_completion_timeout: time, // Specify the time that the request should block waiting for the final response + * keep_alive: time, // Specify the time interval in which the results (partial or final) for this search will be available + * drop_null_columns: boolean, // Should entirely null columns be removed from the results? Their name and type will be returning in a new `all_columns` section. + * 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 asyncQueryGet(array $params = []) + { + $this->checkRequiredParameters(['id'], $params); + $url = '/_query/async/' . $this->encode($params['id']); + $method = 'GET'; + + $url = $this->addQueryString($url, $params, ['wait_for_completion_timeout','keep_alive','drop_null_columns','pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + } + + /** * Executes an ESQL request * @@ -37,12 +114,13 @@ class Esql extends AbstractEndpoint * @param array{ * format: string, // a short version of the Accept header, e.g. json, yaml * delimiter: string, // The character to use between values within a CSV row. Only valid for the csv format. + * drop_null_columns: boolean, // Should entirely null columns be removed from the results? Their name and type will be returning in a new `all_columns` section. * 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) Use the `query` element to start a query. Use `time_zone` to specify an execution time zone and `columnar` to format the answer. + * body: array, // (REQUIRED) Use the `query` element to start a query. Use `columnar` to format the answer. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -57,7 +135,7 @@ public function query(array $params = []) $url = '/_query'; $method = 'POST'; - $url = $this->addQueryString($url, $params, ['format','delimiter','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['format','delimiter','drop_null_columns','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', diff --git a/src/Endpoints/Indices.php b/src/Endpoints/Indices.php index 4614144d7..4ad664e93 100644 --- a/src/Endpoints/Indices.php +++ b/src/Endpoints/Indices.php @@ -1880,6 +1880,45 @@ public function reloadSearchAnalyzers(array $params = []) } + /** + * Resolves the specified index expressions to return information about each cluster, including the local cluster, if included. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-resolve-cluster-api.html + * + * @param array{ + * name: list, // (REQUIRED) A comma-separated list of cluster:index names or wildcard expressions + * ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed) + * ignore_throttled: boolean, // Whether specified concrete, expanded or aliased indices should be ignored when throttled + * 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 wildcard expressions should get expanded to open or closed indices (default: open) + * 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 resolveCluster(array $params = []) + { + $this->checkRequiredParameters(['name'], $params); + $url = '/_resolve/cluster/' . $this->encode($params['name']); + $method = 'GET'; + + $url = $this->addQueryString($url, $params, ['ignore_unavailable','ignore_throttled','allow_no_indices','expand_wildcards','pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + } + + /** * Returns information about any matching indices, aliases, and data streams * @@ -1929,6 +1968,7 @@ public function resolveIndex(array $params = []) * dry_run: boolean, // If set to true the rollover action will only be validated but not actually performed even if a condition matches. The default is false * master_timeout: time, // Specify timeout for connection to master * wait_for_active_shards: string, // Set the number of active shards to wait for on the newly created rollover index before the operation returns. + * lazy: boolean, // If set to true, the rollover action will only mark a data stream to signal that it needs to be rolled over at the next write. Only allowed on data streams. * 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) @@ -1954,7 +1994,7 @@ public function rollover(array $params = []) $url = '/' . $this->encode($params['alias']) . '/_rollover'; $method = 'POST'; } - $url = $this->addQueryString($url, $params, ['timeout','dry_run','master_timeout','wait_for_active_shards','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['timeout','dry_run','master_timeout','wait_for_active_shards','lazy','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', diff --git a/src/Endpoints/Inference.php b/src/Endpoints/Inference.php index 835d59c49..2feba9f54 100644 --- a/src/Endpoints/Inference.php +++ b/src/Endpoints/Inference.php @@ -35,8 +35,8 @@ class Inference extends AbstractEndpoint * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * task_type: string, // (REQUIRED) The model task type - * model_id: string, // (REQUIRED) The model Id + * inference_id: string, // (REQUIRED) The model Id + * task_type: string, // The task type * 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) @@ -53,10 +53,14 @@ class Inference extends AbstractEndpoint */ public function deleteModel(array $params = []) { - $this->checkRequiredParameters(['task_type','model_id'], $params); - $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['model_id']); - $method = 'DELETE'; - + $this->checkRequiredParameters(['inference_id'], $params); + if (isset($params['task_type'])) { + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['inference_id']); + $method = 'DELETE'; + } else { + $url = '/_inference/' . $this->encode($params['inference_id']); + $method = 'DELETE'; + } $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', @@ -72,8 +76,8 @@ public function deleteModel(array $params = []) * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * task_type: string, // (REQUIRED) The model task type - * model_id: string, // (REQUIRED) The model Id + * inference_id: string, // (REQUIRED) The inference Id + * task_type: string, // The task type * 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) @@ -90,10 +94,14 @@ public function deleteModel(array $params = []) */ public function getModel(array $params = []) { - $this->checkRequiredParameters(['task_type','model_id'], $params); - $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['model_id']); - $method = 'GET'; - + $this->checkRequiredParameters(['inference_id'], $params); + if (isset($params['task_type'])) { + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['inference_id']); + $method = 'GET'; + } else { + $url = '/_inference/' . $this->encode($params['inference_id']); + $method = 'GET'; + } $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', @@ -109,8 +117,8 @@ public function getModel(array $params = []) * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * task_type: string, // (REQUIRED) The model task type - * model_id: string, // (REQUIRED) The model Id + * inference_id: string, // (REQUIRED) The inference Id + * task_type: string, // The task type * 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) @@ -128,10 +136,14 @@ public function getModel(array $params = []) */ public function inference(array $params = []) { - $this->checkRequiredParameters(['task_type','model_id'], $params); - $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['model_id']); - $method = 'POST'; - + $this->checkRequiredParameters(['inference_id'], $params); + if (isset($params['task_type'])) { + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['inference_id']); + $method = 'POST'; + } else { + $url = '/_inference/' . $this->encode($params['inference_id']); + $method = 'POST'; + } $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', @@ -148,8 +160,8 @@ public function inference(array $params = []) * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * task_type: string, // (REQUIRED) The model task type - * model_id: string, // (REQUIRED) The model Id + * inference_id: string, // (REQUIRED) The inference Id + * task_type: string, // The task type * 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) @@ -167,10 +179,14 @@ public function inference(array $params = []) */ public function putModel(array $params = []) { - $this->checkRequiredParameters(['task_type','model_id'], $params); - $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['model_id']); - $method = 'PUT'; - + $this->checkRequiredParameters(['inference_id'], $params); + if (isset($params['task_type'])) { + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['inference_id']); + $method = 'PUT'; + } else { + $url = '/_inference/' . $this->encode($params['inference_id']); + $method = 'PUT'; + } $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', diff --git a/src/Endpoints/Profiling.php b/src/Endpoints/Profiling.php index ed7c3d2e7..fb15418f6 100644 --- a/src/Endpoints/Profiling.php +++ b/src/Endpoints/Profiling.php @@ -28,6 +28,74 @@ */ class Profiling extends AbstractEndpoint { + /** + * Extracts a UI-optimized structure to render flamegraphs from Universal Profiling. + * + * @see https://www.elastic.co/guide/en/observability/current/universal-profiling.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) The filter conditions for the flamegraph + * } $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 flamegraph(array $params = []) + { + $this->checkRequiredParameters(['body'], $params); + $url = '/_profiling/flamegraph'; + $method = 'POST'; + + $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)); + } + + + /** + * Extracts raw stacktrace information from Universal Profiling. + * + * @see https://www.elastic.co/guide/en/observability/current/universal-profiling.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) The filter conditions for stacktraces + * } $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 stacktraces(array $params = []) + { + $this->checkRequiredParameters(['body'], $params); + $url = '/_profiling/stacktraces'; + $method = 'POST'; + + $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 basic information about the status of Universal Profiling. * diff --git a/src/Endpoints/Security.php b/src/Endpoints/Security.php index 2d148e9d8..3e570591a 100644 --- a/src/Endpoints/Security.php +++ b/src/Endpoints/Security.php @@ -1763,6 +1763,41 @@ public function queryApiKeys(array $params = []) } + /** + * Retrieves information for Users using a subset of query DSL + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-query-user.html + * + * @param array{ + * with_profile_uid: boolean, // flag to retrieve profile uid (if exists) associated with the user + * 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, // From, size, query, sort and search_after + * } $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 queryUser(array $params = []) + { + $url = '/_security/_query/user'; + $method = empty($params['body']) ? 'GET' : 'POST'; + + $url = $this->addQueryString($url, $params, ['with_profile_uid','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)); + } + + /** * Exchanges a SAML Response message for an Elasticsearch access token and refresh token pair * diff --git a/src/Endpoints/Synonyms.php b/src/Endpoints/Synonyms.php index 2256b4f09..a99f30aff 100644 --- a/src/Endpoints/Synonyms.php +++ b/src/Endpoints/Synonyms.php @@ -32,7 +32,6 @@ class Synonyms extends AbstractEndpoint * Deletes a synonym set * * @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{ * id: string, // (REQUIRED) The id of the synonyms set to be deleted @@ -68,7 +67,6 @@ public function deleteSynonym(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 @@ -106,7 +104,6 @@ public function deleteSynonymRule(array $params = []) * Retrieves a synonym set * * @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{ * id: string, // (REQUIRED) The name of the synonyms set to be retrieved @@ -144,7 +141,6 @@ public function getSynonym(array $params = []) * 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 @@ -182,7 +178,6 @@ public function getSynonymRule(array $params = []) * 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 @@ -217,7 +212,6 @@ public function getSynonymsSets(array $params = []) * Creates or updates a synonyms set * * @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{ * id: string, // (REQUIRED) The id of the synonyms set to be created or updated @@ -255,7 +249,6 @@ public function putSynonym(array $params = []) * 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 diff --git a/src/Endpoints/TextStructure.php b/src/Endpoints/TextStructure.php index db65e57a8..d90f2e6a3 100644 --- a/src/Endpoints/TextStructure.php +++ b/src/Endpoints/TextStructure.php @@ -76,4 +76,40 @@ public function findStructure(array $params = []) ]; return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); } + + + /** + * Tests a Grok pattern on some text. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/test-grok-pattern.html + * + * @param array{ + * ecs_compatibility: string, // Optional parameter to specify the compatibility mode with ECS Grok patterns - may be either 'v1' or 'disabled' + * 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 Grok pattern and text. + * } $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 testGrokPattern(array $params = []) + { + $this->checkRequiredParameters(['body'], $params); + $url = '/_text_structure/test_grok_pattern'; + $method = empty($params['body']) ? 'GET' : 'POST'; + + $url = $this->addQueryString($url, $params, ['ecs_compatibility','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 c4b55beed..7a850486f 100644 --- a/src/Traits/ClientEndpointsTrait.php +++ b/src/Traits/ClientEndpointsTrait.php @@ -45,6 +45,7 @@ trait ClientEndpointsTrait * _source_includes: list, // Default list of fields to extract and return from the _source field, can be overridden on each sub-request * pipeline: string, // The pipeline id to preprocess incoming documents with * require_alias: boolean, // Sets require_alias for all incoming documents. Defaults to unset (false) + * require_data_stream: boolean, // When true, requires the destination to be a data stream (existing or to-be-created). Default is false * list_executed_pipelines: boolean, // Sets list_executed_pipelines for all incoming documents. Defaults to unset (false) * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) * human: boolean, // Return human readable values for statistics. (DEFAULT: true) @@ -70,7 +71,7 @@ public function bulk(array $params = []) $url = '/_bulk'; $method = 'POST'; } - $url = $this->addQueryString($url, $params, ['wait_for_active_shards','refresh','routing','timeout','type','_source','_source_excludes','_source_includes','pipeline','require_alias','list_executed_pipelines','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['wait_for_active_shards','refresh','routing','timeout','type','_source','_source_excludes','_source_includes','pipeline','require_alias','require_data_stream','list_executed_pipelines','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/x-ndjson', @@ -590,6 +591,7 @@ public function explain(array $params = []) * include_unmapped: boolean, // Indicates whether unmapped fields should be included in the response. * filters: list, // An optional set of filters: can include +metadata,-metadata,-nested,-multifield,-parent * types: list, // Only return results for fields that have one of the types in the list + * include_empty_fields: boolean, // Include empty fields in result * 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) @@ -613,7 +615,7 @@ public function fieldCaps(array $params = []) $url = '/_field_caps'; $method = empty($params['body']) ? 'GET' : 'POST'; } - $url = $this->addQueryString($url, $params, ['fields','ignore_unavailable','allow_no_indices','expand_wildcards','include_unmapped','filters','types','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['fields','ignore_unavailable','allow_no_indices','expand_wildcards','include_unmapped','filters','types','include_empty_fields','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', @@ -873,6 +875,7 @@ public function healthReport(array $params = []) * if_primary_term: number, // only perform the index operation if the last operation that has changed the document has the specified primary term * pipeline: string, // The pipeline id to preprocess incoming documents with * require_alias: boolean, // When true, requires destination to be an alias. Default is false + * require_data_stream: boolean, // When true, requires the destination to be a data stream (existing or to-be-created). Default is 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) @@ -898,7 +901,7 @@ public function index(array $params = []) $url = '/' . $this->encode($params['index']) . '/_doc'; $method = 'POST'; } - $url = $this->addQueryString($url, $params, ['wait_for_active_shards','op_type','refresh','routing','timeout','version','version_type','if_seq_no','if_primary_term','pipeline','require_alias','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['wait_for_active_shards','op_type','refresh','routing','timeout','version','version_type','if_seq_no','if_primary_term','pipeline','require_alias','require_data_stream','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', 'Content-Type' => 'application/json',