From 2a7d828a411d95926f04bae69c7db24d06d3396e Mon Sep 17 00:00:00 2001 From: Nick Sergeev <45552280+Nick-S-2018@users.noreply.github.com> Date: Fri, 20 Dec 2024 23:30:39 +0700 Subject: [PATCH] Moved a few Kibana-related endpoints from daemon to Buddy (#73) * Moved a few Kibana-related endpoints from daemon to Buddy * Merged 'main' into 'kibana-endpoints' branch * Updated processing of Kibana-related endpoints * Resolved conflicts * Merged main into the branch --------- Co-authored-by: nick --- src/ManticoreSearch/Response.php | 0 src/Network/Request.php | 39 ++++++++++++++++--- src/Network/Response.php | 0 src/Task/TaskResult.php | 0 .../Network/ManticoreSearch/ClientTest.php | 0 .../ManticoreSearch/ManticoreResponseTest.php | 0 6 files changed, 33 insertions(+), 6 deletions(-) mode change 100644 => 100755 src/ManticoreSearch/Response.php mode change 100644 => 100755 src/Network/Request.php mode change 100644 => 100755 src/Network/Response.php mode change 100644 => 100755 src/Task/TaskResult.php mode change 100644 => 100755 test/BuddyCore/Network/ManticoreSearch/ClientTest.php mode change 100644 => 100755 test/BuddyCore/Network/ManticoreSearch/ManticoreResponseTest.php diff --git a/src/ManticoreSearch/Response.php b/src/ManticoreSearch/Response.php old mode 100644 new mode 100755 diff --git a/src/Network/Request.php b/src/Network/Request.php old mode 100644 new mode 100755 index 098bca1..b7e8db2 --- a/src/Network/Request.php +++ b/src/Network/Request.php @@ -188,10 +188,11 @@ protected function parseOrFail(array $payload): static { // We need to keep the query parameters part in the sql queries // as it's required for the following requests to Manticore $path .= '?' . $urlInfo['query']; - } elseif (str_ends_with($path, '/_bulk')) { + } elseif (str_ends_with($path, '/_bulk') && !str_starts_with($path, '.kibana/')) { // Convert the elastic bulk request path to the Manticore one $path = '_bulk'; } + Buddy::debug('TEST ' . $path); if (static::isElasticPath($path)) { $endpointBundle = Endpoint::Elastic; } elseif (str_contains($path, '/_doc/') || str_contains($path, '/_create/') @@ -248,11 +249,37 @@ protected function parseOrFail(array $payload): static { * @return bool */ protected function isElasticPath(string $path): bool { - return str_starts_with($path, '_index_template/') || str_ends_with($path, '_nodes') - || str_starts_with($path, '_xpack') || str_starts_with($path, '.kibana/') - || str_starts_with($path, '_cluster') - || str_ends_with($path, '/_mapping') || str_ends_with($path, '/_search') - || str_ends_with($path, '.kibana') || str_starts_with($path, '.kibana_task_manager'); + $elasticPathPrefixes = [ + '_index_template/', + '_xpack', + '.kibana/', + '_cluster', + '_mget', + '.kibana_task_manager', + '_aliases', + '_alias/', + '_template/', + '_cat/', + '_field_caps', + ]; + $elasticPathSuffixes = [ + '_nodes', + '/_mapping', + '/_search', + '.kibana', + '/_field_caps', + ]; + foreach ($elasticPathPrefixes as $prefix) { + if (str_starts_with($path, $prefix)) { + return true; + } + } + foreach ($elasticPathSuffixes as $suffix) { + if (str_ends_with($path, $suffix)) { + return true; + } + } + return false; } /** diff --git a/src/Network/Response.php b/src/Network/Response.php old mode 100644 new mode 100755 diff --git a/src/Task/TaskResult.php b/src/Task/TaskResult.php old mode 100644 new mode 100755 diff --git a/test/BuddyCore/Network/ManticoreSearch/ClientTest.php b/test/BuddyCore/Network/ManticoreSearch/ClientTest.php old mode 100644 new mode 100755 diff --git a/test/BuddyCore/Network/ManticoreSearch/ManticoreResponseTest.php b/test/BuddyCore/Network/ManticoreSearch/ManticoreResponseTest.php old mode 100644 new mode 100755