example shows how to find an item using the item name and then shows how to change the name and description of the retrieved item.

This example uses the steps that are described in the Edit the Settings of a Library Item procedure.

require 'Com/Vmware/Content'
require 'Com/Vmware/Content/Library/Item'

# 1 - List the items in a published library.
item_stub =
   Com::Vmware::Content::Library::ItemService.new $my_stub_config
item_ids = item_stub.list $my_library_id

# 2 - List the files uploaded to each library item
#     and print their names and sizes.
file_stub =
   Com::Vmware::Content::Library::Item::File.new $my_stub_config
item_ids.each do |item_id|
  item = item_stub.get item_id
  file_infos = file_stub.list item_id
  file_infos.each do |info|
    puts "Library item #{item.name} has file #{info.name}" +
         " with size #{info.size}"
  end

# 3 - For a library item with a specified name,
#     create an ItemModel to change the name and description of the item.
  if item.name == 'simpleVmTemplate'
    puts "Library item '#{item.name}' with description" + 
         " '#{item.description}'"
    item_model =
       Com::Vmware::Content::Library::ItemModel.new
    item_model.name = 'newItemName'
    item_model.description = 'Description of the newItemName'
    item_stub.update(library_item_id=item_id,
                     update_spec=item_model)
    puts 'has been changed to:'
    puts "Library item '#{item_model.name}' with description" +
         " '#{item_model.description}'"
  end  # if item.name

end  # |item_id|