public ConfigurationOptionSetting unmarshall(StaxUnmarshallerContext context) throws Exception { ConfigurationOptionSetting configurationOptionSetting = new ConfigurationOptionSetting(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; configurationOptionSetting.setResourceName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; configurationOptionSetting.setNamespace(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; configurationOptionSetting.setOptionName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; configurationOptionSetting.setValue(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue;
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getResourceName() == null) ? 0 : getResourceName().hashCode()); hashCode = prime * hashCode + ((getNamespace() == null) ? 0 : getNamespace().hashCode()); hashCode = prime * hashCode + ((getOptionName() == null) ? 0 : getOptionName().hashCode()); hashCode = prime * hashCode + ((getValue() == null) ? 0 : getValue().hashCode()); return hashCode; }
/** * Constructs a new ConfigurationOptionSetting object. Callers should use the setter or fluent setter (with...) * methods to initialize any additional object members. * * @param namespace * A unique namespace identifying the option's associated AWS resource. * @param optionName * The name of the configuration option. * @param value * The current value for the configuration option. */ public ConfigurationOptionSetting(String namespace, String optionName, String value) { setNamespace(namespace); setOptionName(optionName); setValue(value); }
configOptionSetting.add(new ConfigurationOptionSetting().withNamespace(namespace).withOptionName(optionName).withValue(v)); } else if (COMMON_PARAMETERS.containsKey(k)) { String v = "" + properties.get(k); String namespace = COMMON_PARAMETERS.get(k).getNamespace(); String optionName = COMMON_PARAMETERS.get(k).getOptionName(); configOptionSetting.add(new ConfigurationOptionSetting().withNamespace(namespace).withOptionName(optionName).withValue(v)); } else if (extraOptionSettings.containsKey(k)) { ConfigurableOptionSetting cos = extraOptionSettings.get(k); configOptionSetting.add(new ConfigurationOptionSetting(cos.getNamespace(), cos.getOptionName(), v));
format( "Excluding Option Setting: %s:%s['%s']", curOptionSetting.getNamespace(), curOptionSetting.getOptionName(), CredentialsUtil.redact(curOptionSetting.getValue()))); listIterator.remove(); } else { format( "Including Option Setting: %s:%s['%s']", curOptionSetting.getNamespace(), curOptionSetting.getOptionName(), CredentialsUtil.redact(curOptionSetting.getValue()))); ConfigurationOptionSetting newOptionSetting = new ConfigurationOptionSetting("aws:autoscaling:launchconfiguration", "SecurityGroups", securityGroups); newOptionSettings.add(newOptionSetting); getLog() .info( format( "Including Option Setting: %s:%s['%s']", newOptionSetting.getNamespace(), newOptionSetting.getOptionName(), newOptionSetting.getValue()));
@Override public int compare(ConfigurationOptionSetting o1, ConfigurationOptionSetting o2) { return new CompareToBuilder() .append(o1.getNamespace(), o2.getNamespace()) .append(o1.getOptionName(), o2.getOptionName()) .append(o1.getValue(), o2.getValue()) .toComparison(); } };
protected Object executeInternal() throws Exception { waitForNotUpdating(); UpdateEnvironmentRequest req = new UpdateEnvironmentRequest().withEnvironmentId(curEnv.getEnvironmentId()); req.setOptionSettings( Arrays.asList( new ConfigurationOptionSetting().withNamespace("aws:elasticbeanstalk:application:environment").withOptionName(envName).withValue(envValue))); UpdateEnvironmentResult result = getService().updateEnvironment(req); return result; } }
private Collection<ConfigurationOptionSetting> setEnvironmentProperties() { Collection<ConfigurationOptionSetting> configurationOptionSettings = new HashSet<>(); configurationOptionSettings.add(new ConfigurationOptionSetting("aws:autoscaling:launchconfiguration", "InstanceType", "t2.medium")); configurationOptionSettings.add(new ConfigurationOptionSetting("aws:ec2:vpc", "VPCId","thevpcid"); configurationOptionSettings.add(new ConfigurationOptionSetting("aws:ec2:vpc", "Subnets", "thesubnets"); configurationOptionSettings.add(new ConfigurationOptionSetting("aws:ec2:vpc", "ELBSubnets", "theelbsubnets"); configurationOptionSettings.add(new ConfigurationOptionSetting("aws:elasticbeanstalk:application:environment", "ANOTHER_PROPERTY", "a value")); return configurationOptionSettings; }
public static boolean optionSettingMatchesP(ConfigurationOptionSetting optionSetting, String namespace, String option) { return namespace.equals(optionSetting.getNamespace()) && option.equals(optionSetting.getOptionName()); } }
protected boolean isSingleInstance(EnvironmentDescription env) { Validate.isTrue("WebServer".equals(env.getTier().getName()), "Not a Web Server environment!"); final DescribeConfigurationSettingsResult describeConfigurationSettingsResult = parentMojo .getService() .describeConfigurationSettings( new DescribeConfigurationSettingsRequest().withApplicationName(env.getApplicationName()).withEnvironmentName(env.getEnvironmentName())); Validate.isTrue(1 == describeConfigurationSettingsResult.getConfigurationSettings().size(), "There should be one environment"); final List<ConfigurationOptionSetting> optionSettings = describeConfigurationSettingsResult.getConfigurationSettings().get(0).getOptionSettings(); for (ConfigurationOptionSetting optionSetting : optionSettings) { if (ConfigUtil.optionSettingMatchesP(optionSetting, "aws:elasticbeanstalk:environment", "EnvironmentType")) { return "SingleInstance".equals(optionSetting.getValue()); } } throw new IllegalStateException("Unreachable code!"); }
/** * <p> * A unique namespace identifying the option's associated AWS resource. * </p> * * @param namespace * A unique namespace identifying the option's associated AWS resource. * @return Returns a reference to this object so that method calls can be chained together. */ public ConfigurationOptionSetting withNamespace(String namespace) { setNamespace(namespace); return this; }
final String securityGroup = optionSetting.getValue(); boolean bInvalid = isBlank(optionSetting.getValue()); bInvalid = (optionSetting.getNamespace().equals("aws:cloudformation:template:parameter") && optionSetting.getOptionName().equals("AppSource")); bInvalid = (optionSetting.getNamespace().equals("aws:elasticbeanstalk:sns:topics") && optionSetting.getOptionName().equals("Notification Topic ARN")); bInvalid = (optionSetting.getValue().contains(environmentId));
List<ConfigurationOptionSetting> loadConfigurationOptions(String json) { List<ConfigurationOptionSetting> options = new ArrayList<>(); @SuppressWarnings("unchecked") Collection<Map<String, Object>> c = (Collection<Map<String, Object>>) new groovy.json.JsonSlurper().setType(JsonParserType.LAX) .parseText(json); c.forEach(it -> options.add(new ConfigurationOptionSetting((String) it.get("Namespace"), (String) it.get("OptionName"), (String) it.get("Value")))); return options; } }
protected boolean contextDoesNotContainsEC2Role(CreateEnvironmentContext context) { boolean found = false; for (ConfigurationOptionSetting opt : context.getOptionSettings()) { found = opt.getOptionName().equals("IamInstanceProfile") && opt.getNamespace().equals("aws:autoscaling:launchconfiguration"); if (found) { break; } } return !found; } }
/** * Constructs a new ConfigurationOptionSetting object. Callers should use the setter or fluent setter (with...) * methods to initialize any additional object members. * * @param namespace * A unique namespace identifying the option's associated AWS resource. * @param optionName * The name of the configuration option. * @param value * The current value for the configuration option. */ public ConfigurationOptionSetting(String namespace, String optionName, String value) { setNamespace(namespace); setOptionName(optionName); setValue(value); }
/** * <p> * A unique namespace identifying the option's associated AWS resource. * </p> * * @param namespace * A unique namespace identifying the option's associated AWS resource. * @return Returns a reference to this object so that method calls can be chained together. */ public ConfigurationOptionSetting withNamespace(String namespace) { setNamespace(namespace); return this; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof ConfigurationOptionSetting == false) return false; ConfigurationOptionSetting other = (ConfigurationOptionSetting) obj; if (other.getResourceName() == null ^ this.getResourceName() == null) return false; if (other.getResourceName() != null && other.getResourceName().equals(this.getResourceName()) == false) return false; if (other.getNamespace() == null ^ this.getNamespace() == null) return false; if (other.getNamespace() != null && other.getNamespace().equals(this.getNamespace()) == false) return false; if (other.getOptionName() == null ^ this.getOptionName() == null) return false; if (other.getOptionName() != null && other.getOptionName().equals(this.getOptionName()) == false) return false; if (other.getValue() == null ^ this.getValue() == null) return false; if (other.getValue() != null && other.getValue().equals(this.getValue()) == false) return false; return true; }
public ConfigurationOptionSetting unmarshall(StaxUnmarshallerContext context) throws Exception { ConfigurationOptionSetting configurationOptionSetting = new ConfigurationOptionSetting(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; configurationOptionSetting.setResourceName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; configurationOptionSetting.setNamespace(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; configurationOptionSetting.setOptionName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; configurationOptionSetting.setValue(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue;
buf.add(String.format(" <%s>%s</%1$s>", "namespace", setting.getNamespace())); buf.add(String.format(" <%s>%s</%1$s>", "optionName", setting.getOptionName())); buf.add(String.format(" <%s>%s</%1$s>", "value", setting.getValue())); buf.add(" </optionSetting>");
optionSettings.add(new ConfigurationOptionSetting(setting .getNamespace(), setting.getOptionName(), setting .getValue()));