use of org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.AbstractType in project sts4 by spring-projects.
the class BoshCloudConfigSchema method createNetworkBlockSchema.
private YType createNetworkBlockSchema(BoshModels models) {
AbstractType t_manual_nw = f.ybean("ManualNetwork");
{
YBeanType t_subnet = f.ybean("Subnet[Manual]");
addProp(t_subnet, "range", t_ip_range).isRequired(true);
addProp(t_subnet, "gateway", t_ip_address).isRequired(true);
addProp(t_subnet, "dns", f.yseq(t_ip_address));
addProp(t_subnet, "reserved", f.yseq(t_ip_address_or_range));
addProp(t_subnet, "static", f.yseq(t_ip_address_or_range));
addProp(t_subnet, "az", t_az_ref);
addProp(t_subnet, "azs", f.yseq(t_az_ref));
addProp(t_subnet, "cloud_properties", t_params);
addProp(t_manual_nw, "subnets", f.yseq(t_subnet)).isRequired(true);
}
AbstractType t_vip_nw = f.ybean("VipNetwork");
addProp(t_vip_nw, "cloud_properties", t_params);
AbstractType t_dynamic_nw = f.ybean("DynamicNetwork");
addProp(t_dynamic_nw, "dns", f.yseq(t_ip_address));
addProp(t_dynamic_nw, "cloud_properties", t_params);
{
YBeanType t_subnet = f.ybean("Subnet[Dynamic]");
addProp(t_subnet, "dns", f.yseq(t_ip_address));
addProp(t_subnet, "az", t_az_ref);
addProp(t_subnet, "azs", f.yseq(t_az_ref));
addProp(t_subnet, "cloud_properties", t_params);
addProp(t_dynamic_nw, "subnets", f.yseq(t_subnet));
}
t_dynamic_nw.require(Constraints.mutuallyExclusive("dns", "subnets"));
t_dynamic_nw.require(Constraints.mutuallyExclusive("cloud_properties", "subnets"));
AbstractType t_network = f.contextAware("Network", dc -> {
String type = models.getTypeTag(dc);
if (StringUtil.hasText(type)) {
switch(type) {
case "manual":
return t_manual_nw;
case "dynamic":
return t_dynamic_nw;
case "vip":
return t_vip_nw;
default:
}
}
return null;
}).treatAsBean();
// Add shared properties to the 'super' type.
addProp(t_network, "name", t_network_def).isPrimary(true);
addProp(t_network, "type", f.yenum("NetworkType", "manual", "dynamic", "vip")).isRequired(true);
// Add shared properties to all 'sub' types.
for (AbstractType subtype : ImmutableList.of(t_dynamic_nw, t_manual_nw, t_vip_nw)) {
for (YTypedProperty sharedProp : t_network.getProperties()) {
subtype.addProperty(sharedProp);
}
}
return t_network;
}
use of org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.AbstractType in project sts4 by spring-projects.
the class ConcourseModel method addExtraInsertion.
private YValueHint addExtraInsertion(YValueHint h, DynamicSchemaContext dc) {
return new BasicYValueHint(h.getValue(), h.getLabel()).setExtraInsertion(() -> {
String resourceTypeName = h.getValue();
AbstractType sourceType = (AbstractType) resourceTypes.getSourceType(resourceTypeName);
if (sourceType != null && getParentPropertyNode("source", dc) == null) {
// don't auto insert what's already there!
List<YTypedProperty> requiredProps = sourceType.getProperties().stream().filter(p -> p.isRequired()).collect(Collectors.toList());
if (!requiredProps.isEmpty()) {
SnippetBuilder snippet = snippetBuilderFactory.get();
snippet.text("\nsource:");
for (YTypedProperty p : requiredProps) {
snippet.text("\n " + p.getName() + ": ");
snippet.placeHolder();
}
return snippet.toString();
}
}
return null;
});
}
use of org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.AbstractType in project sts4 by spring-projects.
the class ConcourseModel method newStep.
public StepModel newStep(Node _node) {
MappingNode node = (MappingNode) _node;
Set<String> keys = NodeUtil.getScalarKeys(node);
for (Entry<String, AbstractType> primary : stepType.typesByPrimary().entrySet()) {
String stepType = primary.getKey();
if (keys.contains(primary.getKey())) {
return new StepModel(stepType, node);
}
}
throw new IllegalArgumentException("Node does not look like step node: " + node);
}
use of org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.AbstractType in project sts4 by spring-projects.
the class ManifestYmlSchemaTest method getNestedProps.
private List<YTypedProperty> getNestedProps() {
YSeqType applications = (YSeqType) schema.getTopLevelType().getPropertiesMap().get("applications").getType();
AbstractType application = (AbstractType) applications.getDomainType();
return application.getProperties();
}
Aggregations