This example shows how to create a content library that depends on the published content of another content library.

This example uses the steps that are described in the Subscribe to a Content Library procedure.

require 'Com/Vmware/Content'
require 'securerandom'

# Create a StorageBacking instance on a local file system.
storage_backing =
   Com::Vmware::Content::Library::StorageBacking.new
storage_backing.type =
   Com::Vmware::Content::Library::StorageBacking::Type::OTHER
storage_backing.storage_uri = 'file:///mnt/nfs/cls-root'

# Create a new SubscriptionInfo object to describe the subscription behavior.
subscription_info =
   Com::Vmware::Content::Library::SubscriptionInfo.new
subscription_info.authentication_method =
 Com::Vmware::Content::Library::SubscriptionInfo::AuthenticationMethod::BASIC
subscription_info.user_name = 'library-user'
subscription_info.password = 'password'
subscription_info.subscription_url =
   'https://www.example.com/library_inventory/lib.json'
subscription_info.automatic_sync_enabled = true
subscription_info.ssl_thumbprint =
   '98:00:3F:C4:4E:B1:F3:F9:0D:70:47:48:E7:08:D1:A7:0E:DE:60:A5'

# Create a new LibraryModel object for the subscribed library.
library_model =
   Com::Vmware::Content::LibraryModel.new
library_model.type =
   Com::Vmware::Content::LibraryModel::LibraryType::SUBSCRIBED
library_model.name = 'subscrLibrary'

# Attach the storage backing and the subscription info to the library model.
library_model.storage_backings = [storage_backing]
library_model.subscription_info = subscription_info

# Create the new library instance.
idem_token = SecureRandom.uuid
subscribed_library_stub =
   Com::Vmware::Content::SubscribedLibrary.new $my_stub_config
library_id = subscribed_library_stub.create(create_spec=library_model,
                                            client_token=idem_token)