Class: Ubiquity::MediaSilo::API::V3::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ubiquity/mediasilo/api/v3/client/requests/base_request.rb,
lib/ubiquity/mediasilo/api/v3/client.rb

Direct Known Subclasses

Utilities

Defined Under Namespace

Modules: Requests Classes: Paginator

Instance Attribute Summary collapse

API Methods collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = { }) ⇒ Client

Returns a new instance of Client.



11
12
13
14
15
16
17
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 11

def initialize(args = { })
  initialize_logger(args)
  initialize_http_client(args)

  @batch_mode = false
  @batch_requests = [ ]
end

Instance Attribute Details

#batch_requestsObject

Returns the value of attribute batch_requests.



9
10
11
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 9

def batch_requests
  @batch_requests
end

#http_clientObject

Returns the value of attribute http_client.



9
10
11
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 9

def http_client
  @http_client
end

#http_responseObject

Returns the value of attribute http_response.



9
10
11
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 9

def http_response
  @http_response
end

#loggerObject

Returns the value of attribute logger.



7
8
9
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 7

def logger
  @logger
end

#requestObject

Returns the value of attribute request.



9
10
11
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 9

def request
  @request
end

#responseObject

Returns the value of attribute response.



9
10
11
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 9

def response
  @response
end

Instance Method Details

#aspera_file_download_ticket_create(args = { }, options = { }) ⇒ Object



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 97

def aspera_file_download_ticket_create(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'aspera/download/#{path_arguments[:asset_id]}/#{path_arguments[:target]}',
      :http_method => :post,
      :parameters => [
        { :name => :asset_id, :send_in => :path },
        { :name => :target, :send_in => :path } # Either 'source' or 'proxy'
      ]
    }
  )
  response = process_request(_request, options)
  response
end

#aspera_file_upload_ticket_create(args = { }, options = { }) ⇒ Object



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 114

def aspera_file_upload_ticket_create(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'aspera/upload',
      :http_method => :post,
      :parameters => [
        { :name => :fileName, :send_in => :body }
      ]
    }
  )

  response = process_request(_request, options)
  response
end

#asset_copy_to_folder(args = { }, options = { }) ⇒ Object



130
131
132
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 130

def asset_copy_to_folder(args = { }, options = { })
  process_request_using_class(Requests::AssetCopyToFolder, args, options)
end

#asset_copy_to_project(args = { }, options = { }) ⇒ Object



134
135
136
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 134

def asset_copy_to_project(args = { }, options = { })
  process_request_using_class(Requests::AssetCopyToProject, args, options)
end

#asset_create(args = { }, options = { }) ⇒ Object



139
140
141
142
143
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 139

def asset_create(args = { }, options = { })
  # args_out = Requests::AssetCreate.new(args, options).arguments
  # @response = http_client.post('/assets', args_out)
  process_request_using_class(Requests::AssetCreate, args, options)
end

#asset_delete_by_id(args = { }, options = { }) ⇒ Object Also known as: asset_delete



145
146
147
148
149
150
151
152
153
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 145

def asset_delete_by_id(args = { }, options = { })
  # asset_id = asset_id[:id] if asset_id.is_a?(Hash)
  # @response = http_client.delete('/assets/%s' % asset_id)

  args = { :assetId => args } if args.is_a?(String)
  # _request = Requests::AssetDelete.new(args, options)
  # @response = http_client.delete(_request.path)
  process_request_using_class(Requests::AssetDelete, args, options)
end

#asset_edit(args = { }, options = { }) ⇒ Object



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 157

def asset_edit(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_method => :put,
      :http_path => 'assets/#{path_arguments[:asset_id]}',
      :http_success_code => 204,
      :parameters => [
        { :name => :asset_id, :aliases => [ :id ], :send_in => :path, :required => true },
        { :name => :title, :send_in => :body },
        { :name => :description, :send_in => :body }
      ]
    }
  )
  process_request(_request, options)
end

#asset_get_by_id(args = { }, options = { }) ⇒ Object



175
176
177
178
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 175

def asset_get_by_id(args = { }, options = { })
  args = { :asset_id => args } if args.is_a?(String)
  process_request_using_class(Requests::AssetGetById, args, options)
end

#asset_move_to_folder(args = { }, options = { }) ⇒ Object



257
258
259
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 257

def asset_move_to_folder(args = { }, options = { })
  process_request_using_class(Requests::AssetMoveToFolder, args, options)
end

#asset_move_to_project(args = { }, options = { }) ⇒ Object



261
262
263
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 261

def asset_move_to_project(args = { }, options = { })
  process_request_using_class(Requests::AssetMoveToProject, args, options)
end

#asset_tag_add(args = { }, options = { }) ⇒ Object Also known as: asset_tags_add, asset_add_tag



266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 266

def asset_tag_add(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_method => :post,
      :http_success_code => '204',
      :http_path => 'assets/#{path_arguments[:asset_id]}/tags',
      :parameters => [
        { :name => :asset_id, :aliases => [ :id ], :send_in => :path, :required => true },
        { :name => :tags, :aliases => [ :tag ], :send_in => :body },
      ]
    }
  )
  _tags = _request.arguments[:tags]
  _request.arguments[:tags] = [*_tags] unless _tags.is_a?(Array)

  process_request(_request, options)
end

#asset_tag_delete(args = { }, options = { }) ⇒ Object Also known as: asset_tag_remove



287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 287

def asset_tag_delete(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_method => :delete,
      :http_success_code => '204',
      :http_path => 'assets/#{path_arguments[:asset_id]}/tags/#{path_arguments[:tag]}',
      :parameters => [
        { :name => :asset_id, :aliases => [ :id ], :send_in => :path, :required => true },
        { :name => :tag, :send_in => :path },
      ]
    }
  )
  process_request(_request, options)
end

#asset_upload(args = { }, options = { }) ⇒ Object



318
319
320
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 318

def asset_upload(args = { }, options = { })

end

#asset_upload_ticket_create(args = { }, options = { }) ⇒ Object



304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 304

def asset_upload_ticket_create(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_method => :post,
      :http_path => 'assets/upload',
      :parameters => [
        { :name => :fileName, :send_in => :body }
      ]
    }
  )
  process_request(_request, options)
end

#asset_watermark_trigger(args = { }, options = { }) ⇒ Object

This endpoint is available to admins on any user id, or the current user on their own user id. It returns immediately, and watermarking runs in the background. To check whether the watermarking is done, you need to get the ‘proxy’ derivative our of the asset response model and check the ‘progress’ key. Be careful, because there are also ‘progress’ values at the base of the asset response model as well as in the ‘preroll’ derivative. You want the ‘proxy’ one. When that hits 100, the video is ready to play back.

Parameters:

  • args (Hash) (defaults to: { })

    ({ })

Options Hash (args):

  • :asset_id (String)
  • :user_id (String)


331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 331

def asset_watermark_trigger(args = { }, options = { })
  _request = Requests::BaseRequest.new(
      args,
      {
          :http_method => :post,
          :http_success_code => '204',
          :http_path => 'assets/#{path_arguments[:asset_id]}/watermark/#{path_arguments[:user_id]}',
          :parameters => [
              { :name => :asset_id, :aliases => [ :id ], :send_in => :path, :required => true },
              { :name => :user_id, :send_in => :path },
          ]
      }
  )
  process_request(_request, options)
end

#assets_get(args = { }, options = { }) ⇒ Object



181
182
183
184
185
186
187
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 181

def assets_get(args = { }, options = { })
  # query = options[:query] || { :type => '{"in":"video,image,document,archive,audio"}' }
  # @response = http_client.get('/assets', query)
  _response = process_request_using_class(Requests::AssetsGet, args, options)
  _response = [ ] unless _response.is_a?(Array)
  _response
end

#assets_get_by_folder_id(args = { }, options = { }) ⇒ Array

Note:

This will get all assets for a folder

Parameters:

  • args (Hash) (defaults to: { })

Options Hash (args):

  • folder_id (String)

    The Id of the folder to get the assets for

Returns:

  • (Array)

See Also:



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
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 194

def assets_get_by_folder_id(args = { }, options = { })
  args = { :id => args } if args.is_a?(String)

  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'folders/#{path_arguments[:folder_id]}/assets',
      :parameters => [
        { :name => :folder_id, :aliases => [ :id ], :send_in => :path, :required => true },
        {
          :name => :type,
          # Received a 500 Request Failed error if 'type' was not set so we default it
          # :default_value => '{"in":"video,image,document,archive,audio"}',
          :send_in => :query
        },
        { :name => :_page, :aliases => [ :page ], :send_in => :query },
        { :name => :_pageSize, :aliases => [ :page_size ], :send_in => :query },
        { :name => :_sort, :aliases => [ :sort ], :send_in => :query },
        { :name => :_sortBy, :aliases => [ :sort_by ], :send_in => :query }
      ]
    }
  )
  response = process_request(_request, options)
  response
end

#assets_get_by_project_id(args = { }, options = { }) ⇒ Array

Note:

This will get all assets for a project

Parameters:

  • args (Hash) (defaults to: { })

Options Hash (args):

  • project_id (String)

    The Id of the project to get the assets for

Returns:

  • (Array)

See Also:



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
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 226

def assets_get_by_project_id(args = { }, options = { })
  args = { :id => args } if args.is_a?(String)

  # return_all_results = options.fetch(:return_all_results, false)

  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'projects/#{path_arguments[:project_id]}/assets',
      :parameters => [
        { :name => :project_id, :aliases => [ :id ], :send_in => :path, :required => true },
        {
          :name => :type,
          # Received a 500 Request Failed error if 'type' was not set so we default it
          # :default_value => '{"in":"video,image,document,archive,audio"}',
          :send_in => :query
        },
        { :name => :_page, :aliases => [ :page ], :send_in => :query },
        { :name => :_pageSize, :aliases => [ :page_size ], :send_in => :query },
        { :name => :_sort, :aliases => [ :sort ], :send_in => :query },
        { :name => :_sortBy, :aliases => [ :sort_by ], :send_in => :query }
      ]
    }
  )
  response = process_request(_request, args)

  # response.delete_if { |asset| asset['folderId'] } if response.is_a?(Array) &&!return_all_results

  response
end

#batch_execute(requests = nil, options = { }) ⇒ Object

Executes the queued requests as a batch

Parameters:

  • requests (Array) (defaults to: nil)

    (@batch_requests)

  • options (Hash) (defaults to: { })


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
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 350

def batch_execute(requests = nil, options = { })
  if block_given?
    @batch_mode = true
    yield
    _requests = @batch_requests + (requests || [ ])
  else
    _requests = requests.nil? ? @batch_requests.dup : requests.dup
  end
  @batch_mode = false
  return [ ] if _requests.empty?
  _requests.map! { |req| req.respond_to?(:to_batchable_request) ? req.to_batchable_request : req }
  _response = [ ]

  if requests.nil? and options.fetch(:clear_requests, true)
    @batch_requests = [ ]
  else
    requests = [ ]
  end

  # @request_history.concat(_requests)
  _requests.each_slice(50) do |_req|
    process_request_using_class(Requests::Batch, { :requests => _req }, options)
    _response << @response
  end
  @response = _response
end

#batch_mode=(value, options = { }) ⇒ Object

Sets the batch mode

Parameters:

  • value (True, False)


379
380
381
382
383
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 379

def batch_mode=(value, options = { })
  @batch_mode = value
  @batch_requests = [ ] if value and options.fetch(:clear_requests, true)
  @batch_mode
end

#batch_mode?Boolean Also known as: batch_mode

Returns true if the client is currently batching requests

Returns:

  • (Boolean)


386
387
388
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 386

def batch_mode?
  @batch_mode
end

#batch_mode_enableObject



391
392
393
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 391

def batch_mode_enable
  self.batch_mode = true
end

#error_messageObject



33
34
35
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 33

def error_message
  response.is_a?(String) ? response.gsub(/<[^>]*>/ui,'') : ''
end

#folder_create(args = { }, options = { }) ⇒ Object



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
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 396

def folder_create(args = { }, options = { })
  # @response = http_client.post('/folders', args)

  _request = Requests::BaseRequest.new(
    args,
    {
      :http_method => :post,
      :http_path => 'folders',
      :parameters => [
        { :name => :name, :send_in => :body },
        { :name => :projectId, :send_in => :body },
        { :name => :parentId, :default_value => 0, :send_in => :body }
      ]
    }
  )

  # arguments = _request.arguments
  # parent_id = arguments[:parentId]
  #
  # if parent_id && parent_id != 0
  #   logger.debug { 'Unsetting projectId because parentId is set.'  }
  #   arguments.delete(:projectId)
  # end
  #
  # _request.arguments = arguments

  process_request(_request, options)
end

#folder_delete(args = { }, options = { }) ⇒ Object



425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 425

def folder_delete(args = { }, options = { })
  # folder_id = folder_id[:id] if folder_id.is_a?(Hash)
  # @response = http_client.delete('/folders/%s' % folder_id)

  args = { :folder_id => args } if args.is_a?(String)
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_method => :delete,
      :http_path => 'folders/#{path_arguments[:folder_id]}',
      :parameters => [
        { :name => :folder_id, :aliases => [ :id ], :send_in => :path }
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

#folder_get_by_id(args = { }, options = { }) ⇒ Object



443
444
445
446
447
448
449
450
451
452
453
454
455
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 443

def folder_get_by_id(args = { }, options = { })
  args = { :folder_id => args } if args.is_a?(String)
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'folders/#{path_arguments[:folder_id]}',
      :parameters => [
        { :name => :folder_id, :aliases => [ :id ], :send_in => :path }
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

#folders_get_by_parent_id(args = { }) ⇒ Object



457
458
459
460
461
462
463
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 457

def folders_get_by_parent_id(args = { })
  folder_id = case args
                when String; args
                when Hash; args[:id] || args[:parent_id]
              end
  @response = http_client.get('/folders/%s/subfolders' % folder_id)
end

#folders_get_by_project_id(args = { }) ⇒ Object



465
466
467
468
469
470
471
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 465

def folders_get_by_project_id(args = { })
  project_id = case args
                 when String; args
                 when Hash; args[:id] || args[:project_id]
               end
  @response = http_client.get('/projects/%s/folders' % project_id)
end

#initialize_http_client(args = { }) ⇒ Object



29
30
31
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 29

def initialize_http_client(args = { })
  @http_client = Ubiquity::MediaSilo::API::V3::HTTPClient.new(args)
end

#initialize_logger(args = { }) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 19

def initialize_logger(args = { })
  @logger = args[:logger] ||= Logger.new(args[:log_to] || STDOUT)
  log_level = args[:log_level]
  if log_level
    @logger.level = log_level
    args[:logger] = @logger
  end
  @logger
end

#metadata_create_or_update(args = { }, options = { }) ⇒ Object Also known as: metadata_set, metadata_add, metadata_create_if_not_exists



500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 500

def (args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'assets/#{path_arguments[:asset_id]}/metadata',
      :http_method => :post,
      :http_success_code => 204,
      :parameters => [
        { :name => :asset_id, :aliases => [ :id ], :send_in => :path, :required => true },
        { :name => :key, :send_in => :body},
        { :name => :value, :send_in => :body},
        { :name => :metadata, :send_in => :body},
      ]
    }.merge(options)
  )
   = _request.body_arguments.delete(:metadata) { }
   = .map { |k,v| { 'key' => k, 'value' => v } } if .is_a?(Hash)

  _request.body = .delete_if { |h| v = h['value']; (v.respond_to?(:empty?) && v.empty?) } if 
  process_request(_request, options)
end

#metadata_delete(args = { }, options = { }) ⇒ Object



526
527
528
529
530
531
532
533
534
535
536
537
538
539
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 526

def (args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'assets/#{path_arguments[:asset_id]}/metadata/#{path_arguments[:metadata_key]}',
      :http_method => :delete,
      :parameters => [
        { :name => :asset_id, :aliases => [ :id ], :send_in => :path, :required => true },
        { :name => :metadata_key, :aliases => [ :key ], :send_in => :path },
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

#metadata_get(args = { }, options = { }) ⇒ Object Also known as: metadata_get_by_asset_id, metadata_get_by_asset_uuid



473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 473

def (args = { }, options = { })
  return_as_hash = options.delete(:return_as_hash) { false }

  args = { :asset_id => args } unless args.is_a?(Hash)
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'assets/#{path_arguments[:asset_id]}/metadata',
      :http_success_code => %w(200 404),
      :parameters => [
        { :name => :asset_id, :aliases => [ :id ], :send_in => :path }
      ]
    }.merge(options)
  )
  _response = process_request(_request, options)

  return (return_as_hash ? {} : []) if _request.client.http_client.response.code == '404'
  return false unless _response.is_a?(Array)

  return Hash[ _response.map { |m| [ m['key'], m['value'] ] } ] if return_as_hash

  _response
end

#metadata_replace(args = { }, options = { }) ⇒ Object Also known as: metadata_mirror



542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 542

def (args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'assets/#{path_arguments[:asset_id]}/metadata',
      :http_method => :put,
      :parameters => [
        { :name => :asset_id, :aliases => [ :id ], :send_in => :path, :required => true },
        { :name => :key, :send_in => :body },
        { :name => :value, :send_in => :body },
        { :name => :metadata, :send_in => :body },
      ]
    }.merge(options)
  )
   = _request.body_arguments.delete(:metadata) { }
   = .map { |k,v| { 'key' => k, 'value' => v} } if .is_a?(Hash)
  _request.body =  if 
  process_request(_request, options)
end

#paginatorObject



83
84
85
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 83

def paginator
  @paginator ||= Paginator.new(self) if @response
end

#process_request(request, options = nil) ⇒ Object

Parameters:

Options Hash (options):

  • :execute_request (Boolean) — default: true

    Will execute the request

  • :return_request (Boolean) — default: true

    Will return the request instance instead of nil. Only applies if execute_request is false.



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
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 49

def process_request(request, options = nil)
  @paginator = nil
  @response = nil
  @request = request
  logger.warn { "Request is Missing Required Arguments: #{request.missing_required_arguments.inspect}" } unless request.missing_required_arguments.empty?

  if batch_mode
    logger.debug { "Adding Request to Batch. #{request.inspect}" }
    @batch_requests << request
    return batch_requests
  end

  if ([:all, 'all'].include?(request.arguments[:_page]))
    request.arguments[:_page] = 1
    include_remaining_pages = true
  else
    include_remaining_pages = false
  end

  request.client = self unless request.client
  options ||= request.options

  return (options.fetch(:return_request, true) ? request : nil) unless options.fetch(:execute_request, true)

  #@response = http_client.call_method(request.http_method, { :path => request.path, :query => request.query, :body => request.body }, options)
  @response = request.execute

  if include_remaining_pages
    return paginator.include_remaining_pages
  end

  @response
end

#process_request_using_class(request_class, args = { }, options = { }) ⇒ Object



87
88
89
90
91
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 87

def process_request_using_class(request_class, args = { }, options = { })
  @response = nil
  @request = request_class.new(args, options)
  process_request(request, options)
end

#project_create(args = { }, options = { }) ⇒ Object



564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 564

def project_create(args = { }, options = { })
  args = { :name => args } if args.is_a?(String)
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'projects',
      :http_method => :post,
      :parameters => [
        { :name => :name, :send_in => :body, :required => true },
        { :name => :description, :send_in => :body }
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

#project_delete(args = { }, options = { }) ⇒ Object



580
581
582
583
584
585
586
587
588
589
590
591
592
593
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 580

def project_delete(args = { }, options = { })
  args = { :project_id => args } if args.is_a?(String)
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'projects/#{path_arguments[:project_id]}',
      :http_method => :delete,
      :parameters => [
        { :name => :project_id, :aliases => [ :id ], :send_in => :path }
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

#project_get_by_id(args = { }, options = { }) ⇒ Object



595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 595

def project_get_by_id(args = { }, options = { })
  # project_id = project_id[:id] if project_id.is_a?(Hash)
  # @response = http_client.get('/projects/%s' % project_id)

  args = { :project_id => args } if args.is_a?(String)
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'projects/#{path_arguments[:project_id]}',
      :parameters => [
        { :name => :project_id, :aliases => [ :id ], :send_in => :path }
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

#project_watermark_settings_get(args = { }, options = { }) ⇒ Object



628
629
630
631
632
633
634
635
636
637
638
639
640
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 628

def project_watermark_settings_get(args = { }, options = { })
  args = { :project_id => args } if args.is_a?(String)
  _request = Requests::BaseRequest.new(
      args,
      {
          :http_path => 'projects/#{path_arguments[:project_id]}/watermarkSettings',
          :parameters => [
              { :name => :project_id, :aliases => [ :id ], :send_in => :path }
          ]
      }.merge(options)
  )
  process_request(_request, options)
end

#project_watermark_settings_set(args = { }, options = { }) ⇒ Object



642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 642

def project_watermark_settings_set(args = { }, options = { })
  args = { :project_id => args } if args.is_a?(String)
  _request = Requests::BaseRequest.new(
      args,
      {
          :http_path => 'projects/#{body_arguments[:context]}/watermarkSettings',
          :http_method => 'PUT',
          :parameters => [
              { :name => :context, :aliases => [ :project_id ], :send_in => :body },
              { :name => :id, :send_in => :body },
              { :name => :settings, :send_in => :body },
              { :name => :enabled, :send_in => :body },
          ]
      }.merge(options)
  )
  process_request(_request, options)
end

#projects_get(options = { }) ⇒ Object



612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 612

def projects_get(options = { })
  #@response = http_client.get('/projects')

  _request = Requests::BaseRequest.new(
    { },
    {
      :http_path => 'projects',
      :http_success_code => %w(200 404),
    }.merge(options)
  )
  _response = process_request(_request, options)
  return [] if _request.client.http_client.response.code == '404'

  return _response
end


660
661
662
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 660

def quicklink_create(args = { }, options = { })
  process_request_using_class(Requests::QuicklinkCreate, args, options)
end


664
665
666
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 664

def quicklink_share(args = { }, options = { })
  process_request_using_class(Requests::QuicklinkShare, args, options)
end

#success?Boolean

Returns:

  • (Boolean)


37
38
39
40
41
42
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 37

def success?
  return request.success? if request.respond_to?(:success?)

  _code = http_client.response.code
  _code and _code.start_with?('2')
end

#tag_edit(args = { }, options = { }) ⇒ Object



668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 668

def tag_edit(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'tags',
      :http_method => :put,
      :http_success_code => '204',
      :parameters => [
        { :name => :currentName, :required => true, :send_in => :body },
        { :name => :newName, :required => true, :send_in => :body }
      ]
      # :http_success_code => %w(200 404),
    }.merge(options)
  )
  process_request(_request, options)
end

#tags_getObject



685
686
687
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 685

def tags_get
  http_client.get('tags')
end

#user_delete(args = { }, options = { }) ⇒ Object



689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 689

def user_delete(args = { }, options = { })
  args = { :userId => args } if args.is_a?(String)
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => '/users/#{arguments[:userId]}',
      :http_method => :delete,
      :http_success_code => '204',
      :parameters => [
        { :name => :userId, :required => true, :send_in => :query },
      ]
      # :http_success_code => %w(200 404),
    }.merge(options)
  )
  process_request(_request, options)
end

#users_get(args = { }, options = { }) ⇒ Object



706
707
708
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 706

def users_get(args = { }, options = { })
  http_client.get('users?_pageSize=250')
end