This example is based on code in the TaggingWorkflow.java sample file.
This example is based on the information that is provided in Creating a Tag Category.
The category create() function returns an identifier that you use when you create a tag for that category. The empty set for the associable types indicates that any object type can be associated with a tag in this category.
Note: For a complete and up-to-date version of the Java sample code, see the
vsphere-automation-sdk-java VMware repository at GitHub.
... Category categoryStub = myStubFactory.createStub(Category.class, myStubConfiguration); // Set up a tag category create spec. CategoryTypes.CreateSpec createSpec = new CategoryTypes.CreateSpec(); createSpec.setName(“favorites”); createSpec.setDescription(“My favorite virtual machines.”); createSpec.setCardinality(CategoryModel.Cardinality.MULTIPLE); Set<String> associableTypes = new HashSet<String>(); createSpec.setAssociableTypes(associableTypes); String newCategoryId = categoryStub.create(createSpec);