Class: GroupDocsViewerCloud::FileApi

Inherits:
Object
  • Object
show all
Defined in:
lib/groupdocs_viewer_cloud/api/file_api.rb

Overview

GroupDocs.Viewer Cloud API

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ FileApi

Initializes new instance of FileApi

Parameters:



43
44
45
46
47
# File 'lib/groupdocs_viewer_cloud/api/file_api.rb', line 43

def initialize(config)
  @config = config
  @api_client = ApiClient.new(config)
  @access_token = nil
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



34
35
36
# File 'lib/groupdocs_viewer_cloud/api/file_api.rb', line 34

def config
  @config
end

Class Method Details

.from_config(config) ⇒ FileApi

Initializes new instance of FileApi

Parameters:

Returns:

  • (FileApi)

    New instance of FileApi



63
64
65
# File 'lib/groupdocs_viewer_cloud/api/file_api.rb', line 63

def self.from_config(config)
  return new(config)
end

.from_keys(app_sid, app_key) ⇒ FileApi

Initializes new instance of FileApi

Parameters:

  • Application (app_sid)

    identifier (App SID)

  • Application (app_key)

    private key (App Key)

Returns:

  • (FileApi)

    New instance of FileApi



54
55
56
57
# File 'lib/groupdocs_viewer_cloud/api/file_api.rb', line 54

def self.from_keys(app_sid, app_key)
  config = Configuration.new(app_sid, app_key)
  return new(config)
end

Instance Method Details

#copy_file(request) ⇒ nil

Copy file

Parameters:

  • request

    copy_file_request

Returns:

  • (nil)


71
72
73
74
# File 'lib/groupdocs_viewer_cloud/api/file_api.rb', line 71

def copy_file(request)
  copy_file_with_http_info(request)
  nil
end

#copy_file_with_http_info(request) ⇒ Array<(nil, Fixnum, Hash)>

Copy file

nil, response status code and response headers

Parameters:

  • request

    copy_file_request

Returns:

  • (Array<(nil, Fixnum, Hash)>)

Raises:

  • (ArgumentError)


81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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
# File 'lib/groupdocs_viewer_cloud/api/file_api.rb', line 81

def copy_file_with_http_info(request)
  raise ArgumentError, 'Incorrect request type' unless request.is_a? CopyFileRequest

  @api_client.config.logger.debug 'Calling API: FileApi.copy_file ...' if @api_client.config.debugging
  # verify the required parameter 'src_path' is set
  raise ArgumentError, 'Missing the required parameter src_path when calling FileApi.copy_file' if @api_client.config.client_side_validation && request.src_path.nil?
  # verify the required parameter 'dest_path' is set
  raise ArgumentError, 'Missing the required parameter dest_path when calling FileApi.copy_file' if @api_client.config.client_side_validation && request.dest_path.nil?
  # resource path
  local_var_path = '/viewer/storage/file/copy/{srcPath}'
  local_var_path = local_var_path.sub('{' + downcase_first_letter('srcPath') + '}', request.src_path.to_s)

  # query parameters
  query_params = {}
  query_params[downcase_first_letter('destPath')] = request.dest_path

  if local_var_path.include? ('{' + downcase_first_letter('srcStorageName') + '}')
    local_var_path = local_var_path.sub('{' + downcase_first_letter('srcStorageName') + '}', request.src_storage_name.to_s)
  else
    query_params[downcase_first_letter('srcStorageName')] = request.src_storage_name unless request.src_storage_name.nil?
  end
  if local_var_path.include? ('{' + downcase_first_letter('destStorageName') + '}')
    local_var_path = local_var_path.sub('{' + downcase_first_letter('destStorageName') + '}', request.dest_storage_name.to_s)
  else
    query_params[downcase_first_letter('destStorageName')] = request.dest_storage_name unless request.dest_storage_name.nil?
  end
  if local_var_path.include? ('{' + downcase_first_letter('versionId') + '}')
    local_var_path = local_var_path.sub('{' + downcase_first_letter('versionId') + '}', request.version_id.to_s)
  else
    query_params[downcase_first_letter('versionId')] = request.version_id unless request.version_id.nil?
  end

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
                                                    header_params: header_params,
                                                    query_params: query_params,
                                                    form_params: form_params,
                                                    body: post_body,
                                                    access_token: get_access_token)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called:
    FileApi#copy_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  [data, status_code, headers]
end

#delete_file(request) ⇒ nil

Delete file

Parameters:

  • request

    delete_file_request

Returns:

  • (nil)


142
143
144
145
# File 'lib/groupdocs_viewer_cloud/api/file_api.rb', line 142

def delete_file(request)
  delete_file_with_http_info(request)
  nil
end

#delete_file_with_http_info(request) ⇒ Array<(nil, Fixnum, Hash)>

Delete file

nil, response status code and response headers

Parameters:

  • request

    delete_file_request

Returns:

  • (Array<(nil, Fixnum, Hash)>)

Raises:

  • (ArgumentError)


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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/groupdocs_viewer_cloud/api/file_api.rb', line 152

def delete_file_with_http_info(request)
  raise ArgumentError, 'Incorrect request type' unless request.is_a? DeleteFileRequest

  @api_client.config.logger.debug 'Calling API: FileApi.delete_file ...' if @api_client.config.debugging
  # verify the required parameter 'path' is set
  raise ArgumentError, 'Missing the required parameter path when calling FileApi.delete_file' if @api_client.config.client_side_validation && request.path.nil?
  # resource path
  local_var_path = '/viewer/storage/file/{path}'
  local_var_path = local_var_path.sub('{' + downcase_first_letter('path') + '}', request.path.to_s)

  # query parameters
  query_params = {}
  if local_var_path.include? ('{' + downcase_first_letter('storageName') + '}')
    local_var_path = local_var_path.sub('{' + downcase_first_letter('storageName') + '}', request.storage_name.to_s)
  else
    query_params[downcase_first_letter('storageName')] = request.storage_name unless request.storage_name.nil?
  end
  if local_var_path.include? ('{' + downcase_first_letter('versionId') + '}')
    local_var_path = local_var_path.sub('{' + downcase_first_letter('versionId') + '}', request.version_id.to_s)
  else
    query_params[downcase_first_letter('versionId')] = request.version_id unless request.version_id.nil?
  end

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
                                                    header_params: header_params,
                                                    query_params: query_params,
                                                    form_params: form_params,
                                                    body: post_body,
                                                    access_token: get_access_token)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called:
    FileApi#delete_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  [data, status_code, headers]
end

#download_file(request) ⇒ File

Download file

Parameters:

  • request

    download_file_request

Returns:

  • (File)


204
205
206
207
# File 'lib/groupdocs_viewer_cloud/api/file_api.rb', line 204

def download_file(request)
  data, _status_code, _headers = download_file_with_http_info(request)
  data
end

#download_file_with_http_info(request) ⇒ Array<(File, Fixnum, Hash)>

Download file

File data, response status code and response headers

Parameters:

  • request

    download_file_request

Returns:

  • (Array<(File, Fixnum, Hash)>)

Raises:

  • (ArgumentError)


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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/groupdocs_viewer_cloud/api/file_api.rb', line 214

def download_file_with_http_info(request)
  raise ArgumentError, 'Incorrect request type' unless request.is_a? DownloadFileRequest

  @api_client.config.logger.debug 'Calling API: FileApi.download_file ...' if @api_client.config.debugging
  # verify the required parameter 'path' is set
  raise ArgumentError, 'Missing the required parameter path when calling FileApi.download_file' if @api_client.config.client_side_validation && request.path.nil?
  # resource path
  local_var_path = '/viewer/storage/file/{path}'
  local_var_path = local_var_path.sub('{' + downcase_first_letter('path') + '}', request.path.to_s)

  # query parameters
  query_params = {}
  if local_var_path.include? ('{' + downcase_first_letter('storageName') + '}')
    local_var_path = local_var_path.sub('{' + downcase_first_letter('storageName') + '}', request.storage_name.to_s)
  else
    query_params[downcase_first_letter('storageName')] = request.storage_name unless request.storage_name.nil?
  end
  if local_var_path.include? ('{' + downcase_first_letter('versionId') + '}')
    local_var_path = local_var_path.sub('{' + downcase_first_letter('versionId') + '}', request.version_id.to_s)
  else
    query_params[downcase_first_letter('versionId')] = request.version_id unless request.version_id.nil?
  end

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['multipart/form-data'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
                                                    header_params: header_params,
                                                    query_params: query_params,
                                                    form_params: form_params,
                                                    body: post_body,
                                                    access_token: get_access_token,
                                                    return_type: 'File')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called:
    FileApi#download_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  [data, status_code, headers]
end

#move_file(request) ⇒ nil

Move file

Parameters:

  • request

    move_file_request

Returns:

  • (nil)


267
268
269
270
# File 'lib/groupdocs_viewer_cloud/api/file_api.rb', line 267

def move_file(request)
  move_file_with_http_info(request)
  nil
end

#move_file_with_http_info(request) ⇒ Array<(nil, Fixnum, Hash)>

Move file

nil, response status code and response headers

Parameters:

  • request

    move_file_request

Returns:

  • (Array<(nil, Fixnum, Hash)>)

Raises:

  • (ArgumentError)


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
323
324
325
326
327
328
329
330
331
332
# File 'lib/groupdocs_viewer_cloud/api/file_api.rb', line 277

def move_file_with_http_info(request)
  raise ArgumentError, 'Incorrect request type' unless request.is_a? MoveFileRequest

  @api_client.config.logger.debug 'Calling API: FileApi.move_file ...' if @api_client.config.debugging
  # verify the required parameter 'src_path' is set
  raise ArgumentError, 'Missing the required parameter src_path when calling FileApi.move_file' if @api_client.config.client_side_validation && request.src_path.nil?
  # verify the required parameter 'dest_path' is set
  raise ArgumentError, 'Missing the required parameter dest_path when calling FileApi.move_file' if @api_client.config.client_side_validation && request.dest_path.nil?
  # resource path
  local_var_path = '/viewer/storage/file/move/{srcPath}'
  local_var_path = local_var_path.sub('{' + downcase_first_letter('srcPath') + '}', request.src_path.to_s)

  # query parameters
  query_params = {}
  query_params[downcase_first_letter('destPath')] = request.dest_path

  if local_var_path.include? ('{' + downcase_first_letter('srcStorageName') + '}')
    local_var_path = local_var_path.sub('{' + downcase_first_letter('srcStorageName') + '}', request.src_storage_name.to_s)
  else
    query_params[downcase_first_letter('srcStorageName')] = request.src_storage_name unless request.src_storage_name.nil?
  end
  if local_var_path.include? ('{' + downcase_first_letter('destStorageName') + '}')
    local_var_path = local_var_path.sub('{' + downcase_first_letter('destStorageName') + '}', request.dest_storage_name.to_s)
  else
    query_params[downcase_first_letter('destStorageName')] = request.dest_storage_name unless request.dest_storage_name.nil?
  end
  if local_var_path.include? ('{' + downcase_first_letter('versionId') + '}')
    local_var_path = local_var_path.sub('{' + downcase_first_letter('versionId') + '}', request.version_id.to_s)
  else
    query_params[downcase_first_letter('versionId')] = request.version_id unless request.version_id.nil?
  end

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
                                                    header_params: header_params,
                                                    query_params: query_params,
                                                    form_params: form_params,
                                                    body: post_body,
                                                    access_token: get_access_token)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called:
    FileApi#move_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  [data, status_code, headers]
end

#upload_file(request) ⇒ FilesUploadResult

Upload file

Parameters:

  • request

    upload_file_request

Returns:



338
339
340
341
# File 'lib/groupdocs_viewer_cloud/api/file_api.rb', line 338

def upload_file(request)
  data, _status_code, _headers = upload_file_with_http_info(request)
  data
end

#upload_file_with_http_info(request) ⇒ Array<(FilesUploadResult, Fixnum, Hash)>

Upload file

FilesUploadResult data, response status code and response headers

Parameters:

  • request

    upload_file_request

Returns:

Raises:

  • (ArgumentError)


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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'lib/groupdocs_viewer_cloud/api/file_api.rb', line 348

def upload_file_with_http_info(request)
  raise ArgumentError, 'Incorrect request type' unless request.is_a? UploadFileRequest

  @api_client.config.logger.debug 'Calling API: FileApi.upload_file ...' if @api_client.config.debugging
  # verify the required parameter 'path' is set
  raise ArgumentError, 'Missing the required parameter path when calling FileApi.upload_file' if @api_client.config.client_side_validation && request.path.nil?
  # verify the required parameter 'file' is set
  raise ArgumentError, 'Missing the required parameter file when calling FileApi.upload_file' if @api_client.config.client_side_validation && request.file.nil?
  # resource path
  local_var_path = '/viewer/storage/file/{path}'
  local_var_path = local_var_path.sub('{' + downcase_first_letter('path') + '}', request.path.to_s)

  # query parameters
  query_params = {}
  if local_var_path.include? ('{' + downcase_first_letter('storageName') + '}')
    local_var_path = local_var_path.sub('{' + downcase_first_letter('storageName') + '}', request.storage_name.to_s)
  else
    query_params[downcase_first_letter('storageName')] = request.storage_name unless request.storage_name.nil?
  end

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])

  # form parameters
  form_params = {}
  form_params[downcase_first_letter('File')] = request.file

  # http body (model)
  post_body = nil
  data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
                                                    header_params: header_params,
                                                    query_params: query_params,
                                                    form_params: form_params,
                                                    body: post_body,
                                                    access_token: get_access_token,
                                                    return_type: 'FilesUploadResult')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called:
    FileApi#upload_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  [data, status_code, headers]
end