Create an Empty Library
Item
You can create as
many library items as needed and associate them with a local content library.
- Access theItemservice by using thevSphere Automationendpoint.
- Instantiate theItemModelclass.
- Define the settings of the new library item.
- Associate the library item with an existing local library.
- Invoke thecreatefunction on theItemobject to pass the library item specification and the unique client token.
Upload content to the new
library item. See
Upload a File from a Local System to a Library Item
and
Upload a File from a URL to a Library Item.
- Java
- This example shows how to create an empty library item that stores an ISO image file.This example uses the steps that are described in the Create an Empty Library Item procedure.For related code samples, see thevsphere-automation-sdk-javaVMware repository at GitHub.... // Create an instance of the ItemModel class and specify the item settings. ItemModel libItemSpec = new ItemModel(); libItemSpec.setName("ESXi ISO image"); libItemSpec.setDescription("ISO image with the latest security patches for ESXi"); libItemSpec.setType("iso"); // Associate the item with an existing content library. libItemSpec.setLibraryId("<content_library_ID>"); // Create the new Item instance, using the specified model. Item libItemService = this.vapiAuthHelper.getStubFactory().createStub(Item.class, sessionStubconfig); String itemID = UUID.randomUUID().toString(); String newItem = libItemService.create(itemID, libItemSpec);
- Python
- This example shows how to create an empty library item that stores an ISO image file.This example uses the steps that are described in the Create an Empty Library Item procedure.For related code samples, see thevsphere-automation-sdk-pythonVMware repository at GitHub.... # 1 - Create an instance of the ItemModel class and specify the item settings. item_model = library_client.ItemModel() item_model.name = ’ESXi ISO image’ item_model.description = ’ISO image with the latest security patches for ESXi’ item_model.type = ’iso’ # 2 - Associate the new item with an existing library. item_model.library_id = my_library_id # 3 - Create the new instance of the Item class, using the specified model. idem_token = str(uuid.uuid4()) item_stub = library_client.Item(my_stub_config) item_id = item_stub.create(create_spec=item_model, client_token=idem_token)