Class: Manticore::Client::IndexApi
- Inherits:
-
Object
- Object
- Manticore::Client::IndexApi
- Defined in:
- lib/manticore/client/api/index_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#bulk(body, opts = {}) ⇒ BulkResponse
Bulk table operations Sends multiple operatons like inserts, updates, replaces or deletes.
-
#bulk_with_http_info(body, opts = {}) ⇒ Array<(BulkResponse, Integer, Hash)>
Bulk table operations Sends multiple operatons like inserts, updates, replaces or deletes.
-
#delete(delete_document_request, opts = {}) ⇒ DeleteResponse
Delete a document in a table Delete one or several documents.
-
#delete_with_http_info(delete_document_request, opts = {}) ⇒ Array<(DeleteResponse, Integer, Hash)>
Delete a document in a table Delete one or several documents.
-
#initialize(api_client = ApiClient.default) ⇒ IndexApi
constructor
A new instance of IndexApi.
-
#insert(insert_document_request, opts = {}) ⇒ SuccessResponse
Create a new document in a table Insert a document.
-
#insert_with_http_info(insert_document_request, opts = {}) ⇒ Array<(SuccessResponse, Integer, Hash)>
Create a new document in a table Insert a document.
-
#partial_replace(table, id, replace_document_request, opts = {}) ⇒ UpdateResponse
Partially replaces a document in a table Partially replaces a document with given id in a table Responds with an object of the following format:
{'table':'products','updated':1}. -
#partial_replace_with_http_info(table, id, replace_document_request, opts = {}) ⇒ Array<(UpdateResponse, Integer, Hash)>
Partially replaces a document in a table Partially replaces a document with given id in a table Responds with an object of the following format: ``` 'table':'products','updated':1 ```.
-
#replace(insert_document_request, opts = {}) ⇒ SuccessResponse
Replace new document in a table Replace an existing document.
-
#replace_with_http_info(insert_document_request, opts = {}) ⇒ Array<(SuccessResponse, Integer, Hash)>
Replace new document in a table Replace an existing document.
-
#update(update_document_request, opts = {}) ⇒ UpdateResponse
Update a document in a table Update one or several documents.
-
#update_with_http_info(update_document_request, opts = {}) ⇒ Array<(UpdateResponse, Integer, Hash)>
Update a document in a table Update one or several documents.
Constructor Details
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
17 18 19 |
# File 'lib/manticore/client/api/index_api.rb', line 17 def api_client @api_client end |
Instance Method Details
#bulk(body, opts = {}) ⇒ BulkResponse
Bulk table operations
Sends multiple operatons like inserts, updates, replaces or deletes. For each operation it's object must have same format as in their dedicated method. The method expects a raw string as the batch in NDJSON. Each operation object needs to be serialized to JSON and separated by endline (\n). An example of raw input: {\"insert\": {\"table\": \"movies\", \"doc\": {\"plot\": \"A secret team goes to North Pole\", \"rating\": 9.5, \"language\": [2, 3], \"title\": \"This is an older movie\", \"lon\": 51.99, \"meta\": {\"keywords\":[\"travel\",\"ice\"],\"genre\":[\"adventure\"]}, \"year\": 1950, \"lat\": 60.4, \"advise\": \"PG-13\"}}} \\n {\"delete\": {\"table\": \"movies\",\"id\":700}} Responds with an object telling whenever any errors occured and an array with status for each operation: { 'items': [ { 'update':{'table':'products','id':1,'result':'updated'} }, { 'update':{'table':'products','id':2,'result':'updated'} } ], 'errors':false }
27 28 29 30 |
# File 'lib/manticore/client/api/index_api.rb', line 27 def bulk(body, opts = {}) data, _status_code, _headers = bulk_with_http_info(body, opts) data end |
#bulk_with_http_info(body, opts = {}) ⇒ Array<(BulkResponse, Integer, Hash)>
Bulk table operations Sends multiple operatons like inserts, updates, replaces or deletes. For each operation it's object must have same format as in their dedicated method. The method expects a raw string as the batch in NDJSON. Each operation object needs to be serialized to JSON and separated by endline (\n). An example of raw input: ``` {\"table\": \"movies\", \"doc\": {\"plot\": \"A secret team goes to North Pole\", \"rating\": 9.5, \"language\": [2, 3], \"title\": \"This is an older movie\", \"lon\": 51.99, \"meta\": {\"keywords\":[\"travel\",\"ice\"],\"genre\":[\"adventure\"], "year": 1950, "lat": 60.4, "advise": "PG-13"}}} \n {\"table\": \"movies\",\"id\":700} ``` Responds with an object telling whenever any errors occured and an array with status for each operation: ``` { 'items': [ { 'update':'table':'products','id':1,'result':'updated' }, { 'update':'table':'products','id':2,'result':'updated' } ], 'errors':false } ```
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/manticore/client/api/index_api.rb', line 37 def bulk_with_http_info(body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: IndexApi.bulk ...' end # verify the required parameter 'body' is set if @api_client.config.client_side_validation && body.nil? fail ArgumentError, "Missing the required parameter 'body' when calling IndexApi.bulk" end # resource path local_var_path = '/bulk' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/x-ndjson']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(body) # return_type return_type = opts[:debug_return_type] || 'BulkResponse' # auth_names auth_names = opts[:debug_auth_names] || [] = opts.merge( :operation => :"IndexApi.bulk", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: IndexApi#bulk\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#delete(delete_document_request, opts = {}) ⇒ DeleteResponse
Delete a document in a table
Delete one or several documents. The method has 2 ways of deleting: either by id, in case only one document is deleted or by using a match query, in which case multiple documents can be delete . Example of input to delete by id: {'table':'movies','id':100} Example of input to delete using a query: { 'table':'movies', 'query': { 'bool': { 'must': [ {'query_string':'new movie'} ] } } } The match query has same syntax as in for searching. Responds with an object telling how many documents got deleted: {'table':'products','updated':1}
95 96 97 98 |
# File 'lib/manticore/client/api/index_api.rb', line 95 def delete(delete_document_request, opts = {}) data, _status_code, _headers = delete_with_http_info(delete_document_request, opts) data end |
#delete_with_http_info(delete_document_request, opts = {}) ⇒ Array<(DeleteResponse, Integer, Hash)>
Delete a document in a table Delete one or several documents. The method has 2 ways of deleting: either by id, in case only one document is deleted or by using a match query, in which case multiple documents can be delete . Example of input to delete by id: ``` 'table':'movies','id':100 ``` Example of input to delete using a query: ``` { 'table':'movies', 'query': { 'bool': { 'must': [ movie' ] } } } ``` The match query has same syntax as in for searching. Responds with an object telling how many documents got deleted: ``` 'table':'products','updated':1 ```
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/manticore/client/api/index_api.rb', line 105 def delete_with_http_info(delete_document_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: IndexApi.delete ...' end # verify the required parameter 'delete_document_request' is set if @api_client.config.client_side_validation && delete_document_request.nil? fail ArgumentError, "Missing the required parameter 'delete_document_request' when calling IndexApi.delete" end # resource path local_var_path = '/delete' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(delete_document_request) # return_type return_type = opts[:debug_return_type] || 'DeleteResponse' # auth_names auth_names = opts[:debug_auth_names] || [] = opts.merge( :operation => :"IndexApi.delete", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: IndexApi#delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#insert(insert_document_request, opts = {}) ⇒ SuccessResponse
Create a new document in a table
Insert a document. Expects an object like: { 'table':'movies', 'id':701, 'doc': { 'title':'This is an old movie', 'plot':'A secret team goes to North Pole', 'year':1950, 'rating':9.5, 'lat':60.4, 'lon':51.99, 'advise':'PG-13', 'meta':'{\"keywords\":{\"travel\",\"ice\"},\"genre\":{\"adventure\"}}', 'language':[2,3] } } The document id can also be missing, in which case an autogenerated one will be used: { 'table':'movies', 'doc': { 'title':'This is a new movie', 'plot':'A secret team goes to North Pole', 'year':2020, 'rating':9.5, 'lat':60.4, 'lon':51.99, 'advise':'PG-13', 'meta':'{\"keywords\":{\"travel\",\"ice\"},\"genre\":{\"adventure\"}}', 'language':[2,3] } } It responds with an object in format: {'table':'products','id':701,'created':true,'result':'created','status':201}
163 164 165 166 |
# File 'lib/manticore/client/api/index_api.rb', line 163 def insert(insert_document_request, opts = {}) data, _status_code, _headers = insert_with_http_info(insert_document_request, opts) data end |
#insert_with_http_info(insert_document_request, opts = {}) ⇒ Array<(SuccessResponse, Integer, Hash)>
Create a new document in a table Insert a document. Expects an object like: ``` { 'table':'movies', 'id':701, 'doc': { 'title':'This is an old movie', 'plot':'A secret team goes to North Pole', 'year':1950, 'rating':9.5, 'lat':60.4, 'lon':51.99, 'advise':'PG-13', 'meta':'\"keywords\":{\"travel\",\"ice\","genre":\"adventure\"}', 'language':[2,3] } } ``` The document id can also be missing, in which case an autogenerated one will be used: ``` { 'table':'movies', 'doc': { 'title':'This is a new movie', 'plot':'A secret team goes to North Pole', 'year':2020, 'rating':9.5, 'lat':60.4, 'lon':51.99, 'advise':'PG-13', 'meta':'\"keywords\":{\"travel\",\"ice\","genre":\"adventure\"}', 'language':[2,3] } } ``` It responds with an object in format: ``` 'table':'products','id':701,'created':true,'result':'created','status':201 ```
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/manticore/client/api/index_api.rb', line 173 def insert_with_http_info(insert_document_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: IndexApi.insert ...' end # verify the required parameter 'insert_document_request' is set if @api_client.config.client_side_validation && insert_document_request.nil? fail ArgumentError, "Missing the required parameter 'insert_document_request' when calling IndexApi.insert" end # resource path local_var_path = '/insert' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(insert_document_request) # return_type return_type = opts[:debug_return_type] || 'SuccessResponse' # auth_names auth_names = opts[:debug_auth_names] || [] = opts.merge( :operation => :"IndexApi.insert", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: IndexApi#insert\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#partial_replace(table, id, replace_document_request, opts = {}) ⇒ UpdateResponse
Partially replaces a document in a table
Partially replaces a document with given id in a table Responds with an object of the following format: {'table':'products','updated':1}
233 234 235 236 |
# File 'lib/manticore/client/api/index_api.rb', line 233 def partial_replace(table, id, replace_document_request, opts = {}) data, _status_code, _headers = partial_replace_with_http_info(table, id, replace_document_request, opts) data end |
#partial_replace_with_http_info(table, id, replace_document_request, opts = {}) ⇒ Array<(UpdateResponse, Integer, Hash)>
Partially replaces a document in a table Partially replaces a document with given id in a table Responds with an object of the following format: ``` 'table':'products','updated':1 ```
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/manticore/client/api/index_api.rb', line 245 def partial_replace_with_http_info(table, id, replace_document_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: IndexApi.partial_replace ...' end # verify the required parameter 'table' is set if @api_client.config.client_side_validation && table.nil? fail ArgumentError, "Missing the required parameter 'table' when calling IndexApi.partial_replace" end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling IndexApi.partial_replace" end # verify the required parameter 'replace_document_request' is set if @api_client.config.client_side_validation && replace_document_request.nil? fail ArgumentError, "Missing the required parameter 'replace_document_request' when calling IndexApi.partial_replace" end # resource path local_var_path = '/{table}/_update/{id}'.sub('{' + 'table' + '}', CGI.escape(table.to_s)).sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(replace_document_request) # return_type return_type = opts[:debug_return_type] || 'UpdateResponse' # auth_names auth_names = opts[:debug_auth_names] || [] = opts.merge( :operation => :"IndexApi.partial_replace", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: IndexApi#partial_replace\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#replace(insert_document_request, opts = {}) ⇒ SuccessResponse
Replace new document in a table
Replace an existing document. Input has same format as insert operation. Responds with an object in format: {'table':'products','id':1,'created':false,'result':'updated','status':200}
311 312 313 314 |
# File 'lib/manticore/client/api/index_api.rb', line 311 def replace(insert_document_request, opts = {}) data, _status_code, _headers = replace_with_http_info(insert_document_request, opts) data end |
#replace_with_http_info(insert_document_request, opts = {}) ⇒ Array<(SuccessResponse, Integer, Hash)>
Replace new document in a table Replace an existing document. Input has same format as `insert` operation. Responds with an object in format: ``` 'table':'products','id':1,'created':false,'result':'updated','status':200 ```
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
# File 'lib/manticore/client/api/index_api.rb', line 321 def replace_with_http_info(insert_document_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: IndexApi.replace ...' end # verify the required parameter 'insert_document_request' is set if @api_client.config.client_side_validation && insert_document_request.nil? fail ArgumentError, "Missing the required parameter 'insert_document_request' when calling IndexApi.replace" end # resource path local_var_path = '/replace' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(insert_document_request) # return_type return_type = opts[:debug_return_type] || 'SuccessResponse' # auth_names auth_names = opts[:debug_auth_names] || [] = opts.merge( :operation => :"IndexApi.replace", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: IndexApi#replace\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#update(update_document_request, opts = {}) ⇒ UpdateResponse
Update a document in a table
Update one or several documents. The update can be made by passing the id or by using a match query in case multiple documents can be updated. For example update a document using document id: {'table':'movies','doc':{'rating':9.49},'id':100} And update by using a match query: { 'table':'movies', 'doc':{'rating':9.49}, 'query': { 'bool': { 'must': [ {'query_string':'new movie'} ] } } } The match query has same syntax as for searching. Responds with an object that tells how many documents where updated in format: {'table':'products','updated':1}
379 380 381 382 |
# File 'lib/manticore/client/api/index_api.rb', line 379 def update(update_document_request, opts = {}) data, _status_code, _headers = update_with_http_info(update_document_request, opts) data end |
#update_with_http_info(update_document_request, opts = {}) ⇒ Array<(UpdateResponse, Integer, Hash)>
Update a document in a table Update one or several documents. The update can be made by passing the id or by using a match query in case multiple documents can be updated. For example update a document using document id: ``` Manticore::Client::IndexApi.'table':'movies','doc':{'rating':9'table':'movies','doc':{'rating':9.49,'id':100} ``` And update by using a match query: ``` { 'table':'movies', 'doc':Manticore::Client::IndexApi.'rating':9'rating':9.49, 'query': { 'bool': { 'must': [ movie' ] } } } ``` The match query has same syntax as for searching. Responds with an object that tells how many documents where updated in format: ``` 'table':'products','updated':1 ```
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 |
# File 'lib/manticore/client/api/index_api.rb', line 389 def update_with_http_info(update_document_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: IndexApi.update ...' end # verify the required parameter 'update_document_request' is set if @api_client.config.client_side_validation && update_document_request.nil? fail ArgumentError, "Missing the required parameter 'update_document_request' when calling IndexApi.update" end # resource path local_var_path = '/update' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(update_document_request) # return_type return_type = opts[:debug_return_type] || 'UpdateResponse' # auth_names auth_names = opts[:debug_auth_names] || [] = opts.merge( :operation => :"IndexApi.update", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: IndexApi#update\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |