Skip to content

Commit

Permalink
Add new method for ns service
Browse files Browse the repository at this point in the history
  • Loading branch information
Smolevich committed Feb 2, 2024
1 parent dc21bc7 commit 8356531
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Reindexer/Services/Namespaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
19 changes: 19 additions & 0 deletions tests/Feature/Reindexer/ServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}
}

0 comments on commit 8356531

Please sign in to comment.