Class: TrieveRubyClient::FileApi
- Inherits:
-
Object
- Object
- TrieveRubyClient::FileApi
- Defined in:
- lib/trieve_ruby_client/api/file_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#delete_file_handler(tr_dataset, file_id, delete_chunks, opts = {}) ⇒ nil
Delete File Delete File Delete a file from S3 attached to the server based on its id.
-
#delete_file_handler_with_http_info(tr_dataset, file_id, delete_chunks, opts = {}) ⇒ Array<(nil, Integer, Hash)>
Delete File Delete File Delete a file from S3 attached to the server based on its id.
-
#get_dataset_files_handler(tr_dataset, dataset_id, page, opts = {}) ⇒ Array<File>
Get Files for Dataset Get Files for Dataset Get all files which belong to a given dataset specified by the dataset_id parameter.
-
#get_dataset_files_handler_with_http_info(tr_dataset, dataset_id, page, opts = {}) ⇒ Array<(Array<File>, Integer, Hash)>
Get Files for Dataset Get Files for Dataset Get all files which belong to a given dataset specified by the dataset_id parameter.
-
#get_file_handler(tr_dataset, file_id, opts = {}) ⇒ FileDTO
Get File Get File Download a file based on its id.
-
#get_file_handler_with_http_info(tr_dataset, file_id, opts = {}) ⇒ Array<(FileDTO, Integer, Hash)>
Get File Get File Download a file based on its id.
-
#initialize(api_client = ApiClient.default) ⇒ FileApi
constructor
A new instance of FileApi.
-
#upload_file_handler(tr_dataset, upload_file_data, opts = {}) ⇒ UploadFileResult
Upload File Upload File Upload a file to S3 attached to the server.
-
#upload_file_handler_with_http_info(tr_dataset, upload_file_data, opts = {}) ⇒ Array<(UploadFileResult, Integer, Hash)>
Upload File Upload File Upload a file to S3 attached to the server.
Constructor Details
#initialize(api_client = ApiClient.default) ⇒ FileApi
Returns a new instance of FileApi.
19 20 21 |
# File 'lib/trieve_ruby_client/api/file_api.rb', line 19 def initialize(api_client = ApiClient.default) @api_client = api_client end |
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
17 18 19 |
# File 'lib/trieve_ruby_client/api/file_api.rb', line 17 def api_client @api_client end |
Instance Method Details
#delete_file_handler(tr_dataset, file_id, delete_chunks, opts = {}) ⇒ nil
Delete File Delete File Delete a file from S3 attached to the server based on its id. This will disassociate chunks from the file, but only delete them all together if you specify delete_chunks to be true. Auth’ed user must be an admin or owner of the dataset’s organization to delete a file.
29 30 31 32 |
# File 'lib/trieve_ruby_client/api/file_api.rb', line 29 def delete_file_handler(tr_dataset, file_id, delete_chunks, opts = {}) delete_file_handler_with_http_info(tr_dataset, file_id, delete_chunks, opts) nil end |
#delete_file_handler_with_http_info(tr_dataset, file_id, delete_chunks, opts = {}) ⇒ Array<(nil, Integer, Hash)>
Delete File Delete File Delete a file from S3 attached to the server based on its id. This will disassociate chunks from the file, but only delete them all together if you specify delete_chunks to be true. Auth'ed user must be an admin or owner of the dataset's organization to delete a file.
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 89 90 91 92 93 94 95 96 97 |
# File 'lib/trieve_ruby_client/api/file_api.rb', line 41 def delete_file_handler_with_http_info(tr_dataset, file_id, delete_chunks, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FileApi.delete_file_handler ...' end # verify the required parameter 'tr_dataset' is set if @api_client.config.client_side_validation && tr_dataset.nil? fail ArgumentError, "Missing the required parameter 'tr_dataset' when calling FileApi.delete_file_handler" end # verify the required parameter 'file_id' is set if @api_client.config.client_side_validation && file_id.nil? fail ArgumentError, "Missing the required parameter 'file_id' when calling FileApi.delete_file_handler" end # verify the required parameter 'delete_chunks' is set if @api_client.config.client_side_validation && delete_chunks.nil? fail ArgumentError, "Missing the required parameter 'delete_chunks' when calling FileApi.delete_file_handler" end # resource path local_var_path = '/api/file/{file_id}'.sub('{' + 'file_id' + '}', CGI.escape(file_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'delete_chunks'] = delete_chunks # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) header_params[:'TR-Dataset'] = tr_dataset # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] # auth_names auth_names = opts[:debug_auth_names] || ['ApiKey'] = opts.merge( :operation => :"FileApi.delete_file_handler", :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(:DELETE, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: FileApi#delete_file_handler\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#get_dataset_files_handler(tr_dataset, dataset_id, page, opts = {}) ⇒ Array<File>
Get Files for Dataset Get Files for Dataset Get all files which belong to a given dataset specified by the dataset_id parameter. 10 files are returned per page.
106 107 108 109 |
# File 'lib/trieve_ruby_client/api/file_api.rb', line 106 def get_dataset_files_handler(tr_dataset, dataset_id, page, opts = {}) data, _status_code, _headers = get_dataset_files_handler_with_http_info(tr_dataset, dataset_id, page, opts) data end |
#get_dataset_files_handler_with_http_info(tr_dataset, dataset_id, page, opts = {}) ⇒ Array<(Array<File>, Integer, Hash)>
Get Files for Dataset Get Files for Dataset Get all files which belong to a given dataset specified by the dataset_id parameter. 10 files are returned per page.
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 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/trieve_ruby_client/api/file_api.rb', line 118 def get_dataset_files_handler_with_http_info(tr_dataset, dataset_id, page, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FileApi.get_dataset_files_handler ...' end # verify the required parameter 'tr_dataset' is set if @api_client.config.client_side_validation && tr_dataset.nil? fail ArgumentError, "Missing the required parameter 'tr_dataset' when calling FileApi.get_dataset_files_handler" end # verify the required parameter 'dataset_id' is set if @api_client.config.client_side_validation && dataset_id.nil? fail ArgumentError, "Missing the required parameter 'dataset_id' when calling FileApi.get_dataset_files_handler" end # verify the required parameter 'page' is set if @api_client.config.client_side_validation && page.nil? fail ArgumentError, "Missing the required parameter 'page' when calling FileApi.get_dataset_files_handler" end if @api_client.config.client_side_validation && page < 0 fail ArgumentError, 'invalid value for "page" when calling FileApi.get_dataset_files_handler, must be greater than or equal to 0.' end # resource path local_var_path = '/api/dataset/files/{dataset_id}/{page}'.sub('{' + 'dataset_id' + '}', CGI.escape(dataset_id.to_s)).sub('{' + 'page' + '}', CGI.escape(page.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']) header_params[:'TR-Dataset'] = tr_dataset # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Array<File>' # auth_names auth_names = opts[:debug_auth_names] || ['ApiKey'] = opts.merge( :operation => :"FileApi.get_dataset_files_handler", :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(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: FileApi#get_dataset_files_handler\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#get_file_handler(tr_dataset, file_id, opts = {}) ⇒ FileDTO
Get File Get File Download a file based on its id.
185 186 187 188 |
# File 'lib/trieve_ruby_client/api/file_api.rb', line 185 def get_file_handler(tr_dataset, file_id, opts = {}) data, _status_code, _headers = get_file_handler_with_http_info(tr_dataset, file_id, opts) data end |
#get_file_handler_with_http_info(tr_dataset, file_id, opts = {}) ⇒ Array<(FileDTO, Integer, Hash)>
Get File Get File Download a file based on its id.
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 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/trieve_ruby_client/api/file_api.rb', line 196 def get_file_handler_with_http_info(tr_dataset, file_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FileApi.get_file_handler ...' end # verify the required parameter 'tr_dataset' is set if @api_client.config.client_side_validation && tr_dataset.nil? fail ArgumentError, "Missing the required parameter 'tr_dataset' when calling FileApi.get_file_handler" end # verify the required parameter 'file_id' is set if @api_client.config.client_side_validation && file_id.nil? fail ArgumentError, "Missing the required parameter 'file_id' when calling FileApi.get_file_handler" end # resource path local_var_path = '/api/file/{file_id}'.sub('{' + 'file_id' + '}', CGI.escape(file_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']) header_params[:'TR-Dataset'] = tr_dataset # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'FileDTO' # auth_names auth_names = opts[:debug_auth_names] || ['ApiKey'] = opts.merge( :operation => :"FileApi.get_file_handler", :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(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: FileApi#get_file_handler\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#upload_file_handler(tr_dataset, upload_file_data, opts = {}) ⇒ UploadFileResult
Upload File Upload File Upload a file to S3 attached to the server. The file will be converted to HTML with tika and chunked algorithmically, images will be OCR’ed with tesseract. The resulting chunks will be indexed and searchable. Optionally, you can only upload the file and manually create chunks associated to the file after. See docs.trieve.ai and/or contact us for more details and tips. Auth’ed user must be an admin or owner of the dataset’s organization to upload a file.
255 256 257 258 |
# File 'lib/trieve_ruby_client/api/file_api.rb', line 255 def upload_file_handler(tr_dataset, upload_file_data, opts = {}) data, _status_code, _headers = upload_file_handler_with_http_info(tr_dataset, upload_file_data, opts) data end |
#upload_file_handler_with_http_info(tr_dataset, upload_file_data, opts = {}) ⇒ Array<(UploadFileResult, Integer, Hash)>
Upload File Upload File Upload a file to S3 attached to the server. The file will be converted to HTML with tika and chunked algorithmically, images will be OCR'ed with tesseract. The resulting chunks will be indexed and searchable. Optionally, you can only upload the file and manually create chunks associated to the file after. See docs.trieve.ai and/or contact us for more details and tips. Auth'ed user must be an admin or owner of the dataset's organization to upload a file.
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 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'lib/trieve_ruby_client/api/file_api.rb', line 266 def upload_file_handler_with_http_info(tr_dataset, upload_file_data, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: FileApi.upload_file_handler ...' end # verify the required parameter 'tr_dataset' is set if @api_client.config.client_side_validation && tr_dataset.nil? fail ArgumentError, "Missing the required parameter 'tr_dataset' when calling FileApi.upload_file_handler" end # verify the required parameter 'upload_file_data' is set if @api_client.config.client_side_validation && upload_file_data.nil? fail ArgumentError, "Missing the required parameter 'upload_file_data' when calling FileApi.upload_file_handler" end # resource path local_var_path = '/api/file' # 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']) # 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 header_params[:'TR-Dataset'] = tr_dataset # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(upload_file_data) # return_type return_type = opts[:debug_return_type] || 'UploadFileResult' # auth_names auth_names = opts[:debug_auth_names] || ['ApiKey'] = opts.merge( :operation => :"FileApi.upload_file_handler", :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: FileApi#upload_file_handler\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |