1: | <?php |
2: | |
3: | declare(strict_types=1); |
4: | |
5: | /** |
6: | * SPDX-License-Identifier: Apache-2.0 |
7: | * |
8: | * The OpenSearch Contributors require contributions made to |
9: | * this file be licensed under the Apache-2.0 license or a |
10: | * compatible open source license. |
11: | * |
12: | * Modifications Copyright OpenSearch Contributors. See |
13: | * GitHub history for details. |
14: | */ |
15: | |
16: | namespace OpenSearch\Namespaces; |
17: | |
18: | use OpenSearch\Endpoints\Sql\Close; |
19: | use OpenSearch\Endpoints\Sql\Explain; |
20: | use OpenSearch\Endpoints\Sql\GetStats; |
21: | use OpenSearch\Endpoints\Sql\PostStats; |
22: | use OpenSearch\Endpoints\Sql\Query; |
23: | use OpenSearch\Endpoints\Sql\Settings; |
24: | |
25: | /** |
26: | * Class SqlNamespace |
27: | * |
28: | * NOTE: This file is autogenerated using util/GenerateEndpoints.php |
29: | */ |
30: | class SqlNamespace extends AbstractNamespace |
31: | { |
32: | /** |
33: | * Clear the cursor context. |
34: | * |
35: | * $params['format'] = (string) A short version of the Accept header (for example, `json`, `yaml`). |
36: | * $params['sanitize'] = (boolean) Specifies whether to escape special characters in the results (Default = true) |
37: | * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) |
38: | * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) |
39: | * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) |
40: | * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. |
41: | * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-". |
42: | * |
43: | * @param array $params Associative array of parameters |
44: | * @return array |
45: | */ |
46: | public function close(array $params = []) |
47: | { |
48: | $body = $this->extractArgument($params, 'body'); |
49: | |
50: | $endpoint = $this->endpointFactory->getEndpoint(Close::class); |
51: | $endpoint->setParams($params); |
52: | $endpoint->setBody($body); |
53: | |
54: | return $this->performRequest($endpoint); |
55: | } |
56: | |
57: | /** |
58: | * Collect metrics for the plugin within the interval. |
59: | * |
60: | * $params['format'] = (string) A short version of the Accept header (for example, `json`, `yaml`). |
61: | * $params['sanitize'] = (boolean) Specifies whether to escape special characters in the results (Default = true) |
62: | * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) |
63: | * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) |
64: | * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) |
65: | * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. |
66: | * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-". |
67: | * |
68: | * @param array $params Associative array of parameters |
69: | * @return array |
70: | */ |
71: | public function getStats(array $params = []) |
72: | { |
73: | $endpoint = $this->endpointFactory->getEndpoint(GetStats::class); |
74: | $endpoint->setParams($params); |
75: | |
76: | return $this->performRequest($endpoint); |
77: | } |
78: | |
79: | /** |
80: | * By a stats endpoint, you are able to collect metrics for the plugin within the interval. |
81: | * |
82: | * $params['format'] = (string) A short version of the Accept header (for example, `json`, `yaml`). |
83: | * $params['sanitize'] = (boolean) Specifies whether to escape special characters in the results (Default = true) |
84: | * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) |
85: | * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) |
86: | * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) |
87: | * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. |
88: | * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-". |
89: | * |
90: | * @param array $params Associative array of parameters |
91: | * @return array |
92: | */ |
93: | public function postStats(array $params = []) |
94: | { |
95: | $body = $this->extractArgument($params, 'body'); |
96: | |
97: | $endpoint = $this->endpointFactory->getEndpoint(PostStats::class); |
98: | $endpoint->setParams($params); |
99: | $endpoint->setBody($body); |
100: | |
101: | return $this->performRequest($endpoint); |
102: | } |
103: | |
104: | /** |
105: | * Adds SQL settings to the standard OpenSearch cluster settings. |
106: | * |
107: | * $params['format'] = (string) A short version of the Accept header (for example, `json`, `yaml`). |
108: | * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false) |
109: | * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true) |
110: | * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false) |
111: | * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. |
112: | * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-". |
113: | * |
114: | * @param array $params Associative array of parameters |
115: | * @return array |
116: | */ |
117: | public function settings(array $params = []) |
118: | { |
119: | $body = $this->extractArgument($params, 'body'); |
120: | |
121: | $endpoint = $this->endpointFactory->getEndpoint(Settings::class); |
122: | $endpoint->setParams($params); |
123: | $endpoint->setBody($body); |
124: | |
125: | return $this->performRequest($endpoint); |
126: | } |
127: | /** |
128: | * This API will be removed in a future version. Use 'close' API instead. |
129: | * |
130: | * $params['cursor'] = (string) The cursor given by the server |
131: | * |
132: | * @param array{'cursor': string} $params Associative array of parameters |
133: | * @return array |
134: | */ |
135: | public function closeCursor(array $params): array |
136: | { |
137: | $endpoint = $this->endpointFactory->getEndpoint(Close::class); |
138: | $endpoint->setBody(array_filter([ |
139: | 'cursor' => $this->extractArgument($params, 'cursor'), |
140: | ])); |
141: | $endpoint->setParams($params); |
142: | |
143: | return $this->performRequest($endpoint); |
144: | } /** |
145: | * $params['query'] = (string) The SQL Query |
146: | * |
147: | * @param array{'query': string} $params Associative array of parameters |
148: | * @return array |
149: | * |
150: | * Note: Use of query parameter is deprecated. Pass it in `body` instead. |
151: | */ |
152: | public function explain(array $params): array |
153: | { |
154: | $body = $this->extractArgument($params, 'body') ?? []; |
155: | $query = $this->extractArgument($params, 'query'); |
156: | |
157: | $endpoint = $this->endpointFactory->getEndpoint(Explain::class); |
158: | $endpoint->setBody(array_merge($body, [ |
159: | 'query' => $query, |
160: | ])); |
161: | $endpoint->setParams($params); |
162: | |
163: | return $this->performRequest($endpoint); |
164: | } /** |
165: | * $params['query'] = (string) The SQL Query |
166: | * $params['format'] = (string) The response format |
167: | * $params['cursor'] = (string) The cursor given by the server |
168: | * $params['fetch_size'] = (int) The fetch size |
169: | * |
170: | * @param array{'query'?: string, 'cursor'?: string, 'fetch_size'?: int} $params Associative array of parameters |
171: | * @return array |
172: | * |
173: | * Note: Use of `query`, `cursor` and `fetch_size` parameters is deprecated. Pass them in `body` instead. |
174: | * |
175: | */ |
176: | public function query(array $params): array |
177: | { |
178: | $endpoint = $this->endpointFactory->getEndpoint(Query::class); |
179: | $body = $this->extractArgument($params, 'body') ?? []; |
180: | $endpoint->setBody(array_merge($body, array_filter([ |
181: | 'query' => $this->extractArgument($params, 'query'), |
182: | 'cursor' => $this->extractArgument($params, 'cursor'), |
183: | 'fetch_size' => $this->extractArgument($params, 'fetch_size'), |
184: | ]))); |
185: | $endpoint->setParams($params); |
186: | |
187: | return $this->performRequest($endpoint); |
188: | } |
189: | } |
190: |