Skip to content

Commit c86582e

Browse files
committed
Add fake index manager
1 parent 170a57b commit c86582e

4 files changed

Lines changed: 476 additions & 9 deletions

File tree

src/Indices/IndexManager.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* @see https://docs.opensearch.org/latest/api-reference/index-apis/update-settings/
1212
* @see https://docs.opensearch.org/latest/api-reference/index-apis/alias/
1313
*/
14-
class IndexManager
14+
class IndexManager implements IndexManagerInterface
1515
{
1616
/**
1717
* The OpenSearch indices namespace.
@@ -29,7 +29,7 @@ public function __construct(Client $client)
2929
/**
3030
* Open the given index.
3131
*/
32-
public function open(string $index): self
32+
public function open(string $index): static
3333
{
3434
$this->indices->open([
3535
'index' => $index,
@@ -41,7 +41,7 @@ public function open(string $index): self
4141
/**
4242
* Close the given index.
4343
*/
44-
public function close(string $index): self
44+
public function close(string $index): static
4545
{
4646
$this->indices->close([
4747
'index' => $index,
@@ -63,7 +63,7 @@ public function exists(string $index): bool
6363
/**
6464
* Create an index from the given blueprint.
6565
*/
66-
public function create(IndexBlueprint $index): self
66+
public function create(IndexBlueprint $index): static
6767
{
6868
$this->indices->create($index->toArray());
6969

@@ -73,7 +73,7 @@ public function create(IndexBlueprint $index): self
7373
/**
7474
* Update the mapping for the given index.
7575
*/
76-
public function putMapping(string $index, Mapping $mapping): self
76+
public function putMapping(string $index, Mapping $mapping): static
7777
{
7878
$this->indices->putMapping([
7979
'index' => $index,
@@ -86,7 +86,7 @@ public function putMapping(string $index, Mapping $mapping): self
8686
/**
8787
* Update the settings for the given index.
8888
*/
89-
public function putSettings(string $index, Settings $settings): self
89+
public function putSettings(string $index, Settings $settings): static
9090
{
9191
$this->indices->putSettings([
9292
'index' => $index,
@@ -101,7 +101,7 @@ public function putSettings(string $index, Settings $settings): self
101101
/**
102102
* Delete the given index.
103103
*/
104-
public function delete(string $index): self
104+
public function delete(string $index): static
105105
{
106106
$this->indices->delete([
107107
'index' => $index,
@@ -139,7 +139,7 @@ public function getAliases(string $index): array
139139
/**
140140
* Create or update an alias for the given index.
141141
*/
142-
public function putAlias(string $index, Alias $alias): self
142+
public function putAlias(string $index, Alias $alias): static
143143
{
144144
$params = [
145145
'index' => $index,
@@ -158,7 +158,7 @@ public function putAlias(string $index, Alias $alias): self
158158
/**
159159
* Delete the given alias from the index.
160160
*/
161-
public function deleteAlias(string $index, string $aliasName): self
161+
public function deleteAlias(string $index, string $aliasName): static
162162
{
163163
$this->indices->deleteAlias([
164164
'index' => $index,
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
namespace DirectoryTree\OpenSearchAdapter\Indices;
4+
5+
/**
6+
* Manages OpenSearch indices, mappings, settings, and aliases.
7+
*/
8+
interface IndexManagerInterface
9+
{
10+
/**
11+
* Open the given index.
12+
*/
13+
public function open(string $index): static;
14+
15+
/**
16+
* Close the given index.
17+
*/
18+
public function close(string $index): static;
19+
20+
/**
21+
* Determine if the given index exists.
22+
*/
23+
public function exists(string $index): bool;
24+
25+
/**
26+
* Create an index from the given blueprint.
27+
*/
28+
public function create(IndexBlueprint $index): static;
29+
30+
/**
31+
* Update the mapping for the given index.
32+
*/
33+
public function putMapping(string $index, Mapping $mapping): static;
34+
35+
/**
36+
* Update the settings for the given index.
37+
*/
38+
public function putSettings(string $index, Settings $settings): static;
39+
40+
/**
41+
* Delete the given index.
42+
*/
43+
public function delete(string $index): static;
44+
45+
/**
46+
* Get the aliases for the given index.
47+
*
48+
* @return array<string, Alias>
49+
*/
50+
public function getAliases(string $index): array;
51+
52+
/**
53+
* Create or update an alias for the given index.
54+
*/
55+
public function putAlias(string $index, Alias $alias): static;
56+
57+
/**
58+
* Delete the given alias from the index.
59+
*/
60+
public function deleteAlias(string $index, string $aliasName): static;
61+
}

0 commit comments

Comments
 (0)