From b293371697b5a6c535a060597a404effb7960637 Mon Sep 17 00:00:00 2001 From: Enrico Zimuel Date: Wed, 14 Aug 2024 15:51:47 +0200 Subject: [PATCH] Updated the endpoint to 8.15.0 adding the OTel support --- composer.json | 2 +- src/Client.php | 2 +- src/Endpoints/AsyncSearch.php | 16 +- src/Endpoints/Autoscaling.php | 30 ++- src/Endpoints/Cat.php | 104 ++++++-- src/Endpoints/Ccr.php | 52 +++- src/Endpoints/Cluster.php | 67 +++-- src/Endpoints/Connector.php | 211 ++++++++++++--- src/Endpoints/DanglingIndices.php | 12 +- src/Endpoints/Enrich.php | 35 ++- src/Endpoints/Eql.php | 16 +- src/Endpoints/Esql.php | 12 +- src/Endpoints/Features.php | 11 +- src/Endpoints/Fleet.php | 12 +- src/Endpoints/Graph.php | 4 +- src/Endpoints/Ilm.php | 44 +++- src/Endpoints/Indices.php | 236 ++++++++++++----- src/Endpoints/Inference.php | 38 ++- src/Endpoints/Ingest.php | 138 +++++++++- src/Endpoints/License.php | 44 +++- src/Endpoints/Logstash.php | 12 +- src/Endpoints/Migration.php | 12 +- src/Endpoints/Ml.php | 301 +++++++++++++++------ src/Endpoints/Monitoring.php | 4 +- src/Endpoints/Nodes.php | 28 +- src/Endpoints/Profiling.php | 16 +- src/Endpoints/QueryRules.php | 294 +++++++++++++++++++++ src/Endpoints/QueryRuleset.php | 174 ------------- src/Endpoints/Rollup.php | 36 ++- src/Endpoints/SearchApplication.php | 40 ++- src/Endpoints/SearchableSnapshots.php | 16 +- src/Endpoints/Security.php | 361 +++++++++++++++++++++----- src/Endpoints/Shutdown.php | 15 +- src/Endpoints/Simulate.php | 4 +- src/Endpoints/Slm.php | 44 +++- src/Endpoints/Snapshot.php | 51 +++- src/Endpoints/Sql.php | 24 +- src/Endpoints/Ssl.php | 4 +- src/Endpoints/Synonyms.php | 28 +- src/Endpoints/Tasks.php | 12 +- src/Endpoints/TextStructure.php | 16 +- src/Endpoints/Transform.php | 78 +++++- src/Endpoints/Watcher.php | 65 +++-- src/Endpoints/Xpack.php | 8 +- src/Traits/ClientEndpointsTrait.php | 176 +++++++++---- src/Traits/EndpointTrait.php | 54 +++- src/Traits/NamespaceTrait.php | 10 +- tests/Integration/BulkTest.php | 1 + util/ActionTest.php | 12 +- util/YamlTests.php | 15 ++ 50 files changed, 2273 insertions(+), 724 deletions(-) create mode 100644 src/Endpoints/QueryRules.php delete mode 100644 src/Endpoints/QueryRuleset.php diff --git a/composer.json b/composer.json index 50c5c1838..1a71c3be8 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "license": "MIT", "require": { "php": "^7.4 || ^8.0", - "elastic/transport": "^8.8", + "elastic/transport": "^8.10", "psr/http-client": "^1.0", "psr/http-message": "^1.1 || ^2.0", "psr/log": "^1|^2|^3", diff --git a/src/Client.php b/src/Client.php index 50e7dcf72..7bd1ecb9a 100644 --- a/src/Client.php +++ b/src/Client.php @@ -28,7 +28,7 @@ final class Client implements ClientInterface { const CLIENT_NAME = 'es'; - const VERSION = '8.14.0'; + const VERSION = '8.15.0'; const API_COMPATIBILITY_HEADER = '%s/vnd.elasticsearch+%s; compatible-with=8'; use ClientEndpointsTrait; diff --git a/src/Endpoints/AsyncSearch.php b/src/Endpoints/AsyncSearch.php index 46cb8bf22..a1a0cee41 100644 --- a/src/Endpoints/AsyncSearch.php +++ b/src/Endpoints/AsyncSearch.php @@ -59,7 +59,9 @@ public function delete(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'async_search.delete'); + return $this->client->sendRequest($request); } @@ -97,7 +99,9 @@ public function get(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'async_search.get'); + return $this->client->sendRequest($request); } @@ -133,7 +137,9 @@ public function status(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'async_search.status'); + return $this->client->sendRequest($request); } @@ -213,6 +219,8 @@ public function submit(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'async_search.submit'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Autoscaling.php b/src/Endpoints/Autoscaling.php index 9ea7a9860..75481fc88 100644 --- a/src/Endpoints/Autoscaling.php +++ b/src/Endpoints/Autoscaling.php @@ -35,6 +35,8 @@ class Autoscaling extends AbstractEndpoint * * @param array{ * name: string, // (REQUIRED) the name of the autoscaling policy + * master_timeout: time, // Timeout for processing on master node + * timeout: time, // Timeout for acknowledgement of update from all nodes in cluster * 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) @@ -55,11 +57,13 @@ public function deleteAutoscalingPolicy(array $params = []) $url = '/_autoscaling/policy/' . $this->encode($params['name']); $method = 'DELETE'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'autoscaling.delete_autoscaling_policy'); + return $this->client->sendRequest($request); } @@ -69,6 +73,7 @@ public function deleteAutoscalingPolicy(array $params = []) * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-get-autoscaling-capacity.html * * @param array{ + * master_timeout: time, // Timeout for processing on master node * 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) @@ -87,11 +92,13 @@ public function getAutoscalingCapacity(array $params = []) $url = '/_autoscaling/capacity'; $method = 'GET'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['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)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'autoscaling.get_autoscaling_capacity'); + return $this->client->sendRequest($request); } @@ -102,6 +109,7 @@ public function getAutoscalingCapacity(array $params = []) * * @param array{ * name: string, // (REQUIRED) the name of the autoscaling policy + * master_timeout: time, // Timeout for processing on master node * 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) @@ -122,11 +130,13 @@ public function getAutoscalingPolicy(array $params = []) $url = '/_autoscaling/policy/' . $this->encode($params['name']); $method = 'GET'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['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)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'autoscaling.get_autoscaling_policy'); + return $this->client->sendRequest($request); } @@ -137,6 +147,8 @@ public function getAutoscalingPolicy(array $params = []) * * @param array{ * name: string, // (REQUIRED) the name of the autoscaling policy + * master_timeout: time, // Timeout for processing on master node + * timeout: time, // Timeout for acknowledgement of update from all nodes in cluster * 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) @@ -158,11 +170,13 @@ public function putAutoscalingPolicy(array $params = []) $url = '/_autoscaling/policy/' . $this->encode($params['name']); $method = 'PUT'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','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)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'autoscaling.put_autoscaling_policy'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Cat.php b/src/Endpoints/Cat.php index 34943761f..026f7ba32 100644 --- a/src/Endpoints/Cat.php +++ b/src/Endpoints/Cat.php @@ -68,7 +68,9 @@ public function aliases(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'cat.aliases'); + return $this->client->sendRequest($request); } @@ -113,7 +115,9 @@ public function allocation(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['node_id'], $request, 'cat.allocation'); + return $this->client->sendRequest($request); } @@ -157,7 +161,9 @@ public function componentTemplates(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'cat.component_templates'); + return $this->client->sendRequest($request); } @@ -199,7 +205,9 @@ public function count(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'cat.count'); + return $this->client->sendRequest($request); } @@ -242,7 +250,9 @@ public function fielddata(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['fields'], $request, 'cat.fielddata'); + return $this->client->sendRequest($request); } @@ -281,7 +291,9 @@ public function health(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'cat.health'); + return $this->client->sendRequest($request); } @@ -315,7 +327,9 @@ public function help(array $params = []) $headers = [ 'Accept' => 'text/plain', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'cat.help'); + return $this->client->sendRequest($request); } @@ -364,7 +378,9 @@ public function indices(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'cat.indices'); + return $this->client->sendRequest($request); } @@ -403,7 +419,9 @@ public function master(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'cat.master'); + return $this->client->sendRequest($request); } @@ -448,7 +466,9 @@ public function mlDataFrameAnalytics(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'cat.ml_data_frame_analytics'); + return $this->client->sendRequest($request); } @@ -492,7 +512,9 @@ public function mlDatafeeds(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['datafeed_id'], $request, 'cat.ml_datafeeds'); + return $this->client->sendRequest($request); } @@ -537,7 +559,9 @@ public function mlJobs(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id'], $request, 'cat.ml_jobs'); + return $this->client->sendRequest($request); } @@ -584,7 +608,9 @@ public function mlTrainedModels(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['model_id'], $request, 'cat.ml_trained_models'); + return $this->client->sendRequest($request); } @@ -623,7 +649,9 @@ public function nodeattrs(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'cat.nodeattrs'); + return $this->client->sendRequest($request); } @@ -665,7 +693,9 @@ public function nodes(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'cat.nodes'); + return $this->client->sendRequest($request); } @@ -705,7 +735,9 @@ public function pendingTasks(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'cat.pending_tasks'); + return $this->client->sendRequest($request); } @@ -745,7 +777,9 @@ public function plugins(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'cat.plugins'); + return $this->client->sendRequest($request); } @@ -791,7 +825,9 @@ public function recovery(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'cat.recovery'); + return $this->client->sendRequest($request); } @@ -830,7 +866,9 @@ public function repositories(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'cat.repositories'); + return $this->client->sendRequest($request); } @@ -873,7 +911,9 @@ public function segments(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'cat.segments'); + return $this->client->sendRequest($request); } @@ -918,7 +958,9 @@ public function shards(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'cat.shards'); + return $this->client->sendRequest($request); } @@ -963,7 +1005,9 @@ public function snapshots(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['repository'], $request, 'cat.snapshots'); + return $this->client->sendRequest($request); } @@ -1006,7 +1050,9 @@ public function tasks(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'cat.tasks'); + return $this->client->sendRequest($request); } @@ -1050,7 +1096,9 @@ public function templates(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'cat.templates'); + return $this->client->sendRequest($request); } @@ -1096,7 +1144,9 @@ public function threadPool(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['thread_pool_patterns'], $request, 'cat.thread_pool'); + return $this->client->sendRequest($request); } @@ -1142,6 +1192,8 @@ public function transforms(array $params = []) $headers = [ 'Accept' => 'text/plain,application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['transform_id'], $request, 'cat.transforms'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Ccr.php b/src/Endpoints/Ccr.php index 81bca3bc2..9a14314c4 100644 --- a/src/Endpoints/Ccr.php +++ b/src/Endpoints/Ccr.php @@ -60,7 +60,9 @@ public function deleteAutoFollowPattern(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'ccr.delete_auto_follow_pattern'); + return $this->client->sendRequest($request); } @@ -99,7 +101,9 @@ public function follow(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'ccr.follow'); + return $this->client->sendRequest($request); } @@ -135,7 +139,9 @@ public function followInfo(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'ccr.follow_info'); + return $this->client->sendRequest($request); } @@ -171,7 +177,9 @@ public function followStats(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'ccr.follow_stats'); + return $this->client->sendRequest($request); } @@ -209,7 +217,9 @@ public function forgetFollower(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'ccr.forget_follower'); + return $this->client->sendRequest($request); } @@ -247,7 +257,9 @@ public function getAutoFollowPattern(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'ccr.get_auto_follow_pattern'); + return $this->client->sendRequest($request); } @@ -283,7 +295,9 @@ public function pauseAutoFollowPattern(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'ccr.pause_auto_follow_pattern'); + return $this->client->sendRequest($request); } @@ -319,7 +333,9 @@ public function pauseFollow(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'ccr.pause_follow'); + return $this->client->sendRequest($request); } @@ -357,7 +373,9 @@ public function putAutoFollowPattern(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'ccr.put_auto_follow_pattern'); + return $this->client->sendRequest($request); } @@ -393,7 +411,9 @@ public function resumeAutoFollowPattern(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'ccr.resume_auto_follow_pattern'); + return $this->client->sendRequest($request); } @@ -431,7 +451,9 @@ public function resumeFollow(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'ccr.resume_follow'); + return $this->client->sendRequest($request); } @@ -465,7 +487,9 @@ public function stats(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'ccr.stats'); + return $this->client->sendRequest($request); } @@ -501,6 +525,8 @@ public function unfollow(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'ccr.unfollow'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Cluster.php b/src/Endpoints/Cluster.php index f83b4ca91..203fcaf5b 100644 --- a/src/Endpoints/Cluster.php +++ b/src/Endpoints/Cluster.php @@ -34,6 +34,7 @@ class Cluster extends AbstractEndpoint * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-allocation-explain.html * * @param array{ + * master_timeout: time, // Timeout for connection to master node * include_yes_decisions: boolean, // Return 'YES' decisions in explanation (default: false) * include_disk_info: boolean, // Return information about disk usage and shard sizes (default: false) * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) @@ -55,12 +56,14 @@ public function allocationExplain(array $params = []) $url = '/_cluster/allocation/explain'; $method = empty($params['body']) ? 'GET' : 'POST'; - $url = $this->addQueryString($url, $params, ['include_yes_decisions','include_disk_info','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','include_yes_decisions','include_disk_info','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)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'cluster.allocation_explain'); + return $this->client->sendRequest($request); } @@ -97,7 +100,9 @@ public function deleteComponentTemplate(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'cluster.delete_component_template'); + return $this->client->sendRequest($request); } @@ -131,7 +136,9 @@ public function deleteVotingConfigExclusions(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'cluster.delete_voting_config_exclusions'); + return $this->client->sendRequest($request); } @@ -168,7 +175,9 @@ public function existsComponentTemplate(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'cluster.exists_component_template'); + return $this->client->sendRequest($request); } @@ -208,7 +217,9 @@ public function getComponentTemplate(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'cluster.get_component_template'); + return $this->client->sendRequest($request); } @@ -244,7 +255,9 @@ public function getSettings(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'cluster.get_settings'); + return $this->client->sendRequest($request); } @@ -292,7 +305,9 @@ public function health(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'cluster.health'); + return $this->client->sendRequest($request); } @@ -327,7 +342,9 @@ public function info(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['target'], $request, 'cluster.info'); + return $this->client->sendRequest($request); } @@ -362,7 +379,9 @@ public function pendingTasks(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'cluster.pending_tasks'); + return $this->client->sendRequest($request); } @@ -398,7 +417,9 @@ public function postVotingConfigExclusions(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'cluster.post_voting_config_exclusions'); + return $this->client->sendRequest($request); } @@ -438,7 +459,9 @@ public function putComponentTemplate(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'cluster.put_component_template'); + return $this->client->sendRequest($request); } @@ -476,7 +499,9 @@ public function putSettings(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'cluster.put_settings'); + return $this->client->sendRequest($request); } @@ -508,7 +533,9 @@ public function remoteInfo(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'cluster.remote_info'); + return $this->client->sendRequest($request); } @@ -548,7 +575,9 @@ public function reroute(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'cluster.reroute'); + return $this->client->sendRequest($request); } @@ -597,7 +626,9 @@ public function state(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['metric', 'index'], $request, 'cluster.state'); + return $this->client->sendRequest($request); } @@ -636,6 +667,8 @@ public function stats(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['node_id'], $request, 'cluster.stats'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Connector.php b/src/Endpoints/Connector.php index 306461cd9..98ab0ec59 100644 --- a/src/Endpoints/Connector.php +++ b/src/Endpoints/Connector.php @@ -60,7 +60,9 @@ public function checkIn(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_id'], $request, 'connector.check_in'); + return $this->client->sendRequest($request); } @@ -97,7 +99,9 @@ public function delete(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_id'], $request, 'connector.delete'); + return $this->client->sendRequest($request); } @@ -133,7 +137,9 @@ public function get(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_id'], $request, 'connector.get'); + return $this->client->sendRequest($request); } @@ -171,7 +177,9 @@ public function lastSync(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_id'], $request, 'connector.last_sync'); + return $this->client->sendRequest($request); } @@ -210,7 +218,9 @@ public function list(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'connector.list'); + return $this->client->sendRequest($request); } @@ -226,7 +236,7 @@ public function list(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, // (REQUIRED) The connector configuration. + * body: array, // The connector configuration. * } $params * * @throws NoNodeAvailableException if all the hosts are offline @@ -237,7 +247,6 @@ public function list(array $params = []) */ public function post(array $params = []) { - $this->checkRequiredParameters(['body'], $params); $url = '/_connector'; $method = 'POST'; @@ -246,7 +255,9 @@ public function post(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'connector.post'); + return $this->client->sendRequest($request); } @@ -257,16 +268,15 @@ public function post(array $params = []) * @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 created or updated. + * connector_id: string, // The unique identifier of the connector 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. - * body: array, // (REQUIRED) The connector configuration. + * body: array, // The connector configuration. * } $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 @@ -275,16 +285,21 @@ public function post(array $params = []) */ public function put(array $params = []) { - $this->checkRequiredParameters(['connector_id','body'], $params); - $url = '/_connector/' . $this->encode($params['connector_id']); - $method = 'PUT'; - + if (isset($params['connector_id'])) { + $url = '/_connector/' . $this->encode($params['connector_id']); + $method = 'PUT'; + } else { + $url = '/_connector'; + $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)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_id'], $request, 'connector.put'); + return $this->client->sendRequest($request); } @@ -320,7 +335,9 @@ public function syncJobCancel(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_sync_job_id'], $request, 'connector.sync_job_cancel'); + return $this->client->sendRequest($request); } @@ -356,7 +373,49 @@ public function syncJobCheckIn(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_sync_job_id'], $request, 'connector.sync_job_check_in'); + return $this->client->sendRequest($request); + } + + + /** + * Claims a connector sync job. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/claim-connector-sync-job-api.html + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release + * + * @param array{ + * connector_sync_job_id: string, // (REQUIRED) The unique identifier of the connector sync job to be claimed. + * 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) Data to claim a sync job. + * } $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 syncJobClaim(array $params = []) + { + $this->checkRequiredParameters(['connector_sync_job_id','body'], $params); + $url = '/_connector/_sync_job/' . $this->encode($params['connector_sync_job_id']) . '/_claim'; + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_sync_job_id'], $request, 'connector.sync_job_claim'); + return $this->client->sendRequest($request); } @@ -392,7 +451,9 @@ public function syncJobDelete(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_sync_job_id'], $request, 'connector.sync_job_delete'); + return $this->client->sendRequest($request); } @@ -430,7 +491,9 @@ public function syncJobError(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_sync_job_id'], $request, 'connector.sync_job_error'); + return $this->client->sendRequest($request); } @@ -466,7 +529,9 @@ public function syncJobGet(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_sync_job_id'], $request, 'connector.sync_job_get'); + return $this->client->sendRequest($request); } @@ -504,7 +569,9 @@ public function syncJobList(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'connector.sync_job_list'); + return $this->client->sendRequest($request); } @@ -540,7 +607,9 @@ public function syncJobPost(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'connector.sync_job_post'); + return $this->client->sendRequest($request); } @@ -578,7 +647,9 @@ public function syncJobUpdateStats(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_sync_job_id'], $request, 'connector.sync_job_update_stats'); + return $this->client->sendRequest($request); } @@ -615,7 +686,9 @@ public function updateActiveFiltering(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_id'], $request, 'connector.update_active_filtering'); + return $this->client->sendRequest($request); } @@ -653,7 +726,9 @@ public function updateApiKeyId(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_id'], $request, 'connector.update_api_key_id'); + return $this->client->sendRequest($request); } @@ -691,7 +766,9 @@ public function updateConfiguration(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_id'], $request, 'connector.update_configuration'); + return $this->client->sendRequest($request); } @@ -729,7 +806,49 @@ public function updateError(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_id'], $request, 'connector.update_error'); + return $this->client->sendRequest($request); + } + + + /** + * Updates the connector features in the connector document. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-features-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 features 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 updateFeatures(array $params = []) + { + $this->checkRequiredParameters(['connector_id','body'], $params); + $url = '/_connector/' . $this->encode($params['connector_id']) . '/_features'; + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_id'], $request, 'connector.update_features'); + return $this->client->sendRequest($request); } @@ -767,7 +886,9 @@ public function updateFiltering(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_id'], $request, 'connector.update_filtering'); + return $this->client->sendRequest($request); } @@ -805,7 +926,9 @@ public function updateFilteringValidation(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_id'], $request, 'connector.update_filtering_validation'); + return $this->client->sendRequest($request); } @@ -843,7 +966,9 @@ public function updateIndexName(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_id'], $request, 'connector.update_index_name'); + return $this->client->sendRequest($request); } @@ -881,7 +1006,9 @@ public function updateName(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_id'], $request, 'connector.update_name'); + return $this->client->sendRequest($request); } @@ -919,7 +1046,9 @@ public function updateNative(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_id'], $request, 'connector.update_native'); + return $this->client->sendRequest($request); } @@ -957,7 +1086,9 @@ public function updatePipeline(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_id'], $request, 'connector.update_pipeline'); + return $this->client->sendRequest($request); } @@ -995,7 +1126,9 @@ public function updateScheduling(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_id'], $request, 'connector.update_scheduling'); + return $this->client->sendRequest($request); } @@ -1033,7 +1166,9 @@ public function updateServiceType(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_id'], $request, 'connector.update_service_type'); + return $this->client->sendRequest($request); } @@ -1071,6 +1206,8 @@ public function updateStatus(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['connector_id'], $request, 'connector.update_status'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/DanglingIndices.php b/src/Endpoints/DanglingIndices.php index 96ddfc065..b75c77635 100644 --- a/src/Endpoints/DanglingIndices.php +++ b/src/Endpoints/DanglingIndices.php @@ -62,7 +62,9 @@ public function deleteDanglingIndex(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index_uuid'], $request, 'dangling_indices.delete_dangling_index'); + return $this->client->sendRequest($request); } @@ -100,7 +102,9 @@ public function importDanglingIndex(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index_uuid'], $request, 'dangling_indices.import_dangling_index'); + return $this->client->sendRequest($request); } @@ -132,6 +136,8 @@ public function listDanglingIndices(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'dangling_indices.list_dangling_indices'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Enrich.php b/src/Endpoints/Enrich.php index 597c5bea3..b2f893962 100644 --- a/src/Endpoints/Enrich.php +++ b/src/Endpoints/Enrich.php @@ -35,6 +35,7 @@ class Enrich extends AbstractEndpoint * * @param array{ * name: string, // (REQUIRED) The name of the enrich policy + * master_timeout: time, // Timeout for processing on master node * 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) @@ -55,11 +56,13 @@ public function deletePolicy(array $params = []) $url = '/_enrich/policy/' . $this->encode($params['name']); $method = 'DELETE'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['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)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'enrich.delete_policy'); + return $this->client->sendRequest($request); } @@ -71,6 +74,7 @@ public function deletePolicy(array $params = []) * @param array{ * name: string, // (REQUIRED) The name of the enrich policy * wait_for_completion: boolean, // Should the request should block until the execution is complete. + * master_timeout: time, // Timeout for processing on master node * 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) @@ -91,11 +95,13 @@ public function executePolicy(array $params = []) $url = '/_enrich/policy/' . $this->encode($params['name']) . '/_execute'; $method = 'PUT'; - $url = $this->addQueryString($url, $params, ['wait_for_completion','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['wait_for_completion','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)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'enrich.execute_policy'); + return $this->client->sendRequest($request); } @@ -106,6 +112,7 @@ public function executePolicy(array $params = []) * * @param array{ * name: list, // A comma-separated list of enrich policy names + * master_timeout: time, // Timeout for processing on master node * 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,11 +135,13 @@ public function getPolicy(array $params = []) $url = '/_enrich/policy'; $method = 'GET'; } - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['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)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'enrich.get_policy'); + return $this->client->sendRequest($request); } @@ -143,6 +152,7 @@ public function getPolicy(array $params = []) * * @param array{ * name: string, // (REQUIRED) The name of the enrich policy + * master_timeout: time, // Timeout for processing on master node * 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) @@ -164,12 +174,14 @@ public function putPolicy(array $params = []) $url = '/_enrich/policy/' . $this->encode($params['name']); $method = 'PUT'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','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)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'enrich.put_policy'); + return $this->client->sendRequest($request); } @@ -179,6 +191,7 @@ public function putPolicy(array $params = []) * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-stats-api.html * * @param array{ + * master_timeout: time, // Timeout for processing on master node * 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) @@ -197,10 +210,12 @@ public function stats(array $params = []) $url = '/_enrich/_stats'; $method = 'GET'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['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)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'enrich.stats'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Eql.php b/src/Endpoints/Eql.php index d10e8a2fd..4a10691c4 100644 --- a/src/Endpoints/Eql.php +++ b/src/Endpoints/Eql.php @@ -59,7 +59,9 @@ public function delete(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'eql.delete'); + return $this->client->sendRequest($request); } @@ -96,7 +98,9 @@ public function get(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'eql.get'); + return $this->client->sendRequest($request); } @@ -131,7 +135,9 @@ public function getStatus(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'eql.get_status'); + return $this->client->sendRequest($request); } @@ -171,6 +177,8 @@ public function search(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'eql.search'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Esql.php b/src/Endpoints/Esql.php index 1c07eb4d8..0e7388fa0 100644 --- a/src/Endpoints/Esql.php +++ b/src/Endpoints/Esql.php @@ -62,7 +62,9 @@ public function asyncQuery(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'esql.async_query'); + return $this->client->sendRequest($request); } @@ -100,7 +102,9 @@ public function asyncQueryGet(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'esql.async_query_get'); + return $this->client->sendRequest($request); } @@ -138,6 +142,8 @@ public function query(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'esql.query'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Features.php b/src/Endpoints/Features.php index cbd3af711..2cb21fa0e 100644 --- a/src/Endpoints/Features.php +++ b/src/Endpoints/Features.php @@ -57,7 +57,9 @@ public function getFeatures(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'features.get_features'); + return $this->client->sendRequest($request); } @@ -68,6 +70,7 @@ public function getFeatures(array $params = []) * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ + * master_timeout: time, // Explicit operation timeout for connection to master node * 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) @@ -86,10 +89,12 @@ public function resetFeatures(array $params = []) $url = '/_features/_reset'; $method = 'POST'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['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)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'features.reset_features'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Fleet.php b/src/Endpoints/Fleet.php index 54da9c55b..bb0e9e209 100644 --- a/src/Endpoints/Fleet.php +++ b/src/Endpoints/Fleet.php @@ -64,7 +64,9 @@ public function globalCheckpoints(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'fleet.global_checkpoints'); + return $this->client->sendRequest($request); } @@ -104,7 +106,9 @@ public function msearch(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/x-ndjson', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'fleet.msearch'); + return $this->client->sendRequest($request); } @@ -144,6 +148,8 @@ public function search(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'fleet.search'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Graph.php b/src/Endpoints/Graph.php index 0fd0e98e0..416585654 100644 --- a/src/Endpoints/Graph.php +++ b/src/Endpoints/Graph.php @@ -63,6 +63,8 @@ public function explore(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'graph.explore'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Ilm.php b/src/Endpoints/Ilm.php index f96674a1b..1fce30391 100644 --- a/src/Endpoints/Ilm.php +++ b/src/Endpoints/Ilm.php @@ -59,7 +59,9 @@ public function deleteLifecycle(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['policy'], $request, 'ilm.delete_lifecycle'); + return $this->client->sendRequest($request); } @@ -96,7 +98,9 @@ public function explainLifecycle(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'ilm.explain_lifecycle'); + return $this->client->sendRequest($request); } @@ -133,7 +137,9 @@ public function getLifecycle(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['policy'], $request, 'ilm.get_lifecycle'); + return $this->client->sendRequest($request); } @@ -165,7 +171,9 @@ public function getStatus(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'ilm.get_status'); + return $this->client->sendRequest($request); } @@ -200,7 +208,9 @@ public function migrateToDataTiers(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'ilm.migrate_to_data_tiers'); + return $this->client->sendRequest($request); } @@ -237,7 +247,9 @@ public function moveToStep(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'ilm.move_to_step'); + return $this->client->sendRequest($request); } @@ -274,7 +286,9 @@ public function putLifecycle(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['policy'], $request, 'ilm.put_lifecycle'); + return $this->client->sendRequest($request); } @@ -309,7 +323,9 @@ public function removePolicy(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'ilm.remove_policy'); + return $this->client->sendRequest($request); } @@ -344,7 +360,9 @@ public function retry(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'ilm.retry'); + return $this->client->sendRequest($request); } @@ -376,7 +394,9 @@ public function start(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'ilm.start'); + return $this->client->sendRequest($request); } @@ -408,6 +428,8 @@ public function stop(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'ilm.stop'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Indices.php b/src/Endpoints/Indices.php index 4db9a6af2..9ab3c7df0 100644 --- a/src/Endpoints/Indices.php +++ b/src/Endpoints/Indices.php @@ -65,7 +65,9 @@ public function addBlock(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index', 'block'], $request, 'indices.add_block'); + return $this->client->sendRequest($request); } @@ -104,7 +106,9 @@ public function analyze(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.analyze'); + return $this->client->sendRequest($request); } @@ -148,7 +152,9 @@ public function clearCache(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.clear_cache'); + return $this->client->sendRequest($request); } @@ -189,7 +195,9 @@ public function clone(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index', 'target'], $request, 'indices.clone'); + return $this->client->sendRequest($request); } @@ -230,7 +238,9 @@ public function close(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.close'); + return $this->client->sendRequest($request); } @@ -270,7 +280,9 @@ public function create(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.create'); + return $this->client->sendRequest($request); } @@ -305,7 +317,9 @@ public function createDataStream(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'indices.create_data_stream'); + return $this->client->sendRequest($request); } @@ -342,7 +356,9 @@ public function dataStreamsStats(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'indices.data_streams_stats'); + return $this->client->sendRequest($request); } @@ -382,7 +398,9 @@ public function delete(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.delete'); + return $this->client->sendRequest($request); } @@ -420,7 +438,9 @@ public function deleteAlias(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index', 'name'], $request, 'indices.delete_alias'); + return $this->client->sendRequest($request); } @@ -459,7 +479,9 @@ public function deleteDataLifecycle(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'indices.delete_data_lifecycle'); + return $this->client->sendRequest($request); } @@ -495,7 +517,9 @@ public function deleteDataStream(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'indices.delete_data_stream'); + return $this->client->sendRequest($request); } @@ -532,7 +556,9 @@ public function deleteIndexTemplate(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'indices.delete_index_template'); + return $this->client->sendRequest($request); } @@ -569,7 +595,9 @@ public function deleteTemplate(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'indices.delete_template'); + return $this->client->sendRequest($request); } @@ -610,7 +638,9 @@ public function diskUsage(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.disk_usage'); + return $this->client->sendRequest($request); } @@ -649,7 +679,9 @@ public function downsample(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index', 'target_index'], $request, 'indices.downsample'); + return $this->client->sendRequest($request); } @@ -690,7 +722,9 @@ public function exists(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.exists'); + return $this->client->sendRequest($request); } @@ -734,7 +768,9 @@ public function existsAlias(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name', 'index'], $request, 'indices.exists_alias'); + return $this->client->sendRequest($request); } @@ -772,7 +808,9 @@ public function existsIndexTemplate(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'indices.exists_index_template'); + return $this->client->sendRequest($request); } @@ -810,7 +848,9 @@ public function existsTemplate(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'indices.exists_template'); + return $this->client->sendRequest($request); } @@ -848,7 +888,9 @@ public function explainDataLifecycle(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.explain_data_lifecycle'); + return $this->client->sendRequest($request); } @@ -888,7 +930,9 @@ public function fieldUsageStats(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.field_usage_stats'); + return $this->client->sendRequest($request); } @@ -930,7 +974,9 @@ public function flush(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.flush'); + return $this->client->sendRequest($request); } @@ -974,7 +1020,9 @@ public function forcemerge(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.forcemerge'); + return $this->client->sendRequest($request); } @@ -1017,7 +1065,9 @@ public function get(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.get'); + return $this->client->sendRequest($request); } @@ -1065,7 +1115,9 @@ public function getAlias(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name', 'index'], $request, 'indices.get_alias'); + return $this->client->sendRequest($request); } @@ -1103,7 +1155,9 @@ public function getDataLifecycle(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'indices.get_data_lifecycle'); + return $this->client->sendRequest($request); } @@ -1142,7 +1196,9 @@ public function getDataStream(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'indices.get_data_stream'); + return $this->client->sendRequest($request); } @@ -1187,7 +1243,9 @@ public function getFieldMapping(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['fields', 'index'], $request, 'indices.get_field_mapping'); + return $this->client->sendRequest($request); } @@ -1228,7 +1286,9 @@ public function getIndexTemplate(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'indices.get_index_template'); + return $this->client->sendRequest($request); } @@ -1270,7 +1330,9 @@ public function getMapping(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.get_mapping'); + return $this->client->sendRequest($request); } @@ -1321,7 +1383,9 @@ public function getSettings(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index', 'name'], $request, 'indices.get_settings'); + return $this->client->sendRequest($request); } @@ -1361,7 +1425,9 @@ public function getTemplate(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'indices.get_template'); + return $this->client->sendRequest($request); } @@ -1396,7 +1462,9 @@ public function migrateToDataStream(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'indices.migrate_to_data_stream'); + return $this->client->sendRequest($request); } @@ -1431,7 +1499,9 @@ public function modifyDataStream(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'indices.modify_data_stream'); + return $this->client->sendRequest($request); } @@ -1472,7 +1542,9 @@ public function open(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.open'); + return $this->client->sendRequest($request); } @@ -1507,7 +1579,9 @@ public function promoteDataStream(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'indices.promote_data_stream'); + return $this->client->sendRequest($request); } @@ -1547,7 +1621,9 @@ public function putAlias(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index', 'name'], $request, 'indices.put_alias'); + return $this->client->sendRequest($request); } @@ -1587,7 +1663,9 @@ public function putDataLifecycle(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'indices.put_data_lifecycle'); + return $this->client->sendRequest($request); } @@ -1627,7 +1705,9 @@ public function putIndexTemplate(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'indices.put_index_template'); + return $this->client->sendRequest($request); } @@ -1670,7 +1750,9 @@ public function putMapping(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.put_mapping'); + return $this->client->sendRequest($request); } @@ -1718,7 +1800,9 @@ public function putSettings(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.put_settings'); + return $this->client->sendRequest($request); } @@ -1758,7 +1842,9 @@ public function putTemplate(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'indices.put_template'); + return $this->client->sendRequest($request); } @@ -1797,7 +1883,9 @@ public function recovery(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.recovery'); + return $this->client->sendRequest($request); } @@ -1837,7 +1925,9 @@ public function refresh(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.refresh'); + return $this->client->sendRequest($request); } @@ -1876,7 +1966,9 @@ public function reloadSearchAnalyzers(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.reload_search_analyzers'); + return $this->client->sendRequest($request); } @@ -1915,7 +2007,9 @@ public function resolveCluster(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'indices.resolve_cluster'); + return $this->client->sendRequest($request); } @@ -1951,7 +2045,9 @@ public function resolveIndex(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'indices.resolve_index'); + return $this->client->sendRequest($request); } @@ -2000,7 +2096,9 @@ public function rollover(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['alias', 'new_index'], $request, 'indices.rollover'); + return $this->client->sendRequest($request); } @@ -2041,7 +2139,9 @@ public function segments(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.segments'); + return $this->client->sendRequest($request); } @@ -2082,7 +2182,9 @@ public function shardStores(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.shard_stores'); + return $this->client->sendRequest($request); } @@ -2123,7 +2225,9 @@ public function shrink(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index', 'target'], $request, 'indices.shrink'); + return $this->client->sendRequest($request); } @@ -2164,7 +2268,9 @@ public function simulateIndexTemplate(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'indices.simulate_index_template'); + return $this->client->sendRequest($request); } @@ -2207,7 +2313,9 @@ public function simulateTemplate(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'indices.simulate_template'); + return $this->client->sendRequest($request); } @@ -2248,7 +2356,9 @@ public function split(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index', 'target'], $request, 'indices.split'); + return $this->client->sendRequest($request); } @@ -2301,7 +2411,9 @@ public function stats(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['metric', 'index'], $request, 'indices.stats'); + return $this->client->sendRequest($request); } @@ -2342,7 +2454,9 @@ public function unfreeze(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.unfreeze'); + return $this->client->sendRequest($request); } @@ -2379,7 +2493,9 @@ public function updateAliases(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'indices.update_aliases'); + return $this->client->sendRequest($request); } @@ -2430,6 +2546,8 @@ public function validateQuery(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'indices.validate_query'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Inference.php b/src/Endpoints/Inference.php index 04cca3027..65837f068 100644 --- a/src/Endpoints/Inference.php +++ b/src/Endpoints/Inference.php @@ -29,14 +29,16 @@ class Inference extends AbstractEndpoint { /** - * Delete model in the Inference API + * Delete an inference endpoint * * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-inference-api.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release * * @param array{ - * inference_id: string, // (REQUIRED) The model Id + * inference_id: string, // (REQUIRED) The inference Id * task_type: string, // The task type + * dry_run: boolean, // If true the endpoint will not be deleted and a list of ingest processors which reference this endpoint will be returned. + * force: boolean, // If true the endpoint will be forcefully stopped (regardless of whether or not it is referenced by any ingest processors or semantic text fields). * 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) @@ -51,7 +53,7 @@ class Inference extends AbstractEndpoint * * @return Elasticsearch|Promise */ - public function deleteModel(array $params = []) + public function delete(array $params = []) { $this->checkRequiredParameters(['inference_id'], $params); if (isset($params['task_type'])) { @@ -61,16 +63,18 @@ public function deleteModel(array $params = []) $url = '/_inference/' . $this->encode($params['inference_id']); $method = 'DELETE'; } - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['dry_run','force','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['inference_id', 'task_type'], $request, 'inference.delete'); + return $this->client->sendRequest($request); } /** - * Get a model in the Inference API + * Get an inference endpoint * * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-inference-api.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release @@ -91,7 +95,7 @@ public function deleteModel(array $params = []) * * @return Elasticsearch|Promise */ - public function getModel(array $params = []) + public function get(array $params = []) { if (isset($params['task_type']) && isset($params['inference_id'])) { $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['inference_id']); @@ -107,12 +111,14 @@ public function getModel(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['inference_id', 'task_type'], $request, 'inference.get'); + return $this->client->sendRequest($request); } /** - * Perform inference on a model + * Perform inference * * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/post-inference-api.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release @@ -150,12 +156,14 @@ public function inference(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['inference_id', 'task_type'], $request, 'inference.inference'); + return $this->client->sendRequest($request); } /** - * Configure a model for use in the Inference API + * Configure an inference endpoint for use in the Inference API * * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-inference-api.html * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release @@ -168,7 +176,7 @@ public function inference(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 model's task and service settings + * body: array, // The inference endpoint's task and service settings * } $params * * @throws MissingParameterException if a required parameter is missing @@ -178,7 +186,7 @@ public function inference(array $params = []) * * @return Elasticsearch|Promise */ - public function putModel(array $params = []) + public function put(array $params = []) { $this->checkRequiredParameters(['inference_id'], $params); if (isset($params['task_type'])) { @@ -193,6 +201,8 @@ public function putModel(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['inference_id', 'task_type'], $request, 'inference.put'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Ingest.php b/src/Endpoints/Ingest.php index 1208435b9..0626caa35 100644 --- a/src/Endpoints/Ingest.php +++ b/src/Endpoints/Ingest.php @@ -28,6 +28,43 @@ */ class Ingest extends AbstractEndpoint { + /** + * Deletes a geoip database configuration + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/TODO.html + * + * @param array{ + * id: list, // (REQUIRED) A comma-separated list of geoip database configurations to delete + * 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 deleteGeoipDatabase(array $params = []) + { + $this->checkRequiredParameters(['id'], $params); + $url = '/_ingest/geoip/database/' . $this->encode($params['id']); + $method = 'DELETE'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'ingest.delete_geoip_database'); + return $this->client->sendRequest($request); + } + + /** * Deletes a pipeline. * @@ -61,7 +98,9 @@ public function deletePipeline(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'ingest.delete_pipeline'); + return $this->client->sendRequest($request); } @@ -93,7 +132,48 @@ public function geoIpStats(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'ingest.geo_ip_stats'); + return $this->client->sendRequest($request); + } + + + /** + * Returns geoip database configuration. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/TODO.html + * + * @param array{ + * id: list, // A comma-separated list of geoip database configurations to get; use `*` to get all geoip database configurations + * 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 getGeoipDatabase(array $params = []) + { + if (isset($params['id'])) { + $url = '/_ingest/geoip/database/' . $this->encode($params['id']); + $method = 'GET'; + } else { + $url = '/_ingest/geoip/database'; + $method = 'GET'; + } + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'ingest.get_geoip_database'); + return $this->client->sendRequest($request); } @@ -132,7 +212,9 @@ public function getPipeline(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'ingest.get_pipeline'); + return $this->client->sendRequest($request); } @@ -164,7 +246,47 @@ public function processorGrok(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'ingest.processor_grok'); + return $this->client->sendRequest($request); + } + + + /** + * Puts the configuration for a geoip database to be downloaded + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/TODO.html + * + * @param array{ + * id: string, // (REQUIRED) The id of the database configuration + * 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 database configuration 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 putGeoipDatabase(array $params = []) + { + $this->checkRequiredParameters(['id','body'], $params); + $url = '/_ingest/geoip/database/' . $this->encode($params['id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'ingest.put_geoip_database'); + return $this->client->sendRequest($request); } @@ -204,7 +326,9 @@ public function putPipeline(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'ingest.put_pipeline'); + return $this->client->sendRequest($request); } @@ -245,6 +369,8 @@ public function simulate(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'ingest.simulate'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/License.php b/src/Endpoints/License.php index 75cbbfcd7..1c60053a4 100644 --- a/src/Endpoints/License.php +++ b/src/Endpoints/License.php @@ -34,6 +34,8 @@ class License extends AbstractEndpoint * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-license.html * * @param array{ + * master_timeout: time, // Timeout for processing on master node + * timeout: time, // Timeout for acknowledgement of update from all nodes in cluster * 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) @@ -52,11 +54,13 @@ public function delete(array $params = []) $url = '/_license'; $method = 'DELETE'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'license.delete'); + return $this->client->sendRequest($request); } @@ -90,7 +94,9 @@ public function get(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'license.get'); + return $this->client->sendRequest($request); } @@ -122,7 +128,9 @@ public function getBasicStatus(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'license.get_basic_status'); + return $this->client->sendRequest($request); } @@ -154,7 +162,9 @@ public function getTrialStatus(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'license.get_trial_status'); + return $this->client->sendRequest($request); } @@ -165,6 +175,8 @@ public function getTrialStatus(array $params = []) * * @param array{ * acknowledge: boolean, // whether the user has acknowledged acknowledge messages (default: false) + * master_timeout: time, // Timeout for processing on master node + * timeout: time, // Timeout for acknowledgement of update from all nodes in cluster * 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) @@ -184,12 +196,14 @@ public function post(array $params = []) $url = '/_license'; $method = 'PUT'; - $url = $this->addQueryString($url, $params, ['acknowledge','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['acknowledge','master_timeout','timeout','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)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'license.post'); + return $this->client->sendRequest($request); } @@ -200,6 +214,8 @@ public function post(array $params = []) * * @param array{ * acknowledge: boolean, // whether the user has acknowledged acknowledge messages (default: false) + * master_timeout: time, // Timeout for processing on master node + * timeout: time, // Timeout for acknowledgement of update from all nodes in cluster * 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) @@ -218,11 +234,13 @@ public function postStartBasic(array $params = []) $url = '/_license/start_basic'; $method = 'POST'; - $url = $this->addQueryString($url, $params, ['acknowledge','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['acknowledge','master_timeout','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'license.post_start_basic'); + return $this->client->sendRequest($request); } @@ -234,6 +252,8 @@ public function postStartBasic(array $params = []) * @param array{ * type: string, // The type of trial license to generate (default: "trial") * acknowledge: boolean, // whether the user has acknowledged acknowledge messages (default: false) + * master_timeout: time, // Timeout for processing on master node + * timeout: time, // Timeout for acknowledgement of update from all nodes in cluster * 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) @@ -252,10 +272,12 @@ public function postStartTrial(array $params = []) $url = '/_license/start_trial'; $method = 'POST'; - $url = $this->addQueryString($url, $params, ['type','acknowledge','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['type','acknowledge','master_timeout','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'license.post_start_trial'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Logstash.php b/src/Endpoints/Logstash.php index 1dbae86f4..643942d78 100644 --- a/src/Endpoints/Logstash.php +++ b/src/Endpoints/Logstash.php @@ -59,7 +59,9 @@ public function deletePipeline(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'logstash.delete_pipeline'); + return $this->client->sendRequest($request); } @@ -96,7 +98,9 @@ public function getPipeline(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'logstash.get_pipeline'); + return $this->client->sendRequest($request); } @@ -133,6 +137,8 @@ public function putPipeline(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'logstash.put_pipeline'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Migration.php b/src/Endpoints/Migration.php index ccbbe40cc..a14b729a6 100644 --- a/src/Endpoints/Migration.php +++ b/src/Endpoints/Migration.php @@ -61,7 +61,9 @@ public function deprecations(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'migration.deprecations'); + return $this->client->sendRequest($request); } @@ -93,7 +95,9 @@ public function getFeatureUpgradeStatus(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'migration.get_feature_upgrade_status'); + return $this->client->sendRequest($request); } @@ -125,6 +129,8 @@ public function postFeatureUpgrade(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'migration.post_feature_upgrade'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Ml.php b/src/Endpoints/Ml.php index 665844db8..3cdadf612 100644 --- a/src/Endpoints/Ml.php +++ b/src/Endpoints/Ml.php @@ -60,7 +60,9 @@ public function clearTrainedModelDeploymentCache(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['model_id'], $request, 'ml.clear_trained_model_deployment_cache'); + return $this->client->sendRequest($request); } @@ -100,7 +102,9 @@ public function closeJob(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id'], $request, 'ml.close_job'); + return $this->client->sendRequest($request); } @@ -135,7 +139,9 @@ public function deleteCalendar(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['calendar_id'], $request, 'ml.delete_calendar'); + return $this->client->sendRequest($request); } @@ -171,7 +177,9 @@ public function deleteCalendarEvent(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['calendar_id', 'event_id'], $request, 'ml.delete_calendar_event'); + return $this->client->sendRequest($request); } @@ -207,7 +215,9 @@ public function deleteCalendarJob(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['calendar_id', 'job_id'], $request, 'ml.delete_calendar_job'); + return $this->client->sendRequest($request); } @@ -244,7 +254,9 @@ public function deleteDataFrameAnalytics(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'ml.delete_data_frame_analytics'); + return $this->client->sendRequest($request); } @@ -280,7 +292,9 @@ public function deleteDatafeed(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['datafeed_id'], $request, 'ml.delete_datafeed'); + return $this->client->sendRequest($request); } @@ -321,7 +335,9 @@ public function deleteExpiredData(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id'], $request, 'ml.delete_expired_data'); + return $this->client->sendRequest($request); } @@ -356,7 +372,9 @@ public function deleteFilter(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['filter_id'], $request, 'ml.delete_filter'); + return $this->client->sendRequest($request); } @@ -398,7 +416,9 @@ public function deleteForecast(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id', 'forecast_id'], $request, 'ml.delete_forecast'); + return $this->client->sendRequest($request); } @@ -436,7 +456,9 @@ public function deleteJob(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id'], $request, 'ml.delete_job'); + return $this->client->sendRequest($request); } @@ -472,7 +494,9 @@ public function deleteModelSnapshot(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id', 'snapshot_id'], $request, 'ml.delete_model_snapshot'); + return $this->client->sendRequest($request); } @@ -509,7 +533,9 @@ public function deleteTrainedModel(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['model_id'], $request, 'ml.delete_trained_model'); + return $this->client->sendRequest($request); } @@ -546,7 +572,9 @@ public function deleteTrainedModelAlias(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['model_alias', 'model_id'], $request, 'ml.delete_trained_model_alias'); + return $this->client->sendRequest($request); } @@ -581,7 +609,9 @@ public function estimateModelMemory(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'ml.estimate_model_memory'); + return $this->client->sendRequest($request); } @@ -616,7 +646,9 @@ public function evaluateDataFrame(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'ml.evaluate_data_frame'); + return $this->client->sendRequest($request); } @@ -655,7 +687,9 @@ public function explainDataFrameAnalytics(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'ml.explain_data_frame_analytics'); + return $this->client->sendRequest($request); } @@ -697,7 +731,9 @@ public function flushJob(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id'], $request, 'ml.flush_job'); + return $this->client->sendRequest($request); } @@ -737,7 +773,9 @@ public function forecast(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id'], $request, 'ml.forecast'); + return $this->client->sendRequest($request); } @@ -788,7 +826,9 @@ public function getBuckets(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id', 'timestamp'], $request, 'ml.get_buckets'); + return $this->client->sendRequest($request); } @@ -828,7 +868,9 @@ public function getCalendarEvents(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['calendar_id'], $request, 'ml.get_calendar_events'); + return $this->client->sendRequest($request); } @@ -869,7 +911,9 @@ public function getCalendars(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['calendar_id'], $request, 'ml.get_calendars'); + return $this->client->sendRequest($request); } @@ -906,7 +950,7 @@ public function getCategories(array $params = []) $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/results/categories/' . $this->encode($params['category_id']); $method = empty($params['body']) ? 'GET' : 'POST'; } else { - $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/results/categories/'; + $url = '/_ml/anomaly_detectors/' . $this->encode($params['job_id']) . '/results/categories'; $method = empty($params['body']) ? 'GET' : 'POST'; } $url = $this->addQueryString($url, $params, ['from','size','partition_field_value','pretty','human','error_trace','source','filter_path']); @@ -914,7 +958,9 @@ public function getCategories(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id', 'category_id'], $request, 'ml.get_categories'); + return $this->client->sendRequest($request); } @@ -955,7 +1001,9 @@ public function getDataFrameAnalytics(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'ml.get_data_frame_analytics'); + return $this->client->sendRequest($request); } @@ -996,7 +1044,9 @@ public function getDataFrameAnalyticsStats(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'ml.get_data_frame_analytics_stats'); + return $this->client->sendRequest($request); } @@ -1034,7 +1084,9 @@ public function getDatafeedStats(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['datafeed_id'], $request, 'ml.get_datafeed_stats'); + return $this->client->sendRequest($request); } @@ -1073,7 +1125,9 @@ public function getDatafeeds(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['datafeed_id'], $request, 'ml.get_datafeeds'); + return $this->client->sendRequest($request); } @@ -1112,7 +1166,9 @@ public function getFilters(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['filter_id'], $request, 'ml.get_filters'); + return $this->client->sendRequest($request); } @@ -1157,7 +1213,9 @@ public function getInfluencers(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id'], $request, 'ml.get_influencers'); + return $this->client->sendRequest($request); } @@ -1195,7 +1253,9 @@ public function getJobStats(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id'], $request, 'ml.get_job_stats'); + return $this->client->sendRequest($request); } @@ -1234,7 +1294,9 @@ public function getJobs(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id'], $request, 'ml.get_jobs'); + return $this->client->sendRequest($request); } @@ -1273,7 +1335,9 @@ public function getMemoryStats(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['node_id'], $request, 'ml.get_memory_stats'); + return $this->client->sendRequest($request); } @@ -1310,7 +1374,9 @@ public function getModelSnapshotUpgradeStats(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id', 'snapshot_id'], $request, 'ml.get_model_snapshot_upgrade_stats'); + return $this->client->sendRequest($request); } @@ -1358,7 +1424,9 @@ public function getModelSnapshots(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id', 'snapshot_id'], $request, 'ml.get_model_snapshots'); + return $this->client->sendRequest($request); } @@ -1402,7 +1470,9 @@ public function getOverallBuckets(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id'], $request, 'ml.get_overall_buckets'); + return $this->client->sendRequest($request); } @@ -1447,7 +1517,9 @@ public function getRecords(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id'], $request, 'ml.get_records'); + return $this->client->sendRequest($request); } @@ -1492,7 +1564,9 @@ public function getTrainedModels(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['model_id'], $request, 'ml.get_trained_models'); + return $this->client->sendRequest($request); } @@ -1532,7 +1606,9 @@ public function getTrainedModelsStats(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['model_id'], $request, 'ml.get_trained_models_stats'); + return $this->client->sendRequest($request); } @@ -1570,7 +1646,9 @@ public function inferTrainedModel(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['model_id'], $request, 'ml.infer_trained_model'); + return $this->client->sendRequest($request); } @@ -1602,7 +1680,9 @@ public function info(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'ml.info'); + return $this->client->sendRequest($request); } @@ -1639,7 +1719,9 @@ public function openJob(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id'], $request, 'ml.open_job'); + return $this->client->sendRequest($request); } @@ -1676,7 +1758,9 @@ public function postCalendarEvents(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['calendar_id'], $request, 'ml.post_calendar_events'); + return $this->client->sendRequest($request); } @@ -1715,7 +1799,9 @@ public function postData(array $params = []) 'Accept' => 'application/json', 'Content-Type' => isset($params['body']) && (is_string($params['body']) || $this->isAssociativeArray($params['body'])) ? 'application/json' : 'application/x-ndjson', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id'], $request, 'ml.post_data'); + return $this->client->sendRequest($request); } @@ -1754,7 +1840,9 @@ public function previewDataFrameAnalytics(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'ml.preview_data_frame_analytics'); + return $this->client->sendRequest($request); } @@ -1795,7 +1883,9 @@ public function previewDatafeed(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['datafeed_id'], $request, 'ml.preview_datafeed'); + return $this->client->sendRequest($request); } @@ -1832,7 +1922,9 @@ public function putCalendar(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['calendar_id'], $request, 'ml.put_calendar'); + return $this->client->sendRequest($request); } @@ -1868,7 +1960,9 @@ public function putCalendarJob(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['calendar_id', 'job_id'], $request, 'ml.put_calendar_job'); + return $this->client->sendRequest($request); } @@ -1905,7 +1999,9 @@ public function putDataFrameAnalytics(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'ml.put_data_frame_analytics'); + return $this->client->sendRequest($request); } @@ -1946,7 +2042,9 @@ public function putDatafeed(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['datafeed_id'], $request, 'ml.put_datafeed'); + return $this->client->sendRequest($request); } @@ -1983,7 +2081,9 @@ public function putFilter(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['filter_id'], $request, 'ml.put_filter'); + return $this->client->sendRequest($request); } @@ -2024,7 +2124,9 @@ public function putJob(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id'], $request, 'ml.put_job'); + return $this->client->sendRequest($request); } @@ -2063,7 +2165,9 @@ public function putTrainedModel(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['model_id'], $request, 'ml.put_trained_model'); + return $this->client->sendRequest($request); } @@ -2101,7 +2205,9 @@ public function putTrainedModelAlias(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['model_alias', 'model_id'], $request, 'ml.put_trained_model_alias'); + return $this->client->sendRequest($request); } @@ -2139,7 +2245,9 @@ public function putTrainedModelDefinitionPart(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['model_id', 'part'], $request, 'ml.put_trained_model_definition_part'); + return $this->client->sendRequest($request); } @@ -2176,7 +2284,9 @@ public function putTrainedModelVocabulary(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['model_id'], $request, 'ml.put_trained_model_vocabulary'); + return $this->client->sendRequest($request); } @@ -2213,7 +2323,9 @@ public function resetJob(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id'], $request, 'ml.reset_job'); + return $this->client->sendRequest($request); } @@ -2252,7 +2364,9 @@ public function revertModelSnapshot(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id', 'snapshot_id'], $request, 'ml.revert_model_snapshot'); + return $this->client->sendRequest($request); } @@ -2286,7 +2400,9 @@ public function setUpgradeMode(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'ml.set_upgrade_mode'); + return $this->client->sendRequest($request); } @@ -2324,7 +2440,9 @@ public function startDataFrameAnalytics(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'ml.start_data_frame_analytics'); + return $this->client->sendRequest($request); } @@ -2364,7 +2482,9 @@ public function startDatafeed(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['datafeed_id'], $request, 'ml.start_datafeed'); + return $this->client->sendRequest($request); } @@ -2408,7 +2528,9 @@ public function startTrainedModelDeployment(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['model_id'], $request, 'ml.start_trained_model_deployment'); + return $this->client->sendRequest($request); } @@ -2448,7 +2570,9 @@ public function stopDataFrameAnalytics(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'ml.stop_data_frame_analytics'); + return $this->client->sendRequest($request); } @@ -2489,7 +2613,9 @@ public function stopDatafeed(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['datafeed_id'], $request, 'ml.stop_datafeed'); + return $this->client->sendRequest($request); } @@ -2528,7 +2654,9 @@ public function stopTrainedModelDeployment(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['model_id'], $request, 'ml.stop_trained_model_deployment'); + return $this->client->sendRequest($request); } @@ -2565,7 +2693,9 @@ public function updateDataFrameAnalytics(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'ml.update_data_frame_analytics'); + return $this->client->sendRequest($request); } @@ -2606,7 +2736,9 @@ public function updateDatafeed(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['datafeed_id'], $request, 'ml.update_datafeed'); + return $this->client->sendRequest($request); } @@ -2643,7 +2775,9 @@ public function updateFilter(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['filter_id'], $request, 'ml.update_filter'); + return $this->client->sendRequest($request); } @@ -2680,7 +2814,9 @@ public function updateJob(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id'], $request, 'ml.update_job'); + return $this->client->sendRequest($request); } @@ -2718,7 +2854,9 @@ public function updateModelSnapshot(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id', 'snapshot_id'], $request, 'ml.update_model_snapshot'); + return $this->client->sendRequest($request); } @@ -2729,12 +2867,13 @@ public function updateModelSnapshot(array $params = []) * * @param array{ * model_id: string, // (REQUIRED) The unique identifier of the trained model. + * number_of_allocations: int, // Update the model deployment to this number of allocations. * 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 updated trained model deployment settings + * body: array, // The updated trained model deployment settings * } $params * * @throws MissingParameterException if a required parameter is missing @@ -2746,16 +2885,18 @@ public function updateModelSnapshot(array $params = []) */ public function updateTrainedModelDeployment(array $params = []) { - $this->checkRequiredParameters(['model_id','body'], $params); + $this->checkRequiredParameters(['model_id'], $params); $url = '/_ml/trained_models/' . $this->encode($params['model_id']) . '/deployment/_update'; $method = 'POST'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['number_of_allocations','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)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['model_id'], $request, 'ml.update_trained_model_deployment'); + return $this->client->sendRequest($request); } @@ -2793,7 +2934,9 @@ public function upgradeJobSnapshot(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['job_id', 'snapshot_id'], $request, 'ml.upgrade_job_snapshot'); + return $this->client->sendRequest($request); } @@ -2828,7 +2971,9 @@ public function validate(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'ml.validate'); + return $this->client->sendRequest($request); } @@ -2863,6 +3008,8 @@ public function validateDetector(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'ml.validate_detector'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Monitoring.php b/src/Endpoints/Monitoring.php index ff4185c75..c642629a5 100644 --- a/src/Endpoints/Monitoring.php +++ b/src/Endpoints/Monitoring.php @@ -67,6 +67,8 @@ public function bulk(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/x-ndjson', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['type'], $request, 'monitoring.bulk'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Nodes.php b/src/Endpoints/Nodes.php index 7af1b039b..a4f3a93fa 100644 --- a/src/Endpoints/Nodes.php +++ b/src/Endpoints/Nodes.php @@ -61,7 +61,9 @@ public function clearRepositoriesMeteringArchive(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['node_id', 'max_archive_version'], $request, 'nodes.clear_repositories_metering_archive'); + return $this->client->sendRequest($request); } @@ -97,7 +99,9 @@ public function getRepositoriesMeteringInfo(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['node_id'], $request, 'nodes.get_repositories_metering_info'); + return $this->client->sendRequest($request); } @@ -141,7 +145,9 @@ public function hotThreads(array $params = []) $headers = [ 'Accept' => 'text/plain', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['node_id'], $request, 'nodes.hot_threads'); + return $this->client->sendRequest($request); } @@ -187,7 +193,9 @@ public function info(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['node_id', 'metric'], $request, 'nodes.info'); + return $this->client->sendRequest($request); } @@ -227,7 +235,9 @@ public function reloadSecureSettings(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['node_id'], $request, 'nodes.reload_secure_settings'); + return $this->client->sendRequest($request); } @@ -287,7 +297,9 @@ public function stats(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['node_id', 'metric', 'index_metric'], $request, 'nodes.stats'); + return $this->client->sendRequest($request); } @@ -332,6 +344,8 @@ public function usage(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['node_id', 'metric'], $request, 'nodes.usage'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Profiling.php b/src/Endpoints/Profiling.php index b8a287ad1..18c43dac2 100644 --- a/src/Endpoints/Profiling.php +++ b/src/Endpoints/Profiling.php @@ -59,7 +59,9 @@ public function flamegraph(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'profiling.flamegraph'); + return $this->client->sendRequest($request); } @@ -94,7 +96,9 @@ public function stacktraces(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'profiling.stacktraces'); + return $this->client->sendRequest($request); } @@ -129,7 +133,9 @@ public function status(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'profiling.status'); + return $this->client->sendRequest($request); } @@ -164,6 +170,8 @@ public function topnFunctions(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'profiling.topn_functions'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/QueryRules.php b/src/Endpoints/QueryRules.php new file mode 100644 index 000000000..1da8b22f1 --- /dev/null +++ b/src/Endpoints/QueryRules.php @@ -0,0 +1,294 @@ +checkRequiredParameters(['ruleset_id','rule_id'], $params); + $url = '/_query_rules/' . $this->encode($params['ruleset_id']) . '/_rule/' . $this->encode($params['rule_id']); + $method = 'DELETE'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['ruleset_id', 'rule_id'], $request, 'query_rules.delete_rule'); + return $this->client->sendRequest($request); + } + + + /** + * Deletes a query ruleset. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-query-ruleset.html + * + * @param array{ + * ruleset_id: string, // (REQUIRED) The unique identifier of the query ruleset to delete + * 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 deleteRuleset(array $params = []) + { + $this->checkRequiredParameters(['ruleset_id'], $params); + $url = '/_query_rules/' . $this->encode($params['ruleset_id']); + $method = 'DELETE'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['ruleset_id'], $request, 'query_rules.delete_ruleset'); + return $this->client->sendRequest($request); + } + + + /** + * Returns the details about an individual query rule within a ruleset. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-query-rule.html + * + * @param array{ + * ruleset_id: string, // (REQUIRED) The unique identifier of the query ruleset the rule exists within + * rule_id: string, // (REQUIRED) The unique identifier of the rule to be retrieved. + * 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 getRule(array $params = []) + { + $this->checkRequiredParameters(['ruleset_id','rule_id'], $params); + $url = '/_query_rules/' . $this->encode($params['ruleset_id']) . '/_rule/' . $this->encode($params['rule_id']); + $method = 'GET'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['ruleset_id', 'rule_id'], $request, 'query_rules.get_rule'); + return $this->client->sendRequest($request); + } + + + /** + * Returns the details about a query ruleset. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-query-ruleset.html + * + * @param array{ + * ruleset_id: string, // (REQUIRED) The unique identifier of the query ruleset + * 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 getRuleset(array $params = []) + { + $this->checkRequiredParameters(['ruleset_id'], $params); + $url = '/_query_rules/' . $this->encode($params['ruleset_id']); + $method = 'GET'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['ruleset_id'], $request, 'query_rules.get_ruleset'); + return $this->client->sendRequest($request); + } + + + /** + * Lists query rulesets. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/list-query-rulesets.html + * + * @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 listRulesets(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', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'query_rules.list_rulesets'); + return $this->client->sendRequest($request); + } + + + /** + * Creates or updates a query rule within a ruleset. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-query-rule.html + * + * @param array{ + * ruleset_id: string, // (REQUIRED) The unique identifier of the ruleset this rule should be added to. The ruleset will be created if it does not exist. + * rule_id: string, // (REQUIRED) The unique identifier of the rule 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. + * body: array, // (REQUIRED) The query rule configuration, including the type of rule, the criteria to match the rule, and the action that should be taken if the rule matches. + * } $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 putRule(array $params = []) + { + $this->checkRequiredParameters(['ruleset_id','rule_id','body'], $params); + $url = '/_query_rules/' . $this->encode($params['ruleset_id']) . '/_rule/' . $this->encode($params['rule_id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['ruleset_id', 'rule_id'], $request, 'query_rules.put_rule'); + return $this->client->sendRequest($request); + } + + + /** + * Creates or updates a query ruleset. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-query-ruleset.html + * + * @param array{ + * ruleset_id: string, // (REQUIRED) The unique identifier of the ruleset 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. + * body: array, // (REQUIRED) The query ruleset configuration, including `rules` + * } $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 putRuleset(array $params = []) + { + $this->checkRequiredParameters(['ruleset_id','body'], $params); + $url = '/_query_rules/' . $this->encode($params['ruleset_id']); + $method = 'PUT'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['ruleset_id'], $request, 'query_rules.put_ruleset'); + return $this->client->sendRequest($request); + } +} diff --git a/src/Endpoints/QueryRuleset.php b/src/Endpoints/QueryRuleset.php deleted file mode 100644 index ef2857cec..000000000 --- a/src/Endpoints/QueryRuleset.php +++ /dev/null @@ -1,174 +0,0 @@ -checkRequiredParameters(['ruleset_id'], $params); - $url = '/_query_rules/' . $this->encode($params['ruleset_id']); - $method = 'DELETE'; - - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); - $headers = [ - 'Accept' => 'application/json', - ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); - } - - - /** - * Returns the details about a query ruleset. - * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-query-ruleset.html - * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release - * - * @param array{ - * ruleset_id: string, // (REQUIRED) The unique identifier of the query ruleset - * 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(['ruleset_id'], $params); - $url = '/_query_rules/' . $this->encode($params['ruleset_id']); - $method = 'GET'; - - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); - $headers = [ - 'Accept' => 'application/json', - ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); - } - - - /** - * 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. - * - * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-query-ruleset.html - * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release - * - * @param array{ - * ruleset_id: string, // (REQUIRED) The unique identifier of the ruleset 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. - * body: array, // (REQUIRED) The query ruleset configuration, including `rules` - * } $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(['ruleset_id','body'], $params); - $url = '/_query_rules/' . $this->encode($params['ruleset_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)); - } -} diff --git a/src/Endpoints/Rollup.php b/src/Endpoints/Rollup.php index 4fe55d006..e2f00b076 100644 --- a/src/Endpoints/Rollup.php +++ b/src/Endpoints/Rollup.php @@ -60,7 +60,9 @@ public function deleteJob(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'rollup.delete_job'); + return $this->client->sendRequest($request); } @@ -91,14 +93,16 @@ public function getJobs(array $params = []) $url = '/_rollup/job/' . $this->encode($params['id']); $method = 'GET'; } else { - $url = '/_rollup/job/'; + $url = '/_rollup/job'; $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)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'rollup.get_jobs'); + return $this->client->sendRequest($request); } @@ -129,14 +133,16 @@ public function getRollupCaps(array $params = []) $url = '/_rollup/data/' . $this->encode($params['id']); $method = 'GET'; } else { - $url = '/_rollup/data/'; + $url = '/_rollup/data'; $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)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'rollup.get_rollup_caps'); + return $this->client->sendRequest($request); } @@ -172,7 +178,9 @@ public function getRollupIndexCaps(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'rollup.get_rollup_index_caps'); + return $this->client->sendRequest($request); } @@ -210,7 +218,9 @@ public function putJob(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'rollup.put_job'); + return $this->client->sendRequest($request); } @@ -250,7 +260,9 @@ public function rollupSearch(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'rollup.rollup_search'); + return $this->client->sendRequest($request); } @@ -286,7 +298,9 @@ public function startJob(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'rollup.start_job'); + return $this->client->sendRequest($request); } @@ -324,6 +338,8 @@ public function stopJob(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'rollup.stop_job'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/SearchApplication.php b/src/Endpoints/SearchApplication.php index e7769e2a6..fe70863a1 100644 --- a/src/Endpoints/SearchApplication.php +++ b/src/Endpoints/SearchApplication.php @@ -60,7 +60,9 @@ public function delete(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'search_application.delete'); + return $this->client->sendRequest($request); } @@ -96,7 +98,9 @@ public function deleteBehavioralAnalytics(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'search_application.delete_behavioral_analytics'); + return $this->client->sendRequest($request); } @@ -132,7 +136,9 @@ public function get(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'search_application.get'); + return $this->client->sendRequest($request); } @@ -170,7 +176,9 @@ public function getBehavioralAnalytics(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'search_application.get_behavioral_analytics'); + return $this->client->sendRequest($request); } @@ -206,7 +214,9 @@ public function list(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'search_application.list'); + return $this->client->sendRequest($request); } @@ -246,7 +256,9 @@ public function postBehavioralAnalyticsEvent(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['collection_name', 'event_type'], $request, 'search_application.post_behavioral_analytics_event'); + return $this->client->sendRequest($request); } @@ -285,7 +297,9 @@ public function put(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'search_application.put'); + return $this->client->sendRequest($request); } @@ -321,7 +335,9 @@ public function putBehavioralAnalytics(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'search_application.put_behavioral_analytics'); + return $this->client->sendRequest($request); } @@ -359,7 +375,9 @@ public function renderQuery(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'search_application.render_query'); + return $this->client->sendRequest($request); } @@ -398,6 +416,8 @@ public function search(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'search_application.search'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/SearchableSnapshots.php b/src/Endpoints/SearchableSnapshots.php index aae90e659..7eac97558 100644 --- a/src/Endpoints/SearchableSnapshots.php +++ b/src/Endpoints/SearchableSnapshots.php @@ -62,7 +62,9 @@ public function cacheStats(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['node_id'], $request, 'searchable_snapshots.cache_stats'); + return $this->client->sendRequest($request); } @@ -103,7 +105,9 @@ public function clearCache(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'searchable_snapshots.clear_cache'); + return $this->client->sendRequest($request); } @@ -144,7 +148,9 @@ public function mount(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['repository', 'snapshot'], $request, 'searchable_snapshots.mount'); + return $this->client->sendRequest($request); } @@ -182,6 +188,8 @@ public function stats(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'searchable_snapshots.stats'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Security.php b/src/Endpoints/Security.php index 8a6e01359..6841eb65c 100644 --- a/src/Endpoints/Security.php +++ b/src/Endpoints/Security.php @@ -59,7 +59,9 @@ public function activateUserProfile(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.activate_user_profile'); + return $this->client->sendRequest($request); } @@ -91,7 +93,85 @@ public function authenticate(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.authenticate'); + return $this->client->sendRequest($request); + } + + + /** + * Bulk delete roles in the native realm. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-bulk-delete-role.html + * + * @param array{ + * refresh: enum, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * 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 roles to delete + * } $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 bulkDeleteRole(array $params = []) + { + $this->checkRequiredParameters(['body'], $params); + $url = '/_security/role'; + $method = 'DELETE'; + + $url = $this->addQueryString($url, $params, ['refresh','pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.bulk_delete_role'); + return $this->client->sendRequest($request); + } + + + /** + * Bulk adds and updates roles in the native realm. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-bulk-put-role.html + * + * @param array{ + * refresh: enum, // If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * 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 roles to add + * } $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 bulkPutRole(array $params = []) + { + $this->checkRequiredParameters(['body'], $params); + $url = '/_security/role'; + $method = 'POST'; + + $url = $this->addQueryString($url, $params, ['refresh','pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.bulk_put_role'); + return $this->client->sendRequest($request); } @@ -126,7 +206,9 @@ public function bulkUpdateApiKeys(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.bulk_update_api_keys'); + return $this->client->sendRequest($request); } @@ -167,7 +249,9 @@ public function changePassword(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['username'], $request, 'security.change_password'); + return $this->client->sendRequest($request); } @@ -202,7 +286,9 @@ public function clearApiKeyCache(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['ids'], $request, 'security.clear_api_key_cache'); + return $this->client->sendRequest($request); } @@ -237,7 +323,9 @@ public function clearCachedPrivileges(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['application'], $request, 'security.clear_cached_privileges'); + return $this->client->sendRequest($request); } @@ -273,7 +361,9 @@ public function clearCachedRealms(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['realms'], $request, 'security.clear_cached_realms'); + return $this->client->sendRequest($request); } @@ -308,7 +398,9 @@ public function clearCachedRoles(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'security.clear_cached_roles'); + return $this->client->sendRequest($request); } @@ -345,7 +437,9 @@ public function clearCachedServiceTokens(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['namespace', 'service', 'name'], $request, 'security.clear_cached_service_tokens'); + return $this->client->sendRequest($request); } @@ -381,7 +475,9 @@ public function createApiKey(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.create_api_key'); + return $this->client->sendRequest($request); } @@ -416,7 +512,9 @@ public function createCrossClusterApiKey(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.create_cross_cluster_api_key'); + return $this->client->sendRequest($request); } @@ -458,7 +556,9 @@ public function createServiceToken(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['namespace', 'service', 'name'], $request, 'security.create_service_token'); + return $this->client->sendRequest($request); } @@ -495,7 +595,9 @@ public function deletePrivileges(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['application', 'name'], $request, 'security.delete_privileges'); + return $this->client->sendRequest($request); } @@ -531,7 +633,9 @@ public function deleteRole(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'security.delete_role'); + return $this->client->sendRequest($request); } @@ -567,7 +671,9 @@ public function deleteRoleMapping(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'security.delete_role_mapping'); + return $this->client->sendRequest($request); } @@ -605,7 +711,9 @@ public function deleteServiceToken(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['namespace', 'service', 'name'], $request, 'security.delete_service_token'); + return $this->client->sendRequest($request); } @@ -641,7 +749,9 @@ public function deleteUser(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['username'], $request, 'security.delete_user'); + return $this->client->sendRequest($request); } @@ -677,7 +787,9 @@ public function disableUser(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['username'], $request, 'security.disable_user'); + return $this->client->sendRequest($request); } @@ -713,7 +825,9 @@ public function disableUserProfile(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['uid'], $request, 'security.disable_user_profile'); + return $this->client->sendRequest($request); } @@ -749,7 +863,9 @@ public function enableUser(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['username'], $request, 'security.enable_user'); + return $this->client->sendRequest($request); } @@ -785,7 +901,9 @@ public function enableUserProfile(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['uid'], $request, 'security.enable_user_profile'); + return $this->client->sendRequest($request); } @@ -818,7 +936,9 @@ public function enrollKibana(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.enroll_kibana'); + return $this->client->sendRequest($request); } @@ -851,7 +971,9 @@ public function enrollNode(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.enroll_node'); + return $this->client->sendRequest($request); } @@ -891,7 +1013,9 @@ public function getApiKey(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.get_api_key'); + return $this->client->sendRequest($request); } @@ -923,7 +1047,9 @@ public function getBuiltinPrivileges(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.get_builtin_privileges'); + return $this->client->sendRequest($request); } @@ -964,7 +1090,9 @@ public function getPrivileges(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['application', 'name'], $request, 'security.get_privileges'); + return $this->client->sendRequest($request); } @@ -1001,7 +1129,9 @@ public function getRole(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'security.get_role'); + return $this->client->sendRequest($request); } @@ -1038,7 +1168,9 @@ public function getRoleMapping(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'security.get_role_mapping'); + return $this->client->sendRequest($request); } @@ -1079,7 +1211,9 @@ public function getServiceAccounts(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['namespace', 'service'], $request, 'security.get_service_accounts'); + return $this->client->sendRequest($request); } @@ -1115,7 +1249,9 @@ public function getServiceCredentials(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['namespace', 'service'], $request, 'security.get_service_credentials'); + return $this->client->sendRequest($request); } @@ -1125,6 +1261,7 @@ public function getServiceCredentials(array $params = []) * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-settings.html * * @param array{ + * master_timeout: time, // 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) @@ -1143,12 +1280,14 @@ public function getSettings(array $params = []) $url = '/_security/settings'; $method = 'GET'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','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)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.get_settings'); + return $this->client->sendRequest($request); } @@ -1183,7 +1322,9 @@ public function getToken(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.get_token'); + return $this->client->sendRequest($request); } @@ -1221,7 +1362,9 @@ public function getUser(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['username'], $request, 'security.get_user'); + return $this->client->sendRequest($request); } @@ -1253,7 +1396,9 @@ public function getUserPrivileges(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.get_user_privileges'); + return $this->client->sendRequest($request); } @@ -1289,7 +1434,9 @@ public function getUserProfile(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['uid'], $request, 'security.get_user_profile'); + return $this->client->sendRequest($request); } @@ -1325,7 +1472,9 @@ public function grantApiKey(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.grant_api_key'); + return $this->client->sendRequest($request); } @@ -1365,7 +1514,9 @@ public function hasPrivileges(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['user'], $request, 'security.has_privileges'); + return $this->client->sendRequest($request); } @@ -1400,7 +1551,9 @@ public function hasPrivilegesUserProfile(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.has_privileges_user_profile'); + return $this->client->sendRequest($request); } @@ -1435,7 +1588,9 @@ public function invalidateApiKey(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.invalidate_api_key'); + return $this->client->sendRequest($request); } @@ -1470,7 +1625,9 @@ public function invalidateToken(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.invalidate_token'); + return $this->client->sendRequest($request); } @@ -1505,7 +1662,9 @@ public function oidcAuthenticate(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.oidc_authenticate'); + return $this->client->sendRequest($request); } @@ -1540,7 +1699,9 @@ public function oidcLogout(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.oidc_logout'); + return $this->client->sendRequest($request); } @@ -1575,7 +1736,9 @@ public function oidcPrepareAuthentication(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.oidc_prepare_authentication'); + return $this->client->sendRequest($request); } @@ -1603,7 +1766,7 @@ public function oidcPrepareAuthentication(array $params = []) public function putPrivileges(array $params = []) { $this->checkRequiredParameters(['body'], $params); - $url = '/_security/privilege/'; + $url = '/_security/privilege'; $method = 'PUT'; $url = $this->addQueryString($url, $params, ['refresh','pretty','human','error_trace','source','filter_path']); @@ -1611,7 +1774,9 @@ public function putPrivileges(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.put_privileges'); + return $this->client->sendRequest($request); } @@ -1649,7 +1814,9 @@ public function putRole(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'security.put_role'); + return $this->client->sendRequest($request); } @@ -1687,7 +1854,9 @@ public function putRoleMapping(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['name'], $request, 'security.put_role_mapping'); + return $this->client->sendRequest($request); } @@ -1725,7 +1894,9 @@ public function putUser(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['username'], $request, 'security.put_user'); + return $this->client->sendRequest($request); } @@ -1762,7 +1933,45 @@ public function queryApiKeys(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.query_api_keys'); + return $this->client->sendRequest($request); + } + + + /** + * Retrieves information for Roles using a subset of query DSL + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-query-role.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, // 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 queryRole(array $params = []) + { + $url = '/_security/_query/role'; + $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', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.query_role'); + return $this->client->sendRequest($request); } @@ -1797,7 +2006,9 @@ public function queryUser(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.query_user'); + return $this->client->sendRequest($request); } @@ -1832,7 +2043,9 @@ public function samlAuthenticate(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.saml_authenticate'); + return $this->client->sendRequest($request); } @@ -1867,7 +2080,9 @@ public function samlCompleteLogout(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.saml_complete_logout'); + return $this->client->sendRequest($request); } @@ -1902,7 +2117,9 @@ public function samlInvalidate(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.saml_invalidate'); + return $this->client->sendRequest($request); } @@ -1937,7 +2154,9 @@ public function samlLogout(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.saml_logout'); + return $this->client->sendRequest($request); } @@ -1972,7 +2191,9 @@ public function samlPrepareAuthentication(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.saml_prepare_authentication'); + return $this->client->sendRequest($request); } @@ -2008,7 +2229,9 @@ public function samlServiceProviderMetadata(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['realm_name'], $request, 'security.saml_service_provider_metadata'); + return $this->client->sendRequest($request); } @@ -2043,7 +2266,9 @@ public function suggestUserProfiles(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.suggest_user_profiles'); + return $this->client->sendRequest($request); } @@ -2080,7 +2305,9 @@ public function updateApiKey(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'security.update_api_key'); + return $this->client->sendRequest($request); } @@ -2117,7 +2344,9 @@ public function updateCrossClusterApiKey(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'security.update_cross_cluster_api_key'); + return $this->client->sendRequest($request); } @@ -2127,6 +2356,8 @@ public function updateCrossClusterApiKey(array $params = []) * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-update-settings.html * * @param array{ + * master_timeout: time, // Timeout for connection to master + * timeout: time, // Timeout for acknowledgements from all nodes * 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) @@ -2147,12 +2378,14 @@ public function updateSettings(array $params = []) $url = '/_security/settings'; $method = 'PUT'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','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)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'security.update_settings'); + return $this->client->sendRequest($request); } @@ -2192,6 +2425,8 @@ public function updateUserProfileData(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['uid'], $request, 'security.update_user_profile_data'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Shutdown.php b/src/Endpoints/Shutdown.php index 2c9e55e87..a03144389 100644 --- a/src/Endpoints/Shutdown.php +++ b/src/Endpoints/Shutdown.php @@ -60,7 +60,9 @@ public function deleteNode(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['node_id'], $request, 'shutdown.delete_node'); + return $this->client->sendRequest($request); } @@ -71,6 +73,7 @@ public function deleteNode(array $params = []) * * @param array{ * node_id: string, // Which node for which to retrieve the shutdown status + * master_timeout: time, // Timeout for processing on master node * 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) @@ -93,12 +96,14 @@ public function getNode(array $params = []) $url = '/_nodes/shutdown'; $method = 'GET'; } - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','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)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['node_id'], $request, 'shutdown.get_node'); + return $this->client->sendRequest($request); } @@ -135,6 +140,8 @@ public function putNode(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['node_id'], $request, 'shutdown.put_node'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Simulate.php b/src/Endpoints/Simulate.php index cded13a69..02b987137 100644 --- a/src/Endpoints/Simulate.php +++ b/src/Endpoints/Simulate.php @@ -66,6 +66,8 @@ public function ingest(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'simulate.ingest'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Slm.php b/src/Endpoints/Slm.php index 2050a370d..48369ae79 100644 --- a/src/Endpoints/Slm.php +++ b/src/Endpoints/Slm.php @@ -59,7 +59,9 @@ public function deleteLifecycle(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['policy_id'], $request, 'slm.delete_lifecycle'); + return $this->client->sendRequest($request); } @@ -94,7 +96,9 @@ public function executeLifecycle(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['policy_id'], $request, 'slm.execute_lifecycle'); + return $this->client->sendRequest($request); } @@ -126,7 +130,9 @@ public function executeRetention(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'slm.execute_retention'); + return $this->client->sendRequest($request); } @@ -163,7 +169,9 @@ public function getLifecycle(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['policy_id'], $request, 'slm.get_lifecycle'); + return $this->client->sendRequest($request); } @@ -195,7 +203,9 @@ public function getStats(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'slm.get_stats'); + return $this->client->sendRequest($request); } @@ -227,7 +237,9 @@ public function getStatus(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'slm.get_status'); + return $this->client->sendRequest($request); } @@ -264,7 +276,9 @@ public function putLifecycle(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['policy_id'], $request, 'slm.put_lifecycle'); + return $this->client->sendRequest($request); } @@ -274,6 +288,8 @@ public function putLifecycle(array $params = []) * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-start.html * * @param array{ + * master_timeout: time, // Timeout for processing on master node + * timeout: time, // Timeout for acknowledgement of update from all nodes in cluster * 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) @@ -292,11 +308,13 @@ public function start(array $params = []) $url = '/_slm/start'; $method = 'POST'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'slm.start'); + return $this->client->sendRequest($request); } @@ -306,6 +324,8 @@ public function start(array $params = []) * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-stop.html * * @param array{ + * master_timeout: time, // Timeout for processing on master node + * timeout: time, // Timeout for acknowledgement of update from all nodes in cluster * 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) @@ -324,10 +344,12 @@ public function stop(array $params = []) $url = '/_slm/stop'; $method = 'POST'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','timeout','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'slm.stop'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Snapshot.php b/src/Endpoints/Snapshot.php index f2732da66..331d36295 100644 --- a/src/Endpoints/Snapshot.php +++ b/src/Endpoints/Snapshot.php @@ -61,7 +61,9 @@ public function cleanupRepository(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['repository'], $request, 'snapshot.cleanup_repository'); + return $this->client->sendRequest($request); } @@ -101,7 +103,9 @@ public function clone(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['repository', 'snapshot', 'target_snapshot'], $request, 'snapshot.clone'); + return $this->client->sendRequest($request); } @@ -141,7 +145,9 @@ public function create(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['repository', 'snapshot'], $request, 'snapshot.create'); + return $this->client->sendRequest($request); } @@ -181,7 +187,9 @@ public function createRepository(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['repository'], $request, 'snapshot.create_repository'); + return $this->client->sendRequest($request); } @@ -194,6 +202,7 @@ public function createRepository(array $params = []) * repository: string, // (REQUIRED) A repository name * snapshot: list, // (REQUIRED) A comma-separated list of snapshot names * master_timeout: time, // Explicit operation timeout for connection to master node + * wait_for_completion: boolean, // Should this request wait until the operation has completed before returning * 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) @@ -214,11 +223,13 @@ public function delete(array $params = []) $url = '/_snapshot/' . $this->encode($params['repository']) . '/' . $this->encode($params['snapshot']); $method = 'DELETE'; - $url = $this->addQueryString($url, $params, ['master_timeout','pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','wait_for_completion','pretty','human','error_trace','source','filter_path']); $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['repository', 'snapshot'], $request, 'snapshot.delete'); + return $this->client->sendRequest($request); } @@ -255,7 +266,9 @@ public function deleteRepository(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['repository'], $request, 'snapshot.delete_repository'); + return $this->client->sendRequest($request); } @@ -304,7 +317,9 @@ public function get(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['repository', 'snapshot'], $request, 'snapshot.get'); + return $this->client->sendRequest($request); } @@ -343,7 +358,9 @@ public function getRepository(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['repository'], $request, 'snapshot.get_repository'); + return $this->client->sendRequest($request); } @@ -389,7 +406,9 @@ public function repositoryAnalyze(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['repository'], $request, 'snapshot.repository_analyze'); + return $this->client->sendRequest($request); } @@ -429,7 +448,9 @@ public function restore(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['repository', 'snapshot'], $request, 'snapshot.restore'); + return $this->client->sendRequest($request); } @@ -472,7 +493,9 @@ public function status(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['repository', 'snapshot'], $request, 'snapshot.status'); + return $this->client->sendRequest($request); } @@ -509,6 +532,8 @@ public function verifyRepository(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['repository'], $request, 'snapshot.verify_repository'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Sql.php b/src/Endpoints/Sql.php index 9be51a83e..1524f3da6 100644 --- a/src/Endpoints/Sql.php +++ b/src/Endpoints/Sql.php @@ -59,7 +59,9 @@ public function clearCursor(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'sql.clear_cursor'); + return $this->client->sendRequest($request); } @@ -94,7 +96,9 @@ public function deleteAsync(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'sql.delete_async'); + return $this->client->sendRequest($request); } @@ -133,7 +137,9 @@ public function getAsync(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'sql.get_async'); + return $this->client->sendRequest($request); } @@ -168,7 +174,9 @@ public function getAsyncStatus(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'sql.get_async_status'); + return $this->client->sendRequest($request); } @@ -204,7 +212,9 @@ public function query(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'sql.query'); + return $this->client->sendRequest($request); } @@ -239,6 +249,8 @@ public function translate(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'sql.translate'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Ssl.php b/src/Endpoints/Ssl.php index 5de7475e4..81ca3786e 100644 --- a/src/Endpoints/Ssl.php +++ b/src/Endpoints/Ssl.php @@ -56,6 +56,8 @@ public function certificates(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'ssl.certificates'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Synonyms.php b/src/Endpoints/Synonyms.php index a99f30aff..8f79597e7 100644 --- a/src/Endpoints/Synonyms.php +++ b/src/Endpoints/Synonyms.php @@ -59,7 +59,9 @@ public function deleteSynonym(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'synonyms.delete_synonym'); + return $this->client->sendRequest($request); } @@ -96,7 +98,9 @@ public function deleteSynonymRule(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['set_id', 'rule_id'], $request, 'synonyms.delete_synonym_rule'); + return $this->client->sendRequest($request); } @@ -133,7 +137,9 @@ public function getSynonym(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'synonyms.get_synonym'); + return $this->client->sendRequest($request); } @@ -170,7 +176,9 @@ public function getSynonymRule(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['set_id', 'rule_id'], $request, 'synonyms.get_synonym_rule'); + return $this->client->sendRequest($request); } @@ -204,7 +212,9 @@ public function getSynonymsSets(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'synonyms.get_synonyms_sets'); + return $this->client->sendRequest($request); } @@ -241,7 +251,9 @@ public function putSynonym(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'synonyms.put_synonym'); + return $this->client->sendRequest($request); } @@ -279,6 +291,8 @@ public function putSynonymRule(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['set_id', 'rule_id'], $request, 'synonyms.put_synonym_rule'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Tasks.php b/src/Endpoints/Tasks.php index 6097bdc13..a305f5c54 100644 --- a/src/Endpoints/Tasks.php +++ b/src/Endpoints/Tasks.php @@ -66,7 +66,9 @@ public function cancel(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['task_id'], $request, 'tasks.cancel'); + return $this->client->sendRequest($request); } @@ -104,7 +106,9 @@ public function get(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['task_id'], $request, 'tasks.get'); + return $this->client->sendRequest($request); } @@ -144,6 +148,8 @@ public function list(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'tasks.list'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/TextStructure.php b/src/Endpoints/TextStructure.php index 6bfa564a3..a9e121ecd 100644 --- a/src/Endpoints/TextStructure.php +++ b/src/Endpoints/TextStructure.php @@ -71,7 +71,9 @@ public function findFieldStructure(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'text_structure.find_field_structure'); + return $this->client->sendRequest($request); } @@ -117,7 +119,9 @@ public function findMessageStructure(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'text_structure.find_message_structure'); + return $this->client->sendRequest($request); } @@ -167,7 +171,9 @@ public function findStructure(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/x-ndjson', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'text_structure.find_structure'); + return $this->client->sendRequest($request); } @@ -203,6 +209,8 @@ public function testGrokPattern(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'text_structure.test_grok_pattern'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Transform.php b/src/Endpoints/Transform.php index 660457db9..653a8c5a7 100644 --- a/src/Endpoints/Transform.php +++ b/src/Endpoints/Transform.php @@ -62,7 +62,43 @@ public function deleteTransform(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['transform_id'], $request, 'transform.delete_transform'); + return $this->client->sendRequest($request); + } + + + /** + * Retrieves transform usage information for transform nodes. + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform-node-stats.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 getNodeStats(array $params = []) + { + $url = '/_transform/_node_stats'; + $method = 'GET'; + + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $headers = [ + 'Accept' => 'application/json', + ]; + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'transform.get_node_stats'); + return $this->client->sendRequest($request); } @@ -103,7 +139,9 @@ public function getTransform(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['transform_id'], $request, 'transform.get_transform'); + return $this->client->sendRequest($request); } @@ -142,7 +180,9 @@ public function getTransformStats(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['transform_id'], $request, 'transform.get_transform_stats'); + return $this->client->sendRequest($request); } @@ -182,7 +222,9 @@ public function previewTransform(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['transform_id'], $request, 'transform.preview_transform'); + return $this->client->sendRequest($request); } @@ -221,7 +263,9 @@ public function putTransform(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['transform_id'], $request, 'transform.put_transform'); + return $this->client->sendRequest($request); } @@ -258,7 +302,9 @@ public function resetTransform(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['transform_id'], $request, 'transform.reset_transform'); + return $this->client->sendRequest($request); } @@ -295,7 +341,9 @@ public function scheduleNowTransform(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['transform_id'], $request, 'transform.schedule_now_transform'); + return $this->client->sendRequest($request); } @@ -332,7 +380,9 @@ public function startTransform(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['transform_id'], $request, 'transform.start_transform'); + return $this->client->sendRequest($request); } @@ -372,7 +422,9 @@ public function stopTransform(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['transform_id'], $request, 'transform.stop_transform'); + return $this->client->sendRequest($request); } @@ -411,7 +463,9 @@ public function updateTransform(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['transform_id'], $request, 'transform.update_transform'); + return $this->client->sendRequest($request); } @@ -446,6 +500,8 @@ public function upgradeTransforms(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'transform.upgrade_transforms'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Watcher.php b/src/Endpoints/Watcher.php index 810cc15cb..872179a64 100644 --- a/src/Endpoints/Watcher.php +++ b/src/Endpoints/Watcher.php @@ -64,7 +64,9 @@ public function ackWatch(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['watch_id', 'action_id'], $request, 'watcher.ack_watch'); + return $this->client->sendRequest($request); } @@ -99,7 +101,9 @@ public function activateWatch(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['watch_id'], $request, 'watcher.activate_watch'); + return $this->client->sendRequest($request); } @@ -134,7 +138,9 @@ public function deactivateWatch(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['watch_id'], $request, 'watcher.deactivate_watch'); + return $this->client->sendRequest($request); } @@ -169,7 +175,9 @@ public function deleteWatch(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'watcher.delete_watch'); + return $this->client->sendRequest($request); } @@ -209,7 +217,9 @@ public function executeWatch(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'watcher.execute_watch'); + return $this->client->sendRequest($request); } @@ -219,6 +229,7 @@ public function executeWatch(array $params = []) * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-get-settings.html * * @param array{ + * 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) @@ -237,12 +248,14 @@ public function getSettings(array $params = []) $url = '/_watcher/settings'; $method = 'GET'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['master_timeout','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)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'watcher.get_settings'); + return $this->client->sendRequest($request); } @@ -277,7 +290,9 @@ public function getWatch(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'watcher.get_watch'); + return $this->client->sendRequest($request); } @@ -318,7 +333,9 @@ public function putWatch(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'watcher.put_watch'); + return $this->client->sendRequest($request); } @@ -352,7 +369,9 @@ public function queryWatches(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'watcher.query_watches'); + return $this->client->sendRequest($request); } @@ -362,6 +381,7 @@ public function queryWatches(array $params = []) * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-start.html * * @param array{ + * 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) @@ -380,11 +400,13 @@ public function start(array $params = []) $url = '/_watcher/_start'; $method = 'POST'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['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)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'watcher.start'); + return $this->client->sendRequest($request); } @@ -422,7 +444,9 @@ public function stats(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['metric'], $request, 'watcher.stats'); + return $this->client->sendRequest($request); } @@ -432,6 +456,7 @@ public function stats(array $params = []) * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stop.html * * @param array{ + * 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) @@ -450,11 +475,13 @@ public function stop(array $params = []) $url = '/_watcher/_stop'; $method = 'POST'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['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)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'watcher.stop'); + return $this->client->sendRequest($request); } @@ -464,6 +491,8 @@ public function stop(array $params = []) * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-update-settings.html * * @param array{ + * timeout: time, // Specify timeout for waiting for acknowledgement from all nodes + * 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) @@ -484,11 +513,13 @@ public function updateSettings(array $params = []) $url = '/_watcher/settings'; $method = 'PUT'; - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); + $url = $this->addQueryString($url, $params, ['timeout','master_timeout','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)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'watcher.update_settings'); + return $this->client->sendRequest($request); } } diff --git a/src/Endpoints/Xpack.php b/src/Endpoints/Xpack.php index 7095ad637..19b17f25e 100644 --- a/src/Endpoints/Xpack.php +++ b/src/Endpoints/Xpack.php @@ -58,7 +58,9 @@ public function info(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'xpack.info'); + return $this->client->sendRequest($request); } @@ -91,6 +93,8 @@ public function usage(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'xpack.usage'); + return $this->client->sendRequest($request); } } diff --git a/src/Traits/ClientEndpointsTrait.php b/src/Traits/ClientEndpointsTrait.php index 7a850486f..e2cfe6199 100644 --- a/src/Traits/ClientEndpointsTrait.php +++ b/src/Traits/ClientEndpointsTrait.php @@ -76,7 +76,9 @@ public function bulk(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/x-ndjson', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'bulk'); + return $this->sendRequest($request); } @@ -115,7 +117,9 @@ public function clearScroll(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['scroll_id'], $request, 'clear_scroll'); + return $this->sendRequest($request); } @@ -149,7 +153,9 @@ public function closePointInTime(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'close_point_in_time'); + return $this->sendRequest($request); } @@ -202,7 +208,9 @@ public function count(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'count'); + return $this->sendRequest($request); } @@ -249,7 +257,9 @@ public function create(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id', 'index'], $request, 'create'); + return $this->sendRequest($request); } @@ -293,7 +303,9 @@ public function delete(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id', 'index'], $request, 'delete'); + return $this->sendRequest($request); } @@ -359,7 +371,9 @@ public function deleteByQuery(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'delete_by_query'); + return $this->sendRequest($request); } @@ -395,7 +409,9 @@ public function deleteByQueryRethrottle(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['task_id'], $request, 'delete_by_query_rethrottle'); + return $this->sendRequest($request); } @@ -432,7 +448,9 @@ public function deleteScript(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'delete_script'); + return $this->sendRequest($request); } @@ -478,7 +496,9 @@ public function exists(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id', 'index'], $request, 'exists'); + return $this->sendRequest($request); } @@ -523,7 +543,9 @@ public function existsSource(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id', 'index'], $request, 'exists_source'); + return $this->sendRequest($request); } @@ -573,7 +595,9 @@ public function explain(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id', 'index'], $request, 'explain'); + return $this->sendRequest($request); } @@ -620,7 +644,9 @@ public function fieldCaps(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'field_caps'); + return $this->sendRequest($request); } @@ -667,7 +693,9 @@ public function get(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id', 'index'], $request, 'get'); + return $this->sendRequest($request); } @@ -703,7 +731,9 @@ public function getScript(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'get_script'); + return $this->sendRequest($request); } @@ -735,7 +765,9 @@ public function getScriptContext(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'get_script_context'); + return $this->sendRequest($request); } @@ -767,7 +799,9 @@ public function getScriptLanguages(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'get_script_languages'); + return $this->sendRequest($request); } @@ -812,7 +846,9 @@ public function getSource(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id', 'index'], $request, 'get_source'); + return $this->sendRequest($request); } @@ -852,7 +888,9 @@ public function healthReport(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['feature'], $request, 'health_report'); + return $this->sendRequest($request); } @@ -906,7 +944,9 @@ public function index(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id', 'index'], $request, 'index'); + return $this->sendRequest($request); } @@ -938,7 +978,9 @@ public function info(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'info'); + return $this->sendRequest($request); } @@ -977,7 +1019,9 @@ public function knnSearch(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'knn_search'); + return $this->sendRequest($request); } @@ -1026,7 +1070,9 @@ public function mget(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'mget'); + return $this->sendRequest($request); } @@ -1073,7 +1119,9 @@ public function msearch(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/x-ndjson', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'msearch'); + return $this->sendRequest($request); } @@ -1118,7 +1166,9 @@ public function msearchTemplate(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/x-ndjson', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'msearch_template'); + return $this->sendRequest($request); } @@ -1169,7 +1219,9 @@ public function mtermvectors(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'mtermvectors'); + return $this->sendRequest($request); } @@ -1211,7 +1263,9 @@ public function openPointInTime(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'open_point_in_time'); + return $this->sendRequest($request); } @@ -1243,7 +1297,9 @@ public function ping(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'ping'); + return $this->sendRequest($request); } @@ -1287,7 +1343,9 @@ public function putScript(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id', 'context'], $request, 'put_script'); + return $this->sendRequest($request); } @@ -1331,7 +1389,9 @@ public function rankEval(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'rank_eval'); + return $this->sendRequest($request); } @@ -1376,7 +1436,9 @@ public function reindex(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'reindex'); + return $this->sendRequest($request); } @@ -1412,7 +1474,9 @@ public function reindexRethrottle(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['task_id'], $request, 'reindex_rethrottle'); + return $this->sendRequest($request); } @@ -1451,7 +1515,9 @@ public function renderSearchTemplate(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id'], $request, 'render_search_template'); + return $this->sendRequest($request); } @@ -1486,7 +1552,9 @@ public function scriptsPainlessExecute(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, [], $request, 'scripts_painless_execute'); + return $this->sendRequest($request); } @@ -1527,7 +1595,9 @@ public function scroll(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['scroll_id'], $request, 'scroll'); + return $this->sendRequest($request); } @@ -1611,7 +1681,9 @@ public function search(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'search'); + return $this->sendRequest($request); } @@ -1660,7 +1732,9 @@ public function searchMvt(array $params = []) 'Accept' => 'application/vnd.mapbox-vector-tile', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index', 'field', 'zoom', 'x', 'y'], $request, 'search_mvt'); + return $this->sendRequest($request); } @@ -1703,7 +1777,9 @@ public function searchShards(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'search_shards'); + return $this->sendRequest($request); } @@ -1756,7 +1832,9 @@ public function searchTemplate(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'search_template'); + return $this->sendRequest($request); } @@ -1793,7 +1871,9 @@ public function termsEnum(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'terms_enum'); + return $this->sendRequest($request); } @@ -1846,7 +1926,9 @@ public function termvectors(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index', 'id'], $request, 'termvectors'); + return $this->sendRequest($request); } @@ -1896,7 +1978,9 @@ public function update(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['id', 'index'], $request, 'update'); + return $this->sendRequest($request); } @@ -1965,7 +2049,9 @@ public function updateByQuery(array $params = []) 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['index'], $request, 'update_by_query'); + return $this->sendRequest($request); } @@ -2001,6 +2087,8 @@ public function updateByQueryRethrottle(array $params = []) $headers = [ 'Accept' => 'application/json', ]; - return $this->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); + $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null); + $request = $this->addOtelAttributes($params, ['task_id'], $request, 'update_by_query_rethrottle'); + return $this->sendRequest($request); } } diff --git a/src/Traits/EndpointTrait.php b/src/Traits/EndpointTrait.php index 8a67b83d5..5aa2ca652 100644 --- a/src/Traits/EndpointTrait.php +++ b/src/Traits/EndpointTrait.php @@ -18,10 +18,12 @@ use Elastic\Elasticsearch\Exception\ContentTypeException; use Elastic\Elasticsearch\Exception\MissingParameterException; use Elastic\Elasticsearch\Utility; +use Elastic\Transport\OpenTelemetry; use Elastic\Transport\Serializer\JsonSerializer; use Elastic\Transport\Serializer\NDJsonSerializer; use Http\Discovery\Psr17FactoryDiscovery; use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ServerRequestInterface; use function http_build_query; use function strpos; @@ -29,6 +31,19 @@ trait EndpointTrait { + const SEARCH_ENDPOINTS = [ + 'search', + 'async_search.submit', + 'msearch', + 'eql.search', + 'terms_enum', + 'search_template', + 'msearch_template', + 'render_search_template', + 'esql.query', + 'knnSearch' + ]; + /** * Check if an array containts nested array */ @@ -129,10 +144,10 @@ protected function bodySerialize($body, string $contentType): string */ protected function createRequest(string $method, string $url, array $headers, $body = null): RequestInterface { - $requestFactory = Psr17FactoryDiscovery::findRequestFactory(); + $requestFactory = Psr17FactoryDiscovery::findServerRequestFactory(); $streamFactory = Psr17FactoryDiscovery::findStreamFactory(); - $request = $requestFactory->createRequest($method, $url); + $request = $requestFactory->createServerRequest($method, $url); // Body request if (!empty($body)) { if (!isset($headers['Content-Type'])) { @@ -194,4 +209,39 @@ protected function checkRequiredParameters(array $required, array $params): void } } } + + /** + * Add the OpenTelemetry attributes to the PSR-7 ServerRequest + */ + protected function addOtelAttributes( + array $params, + array $requiredPathParts, + ServerRequestInterface $request, + string $endpoint + ): ServerRequestInterface + { + // Check if OpenTelemetry instrumentation is enbaled + if (!getenv(OpenTelemetry::ENV_VARIABLE_ENABLED)) { + return $request; + } + $otel = []; + foreach ($requiredPathParts as $part) { + if (isset($params[$part])) { + $otel["db.elasticsearch.path_parts.$part"] = $params[$part]; + } + } + if (in_array($endpoint, self::SEARCH_ENDPOINTS)) { + $body = $request->getBody()->getContents(); + if (!empty($body)) { + $otel['db.query.text'] = OpenTelemetry::redactBody($body); + } + } + return $request->withAttribute( + OpenTelemetry::PSR7_OTEL_ATTRIBUTE_NAME, + array_merge($otel, [ + 'db.system' => 'elasticsearch', + 'db.operation.name' => $endpoint + ]) + ); + } } \ No newline at end of file diff --git a/src/Traits/NamespaceTrait.php b/src/Traits/NamespaceTrait.php index 2bfa63f50..c15f4bfd9 100644 --- a/src/Traits/NamespaceTrait.php +++ b/src/Traits/NamespaceTrait.php @@ -40,7 +40,7 @@ use Elastic\Elasticsearch\Endpoints\Monitoring; use Elastic\Elasticsearch\Endpoints\Nodes; use Elastic\Elasticsearch\Endpoints\Profiling; -use Elastic\Elasticsearch\Endpoints\QueryRuleset; +use Elastic\Elasticsearch\Endpoints\QueryRules; use Elastic\Elasticsearch\Endpoints\Rollup; use Elastic\Elasticsearch\Endpoints\SearchApplication; use Elastic\Elasticsearch\Endpoints\SearchableSnapshots; @@ -283,12 +283,12 @@ public function profiling(): Profiling } - public function queryRuleset(): QueryRuleset + public function queryRules(): QueryRules { - if (!isset($this->namespace['QueryRuleset'])) { - $this->namespace['QueryRuleset'] = new QueryRuleset($this); + if (!isset($this->namespace['QueryRules'])) { + $this->namespace['QueryRules'] = new QueryRules($this); } - return $this->namespace['QueryRuleset']; + return $this->namespace['QueryRules']; } diff --git a/tests/Integration/BulkTest.php b/tests/Integration/BulkTest.php index b7d535e8a..f09e95763 100644 --- a/tests/Integration/BulkTest.php +++ b/tests/Integration/BulkTest.php @@ -14,6 +14,7 @@ namespace Elastic\Elasticsearch\Tests\Integration; +use Elastic\Elasticsearch\Client; use Elastic\Elasticsearch\Tests\Utility; use PHPUnit\Framework\TestCase; diff --git a/util/ActionTest.php b/util/ActionTest.php index 79b32ce1c..3f1c48859 100644 --- a/util/ActionTest.php +++ b/util/ActionTest.php @@ -166,7 +166,7 @@ private function transform_and_set(array $action): string $param2 = $matches[2][0]; $this->variables[] = $key; return YamlTests::render(self::TEMPLATE_TRANSFORM_AND_SET, [ - ':var' => $key, + ':var' => $this->convertVariableNameforPhp($key), ':param' => sprintf("\$response['%s'] . ':' . \$response['%s']", $param1, $param2) ]); } @@ -179,7 +179,7 @@ private function set(array $action): string foreach ($action as $key => $var) { $this->variables[] = $var; $output .= YamlTests::render(self::TEMPLATE_SET_VARIABLE, [ - ':var' => $var, + ':var' => $this->convertVariableNameforPhp($var), ':value' => $this->convertResponseField($key) ]); } @@ -588,4 +588,12 @@ private function formatHeaders(array $headers): string } return $result; } + + /** + * Convert a variable name in a valid PHP variable name + */ + private function convertVariableNameforPhp(string $var): string + { + return str_replace('-', '_', $var); + } } \ No newline at end of file diff --git a/util/YamlTests.php b/util/YamlTests.php index 3cea1ac21..555ec8f89 100644 --- a/util/YamlTests.php +++ b/util/YamlTests.php @@ -69,6 +69,20 @@ class YamlTests 'ApiKey\_20_QueryTest::TestQueryApiKey' => 'Mismatch values', 'DataStream\_80_Resolve_Index_Data_StreamsTest::*' => 'Skipped all tests', 'Dlm\_10_UsageTest::TestDataStreamLifecycleUsageStats' => 'Mismatch values', + 'Entsearch\Analytics\_40_Behavioral_Analytics_Event_PostTest::*' => '401 Unauthorized', + 'Entsearch\Connector\Secret\_10_Connector_Secret_PostTest::*' => 'Undefined method', + 'Entsearch\Connector\Secret\_20_Connector_Secret_PutTest::*' => 'Undefined method', + 'Entsearch\Connector\Secret\_30_Connector_Secret_GetTest::*' => 'Undefined method', + 'Entsearch\Connector\Secret\_40_Connector_Secret_DeleteTest::*' => 'Undefined method', + 'Entsearch\Connector\SyncJob\_20_Connector_Sync_Job_DeleteTest::*' => 'Undefined constant', + 'Entsearch\Connector\SyncJob\_40_Connector_Sync_Job_CancelTest::*' => 'Undefined constant', + 'Entsearch\Connector\SyncJob\_50_Connector_Sync_Job_GetTest::*' => 'Undefined constant', + 'Entsearch\Connector\SyncJob\_80_Connector_Sync_Job_ListTest::*' => 'Undefined constant', + 'Entsearch\Connector\_20_Connector_ListTest::*' => '401 Unauthorized', + 'Entsearch\Connector\_60_Connector_Update_FilteringTest::*' => 'Cannot access offset of type string on string', + 'Entsearch\Rules\_40_Rule_Query_SearchTest::*' => '401 Unauthorized', + 'Entsearch\Search\_55_Search_Application_SearchTest::*' => '401 Unauthorized', + 'Entsearch\Search\_56_Search_Application_Search_With_ApikeyTest::*' => '401 Unauthorized', 'Esql\_30_TypesTest::Unsigned_long' => 'Format number issue', 'Health\_10_UsageTest::UsageStatsOnTheHealthAPI' => 'Undefined array key \"green\"', 'License\_20_Put_LicenseTest::*' => 'License issue', @@ -85,6 +99,7 @@ class YamlTests 'Ml\_Get_Trained_Model_StatsTest::*' => 'Skipped all tests', 'Ml\_Get_Trained_Model_StatsTest::TestGetStatsGivenTrainedModels' => 'cannot assign model_alias', 'Ml\_Inference_RescoreTest::*' => 'unknown field [learn_to_rank]', + 'Ml\_Learning_To_Rank_RescorerTest::*' => 'Bad request', 'Rollup\_Put_JobTest::TestPutJobWithTemplates' => 'version not converted from variable', 'RuntimeFields\_100_Geo_PointTest::GetMapping' => 'Substring mismatch', 'RuntimeFields\_10_KeywordTest::GetMapping' => 'Substring mismatch',