Last active
March 25, 2017 01:31
-
-
Save trisharia/8786757ad28738a8d445eec0addbb58d to your computer and use it in GitHub Desktop.
Create a vCenter tag via VAPI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// VMware vRealize Orchestrator action sample | |
// | |
// Create a vCenter tag via VAPI | |
// If description is empty, sets the description as the Tag name by default. | |
// | |
// For vRO/VAPI 7.0+ | |
// | |
// Action Inputs: | |
// endpoint - VAPIEndpoint - VAPI Endpoint | |
// name - string - Name of the Tag | |
// categoryId - string - ID of the Tag Category | |
// description - string - Optional description of the Tag | |
// | |
// Return type: string - ID of the tag | |
var tagClient = endpoint.client(); | |
var tagService = new com_vmware_cis_tagging_tag(tagClient); | |
var tagCreateSpec = createTagSpec(name,categoryId,description); | |
tagId = tagService.create(tagCreateSpec); | |
return tagId; | |
function createTagSpec(name,categoryId,description) { | |
var spec = new com_vmware_cis_tagging_tag_create__spec() ; | |
spec.category_id = categoryId; | |
spec.name = name; | |
spec.description = (isSet(description)) ? description : name; | |
return spec; | |
} | |
function isSet(s) { | |
return s != null && s != ""; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment