Class: Kaltura::Service::BaseEntryService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/kaltura/service/base_entry_service.rb

Overview

BaseEntryService is a service for generic entries. If you do not know what type of media you are working with, this is a good service to use. You need to know what media type you are working with for MediaService.

Examples:

Retrieve a base entry:

client.base_entry_service.get('1_qua324a')

Upload a new entry:

upload_file = File.open("/path/to/media_file")
upload_token = client.base_entry_service.upload(upload_file)
base_entry = Kaltura::BaseEntry.new
base_entry.name = "WAFFLES ARE MY FRIEND"
client.base_entry_service.add_from_uploaded_file(base_entry,upload_token)

Update an existing entry:

update_entry = Kaltura::BaseEntry.new
update_entry.description = "Pancakes are lame yo."
client.base_entry_service.update('1_qua324a',update_entry)

Delete an existing entry:

client.base_entry_service.delete('1_qua324a')

Update an Entry thumbnail via file upload:

thumbnail_file = File.open('/path/to/thumbnail_file')
client.base_entry_service.update_thumbnail_from_jpeg('1_qua324a',thumbnail_file)

Update an entry thumbnail from a url:

client.base_entry_service.update_thumbnail_from_url('1_qua324a','http://twitter.com/waffles/waffletastic.jpg')

Update an entry thumbnail from another entry:

client.base_entry_service.update_thumbnail_from_source_entry('1_qua324a','0_k24aj1b',5)

Instance Attribute Summary

Attributes inherited from BaseService

#client

Instance Method Summary collapse

Methods inherited from BaseService

#initialize, #perform_request

Constructor Details

This class inherits a constructor from Kaltura::Service::BaseService

Instance Method Details

#add_from_uploaded_file(entry, upload_token_id, type = -1)) ⇒ Kaltura::BaseEntry

Generic add entry using an uploaded file, should be used when the uploaded entry type is not known.

Parameters:

  • entry (Kaltura::BaseEntry)

    A newly instantiated BaseEntry object filled in with appropriate fields.

  • upload_token_id (String)

    The upload token from the upload() method.

  • type (Kaltura::Constants::Entry::Type) (defaults to: -1))

    The type of entry. This should be defaulted. Otherwise use the MediaService.

Returns:

  • (Kaltura::BaseEntry)

    Returns a Kaltura Entry. This is helpful to retrieve the entry_id.

Raises:



48
49
50
51
52
53
54
# File 'lib/kaltura/service/base_entry_service.rb', line 48

def add_from_uploaded_file(entry, upload_token_id, type=-1)
  kparams = {}
  client.add_param(kparams, 'entry', entry)
  client.add_param(kparams, 'uploadTokenId', upload_token_id)
  client.add_param(kparams, 'type', type)
  perform_request('baseEntry','addFromUploadedFile',kparams,false)
end

#anonymous_rank(entry_id, rank) ⇒ nil

Anonymously ranks an entry. There is no validation done on duplicate rankings.

Parameters:

  • entry_id (String)

    The Kaltura entry to rank.

  • rank (Integer)

    The rank to assign.

Returns:

  • (nil)

    Returns nothing.

Raises:



304
305
306
307
308
309
# File 'lib/kaltura/service/base_entry_service.rb', line 304

def anonymous_rank(entry_id, rank)
  kparams = {}
  client.add_param(kparams, 'entryId', entry_id)
  client.add_param(kparams, 'rank', rank)
  perform_request('baseEntry','anonymousRank',kparams,false)
end

#approve(entry_id) ⇒ nil

Approves an entry and marks any pending flags as moderated.

This makes the entry playable.

Parameters:

  • entry_id (String)

    The Kaltura entry to approve.

Returns:

  • (nil)

    Returns nothing.

Raises:

  • (Kaltura::APIError)

    raises “ENTRY_ID_NOT_FOUND” if the entry_id isn’t found in addition to default errors.



270
271
272
273
274
# File 'lib/kaltura/service/base_entry_service.rb', line 270

def approve(entry_id)
  kparams = {}
  client.add_param(kparams, 'entryId', entry_id)
  perform_request('baseEntry','approve',kparams,false)
end

#count(filter = nil) ⇒ Integer

Returns a count based on a specified base entry filter.

Parameters:

Returns:

  • (Integer)

    Number of base entries within the filter.

Raises:



147
148
149
150
151
# File 'lib/kaltura/service/base_entry_service.rb', line 147

def count(filter=nil)
  kparams = {}
  client.add_param(kparams, 'filter', filter)
  perform_request('baseEntry','count',kparams,false)
end

#delete(entry_id) ⇒ nil

Deletes the specified Kaltura Entry.

Parameters:

  • entry_id (String)

    The Kaltura entry to be deleted.

Returns:

  • (nil)

    Returns nothing.

Raises:



115
116
117
118
119
# File 'lib/kaltura/service/base_entry_service.rb', line 115

def delete(entry_id)
  kparams = {}
  client.add_param(kparams, 'entryId', entry_id)
  perform_request('baseEntry','delete',kparams,false)
end

#flag(moderation_flag) ⇒ nil

Flags an inappropriate Kaltura entry for moderation. The entry ID is provided in the moderation_flag, so it isn’t blatently obvious which entry you are interacting with. The method also outputs nothing, so success/failure is more difficult than necessary to track.

Parameters:

  • moderation_flag (Kaltura::ModerationFlag)

    The Kaltura Entry being flagged is hidden down in the field ‘flagged_entry_id’.

Returns:

  • (nil)

    Returns nothing.

Raises:

  • (Kaltura::APIError)

    raises “ENTRY_ID_NOT_FOUND” if the entry_id isn’t found in addition to default errors.



238
239
240
241
242
# File 'lib/kaltura/service/base_entry_service.rb', line 238

def flag(moderation_flag)
  kparams = {}
  client.add_param(kparams, 'moderationFlag', moderation_flag)
  perform_request('baseEntry','flag',kparams,false)
end

#get(entry_id, version = -1)) ⇒ Kaltura::BaseEntry

Gets a base entry by ID.

Parameters:

  • entry_id (String)

    Kaltura entry.

  • version (Integer) (defaults to: -1))

    Version of the entry.

Returns:

Raises:



66
67
68
69
70
71
# File 'lib/kaltura/service/base_entry_service.rb', line 66

def get(entry_id, version=-1)
  kparams = {}
  client.add_param(kparams, 'entryId', entry_id)
  client.add_param(kparams, 'version', version)
  perform_request('baseEntry','get',kparams,false)
end

#get_by_ids(entry_ids) ⇒ Array

Retrieves an array of BaseEntries when provided a comma seperated list of entry_id’s.

Parameters:

  • entry_ids (String)

    A comma delimited list of Kaltura entry_id’s.

Returns:

  • (Array)

    Returns an array of Entries, based upon their format.

Raises:



100
101
102
103
104
# File 'lib/kaltura/service/base_entry_service.rb', line 100

def get_by_ids(entry_ids)
  kparams = {}
  client.add_param(kparams, 'entryIds', entry_ids)
  perform_request('baseEntry','getByIds',kparams,false)
end

#get_context_data(entry_id, context_data_params) ⇒ Kaltura::EntryContextDataResult

Retrieves the context data from a Kaltura entry. This is not documented in the API. I’d be cautious about actually using this method.

Parameters:

  • entry_id (String)

    The Kaltura entry.

  • context_data_params (Kaltura::EntryContextDataParams)

    The only field not inherited from Kaltura::ObjectBase is referrer, so I imagine that is what you should set.

Returns:

Raises:



323
324
325
326
327
328
# File 'lib/kaltura/service/base_entry_service.rb', line 323

def get_context_data(entry_id, context_data_params)
  kparams = {}
  client.add_param(kparams, 'entryId', entry_id)
  client.add_param(kparams, 'contextDataParams', context_data_params)
  perform_request('baseEntry','getContextData',kparams,false)
end

#list(filter = nil, pager = nil) ⇒ Kaltura::Response::BaseEntryListResponse

Lists base entries by the filter with paging support.

Parameters:

Returns:

Raises:



131
132
133
134
135
136
# File 'lib/kaltura/service/base_entry_service.rb', line 131

def list(filter=nil, pager=nil)
  kparams = {}
  client.add_param(kparams, 'filter', filter)
  client.add_param(kparams, 'pager', pager)
  perform_request('baseEntry','list',kparams,false)
end

#list_flags(entry_id, pager = nil) ⇒ Kaltura::Response::ModerationFlagListResponse

Lists all pending moderation flags for the specified entry.

Parameters:

  • entry_id (String)

    The Kaltura entry.

  • pager (Kaltura::FilterPager) (defaults to: nil)

    An optional pager to use for a large list of pending moderation flags.

Returns:

Raises:



286
287
288
289
290
291
# File 'lib/kaltura/service/base_entry_service.rb', line 286

def list_flags(entry_id, pager=nil)
  kparams = {}
  client.add_param(kparams, 'entryId', entry_id)
  client.add_param(kparams, 'pager', pager)
  perform_request('baseEntry','listFlags',kparams,false)
end

#reject(entry_id) ⇒ nil

Rejects a Kaltura entry and marks any pending flags as moderated. This makes the entry unplayable and is a much more sane method to flag content than the flag method.

Parameters:

  • entry_id (String)

    The Kaltura entry to reject.

Returns:

  • (nil)

    Returns nothing.

Raises:

  • (Kaltura::APIError)

    raises “ENTRY_ID_NOT_FOUND” if the entry_id isn’t found in addition to default errors.



254
255
256
257
258
# File 'lib/kaltura/service/base_entry_service.rb', line 254

def reject(entry_id)
  kparams = {}
  client.add_param(kparams, 'entryId', entry_id)
  perform_request('baseEntry','reject',kparams,false)
end

#update(entry_id, base_entry) ⇒ Kaltura::BaseEntry

Updates a base entry. It is best to instantiate a new base entry for the second parameter and initilize those fields for the changes you want to change instead of using an existing entry object.

Parameters:

  • entry_id (String)

    The Kaltura entry to be updated.

  • base_entry (Kaltura::BaseEntry)

    A BaseEntry object with fields populated that you wish to change.

Returns:

Raises:

  • (Kaltura::APIError)

    raises “ENTRY_ID_NOT_FOUND” if the entry_id isn’t found in addition to default errors.



84
85
86
87
88
89
# File 'lib/kaltura/service/base_entry_service.rb', line 84

def update(entry_id, base_entry)
  kparams = {}
  client.add_param(kparams, 'entryId', entry_id)
  client.add_param(kparams, 'baseEntry', base_entry)
  perform_request('baseEntry','update',kparams,false)
end

#update_thumbnail_from_source_entry(entry_id, source_entry_id, time_offset) ⇒ Kaltura::BaseEntry

Updates the entries thumbnail from another entry given a specified time offset. This is one truly odd API call.

Parameters:

  • entry_id (String)

    The Kaltura entry to be changed.

  • source_entry_id (String)

    The Kaltura entry providing the change.

  • time_offset (Integer)

    The time in seconds to offset the source_entry_id thumbnail by.

Returns:

  • (Kaltura::BaseEntry)

    The updated Kaltura entry. The primary change will be a version bump.

Raises:

  • (Kaltura::APIError)

    Will raise ‘PERMISSION_DENIED_TO_UPDATE_ENTRY’ if the user session doesn’t have permissions to edit this particular entry.



218
219
220
221
222
223
224
# File 'lib/kaltura/service/base_entry_service.rb', line 218

def update_thumbnail_from_source_entry(entry_id, source_entry_id, time_offset)
  kparams = {}
  client.add_param(kparams, 'entryId', entry_id)
  client.add_param(kparams, 'sourceEntryId', source_entry_id)
  client.add_param(kparams, 'timeOffset', time_offset)
  perform_request('baseEntry','updateThumbnailFromSourceEntry',kparams,false)
end

#update_thumbnail_from_url(entry_id, url) ⇒ Kaltura::BaseEntry

Updates an entries thumbnail using a valid URL.

Parameters:

  • entry_id (String)

    The Kaltura entry.

  • url (File)

    The URL to pull the thumbnail from. This will update the entries version and the thumbnail’s version.

Returns:

  • (Kaltura::BaseEntry)

    The updated Kaltura entry. The primary change will be a version bump.

Raises:

  • (Kaltura::APIError)

    Will raise ‘PERMISSION_DENIED_TO_UPDATE_ENTRY’ if the user session doesn’t have permissions to edit this particular entry.



198
199
200
201
202
203
# File 'lib/kaltura/service/base_entry_service.rb', line 198

def update_thumbnail_from_url(entry_id, url)
  kparams = {}
  client.add_param(kparams, 'entryId', entry_id)
  client.add_param(kparams, 'url', url)
  perform_request('baseEntry','updateThumbnailFromUrl',kparams,false)
end

#update_thumbnail_jpeg(entry_id, file_data) ⇒ Kaltura::BaseEntry

Updates an entries thumbnail using a raw jpeg file.

Parameters:

  • entry_id (String)

    The Kaltura entry.

  • file_data (File)

    The MIME type of ‘image/jpg’ file to be used as the entries thumbnail. This will update the entries version and the thumbnail’s version.

Returns:

  • (Kaltura::BaseEntry)

    The updated Kaltura entry. The primary change will be a version bump.

Raises:

  • (Kaltura::APIError)

    Will raise ‘PERMISSION_DENIED_TO_UPDATE_ENTRY’ if the user session doesn’t have permissions to edit this particular entry.



180
181
182
183
184
185
# File 'lib/kaltura/service/base_entry_service.rb', line 180

def update_thumbnail_jpeg(entry_id, file_data)
  kparams = {}
  client.add_param(kparams, 'entryId', entry_id)
  client.add_param(kparams, 'fileData', file_data)
  perform_request('baseEntry','updateThumbnailJpeg',kparams,false)
end

#upload(file_data) ⇒ String

Uploads a file to the Kaltura server and returns a token to be used to create a Kaltura entry.

Parameters:

  • file_data (File)

    The file to upload to Kaltura.

Returns:

  • (String)

    The file upload_token_id to be used by entry adding methods.

Raises:



162
163
164
165
166
# File 'lib/kaltura/service/base_entry_service.rb', line 162

def upload(file_data)
  kparams = {}
  client.add_param(kparams, 'fileData', file_data)
  perform_request('baseEntry','upload',kparams,false)
end