Java Example of Storing Library Content on a Datastore

This example is based on the code in the
LibraryCrud.java
sample file.
For more information about storing the contents of a local library, see Content Library Storage.
For a complete and up-to-date version of the sample code, see the vSphere Automation SDK Java samples at GitHub.
... // Create a StorageBacking instance for storing the library content on a datastore. StorageBacking libraryBacking = new StorageBacking(); libraryBacking.setType(Type.DATASTORE); /* * Pass the value of the datastore
ManagedObjectReference
. * See the
vSphere Web Services SDK Programming Guide
* and the vSphere Web Services SDK samples. In addition, the
vSphere Automation SDK for Java
provides * the
VimUtil
utility class in the
vmware.samples.vim.helpers
package. * You can use the utility to retrieve the
ManagedObjectReference
* of the datastore entity. */ libraryBacking.setDatastoreId("datastore-123"); // Create a LibraryModel that represents a local library backed on a datastore. LibraryModel libraryModel = new LibraryModel(); libraryModel.setName("AcmeLibrary"); libraryModel.setDescription("Local library backed by VC datastore"); libraryModel.setType(LibraryType.LOCAL); libraryModel.setStorageBackings(Collections.singletonList(libraryBacking));