Total Complexity | 5 |
Total Lines | 57 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
6 | class Reindex extends AbstractMigration |
||
7 | { |
||
8 | /** |
||
9 | * Get validation rules |
||
10 | * |
||
11 | * @return array |
||
12 | */ |
||
13 | 3 | public function getValidationRules(): array |
|
14 | { |
||
15 | return [ |
||
16 | 3 | 'body' => 'required|array', |
|
17 | 'body.source.index' => 'required|string', |
||
18 | 'body.dest.index' => 'required|string' |
||
19 | ]; |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * Pre check |
||
24 | * |
||
25 | * @param Client $esClient |
||
26 | * @param array $params |
||
27 | * |
||
28 | * @throws \Exception |
||
29 | */ |
||
30 | 2 | public function preCheck(Client $esClient, array $params) |
|
31 | { |
||
32 | 2 | $indices = implode(',', [ |
|
33 | 2 | array_get($params, 'body.source.index'), |
|
34 | 2 | array_get($params, 'body.dest.index') |
|
35 | ]); |
||
36 | |||
37 | 2 | if (!$esClient->indices()->exists(['index' => $indices])) { |
|
38 | 1 | throw new \Exception(sprintf("Index not exist: %s", $indices)); |
|
39 | } |
||
40 | 1 | } |
|
41 | |||
42 | /** |
||
43 | * Start migration |
||
44 | * |
||
45 | * @param Client $esClient |
||
46 | * @param array $params |
||
47 | */ |
||
48 | 1 | public function startMigration(Client $esClient, array $params) |
|
51 | 1 | } |
|
52 | |||
53 | /** |
||
54 | * Post check |
||
55 | * |
||
56 | * @param Client $esClient |
||
57 | * @param array $params |
||
58 | * |
||
59 | * @throws \Exception |
||
60 | */ |
||
61 | 1 | public function postCheck(Client $esClient, array $params) |
|
63 | // TODO: Implement postCheck() method. |
||
64 | 1 | } |
|
65 | } |
||
66 |