Class: Vidispine::API::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/vidispine/api/client.rb,
lib/vidispine/api/client/http_client.rb,
lib/vidispine/api/client/requests/base_request.rb

Direct Known Subclasses

Utilities

Defined Under Namespace

Modules: Requests Classes: HTTPClient

Instance Attribute Summary collapse

API Endpoints collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = { }) ⇒ Client

Returns a new instance of Client.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/vidispine/api/client.rb', line 14

def initialize(args = { })

  # API Path
  @api_endpoint_prefix = args.fetch(:api_endpoint_prefix, 'API')

  # APInoAuth Path
  @api_noauth_endpoint_prefix = args.fetch(:api_noauth_endpoint_prefix, 'APInoauth')

  # Default useragent but only if it is not set
  args[:user_agent] ||= args.fetch(:user_agent, "Vidispine Ruby SDK v#{Vidispine::VERSION}")

  @http_client = HTTPClient.new(args)
  @logger = http_client.logger
end

Instance Attribute Details

#api_endpoint_prefixObject

Returns the value of attribute api_endpoint_prefix.



12
13
14
# File 'lib/vidispine/api/client.rb', line 12

def api_endpoint_prefix
  @api_endpoint_prefix
end

#api_noauth_endpoint_prefixObject

Returns the value of attribute api_noauth_endpoint_prefix.



12
13
14
# File 'lib/vidispine/api/client.rb', line 12

def api_noauth_endpoint_prefix
  @api_noauth_endpoint_prefix
end

#http_clientObject

Returns the value of attribute http_client.



10
11
12
# File 'lib/vidispine/api/client.rb', line 10

def http_client
  @http_client
end

#loggerObject

Returns the value of attribute logger.



10
11
12
# File 'lib/vidispine/api/client.rb', line 10

def logger
  @logger
end

#requestObject

Returns the value of attribute request.



10
11
12
# File 'lib/vidispine/api/client.rb', line 10

def request
  @request
end

#responseObject

Returns the value of attribute response.



10
11
12
# File 'lib/vidispine/api/client.rb', line 10

def response
  @response
end

Instance Method Details

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

############################################################################################################## #



112
113
114
# File 'lib/vidispine/api/client.rb', line 112

def collection_access_add(args = { }, options = { })
  process_request_using_class(Requests::CollectionAccessAdd, args, options)
end

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



116
117
118
# File 'lib/vidispine/api/client.rb', line 116

def collection_access_delete(args = { }, options = { })
  process_request_using_class(Requests::CollectionAccessDelete, args, options)
end

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



121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/vidispine/api/client.rb', line 121

def collection_access_get(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'collection/#{path_arguments[:collection_id]}/access/#{path_arguments[:access_id]}',
      :parameters => [
        { :name => :collection_id, :aliases => [ :id ], :send_in => :path, :required => true },
        { :name => :access_id, :send_in => :path },
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

#collection_create(args = { }) ⇒ Object



136
137
138
139
140
141
142
143
144
# File 'lib/vidispine/api/client.rb', line 136

def collection_create(args = { })
  collection_name = args.is_a?(String) ? args : begin
    _data = Requests::BaseRequest.process_parameters([ { :name => :name, :aliases => [ :collection_name ], :send_in => :query } ], args)
    _args = _data[:arguments_out]
    _args[:name]
  end
  path = File.join(api_endpoint_prefix, '/collection')
  http(:post, path, '{}', :query => { :name => collection_name })
end

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



147
148
149
150
151
152
153
154
155
# File 'lib/vidispine/api/client.rb', line 147

def collection_delete(args = { }, options = { })
  collection_id = args.is_a?(String) ? args : begin
    _data = Requests::BaseRequest.process_parameters([ { :name => :collection_id, :aliases => [ :id ] } ], args)
    _args = _data[:arguments_out]
    _args[:collection_id]
  end
  path = File.join(api_endpoint_prefix, "/collection/#{collection_id}")
  http(:delete, path)
end

#collection_get(args = { }, options = { }) ⇒ Object Also known as: collection



158
159
160
161
162
163
164
165
166
# File 'lib/vidispine/api/client.rb', line 158

def collection_get(args = { }, options = { })
  collection_id = args.is_a?(String) ? args : begin
    _data = Requests::BaseRequest.process_parameters([ { :name => :collection_id, :aliases => [ :id ] } ], args)
    _args = _data[:arguments_out]
    _args[:collection_id]
  end
  path = File.join(api_endpoint_prefix, "/collection/#{collection_id}")
  http(:get, path)
end

#collection_items_get(args = { }, options = { }) ⇒ Object Also known as: collection_items



170
171
172
173
174
175
176
177
178
# File 'lib/vidispine/api/client.rb', line 170

def collection_items_get(args = { }, options = { })
  collection_id = args.is_a?(String) ? args : begin
    _data = Requests::BaseRequest.process_parameters([ { :name => :collection_id, :aliases => [ :id ] } ], args)
    _args = _data[:arguments_out]
    _args[:collection_id]
  end
  path = File.join(api_endpoint_prefix, "collection/#{collection_id}/item")
  http(:get, path)
end

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



183
184
185
186
187
188
189
190
191
# File 'lib/vidispine/api/client.rb', line 183

def (args = { }, options = { })
  collection_id = args.is_a?(String) ? args : begin
    _data = Requests::BaseRequest.process_parameters([ { :name => :collection_id, :aliases => [ :id ] } ], args)
    _args = _data[:arguments_out]
    _args[:collection_id]
  end
  path = File.join(api_endpoint_prefix, "/collection/#{collection_id}/metadata")
  http(:get, path)
end

#collection_metadata_set(args = { }, options = { }) ⇒ Object Also known as: collection_metadata_update



194
195
196
# File 'lib/vidispine/api/client.rb', line 194

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

#collection_object_add(args = { }, options = { }) ⇒ Object Also known as: collection_item_add



200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/vidispine/api/client.rb', line 200

def collection_object_add(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'collection/#{path_arguments[:collection_id]}/#{path_arguments[:object_id]}',
      :http_method => :put,
      :parameters => [
        { :name => :collection_id, :required => true, :send_in => :path },
        { :name => :object_id,
          :aliases => [ :item_id, :library_id, :collection_to_add_id ], :required => true, :send_in => :path },
        { :name => :type, :aliases => [ :object_type ], :default_value => 'item' }, # The documentation states that item is the default, but we get a 'Type is missing error if this is not passed'
        :addItems
      ],
    }.merge(options)
  )
  process_request(_request, options)
end

#collection_object_remove(args = { }, options = { }) ⇒ Object Also known as: collection_item_remove



220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/vidispine/api/client.rb', line 220

def collection_object_remove(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'collection/#{path_arguments[:collection_id]}/#{path_arguments[:object_id]}',
      :http_method => :delete,
      :parameters => [
        { :name => :collection_id, :required => true, :send_in => :path },
        { :name => :object_id,
          :aliases => [ :item_id, :library_id, :collection_to_add_id ], :required => true, :send_in => :path },
        { :name => :type, :aliases => [ :object_type ] },
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

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

Parameters:

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

Options Hash (args):

  • :collection_id (String)

See Also:



241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/vidispine/api/client.rb', line 241

def collection_rename(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_method => :put,
      :http_path => 'collection/#{arguments[:collection_id]}/rename',
      :parameters => [
        { :name => :collection_id, :aliases => [ :id ], :send_in => :path },
        { :name => :name, :aliases => [ :collection_name ] },
      ]
    }.merge(options)
  )
  return http(:put, _request.path, '', :query => _request.query_arguments, :headers => { 'Content-Type' => 'text/plain' } )
end

#collections_get(args = { }, options = { }) ⇒ Object Also known as: collections



257
258
259
260
261
262
263
264
265
266
267
268
269
270
# File 'lib/vidispine/api/client.rb', line 257

def collections_get(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_method => :get,
      :http_path => 'collection',
      :parameters => [
        { :name => :first, :send_in => :matrix },
        { :name => :number, :send_in => :matrix },
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

#errorObject

Will try to return the most concise error message possible

Example: {

"invalidInput": {
    "id": "portal_mf734147",
    "context": "metadata-field",
    "value": null,
"explanation": "The metadata value is invalid"
},
"conflict": null,
"notAuthorized": null,
"fileAlreadyExists": null,
"licenseFault": null,
"notFound": null,
"internalServer": null,
"forbidden": null,
"notYetImplemented": null

}

will become

{

"invalidInput"=> {
  "id"=>"portal_mf734147",
  "context"=>"metadata-field",
  "value"=>nil,
  "explanation"=>"The metadata value is invalid"
}

}



98
99
100
101
102
103
104
105
106
107
# File 'lib/vidispine/api/client.rb', line 98

def error
  _response_parsed = http_client.response_parsed
  if _response_parsed.is_a?(Hash)
    _error = _response_parsed.delete_if { |k,v| v.nil? }
    _error
  else
    _response = http_client.response
    _response.body if _response.respond_to?(:body)
  end
end

#http(method, *args) ⇒ Object

Exposes HTTP Methods

Examples:

http(:get, ‘/’)




46
47
48
49
50
51
# File 'lib/vidispine/api/client.rb', line 46

def http(method, *args)
  @request = nil
  @response = http_client.send(method, *args)
  @request = http_client.request
  response
end

#import_placeholder(args = { }, options = { }) ⇒ Object Also known as: placeholder_create



274
275
276
277
278
# File 'lib/vidispine/api/client.rb', line 274

def import_placeholder(args = { }, options = { })
  #query = options[:query] || { }
  # http(:post, '/import/placeholder', :query => query)
  process_request_using_class(Requests::ImportPlaceholder, args, options)
end

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



282
283
284
# File 'lib/vidispine/api/client.rb', line 282

def import_placeholder_item(args = { }, options = { })
  process_request_using_class(Requests::ImportPlaceholderItem, args, options)
end

#import_using_uri(args = { }, options = { }) ⇒ Object Also known as: import



287
288
289
# File 'lib/vidispine/api/client.rb', line 287

def import_using_uri(args = { }, options = { })
  process_request_using_class(Requests::ImportUsingURI, args, options)
end

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



292
293
294
# File 'lib/vidispine/api/client.rb', line 292

def item_access_add(args = { }, options = { })
  process_request_using_class(Requests::ItemAccessAdd, args, options)
end

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



296
297
298
# File 'lib/vidispine/api/client.rb', line 296

def item_access_delete(args = { }, options = { })
  process_request_using_class(Requests::ItemAccessDelete, args, options)
end

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



301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/vidispine/api/client.rb', line 301

def item_access_get(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'item/#{path_arguments[:item_id]}/access/#{path_arguments[:access_id]}',
      :parameters => [
        { :name => :item_id, :aliases => [ :id ], :send_in => :path, :required => true },
        { :name => :access_id, :send_in => :path },
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

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



316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/vidispine/api/client.rb', line 316

def item_access_list(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'item/#{path_arguments[:item_id]}/access',
      :parameters => [
        { :name => :item_id, :aliases => [ :id ], :send_in => :path, :required => true },
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

#item_collections_get(args = { }, options = { }) ⇒ Object Also known as: item_collections



331
332
333
334
335
336
337
338
339
# File 'lib/vidispine/api/client.rb', line 331

def item_collections_get(args = { }, options = { })
  item_id = args.is_a?(String) ? args : begin
    _data = Requests::BaseRequest.process_parameters([ { :name => :item_id, :aliases => [ :id ] } ], args)
    _args = _data[:arguments_out]
    _args[:item_id]
  end
  path = File.join(api_endpoint_prefix, "/item/#{item_id}/collections")
  http(:get, path)
end

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



343
344
345
# File 'lib/vidispine/api/client.rb', line 343

def item_delete(args = { }, options = { })
  process_request_using_class(Requests::ItemDelete, args, options)
end

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



348
349
350
# File 'lib/vidispine/api/client.rb', line 348

def item_export(args = { }, options = { })
  process_request_using_class(Requests::ItemExport, args, options)
end

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

Gets the field group of an item Undocumented endpoint



354
355
356
357
358
359
360
361
362
363
364
365
366
# File 'lib/vidispine/api/client.rb', line 354

def item_field_group_get(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path   => '/item/#{item_id}/field-group',
      :http_method => :get,
      :parameters  => [
        { :name => :item_id, :send_in => :path, :required => true },
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

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

Sets the field group of an item Undocumented endpoint



370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# File 'lib/vidispine/api/client.rb', line 370

def item_field_group_set(args = { }, options = { })
  _request = Requests::BaseRequest.new(
      args,
      {
        :http_path => '/item/#{item_id}/field-group/#{field_group}',
        :http_method => :put,
        :default_parameter_send_in_value => :path,
        :parameters => [
          { :name => :item_id, :required => true },
          { :name => :field_group, :required => true }
        ]
      }.merge(options)
  )
  process_request(_request, options)
end

#item_get(args = { }, options = { }) ⇒ Object Also known as: item



387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
# File 'lib/vidispine/api/client.rb', line 387

def item_get(args = { }, options = { })
  # item_id = args.is_a?(String) ? args : begin
  #   _data = Requests::BaseRequest.process_parameters([ { :name => :item_id, :aliases => [ :id ] } ], args)
  #   _args = _data[:arguments_out]
  #   _args[:item_id]
  # end
  # http(:get, "/item/#{item_id}")

  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'item/#{path_arguments[:item_id]}',
      :parameters => [
        { :name => :item_id, :aliases => [ :id ], :send_in => :path, :required => true },
        { :name => :starttc, :send_in => :matrix },

        'noauth-url',
        'baseURI'
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

#item_metadata_get(args = { }, options = { }) ⇒ Object Also known as: item_metadata



417
418
419
# File 'lib/vidispine/api/client.rb', line 417

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

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



423
424
425
# File 'lib/vidispine/api/client.rb', line 423

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

#item_notifications_deleteObject



412
413
414
# File 'lib/vidispine/api/client.rb', line 412

def item_notifications_delete
  http(:delete, '/item/notification')
end

#item_shape_files_get(args = { }, options = { }) ⇒ Object Also known as: item_shape_files



428
429
430
431
432
433
434
435
436
437
438
439
440
441
# File 'lib/vidispine/api/client.rb', line 428

def item_shape_files_get(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => '/item/#{path_arguments[:item_id]}/shape/#{path_arguments[:shape_id]}/file',
      :default_parameter_send_in_value => :path,
      :parameters => [
        { :name => :item_id, :required => true },
        { :name => :shape_id, :required => true }
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

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



445
446
447
448
449
450
451
452
453
454
455
456
457
458
# File 'lib/vidispine/api/client.rb', line 445

def item_shape_get(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => '/item/#{path_arguments[:item_id]}/shape/#{path_arguments[:shape_id]}',
      :default_parameter_send_in_value => :path,
      :parameters => [
        { :name => :item_id, :required => true },
        { :name => :shape_id },
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

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



502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
# File 'lib/vidispine/api/client.rb', line 502

def item_shape_import(args = { }, options = { })
  # _request = Requests::BaseRequest.new(
  #   args,
  #   {
  #     :http_path => '"/item/#{item_id}/shape"',
  #     :parameters => [
  #       { :name => :item_id, :aliases => [ :id ], :send_in => :path },
  #       :uri,
  #       :fileId,
  #       { :name => :tag, :aliases => [ :tags ] },
  #       :settings,
  #       :notification,
  #       :notificationData,
  #       :priority,
  #       :jobmetadata
  #     ],
  #   }.merge(options)
  # )
  # process_request(_request, options)

  _data = Requests::BaseRequest.process_parameters(
    [
      { :name => :item_id, :aliases => [ :id ], :send_in => :path },
      :uri,
      :fileId,
      { :name => :tag, :aliases => [ :tags ] },
      :settings,
      :notification,
      :notificationData,
      :priority,
      :jobmetadata
    ],
    args
  )
  _args = _data[:arguments_out]

  item_id = _args[:item_id]
  uri = _args[:uri]
  file_id = _args[:fileId]
  tag = _args[:tag]
  tag = tag.join(',') if tag.is_a?(Array)
  settings = _args[:settings]
  notification = _args[:notification]
  notification_data = _args[:notificationData]
  priority = _args[:priority]
   = _args[:jobmetadata]

  query = { }
  query[:uri] = uri if uri
  query[:fileId] = file_id if file_id
  query[:tag] = tag if tag
  query[:settings] = settings if settings
  query[:notification] = notification if notification
  query[:notificationData] = notification_data if notification_data
  query[:priority] = priority if priority
  query[:jobmetadata] =  if 

  path = File.join(api_endpoint_prefix, "/item/#{item_id}/shape")
  http(:post, path, '', :query => query)
end

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

Create a placeholder shape



462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
# File 'lib/vidispine/api/client.rb', line 462

def item_shape_placholder_create(args = { }, options = { })
  _request = Requests::BaseRequest.new(
      args,
      {
          :http_path => '/item/#{path_arguments[:item_id]}/shape/placeholder',
          :default_parameter_send_in_value => :query,
          :parameters => [
              { :name => :item_id, :required => true, :type => :path },
              { :name => :tag },
              { :name => :container },
              { :name => :audio },
              { :name => :video },
              { :name => :frameDuration },
          ]
      }.merge(options)
  )
  process_request(_request, options)
end

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



482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
# File 'lib/vidispine/api/client.rb', line 482

def item_shapes_get(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => '/item/#{path_arguments[:item_id]}/shape',
      :default_parameter_send_in_value => :path,
      :parameters => [
        { :name => :item_id, :required => true },
        { :name => :uri, :send_in => :query },
        { :name => :placeholder, :send_in => :query },
        { :name => :tag, :send_in => :query }, # Not Documented
        { :name => :version, :send_in => :matrix }
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

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



563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
# File 'lib/vidispine/api/client.rb', line 563

def item_sidecar_import(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'import/sidecar/#{path_arguments[:item_id]}',
      :http_method => :post,
      :parameters => [
        { :name => :item_id, :send_in => :path, :required => true },

        :sidecar,
        :notification,
        :notificationData,
        :priority,
        :jobmetadata,
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

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



584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
# File 'lib/vidispine/api/client.rb', line 584

def item_thumbnail(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'item/#{path_arguments[:item_id]}/thumbnail',
      :http_method => :post,
      :parameters => [
        { :name => :item_id, :send_in => :path, :required => true },

        :createThumbnails,
        :createPosters,
        :thumbnailWidth,
        :thumbnailHeight,
        :thumbnailPeriod,
        :posterWidth,
        :posterHeight,
        :postFormat,
        :notification,
        :notificationData,
        :priority,
        :jobmetadata,
        :version,
        :sourceTag
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

#item_transcode(args = { }, options = { }) ⇒ Object Also known as: item_create_thumbnail



614
615
616
# File 'lib/vidispine/api/client.rb', line 614

def item_transcode(args = { }, options = { })
  process_request_using_class(Requests::ItemTranscode, args, options)
end

#item_uris_get(args = { }, options = { }) ⇒ Object Also known as: item_uri_get, item_uris, item_uri



620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
# File 'lib/vidispine/api/client.rb', line 620

def item_uris_get(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => '/item/#{arguments[:item_id]}/uri',
      :parameters => [
        { :name => :item_id, :aliases => [ :id ], :required => true, :send_in => :path },
        :type,
        { :name => :tag, :aliases => [ :tags ] },
        :scheme,
        :closedFiles
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

#items_get(args = { }, options = { }) ⇒ Object Also known as: items



641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
# File 'lib/vidispine/api/client.rb', line 641

def items_get(args = { }, options = { })
  #http(:get, 'item')
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'item',
      :default_parameter_send_in_value => :matrix,
      :parameters => [
        { :name => :result, :send_in => :query },
        { :name => :q, :send_in => :query },

        :library,
        :first,
        :number,
        :libraryId,
        :autoRefresh,
        :updateMode,
        :updateFrequency
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

#items_search(args = { }, options = { }) ⇒ Object Also known as: item_search



667
668
669
# File 'lib/vidispine/api/client.rb', line 667

def items_search(args = { }, options = { })
  process_request_using_class(Requests::ItemsSearch, args, options)
end

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



673
674
675
676
677
678
679
680
681
682
683
684
685
686
# File 'lib/vidispine/api/client.rb', line 673

def job_abort(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'job/#{arguments[:job_id]}',
      :http_method => :delete,
      :parameters => [
        { :name => :job_id, :aliases => [ :id ], :send_in => :path },
        :reason
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

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



689
690
691
692
693
694
695
696
697
698
699
700
701
# File 'lib/vidispine/api/client.rb', line 689

def job_get(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'job/#{arguments[:job_id]}',
      :parameters => [
        { :name => :job_id, :aliases => [ :id ], :send_in => :path },
        :metadata
      ]
    }
  )
  process_request(_request, options)
end

#jobs_get(args = { }, options = { }) ⇒ Object Also known as: jobs



704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
# File 'lib/vidispine/api/client.rb', line 704

def jobs_get(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'job',
      :parameters => [
        { :name => :jobmetadata, :send_in => :query },
        { :name => :metadata, :send_in => :query },
        { :name => :idOnly, :send_in => :query },
        { :name => 'starttime-from', :send_in => :query },
        { :name => 'starttime-to', :send_in => :qeury },
        { :name => :step, :send_in => :query },

        { :name => :type, :send_in => :matrix },
        { :name => :state, :send_in => :matrix },
        { :name => :first, :send_in => :matrix },
        { :name => :number, :send_in => :matrix },
        { :name => :sort, :send_in => :matrix },
        { :name => :user, :send_in => :matrix }
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

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



731
732
733
734
735
736
737
738
739
740
741
742
743
# File 'lib/vidispine/api/client.rb', line 731

def (args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'metadata/#{arguments[:field_name]}',
      :http_method => :delete,
      :parameters => [
        { :name => :field_name, :aliases => [ :name ], :send_in => :path }
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

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



746
747
748
749
750
751
752
753
754
755
756
757
# File 'lib/vidispine/api/client.rb', line 746

def (args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'metadata/#{arguments[:field_name]}',
      :parameters => [
        { :name => :field_name, :aliases => [ :name ], :send_in => :path }
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

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



760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
# File 'lib/vidispine/api/client.rb', line 760

def (args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'metadata-field/field-group/#{path_arguments[:group_name]}',
      :parameters => [
        { :name => :group_name, :aliases => [ :name ], :send_in => :path },
        :include_values,
        :traverse,
        :data
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

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



777
778
779
780
781
782
783
784
785
786
787
788
789
790
# File 'lib/vidispine/api/client.rb', line 777

def (args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'metadata-field/field-group',
      :parameters => [
        :content,
        :traverse,
        :data
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

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



793
794
795
796
797
798
# File 'lib/vidispine/api/client.rb', line 793

def (args = { }, options = { })
  default_options = { :headers => { 'accept' => '*/*' } }
  _options = default_options.merge(options)
  path = File.join(api_endpoint_prefix, 'metadata-field/terse-schema')
  http(:get, path, _options)
end

#metadata_fields_get(args = { }, options = { }) ⇒ Object Also known as: metadata_fields



801
802
803
804
# File 'lib/vidispine/api/client.rb', line 801

def (args = { }, options = { })
  path = File.join(api_endpoint_prefix, 'metadata-field')
  http(:get, path, options)
end

#process_request(request, options = nil) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/vidispine/api/client.rb', line 29

def process_request(request, options = nil)
  @response = nil
  @request = request
  request.client = self unless request.client
  options ||= request.options
  logger.warn { "Request is Missing Required Arguments: #{request.missing_required_arguments.inspect}" } unless request.missing_required_arguments.empty?
  @response = http_client.build_and_send_request(request.http_method, { :path => request.path, :query => request.query, :body => request.body }, options)
end

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



38
39
40
41
42
# File 'lib/vidispine/api/client.rb', line 38

def process_request_using_class(request_class, args, options = { })
  @response = nil
  @request = request_class.new(args, options.merge(:client => self))
  process_request(request, options)
end

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

Examples:

search(:content => :metadata, :field => :title, :item_search_document => { :field => [ { :name => ‘title’, :value => [ { :value => ‘something’ } ] } ] } )


See Also:



809
810
811
# File 'lib/vidispine/api/client.rb', line 809

def search(args = { }, options = { })
  process_request_using_class(Requests::Search, args, options)
end

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



813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
# File 'lib/vidispine/api/client.rb', line 813

def search_browse(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'search',
      :parameters => [
        :content,
        :interval,
        :field,
        :group,
        :language,
        :samplerate,
        :track,
        :terse,
        :include,
        :type,
        :tag,
        :scheme,
        :closedFiles,
        'noauth-url',
        :defaultValue,
        :methodType,
        :version,
        :revision,

        { :name => :first, :send_in => :matrix },

        { :name => :ItemSearchDocument, :send_in => :body }
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

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



848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
# File 'lib/vidispine/api/client.rb', line 848

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

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



865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
# File 'lib/vidispine/api/client.rb', line 865

def storage_file_copy(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args, 
    {
      :http_path => 'storage/#{path_arguments[:source_storage_id]}/file/#{path_argumetns[:file_id]}/storage/#{path_arguments[:target_source_id]}',
      :http_method => :post,
      :parameters => [
        { :name => :file_id, :send_in => :path, :required => true },
        { :name => :source_storage_id, :send_in => :path, :required => true },
        { :name => :target_storage_id, :send_in => :path, :required => true },
        
        :move,
        :filename,
        :timeDependency,
        :limitRate,
        :notification,
        :notificationData,
        :priority,
        :jobmetadata
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

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

Parameters:

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

Options Hash (args):

  • :storage_id (String) — default: Required
  • :path (String) — default: Required
  • :create_only (Boolean)
  • :state (String)

See Also:



897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
# File 'lib/vidispine/api/client.rb', line 897

def storage_file_create(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'storage/#{path_arguments[:storage_id]}/file',
      :http_method => :post,
      :parameters => [
        { :name => :storage_id, :send_in => :path, :required => true },

        :createOnly,
        :state,

        { :name => :path, :send_in => :body }
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

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

Exposes two functions

1. Get status of file in storage
  @see http://apidoc.vidispine.com/4.2.3/ref/storage/file.html#get-status-of-file-in-storage

2. Get direct download access to file in storage
  @see http://apidoc.vidispine.com/4.2.3/ref/storage/file.html#get-direct-download-access-to-file-in-storage


940
941
942
# File 'lib/vidispine/api/client.rb', line 940

def storage_file_get(args = { }, options = { })
  process_request_using_class(Requests::StorageFileGet, args, options)
end

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



916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
# File 'lib/vidispine/api/client.rb', line 916

def storage_file_item_get(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'storage/#{path_arguments[:storage_id]}/file/#{path_arguments[:file_id]}/item',
      :http_method => :get,
      :parameters => [
        { :name => :storage_id, :send_in => :path, :required => true },
        { :name => :file_id, :send_in => :path, :required => true },

        { :name => :uri, :send_in => :matrix },
        { :name => :path, :send_in => :matrix }
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

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



945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
# File 'lib/vidispine/api/client.rb', line 945

def storage_file_state_set(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'storage/file/#{path_arguments[:file_id]}/state/#{path_arguments[:state]}',
      :http_method => :put,
      :default_parameter_send_in_value => :path,
      :parameters => [
        { :name => :file_id, :required => true },
        { :name => :state, :required => true },
      ]
    }.merge(options)
  )
  process_request(_request, options)

end

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



963
964
965
# File 'lib/vidispine/api/client.rb', line 963

def storage_files_get(args = { }, options = { })
  process_request_using_class(Requests::StorageFilesGet, args, options)
end

#storage_get(args = { }, options = { }) ⇒ Object Also known as: storage



968
969
970
971
972
973
974
975
976
977
978
979
980
# File 'lib/vidispine/api/client.rb', line 968

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

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



984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
# File 'lib/vidispine/api/client.rb', line 984

def storage_method_get(args = { }, options = { })
  args = { :storage_id => args } if args.is_a?(String)
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'storage/#{path_arguments[:storage_id]}/method',
      :parameters => [
        { :name => :storage_id, :aliases => [ :id ], :send_in => :path, :required => true },

        { :name => :read, :send_in => :matrix },
        { :name => :write, :send_in => :matrix },
        { :name => :browse, :send_in => :matrix },

        :url,
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

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

Parameters:

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

Options Hash (args):

  • :storage_id (String)

See Also:



1007
1008
1009
1010
1011
1012
1013
1014
1015
# File 'lib/vidispine/api/client.rb', line 1007

def storage_rescan(args = { }, options = { })
  storage_id = args.is_a?(String) ? args : begin
    _data = Requests::BaseRequest.process_parameters([ { :name => :storage_id, :aliases => [ :id ] } ], args)
    _args = _data[:arguments_out]
    _args[:storage_id]
  end
  path = File.join(api_endpoint_prefix, "storage/#{storage_id ? "#{storage_id}/" : ''}rescan")
  http(:post, path, '')
end

#storages_get(args = { }, options = { }) ⇒ Object Also known as: storages



1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
# File 'lib/vidispine/api/client.rb', line 1018

def storages_get(args = { }, options = { })
  _request = Requests::BaseRequest.new(
    args,
    {
      :http_path => 'storage',
      :parameters => [
        :size,
        :freebytes,
        :usedbytes,
        :freeamount,
        :files,
        :storagegroup,
        :status
      ]
    }.merge(options)
  )
  process_request(_request, options)
end

#success?Boolean

Tries to determine if the last request got a successful response

Returns:

  • (Boolean)


54
55
56
57
58
59
60
61
62
# File 'lib/vidispine/api/client.rb', line 54

def success?
  return unless @request
  if @request.respond_to?(:success?)
    @request.success?
  else
    _response = http_client.response
    _response && _response.code.start_with?('2')
  end
end

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



1038
1039
1040
# File 'lib/vidispine/api/client.rb', line 1038

def version(args = { }, options = { })
  http(:get, File.join(api_endpoint_prefix, 'version'))
end