Indices::flushramchunk()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

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