Skip to content

Instantly share code, notes, and snippets.

@trisharia
Last active March 25, 2017 01:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trisharia/bcb16e1d500c7f71dc59539f8cf38b1d to your computer and use it in GitHub Desktop.
Save trisharia/bcb16e1d500c7f71dc59539f8cf38b1d to your computer and use it in GitHub Desktop.
Creates a vCenter Tag Category via VAPI
// 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