Create logPayloadProperties.js

This commit is contained in:
John Bowdre 2022-06-14 09:31:45 -05:00 committed by GitHub
parent 31a26de026
commit 745e44fad9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,30 @@
/* JavaScript: logPayloadProperties action
Writes out all the properties of a VM request payload from vRA for testing purposes.
Inputs: payload (Properties)
Return Type: string
*/
System.debug("==== Begin: vRA Event Broker Payload Properties ====");
logAllProperties(inputProperties,0);
System.debug("==== End: vRA Event Broker Payload Properties ====");
function logAllProperties(props,indent) {
var keys = (props.keys).sort();
for each (var key in keys) {
var prop = props.get(key);
var type = System.getObjectType(prop);
if (type == "Properties") {
logSingleProperty(key,prop,indent);
logAllProperties(prop,indent+1);
} else {
logSingleProperty(key,prop,indent);
}
}
}
function logSingleProperty(name,value,i) {
var prefix = "";
if (i > 0) {
var prefix = Array(i+1).join("-") + " ";
}
System.debug(prefix + name + " :: " + System.getObjectType(value) + " :: " + value);
}