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.

use Com::Vmware::Cis::Tagging::Category;
use Com::Vmware::Cis::Tagging::CategoryModel;

$my_category_stub = $my_stub_factory->create_stub(
                    'service_name' => 'Com::Vmware::Cis::Tagging::Category',
                    'stub_config'  => $my_stub_config);
my $create_spec = new
   Com::Vmware::Cis::Tagging::Category::CreateSpec();
$create_spec->set_name(
              'name' => 'favorites');
$create_spec->set_description(
              'description' => 'My favorite virtual machines');
$create_spec->set_cardinality(
              'cardinality' =>
      Com::Vmware::Cis::Tagging::CategoryModel::Cardinality::MULTIPLE);
$create_spec->set_associable_types( 'associable_types' => [] );
$my_category_id = $my_category_stub->create('create_spec' => $create_spec );