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.

use Com::Vmware::Content::Library;
use Data::GUID;

# Create a StorageBacking instance on a local file system.
my $library_backing = new
   Com::Vmware::Content::Library::StorageBacking();
$library_backing->set_type(
   Com::Vmware::Content::Library::StorageBacking::Type::OTHER);
$library_backing->set_storage_uri('file:///mnt/nfs/cls-root');

# Create a new SubscriptionInfo object to describe the subscription behavior.
my $subscription_info = new
   Com::Vmware::Content::Library::SubscriptionInfo();
$subscription_info->set_authentication_method(
Com::Vmware::Content::Library::SubscriptionInfo::AuthenticationMethod::BASIC);
$subscription_info->set_user_name('library-user');
$subscription_info->set_password('password');
$subscription_info->set_subscription_url(
   'https://www.example.com/library_inventory/lib.json');
$subscription_info->set_automatic_sync_enabled(1);
$subscription_info->set_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.
my $library_model = new
   Com::Vmware::Content::LibraryModel();
$library_model->set_type(
   Com::Vmware::Content::LibraryModel::LibraryType::SUBSCRIBED);
$library_model->set_name('subscrLibrary');

# Attach the storage backing and the subscription info to the library model.
$library_model->set_storage_backings( [library_backing] );
$library_model->set_subscription_info($subscription_info);

# Create the new library instance.
my $idem_token = Data::GUID->guid_string;
my $subscribed_library_stub = new
   Com::Vmware::Content::SubscribedLibrary($my_stub_config);
$my_library_id = $subscribed_library_stub->create(
                 create_spec => $library_model,
                 client_token => $idem_token);