This example is based on code in the TaggingWorkflow.java sample file. This file is located in the following vCloud Suite SDK for Java directory: client/samples/java/com/vmware/vcloud/suite/sample/interop
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.
import com.vmware.cis.tagging.Category; import com.vmware.cis.tagging.CategoryMadel; import com.vmware.cis.tagging.CategoryTypes; import com.vmware.cis.tagging.Tag; import com.vmware.cis.tagging.TagCategory; import com.vmware.cis.tagging.TagAssociation; 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);