.NET Example of Creating a Tag Category
This example is based on code in the TaggingWorkflow.cs 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 sample code, see the
vSphere Automation SDK .NET
samples at GitHub.
... var categoryStub = myStubFactory.CreateStub<Category>(myStubConfiguration); // Set up a tag category create spec. var createSpec = new CategoryTypes.CreateSpec(); createSpec.SetName(“favorites”); createSpec.SetDescription(“My favorite virtual machines.”); createSpec.SetCardinality(CategoryModel.Cardinality.MULTIPLE); HashSet<String> associableTypes = new HashSet<String>(); createSpec.SetAssociableTypes(associableTypes); // Create the tag category. String newCategoryId = categoryStub.Create(createSpec);