Java Example of Creating a Tag
This example is based on code in the TaggingWorkflow.java 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 Java samples at GitHub.
... Tag tagStub = myStubFactory.createStub(Tag.class, myStubConfiguration); // Set up a tag create spec. TagTypes.CreateSpec spec = new TagTypes.CreateSpec(); spec.setName(“red”); spec.setDescription(“My favorite color”); spec.setCategoryId(newCategoryId); String tagId = tagStub.create(spec);