if ("template".equals(entry.getKey())) {
// Sometimes Cloudstack will say 'template' and the payload is a Template object.
// Sometimes Cloudstack will say 'template' and the payload is a TemplateExtraction object.
// The 'state' field only exists on TemplateExtraction, so we can test this to work out what we have actually been given.
Template template = json.fromJson(entry.getValue().toString(), Template.class);
TemplateExtraction templateExtraction = json.fromJson(entry.getValue().toString(), TemplateExtraction.class);
boolean isTemplate = Strings.isNullOrEmpty(templateExtraction.getState());
builder.result(isTemplate ? template : templateExtraction);
} else if (typeMap.containsKey(entry.getKey())) {
builder.result(json.fromJson(entry.getValue().toString(), typeMap.get(entry.getKey())));
} else {
logger.warn(