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