Completed
Push — 1.x ( 747b4c...b6bf38 )
by Adrian
04:52 queued 11s
created

Indices::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 1
eloc 7
c 2
b 0
f 1
nc 1
nop 1
dl 0
loc 9
rs 10
1
<?php
2
3
4
namespace Manticoresearch;
5
6
use Manticoresearch\Endpoints\Indices\Alter;
7
use Manticoresearch\Endpoints\Indices\Create;
8
use Manticoresearch\Endpoints\Indices\Describe;
9
use Manticoresearch\Endpoints\Indices\Drop;
10
use Manticoresearch\Endpoints\Indices\FlushRamchunk;
11
use Manticoresearch\Endpoints\Indices\FlushRtindex;
12
use Manticoresearch\Endpoints\Indices\Import;
13
use Manticoresearch\Endpoints\Indices\Optimize;
14
use Manticoresearch\Endpoints\Indices\Settings;
15
use Manticoresearch\Endpoints\Indices\Status;
16
use Manticoresearch\Endpoints\Indices\Truncate;
17
use Manticoresearch\Endpoints\Sql;
18
use Manticoresearch\Exceptions\RuntimeException;
19
20
class Indices
21
{
22
    use Utils;
23
    /**
24
     * @var Client
25
     */
26
    protected $client;
27
28
    /**
29
     * @var array
30
     */
31
    protected $params;
32
33
    /**
34
     * Pq constructor.
35
     * @param Client $client
36
     */
37
    public function __construct($client)
38
    {
39
        $this->client = $client;
40
        $this->params = ['responseClass' => 'Manticoresearch\\Response\\SqlToArray'];
41
    }
42
43
    /**
44
     * @param array $params
45
     * @return mixed
46
     */
47
    public function alter($params)
48
    {
49
        $index = $params['index'] ?? null;
50
        $body = $params['body'];
51
        $endpoint = new Alter();
52
        $endpoint->setIndex($index);
53
        $endpoint->setBody($body);
54
        $response = $this->client->request($endpoint, $this->params);
55
        return $response->getResponse();
56
    }
57
58
59
    /**
60
     *
61
     * @param array $params
62
     * @return mixed
63
     */
64
    public function create($params)
65
    {
66
        $index = $params['index'] ?? null;
67
        $body = $params['body'];
68
        $endpoint = new Create();
69
        $endpoint->setIndex($index);
70
        $endpoint->setBody($body);
71
        $response = $this->client->request($endpoint, $this->params);
72
        return $response->getResponse();
73
    }
74
75
    /**
76
     * @param array $params
77
     * @return mixed
78
     */
79
    public function describe($params)
80
    {
81
        $index = $params['index'] ?? null;
82
        $body = $params['body'] ?? [];
83
        $endpoint = new Describe();
84
        $endpoint->setIndex($index);
85
        $endpoint->setBody($body);
86
        $response = $this->client->request($endpoint, $this->params);
87
        return $response->getResponse();
88
    }
89
90
    /**
91
     * @param array $params
92
     * @return mixed
93
     */
94
    public function drop($params)
95
    {
96
        $index = $params['index'] ?? null;
97
        $body = $params['body'] ?? [];
98
        $endpoint = new Drop();
99
        $endpoint->setIndex($index);
100
        $endpoint->setBody($body);
101
        $response = $this->client->request($endpoint, $this->params);
102
        return $response->getResponse();
103
    }
104
    /**
105
     * @param array $params
106
     * @return mixed
107
     */
108
    public function import($params)
109
    {
110
        $index = $params['index'] ?? null;
111
        $body = $params['body'] ?? [];
112
        $endpoint = new Import();
113
        $endpoint->setIndex($index);
114
        $endpoint->setBody($body);
115
        $response = $this->client->request($endpoint, $this->params);
116
        return $response->getResponse();
117
    }
118
    /**
119
     * @param array $params
120
     * @return mixed
121
     */
122
    public function flushramchunk($params)
123
    {
124
        $index = $params['index'] ?? null;
125
        $endpoint = new FlushRamchunk();
126
        $endpoint->setIndex($index);
127
        $endpoint->setBody();
128
        $response = $this->client->request($endpoint, $this->params);
129
        return $response->getResponse();
130
    }
131
132
    /**
133
     * @param array $params
134
     * @return mixed
135
     */
136
    public function flushrtindex($params)
137
    {
138
        $index = $params['index'] ?? null;
139
        $endpoint = new FlushRtindex();
140
        $endpoint->setIndex($index);
141
        $endpoint->setBody();
142
        $response = $this->client->request($endpoint, $this->params);
143
        return $response->getResponse();
144
    }
145
146
    /**
147
     * @param array $params
148
     * @return mixed
149
     */
150
    public function optimize($params)
151
    {
152
        $index = $params['index'] ?? null;
153
        $body = $params['body'] ?? null;
154
        $endpoint = new Optimize();
155
        $endpoint->setIndex($index);
156
        $endpoint->setBody($body);
157
        $response = $this->client->request($endpoint, $this->params);
158
        return $response->getResponse();
159
    }
160
161
    /**
162
     * @param array $params
163
     * @return mixed
164
     */
165
    public function status($params)
166
    {
167
        $index = $params['index'] ?? null;
168
        $body = $params['body'] ?? null;
169
        $endpoint = new Status();
170
        $endpoint->setIndex($index);
171
        $endpoint->setBody($body);
172
        $response = $this->client->request($endpoint, $this->params);
173
        return $response->getResponse();
174
    }
175
176
    /**
177
     * @param array $params
178
     * @return array|mixed|string
179
     */
180
    public function settings($params)
181
    {
182
        $index = $params['index'] ?? null;
183
        $body = $params['body'] ?? null;
184
        $endpoint = new Settings();
185
        $endpoint->setIndex($index);
186
        $endpoint->setBody($body);
187
        $response = $this->client->request($endpoint, $this->params);
188
        return $response->getResponse();
189
    }
190
191
    /**
192
     * @param array $params
193
     * @return mixed
194
     */
195
    public function truncate($params)
196
    {
197
        $index = $params['index'] ?? null;
198
        $body = $params['body'] ?? null;
199
        $endpoint = new Truncate();
200
        $endpoint->setIndex($index);
201
        $endpoint->setBody($body);
202
        $response = $this->client->request($endpoint, $this->params);
203
        return $response->getResponse();
204
    }
205
}
206