in src/main/java/software/amazon/cloudformation/resource/ResourceTypeSchema.java [68:192]
public ResourceTypeSchema(Schema schema) {
this.schema = schema;
schema.getUnprocessedProperties().forEach(this.unprocessedProperties::put);
this.sourceUrl = this.unprocessedProperties.containsKey("sourceUrl")
? this.unprocessedProperties.get("sourceUrl").toString()
: null;
this.unprocessedProperties.remove("sourceUrl");
this.documentationUrl = this.unprocessedProperties.containsKey("documentationUrl")
? this.unprocessedProperties.get("documentationUrl").toString()
: null;
this.unprocessedProperties.remove("documentationUrl");
// typeName is mandatory by schema
this.typeName = this.unprocessedProperties.get("typeName").toString();
this.unprocessedProperties.remove("typeName");
this.schemaUrl = this.unprocessedProperties.containsKey("$schema")
? this.unprocessedProperties.get("$schema").toString()
: null;
this.unprocessedProperties.remove("$schema");
this.replacementStrategy = this.unprocessedProperties.containsKey("replacementStrategy")
? this.unprocessedProperties.get("replacementStrategy").toString()
: "create_then_delete";
this.unprocessedProperties.remove("replacementStrategy");
this.unprocessedProperties.computeIfPresent("conditionalCreateOnlyProperties", (k, v) -> {
((ArrayList<?>) v).forEach(p -> this.conditionalCreateOnlyProperties.add(new JSONPointer(p.toString())));
return null;
});
this.unprocessedProperties.computeIfPresent("createOnlyProperties", (k, v) -> {
((ArrayList<?>) v).forEach(p -> this.createOnlyProperties.add(new JSONPointer(p.toString())));
return null;
});
this.unprocessedProperties.computeIfPresent("deprecatedProperties", (k, v) -> {
((ArrayList<?>) v).forEach(p -> this.deprecatedProperties.add(new JSONPointer(p.toString())));
return null;
});
this.unprocessedProperties.computeIfPresent("primaryIdentifier", (k, v) -> {
((ArrayList<?>) v).forEach(p -> this.primaryIdentifier.add(new JSONPointer(p.toString())));
return null;
});
this.unprocessedProperties.computeIfPresent("additionalIdentifiers", (k, v) -> {
((ArrayList<?>) v).forEach(p -> {
final ArrayList<JSONPointer> identifiers = new ArrayList<>();
((ArrayList<?>) p).forEach(pi -> identifiers.add(new JSONPointer(pi.toString())));
this.additionalIdentifiers.add(identifiers);
});
return null;
});
this.unprocessedProperties.computeIfPresent("readOnlyProperties", (k, v) -> {
((ArrayList<?>) v).forEach(p -> this.readOnlyProperties.add(new JSONPointer(p.toString())));
return null;
});
this.unprocessedProperties.computeIfPresent("writeOnlyProperties", (k, v) -> {
((ArrayList<?>) v).forEach(p -> this.writeOnlyProperties.add(new JSONPointer(p.toString())));
return null;
});
this.unprocessedProperties.computeIfPresent("propertyTransform", (k, v) -> {
((Map<?, ?>) v).forEach((key, value) -> {
this.propertyTransform.put(key.toString(), value.toString());
});
return null;
});
this.unprocessedProperties.computeIfPresent("handlers", (k, v) -> {
((HashMap<?, ?>) v).keySet().forEach(handlerKey -> {
HashMap<?, ?> handlerInfo = (HashMap<?, ?>) ((HashMap<?, ?>) v).get(handlerKey);
HashSet<String> handlerPermissions = new HashSet<>();
((List<?>) handlerInfo.get("permissions")).forEach(permission -> handlerPermissions.add(permission.toString()));
Integer timeoutInMinutes = handlerInfo.containsKey("timeoutInMinutes")
? ((Integer) handlerInfo.get("timeoutInMinutes"))
: DEFAULT_TIMEOUT_IN_MINUTES;
this.handlers.put(handlerKey.toString(), new Handler(handlerPermissions, timeoutInMinutes));
});
return null;
});
this.unprocessedProperties.computeIfPresent("tagging", (k, v) -> {
hasConfiguredTagging = true;
((Map<?, ?>) v).forEach((key, value) -> {
if (key.equals(ResourceTagging.TAGGABLE)) {
this.tagging.setTaggable(Boolean.parseBoolean(value.toString()));
} else if (key.equals(ResourceTagging.TAG_ON_CREATE)) {
this.tagging.setTagOnCreate(Boolean.parseBoolean(value.toString()));
} else if (key.equals(ResourceTagging.TAG_UPDATABLE)) {
this.tagging.setTagUpdatable(Boolean.parseBoolean(value.toString()));
} else if (key.equals(ResourceTagging.CLOUDFORMATION_SYSTEM_TAGS)) {
this.tagging.setCloudFormationSystemTags(Boolean.parseBoolean(value.toString()));
} else if (key.equals(ResourceTagging.TAG_PROPERTY)) {
this.tagging.setTagProperty(new JSONPointer(value.toString()));
} else {
throw new ValidationException("Unexpected tagging metadata attribute", "tagging", "#/tagging/" + key);
}
});
if (!this.tagging.isTaggable()) {
// reset other metadata values if resource is not taggable
this.tagging.resetTaggable(this.tagging.isTaggable());
}
tagging.validateTaggingMetadata(this.handlers.containsKey("update"), this.schema);
return null;
});
if (this.unprocessedProperties.containsKey("taggable")) {
this.taggable = Boolean.parseBoolean(this.unprocessedProperties.get("taggable").toString());
if (!hasConfiguredTagging) {
// set tagging metadata based on deprecated taggable value
this.tagging.resetTaggable(this.taggable);
} else {
throw new ValidationException("More than one configuration found for taggable value." +
" Please remove the deprecated taggable property.", "tagging", "#/tagging/taggable");
}
} else {
this.taggable = true;
}
this.unprocessedProperties.remove("taggable");
}