List of usage examples for com.amazonaws.services.elasticbeanstalk.model EnvironmentDescription getCNAME
public String getCNAME()
The URL to the CNAME for this environment.
From source file:br.com.ingenieux.mojo.beanstalk.cmd.env.waitfor.WaitForEnvironmentCommand.java
License:Apache License
protected List<Predicate<EnvironmentDescription>> getEnvironmentDescriptionPredicate( WaitForEnvironmentContext context) { // as well as those (which are used as predicate variables, thus being // final)//from w ww.j av a 2 s . c om final String environmentRef = context.getEnvironmentRef(); final String statusToWaitFor = defaultString(context.getStatusToWaitFor(), "!Terminated"); final String healthToWaitFor = context.getHealth(); // Sanity Check Validate.isTrue(isNotBlank(environmentRef), "EnvironmentRef is blank or null", environmentRef); // some argument juggling final boolean negated = statusToWaitFor.startsWith("!"); // argument juggling List<Predicate<EnvironmentDescription>> result = new ArrayList<Predicate<EnvironmentDescription>>(); if (environmentRef.matches("e-\\p{Alnum}{10}")) { result.add(new Predicate<EnvironmentDescription>() { @Override public boolean apply(EnvironmentDescription t) { return t.getEnvironmentId().equals(environmentRef); } }); info("... with environmentId equal to '%s'", environmentRef); } else if (environmentRef.matches(".*\\Q.elasticbeanstalk.com\\E")) { result.add(new Predicate<EnvironmentDescription>() { @Override public boolean apply(EnvironmentDescription t) { return defaultString(t.getCNAME()).equals(environmentRef); } }); info("... with cname set to '%s'", environmentRef); } else { String tmpRE = Pattern.quote(environmentRef); if (environmentRef.endsWith("*")) { tmpRE = format("^\\Q%s\\E.*", environmentRef.substring(0, -1 + environmentRef.length())); } final String environmentRefNameRE = tmpRE; result.add(new Predicate<EnvironmentDescription>() { @Override public boolean apply(EnvironmentDescription t) { return t.getEnvironmentName().matches(environmentRefNameRE); } }); info("... with environmentName matching re '%s'", environmentRefNameRE); } { // start building predicates with the status one - "![status]" must // be equal to status or not status final int offset = negated ? 1 : 0; final String vStatusToWaitFor = statusToWaitFor.substring(offset); result.add(new Predicate<EnvironmentDescription>() { public boolean apply(EnvironmentDescription t) { boolean result = vStatusToWaitFor.equals(t.getStatus()); if (negated) { result = !result; } debug("testing status '%s' as equal as '%s' (negated? %s, offset: %d): %s", vStatusToWaitFor, t.getStatus(), negated, offset, result); return result; } }); info("... with status %s set to '%s'", (negated ? "*NOT*" : " "), vStatusToWaitFor); } { if (isNotBlank(healthToWaitFor)) { result.add(new Predicate<EnvironmentDescription>() { @Override public boolean apply(EnvironmentDescription t) { return t.getHealth().equals(healthToWaitFor); } }); info("... with health equal to '%s'", healthToWaitFor); } } return result; }
From source file:br.com.ingenieux.mojo.beanstalk.env.ReplaceEnvironmentMojo.java
License:Apache License
/** * Returns the environment description matching applicationName and environmentRef * * @param applicationName application name * @param cnamePrefix cname prefix/*from w ww. j a va2 s . c o m*/ * @return environment description */ protected EnvironmentDescription getEnvironmentFor(String applicationName, String cnamePrefix) { Collection<EnvironmentDescription> environments = getEnvironmentsFor(applicationName); String cnameToMatch = String.format("%s.elasticbeanstalk.com", cnamePrefix); /* * Finds a matching environment */ for (EnvironmentDescription envDesc : environments) { if (cnameToMatch.equals(envDesc.getCNAME())) { return envDesc; } } return null; }
From source file:br.com.ingenieux.mojo.beanstalk.util.EnvironmentHostnameUtil.java
License:Apache License
public static Predicate<EnvironmentDescription> getHostnamePredicate(Region region, String cnamePrefix) { final Set<String> hostnamesToMatch = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); hostnamesToMatch.add(format("%s.elasticbeanstalk.com", cnamePrefix).toLowerCase()); hostnamesToMatch.add(format("%s.%s.elasticbeanstalk.com", cnamePrefix, region.getName()).toLowerCase()); return new Predicate<EnvironmentDescription>() { @Override/*from ww w . j av a2 s . c om*/ public boolean apply(EnvironmentDescription t) { return hostnamesToMatch.contains(t.getCNAME()); } @Override public String toString() { return format("... with cname belonging to %s", StringUtils.join(hostnamesToMatch.iterator(), " or ")); } }; }
From source file:jp.classmethod.aws.gradle.elasticbeanstalk.AwsBeanstalkPluginExtension.java
License:Apache License
public String getEbEnvironmentCNAME(String environmentName) { DescribeEnvironmentsResult der = getClient().describeEnvironments(new DescribeEnvironmentsRequest() .withApplicationName(appName).withEnvironmentNames(environmentName)); EnvironmentDescription env = der.getEnvironments().get(0); return env.getCNAME(); }