This example creates a tag specification and then uses it to create the tag. The tag specification references the category identifier that was returned from the category create operation. Use the returned tag identifier for subsequent operations on the tag.

This example is based on the information that is provided in Creating a Tag.

use Com::Vmware::Cis::Tagging::Tag;

# Create a tag specification for the new tag.
my $create_spec = new Com::Vmware::Cis::Tagging::Tag::CreateSpec();
$create_spec->set_name(
              'name' => 'red');
$create_spec->set_description(
              'description' => 'My favorite color');
$create_spec->set_category_id(
              'category_id' => $my_category_id);

# Use the tag specification in a create() call.
my $tag_stub = $my_Stub_factory->create_stub(
               'service_name' => 'Com::Vmware::Cis::Tagging::Tag',
               'stub_config'  => $my_stub_config);
$my_tag_id = $tag_stub->create(
             'create_spec' => $create_spec );