Class: OpenApiOpenAIClient::UploadsApi
- Inherits:
-
Object
- Object
- OpenApiOpenAIClient::UploadsApi
- Defined in:
- lib/openapi_openai/api/uploads_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#add_upload_part(upload_id, data, opts = {}) ⇒ UploadPart
Adds a [Part](/docs/api-reference/uploads/part-object) to an [Upload](/docs/api-reference/uploads/object) object.
-
#add_upload_part_with_http_info(upload_id, data, opts = {}) ⇒ Array<(UploadPart, Integer, Hash)>
Adds a [Part](/docs/api-reference/uploads/part-object) to an [Upload](/docs/api-reference/uploads/object) object.
-
#cancel_upload(upload_id, opts = {}) ⇒ Upload
Cancels the Upload.
-
#cancel_upload_with_http_info(upload_id, opts = {}) ⇒ Array<(Upload, Integer, Hash)>
Cancels the Upload.
-
#complete_upload(upload_id, complete_upload_request, opts = {}) ⇒ Upload
Completes the [Upload](/docs/api-reference/uploads/object).
-
#complete_upload_with_http_info(upload_id, complete_upload_request, opts = {}) ⇒ Array<(Upload, Integer, Hash)>
Completes the [Upload](/docs/api-reference/uploads/object).
-
#create_upload(create_upload_request, opts = {}) ⇒ Upload
Creates an intermediate [Upload](/docs/api-reference/uploads/object) object that you can add [Parts](/docs/api-reference/uploads/part-object) to.
-
#create_upload_with_http_info(create_upload_request, opts = {}) ⇒ Array<(Upload, Integer, Hash)>
Creates an intermediate [Upload](/docs/api-reference/uploads/object) object that you can add [Parts](/docs/api-reference/uploads/part-object) to.
-
#initialize(api_client = ApiClient.default) ⇒ UploadsApi
constructor
A new instance of UploadsApi.
Constructor Details
#initialize(api_client = ApiClient.default) ⇒ UploadsApi
Returns a new instance of UploadsApi.
19 20 21 |
# File 'lib/openapi_openai/api/uploads_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/openapi_openai/api/uploads_api.rb', line 17 def api_client @api_client end |
Instance Method Details
#add_upload_part(upload_id, data, opts = {}) ⇒ UploadPart
Adds a [Part](/docs/api-reference/uploads/part-object) to an [Upload](/docs/api-reference/uploads/object) object. A Part represents a chunk of bytes from the file you are trying to upload. Each Part can be at most 64 MB, and you can add Parts until you hit the Upload maximum of 8 GB. It is possible to add multiple Parts in parallel. You can decide the intended order of the Parts when you [complete the Upload](/docs/api-reference/uploads/complete).
27 28 29 30 |
# File 'lib/openapi_openai/api/uploads_api.rb', line 27 def add_upload_part(upload_id, data, opts = {}) data, _status_code, _headers = add_upload_part_with_http_info(upload_id, data, opts) data end |
#add_upload_part_with_http_info(upload_id, data, opts = {}) ⇒ Array<(UploadPart, Integer, Hash)>
Adds a [Part](/docs/api-reference/uploads/part-object) to an [Upload](/docs/api-reference/uploads/object) object. A Part represents a chunk of bytes from the file you are trying to upload. Each Part can be at most 64 MB, and you can add Parts until you hit the Upload maximum of 8 GB. It is possible to add multiple Parts in parallel. You can decide the intended order of the Parts when you [complete the Upload](/docs/api-reference/uploads/complete).
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 89 90 91 92 93 |
# File 'lib/openapi_openai/api/uploads_api.rb', line 37 def add_upload_part_with_http_info(upload_id, data, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: UploadsApi.add_upload_part ...' end # verify the required parameter 'upload_id' is set if @api_client.config.client_side_validation && upload_id.nil? fail ArgumentError, "Missing the required parameter 'upload_id' when calling UploadsApi.add_upload_part" end # verify the required parameter 'data' is set if @api_client.config.client_side_validation && data.nil? fail ArgumentError, "Missing the required parameter 'data' when calling UploadsApi.add_upload_part" end # resource path local_var_path = '/uploads/{upload_id}/parts'.sub('{' + 'upload_id' + '}', CGI.escape(upload_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(['multipart/form-data']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} form_params['data'] = data # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'UploadPart' # auth_names auth_names = opts[:debug_auth_names] || ['ApiKeyAuth'] = opts.merge( :operation => :"UploadsApi.add_upload_part", :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: UploadsApi#add_upload_part\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#cancel_upload(upload_id, opts = {}) ⇒ Upload
Cancels the Upload. No Parts may be added after an Upload is cancelled.
99 100 101 102 |
# File 'lib/openapi_openai/api/uploads_api.rb', line 99 def cancel_upload(upload_id, opts = {}) data, _status_code, _headers = cancel_upload_with_http_info(upload_id, opts) data end |
#cancel_upload_with_http_info(upload_id, opts = {}) ⇒ Array<(Upload, Integer, Hash)>
Cancels the Upload. No Parts may be added after an Upload is cancelled.
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 |
# File 'lib/openapi_openai/api/uploads_api.rb', line 108 def cancel_upload_with_http_info(upload_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: UploadsApi.cancel_upload ...' end # verify the required parameter 'upload_id' is set if @api_client.config.client_side_validation && upload_id.nil? fail ArgumentError, "Missing the required parameter 'upload_id' when calling UploadsApi.cancel_upload" end # resource path local_var_path = '/uploads/{upload_id}/cancel'.sub('{' + 'upload_id' + '}', CGI.escape(upload_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'] # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Upload' # auth_names auth_names = opts[:debug_auth_names] || ['ApiKeyAuth'] = opts.merge( :operation => :"UploadsApi.cancel_upload", :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: UploadsApi#cancel_upload\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#complete_upload(upload_id, complete_upload_request, opts = {}) ⇒ Upload
Completes the [Upload](/docs/api-reference/uploads/object). Within the returned Upload object, there is a nested [File](/docs/api-reference/files/object) object that is ready to use in the rest of the platform. You can specify the order of the Parts by passing in an ordered list of the Part IDs. The number of bytes uploaded upon completion must match the number of bytes initially specified when creating the Upload object. No Parts may be added after an Upload is completed.
161 162 163 164 |
# File 'lib/openapi_openai/api/uploads_api.rb', line 161 def complete_upload(upload_id, complete_upload_request, opts = {}) data, _status_code, _headers = complete_upload_with_http_info(upload_id, complete_upload_request, opts) data end |
#complete_upload_with_http_info(upload_id, complete_upload_request, opts = {}) ⇒ Array<(Upload, Integer, Hash)>
Completes the [Upload](/docs/api-reference/uploads/object). Within the returned Upload object, there is a nested [File](/docs/api-reference/files/object) object that is ready to use in the rest of the platform. You can specify the order of the Parts by passing in an ordered list of the Part IDs. The number of bytes uploaded upon completion must match the number of bytes initially specified when creating the Upload object. No Parts may be added after an Upload is completed.
171 172 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 225 226 |
# File 'lib/openapi_openai/api/uploads_api.rb', line 171 def complete_upload_with_http_info(upload_id, complete_upload_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: UploadsApi.complete_upload ...' end # verify the required parameter 'upload_id' is set if @api_client.config.client_side_validation && upload_id.nil? fail ArgumentError, "Missing the required parameter 'upload_id' when calling UploadsApi.complete_upload" end # verify the required parameter 'complete_upload_request' is set if @api_client.config.client_side_validation && complete_upload_request.nil? fail ArgumentError, "Missing the required parameter 'complete_upload_request' when calling UploadsApi.complete_upload" end # resource path local_var_path = '/uploads/{upload_id}/complete'.sub('{' + 'upload_id' + '}', CGI.escape(upload_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(complete_upload_request) # return_type return_type = opts[:debug_return_type] || 'Upload' # auth_names auth_names = opts[:debug_auth_names] || ['ApiKeyAuth'] = opts.merge( :operation => :"UploadsApi.complete_upload", :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: UploadsApi#complete_upload\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#create_upload(create_upload_request, opts = {}) ⇒ Upload
Creates an intermediate [Upload](/docs/api-reference/uploads/object) object that you can add [Parts](/docs/api-reference/uploads/part-object) to. Currently, an Upload can accept at most 8 GB in total and expires after an hour after you create it. Once you complete the Upload, we will create a [File](/docs/api-reference/files/object) object that contains all the parts you uploaded. This File is usable in the rest of our platform as a regular File object. For certain ‘purpose`s, the correct mime_type must be specified. Please refer to documentation for the supported MIME types for your use case: - [Assistants](/docs/assistants/tools/file-search#supported-files) For guidance on the proper filename extensions for each purpose, please follow the documentation on [creating a File](/docs/api-reference/files/create).
232 233 234 235 |
# File 'lib/openapi_openai/api/uploads_api.rb', line 232 def create_upload(create_upload_request, opts = {}) data, _status_code, _headers = create_upload_with_http_info(create_upload_request, opts) data end |
#create_upload_with_http_info(create_upload_request, opts = {}) ⇒ Array<(Upload, Integer, Hash)>
Creates an intermediate [Upload](/docs/api-reference/uploads/object) object that you can add [Parts](/docs/api-reference/uploads/part-object) to. Currently, an Upload can accept at most 8 GB in total and expires after an hour after you create it. Once you complete the Upload, we will create a [File](/docs/api-reference/files/object) object that contains all the parts you uploaded. This File is usable in the rest of our platform as a regular File object. For certain `purpose`s, the correct `mime_type` must be specified. Please refer to documentation for the supported MIME types for your use case: - [Assistants](/docs/assistants/tools/file-search#supported-files) For guidance on the proper filename extensions for each purpose, please follow the documentation on [creating a File](/docs/api-reference/files/create).
241 242 243 244 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 |
# File 'lib/openapi_openai/api/uploads_api.rb', line 241 def create_upload_with_http_info(create_upload_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: UploadsApi.create_upload ...' end # verify the required parameter 'create_upload_request' is set if @api_client.config.client_side_validation && create_upload_request.nil? fail ArgumentError, "Missing the required parameter 'create_upload_request' when calling UploadsApi.create_upload" end # resource path local_var_path = '/uploads' # 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(create_upload_request) # return_type return_type = opts[:debug_return_type] || 'Upload' # auth_names auth_names = opts[:debug_auth_names] || ['ApiKeyAuth'] = opts.merge( :operation => :"UploadsApi.create_upload", :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: UploadsApi#create_upload\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |