Perl Example of Creating a Tag
This example is based on code in the tagging_workflow.pl sample file.
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.
Note: For a complete and
up-to-date version of the sample code, see the
vSphere Automation SDK Perl
samples at GitHub.
... # 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 );