diff --git a/src/Delegates/HandlesSystem.php b/src/Delegates/HandlesSystem.php index 74a5f97a2..15799f65c 100644 --- a/src/Delegates/HandlesSystem.php +++ b/src/Delegates/HandlesSystem.php @@ -36,4 +36,11 @@ public function generateTenantToken(string $apiKeyUid, $searchRules, ?array $opt { return $this->tenantToken->generateTenantToken($apiKeyUid, $searchRules, $options); } + + public function swapIndexes(array $indexes) + { + $options = array_map(function ($data) { return ['indexes' => $data]; }, $indexes); + + return $this->index->swapIndexes($options); + } } diff --git a/src/Endpoints/Indexes.php b/src/Endpoints/Indexes.php index c8988dad9..39e6650b9 100644 --- a/src/Endpoints/Indexes.php +++ b/src/Endpoints/Indexes.php @@ -153,6 +153,14 @@ public function delete(): array return $this->http->delete(self::PATH.'/'.$this->uid) ?? []; } + /** + * @param array $indexes + */ + public function swapIndexes(array $indexes): array + { + return $this->http->post('/swap-indexes', $indexes); + } + // Tasks public function getTask($uid): array diff --git a/tests/Endpoints/IndexTest.php b/tests/Endpoints/IndexTest.php index edfb9ad1e..ae60deba2 100644 --- a/tests/Endpoints/IndexTest.php +++ b/tests/Endpoints/IndexTest.php @@ -268,6 +268,14 @@ public function testDeleteIndexes(): void $this->assertArrayHasKey('enqueuedAt', $res); } + public function testSwapIndexes(): void + { + $promise = $this->client->swapIndexes([['indexA', 'indexB'], ['indexC', 'indexD']]); + $response = $this->client->waitForTask($promise['taskUid']); + + $this->assertSame($response['details']['swaps'], [['indexes' => ['indexA', 'indexB']], ['indexes' => ['indexC', 'indexD']]]); + } + public function testParseDate(): void { $date = '2021-01-01T01:23:45.123456Z';