Last active
March 25, 2017 01:32
-
-
Save trisharia/bcb16e1d500c7f71dc59539f8cf38b1d to your computer and use it in GitHub Desktop.
Creates a vCenter Tag Category 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 category via VAPI | |
// If description is empty, sets the description as the tag category name by default. | |
// | |
// For vRO/VAPI 7.0+ | |
// | |
// Action Inputs: | |
// endpoint - VAPIEndpoint - VAPI Endpoint | |
// name - string - Name of the Tag Category | |
// description - string - Optional description of the Tag Category | |
// cardinality - string - Category cardinality (SINGLE, MULTIPLE) | |
// associableTypes - Array/string - Associable types | |
// | |
// Return type: string - ID of the tag category | |
var client = endpoint.client(); | |
var catService = new com_vmware_cis_tagging_category(client); | |
var spec = getCategorySpec(name,description,cardinality,associableTypes); | |
var categoryId = catService.create(spec); | |
return categoryId; | |
function getCategorySpec(name,description,cardinality,associableTypes) { | |
var spec = new com_vmware_cis_tagging_category_create__spec(); | |
spec.name = name; | |
spec.description = (isSet(description)) ? description : name; | |
spec.cardinality = cardinality; | |
spec.associable_types = associableTypes; | |
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