This example creates a tag category specification and then uses it to create the category. You need to create a category before you can create a tag.

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.

require 'com/vmware/cis/tagging/vapi'

# Set up a tag category create spec.
create_spec =
   Com::Vmware::Cis::Tagging::Category::CreateSpec.new
create_spec.name = 'favorites'
create_spec.description = 'My favorite virtual machines'
create_spec.cardinality =
   Com::Vmware::Cis::Tagging::CategoryModel::Cardinality::MULTIPLE
create_spec.associable_types = Set.new

# Create the tag category.
category_stub =
   Com::Vmware::Cis::Tagging::Category.new $my_stub_config
$my_category_id = category_stub.create create_spec