From 83565313b26ce88ccda6d5f77085e3c9c4e02535 Mon Sep 17 00:00:00 2001 From: stanislav shupilkin Date: Sat, 3 Feb 2024 00:01:32 +0400 Subject: [PATCH] Add new method for ns service --- src/Reindexer/Services/Namespaces.php | 19 +++++++++++++++++++ tests/Feature/Reindexer/ServiceTest.php | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/Reindexer/Services/Namespaces.php b/src/Reindexer/Services/Namespaces.php index 7907eae..6be8b30 100644 --- a/src/Reindexer/Services/Namespaces.php +++ b/src/Reindexer/Services/Namespaces.php @@ -219,4 +219,23 @@ public function getMetaDataKey(string $name, string $key): Response $this->defaultHeaders ); } + + public function schema(string $name, array $config): Response + { + $uri = new Uri( + sprintf( + '/api/%s/db/%s/namespaces/%s/schema', + $this->version, + $this->getDatabase(), + $name + ) + ); + + return $this->client->request( + 'PUT', + (string)$uri, + json_encode($config), + $this->defaultHeaders + ); + } } diff --git a/tests/Feature/Reindexer/ServiceTest.php b/tests/Feature/Reindexer/ServiceTest.php index e9ee427..81a8d45 100644 --- a/tests/Feature/Reindexer/ServiceTest.php +++ b/tests/Feature/Reindexer/ServiceTest.php @@ -172,4 +172,23 @@ public function testSetHeaders() ); $this->assertCount(2, $response->getRequestHeaders()); } + + public function testSchema() + { + $config = [ + 'type' => 'namespaces', + 'namespaces' => [ + 'wal_size' => 5000000 + ] + ]; + $response = $this->nsService->schema($this->namespaceName, $config); + $this->assertSame( + [ + 'success' => true, + 'response_code' => 200, + 'description' => '' + ], + $response->getDecodedResponseBody(true) + ); + } }