Python Example of Creating a Tag Category

This example is based on code in the tagging_workflow.py 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-python VMware repository at GitHub.
...
 
category_stub = tagging_client.Category(my_stub_config)
 
# Set up a tag category create spec.
tc_create_spec = category_stub.CreateSpec(name = ‘favorites’,
                                          description = ‘My favorite virtual machines’,
                                          cardinality = CategoryModel.Cardinality.MULTIPLE,
                                          associable_types = set())
 
# Create the tag category.
fav_category_id = category_stub.create(create_spec)