-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlias.php
More file actions
82 lines (71 loc) · 1.71 KB
/
Copy pathAlias.php
File metadata and controls
82 lines (71 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
namespace DirectoryTree\OpenSearchAdapter\Indices;
/**
* @see https://docs.opensearch.org/latest/api-reference/index-apis/alias/
*/
class Alias
{
/**
* Create a new alias instance.
*
* @param string $name The alias name.
* @param array<string, mixed>|null $filter
* @param string|null $routing The optional alias routing value.
* @param bool|null $isWriteIndex Whether this is the alias write index.
*/
public function __construct(
protected string $name,
protected ?array $filter = null,
protected ?string $routing = null,
protected ?bool $isWriteIndex = null,
) {}
/**
* Get the alias name.
*/
public function name(): string
{
return $this->name;
}
/**
* Get the alias filter.
*
* @return array<string, mixed>|null
*/
public function filter(): ?array
{
return $this->filter;
}
/**
* Get the alias routing value.
*/
public function routing(): ?string
{
return $this->routing;
}
/**
* Determine whether this is the alias write index.
*/
public function isWriteIndex(): ?bool
{
return $this->isWriteIndex;
}
/**
* Get the OpenSearch alias body payload.
*
* @return array<string, mixed>
*/
public function toArray(): array
{
$body = [];
if ($this->routing) {
$body['routing'] = $this->routing;
}
if ($this->filter) {
$body['filter'] = $this->filter;
}
if (! is_null($this->isWriteIndex)) {
$body['is_write_index'] = $this->isWriteIndex;
}
return $body;
}
}