StringBuilder sb = new StringBuilder(); sb.append("{"); if (getEnvironmentName() != null) sb.append("EnvironmentName: ").append(getEnvironmentName()).append(","); if (getEnvironmentId() != null) sb.append("EnvironmentId: ").append(getEnvironmentId()).append(",");
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getEnvironmentName() == null) ? 0 : getEnvironmentName().hashCode()); hashCode = prime * hashCode + ((getEnvironmentId() == null) ? 0 : getEnvironmentId().hashCode()); hashCode = prime * hashCode + ((getApplicationName() == null) ? 0 : getApplicationName().hashCode()); hashCode = prime * hashCode + ((getVersionLabel() == null) ? 0 : getVersionLabel().hashCode()); hashCode = prime * hashCode + ((getSolutionStackName() == null) ? 0 : getSolutionStackName().hashCode()); hashCode = prime * hashCode + ((getPlatformArn() == null) ? 0 : getPlatformArn().hashCode()); hashCode = prime * hashCode + ((getTemplateName() == null) ? 0 : getTemplateName().hashCode()); hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); hashCode = prime * hashCode + ((getEndpointURL() == null) ? 0 : getEndpointURL().hashCode()); hashCode = prime * hashCode + ((getCNAME() == null) ? 0 : getCNAME().hashCode()); hashCode = prime * hashCode + ((getDateCreated() == null) ? 0 : getDateCreated().hashCode()); hashCode = prime * hashCode + ((getDateUpdated() == null) ? 0 : getDateUpdated().hashCode()); hashCode = prime * hashCode + ((getStatus() == null) ? 0 : getStatus().hashCode()); hashCode = prime * hashCode + ((getAbortableOperationInProgress() == null) ? 0 : getAbortableOperationInProgress().hashCode()); hashCode = prime * hashCode + ((getHealth() == null) ? 0 : getHealth().hashCode()); hashCode = prime * hashCode + ((getHealthStatus() == null) ? 0 : getHealthStatus().hashCode()); hashCode = prime * hashCode + ((getResources() == null) ? 0 : getResources().hashCode()); hashCode = prime * hashCode + ((getTier() == null) ? 0 : getTier().hashCode()); hashCode = prime * hashCode + ((getEnvironmentLinks() == null) ? 0 : getEnvironmentLinks().hashCode()); hashCode = prime * hashCode + ((getEnvironmentArn() == null) ? 0 : getEnvironmentArn().hashCode()); return hashCode; }
return false; EnvironmentDescription other = (EnvironmentDescription) obj; if (other.getEnvironmentName() == null ^ this.getEnvironmentName() == null) return false; if (other.getEnvironmentName() != null && other.getEnvironmentName().equals(this.getEnvironmentName()) == false) return false; if (other.getEnvironmentId() == null ^ this.getEnvironmentId() == null)
@Override public boolean apply(EnvironmentDescription t) { return t.getEnvironmentName().matches(environmentRefNameRE); } });
@Override public String apply(EnvironmentDescription input) { return format("%s[%s]", input.getEnvironmentId(), input.getEnvironmentName()); } });
/** * Boolean predicate for named environment * * @param environmentName environment name * @return true if environment name exists */ protected boolean containsNamedEnvironment(String environmentName) { for (EnvironmentDescription envDesc : getEnvironmentsFor(applicationName)) { if (envDesc.getEnvironmentName().equals(environmentName)) { return true; } } return false; } }
@Override protected Object executeInternal() throws AbstractMojoExecutionException { Set<String> configTemplates = new TreeSet<String>(super.getConfigurationTemplates(applicationName)); String today = DATE_FORMAT.format(new Date()); if (StringUtils.isBlank(templateName)) { int i = 1; do { templateName = String.format("%s-%s-%02d", curEnv.getEnvironmentName(), today, i++); } while (configTemplates.contains(templateName)); } CreateConfigurationTemplateResult result = getService() .createConfigurationTemplate( new CreateConfigurationTemplateRequest() .withEnvironmentId(curEnv.getEnvironmentId()) .withTemplateName(templateName) .withApplicationName(curEnv.getApplicationName())); getLog().info("Created config template " + templateName + " for environment " + curEnv.getEnvironmentId()); return result; } }
protected Object executeInternal() throws MojoExecutionException, MojoFailureException { boolean bTemplateNameDefined = isNotBlank(templateName) && !GlobUtil.hasWildcards(templateName); DescribeConfigurationSettingsRequest req = new DescribeConfigurationSettingsRequest().withApplicationName(applicationName); if (bTemplateNameDefined) { req.withTemplateName(templateName); } else if (null != curEnv) { req.withEnvironmentName(curEnv.getEnvironmentName()); } else { getLog().warn("You must supply a templateName or environmentName. Ignoring"); return null; } getLog().info("Request: " + req); return getService().describeConfigurationSettings(req); } }
@Override protected Object executeInternal() throws MojoExecutionException, MojoFailureException { AbortEnvironmentUpdateRequest req = new AbortEnvironmentUpdateRequest(); req.setEnvironmentId(curEnv.getEnvironmentId()); req.setEnvironmentName(curEnv.getEnvironmentName()); super.configure(); return curEnv; } }
private EnvironmentDescription lookupEnvironmentIds(List<String> environmentNames) throws InvalidEnvironmentsSizeException, InvalidDeploymentTypeException { DescribeEnvironmentsResult environments = getAwseb() .describeEnvironments(new DescribeEnvironmentsRequest() .withApplicationName(c.config.getApplicationName()) .withIncludeDeleted(false)); for (EnvironmentDescription env : environments.getEnvironments()) { if (environmentNames.contains(env.getEnvironmentName())) { if (WORKER_ENVIRONMENT_TYPE.equals(env.getTier().getName())) { throw new InvalidDeploymentTypeException(); } return env; } } throw new InvalidEnvironmentsSizeException(c.config.getApplicationName(), environmentNames.get(0), environments.getEnvironments().size()); }
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!"); }
@Override protected Object executeInternal() throws MojoExecutionException, MojoFailureException { RestartAppServerRequest req = new RestartAppServerRequest(); req.setEnvironmentId(curEnv.getEnvironmentId()); req.setEnvironmentName(curEnv.getEnvironmentName()); getService().restartAppServer(req); return null; } }
@Override protected Object executeInternal() throws AbstractMojoExecutionException { RebuildEnvironmentRequest req = new RebuildEnvironmentRequest(); req.setEnvironmentId(curEnv.getEnvironmentId()); req.setEnvironmentName(curEnv.getEnvironmentName()); getService().rebuildEnvironment(req); return null; } }
@Override protected Object executeInternal() throws MojoExecutionException, MojoFailureException { return getService() .describeEnvironmentResources( new DescribeEnvironmentResourcesRequest().withEnvironmentId(curEnv.getEnvironmentId()).withEnvironmentName(curEnv.getEnvironmentName())); } }
@Override protected Object executeInternal() throws MojoExecutionException, MojoFailureException { RetrieveEnvironmentInfoRequest request = new RetrieveEnvironmentInfoRequest() .withEnvironmentId(curEnv.getEnvironmentId()) .withEnvironmentName(curEnv.getEnvironmentName()) .withInfoType(infoType); RetrieveEnvironmentInfoResult result = getService().retrieveEnvironmentInfo(request); return result; } }
@Override protected Object executeInternal() throws MojoExecutionException, MojoFailureException { RequestEnvironmentInfoRequest request = new RequestEnvironmentInfoRequest() .withEnvironmentId(curEnv.getEnvironmentId()) .withEnvironmentName(curEnv.getEnvironmentName()) .withInfoType(infoType); getService().requestEnvironmentInfo(request); return null; } }
@Override protected Object executeInternal() throws AbstractMojoExecutionException { TerminateEnvironmentContext context = TerminateEnvironmentContextBuilder.terminateEnvironmentContext() .withEnvironmentId(curEnv.getEnvironmentId()) .withEnvironmentName(curEnv.getEnvironmentName()) .withTerminateResources(terminateResources) .build(); TerminateEnvironmentCommand command = new TerminateEnvironmentCommand(this); return command.execute(context); } }
protected Object executeInternal() throws MojoExecutionException, MojoFailureException { DescribeConfigurationOptionsRequest req = new DescribeConfigurationOptionsRequest() // .withApplicationName(this.applicationName) // .withEnvironmentName(curEnv.getEnvironmentName()) // .withOptions(optionSpecifications) // .withSolutionStackName(solutionStack) // .withTemplateName(templateName) // ; return getService().describeConfigurationOptions(req); } }
Object changeToVersion(EnvironmentDescription d, ApplicationVersionDescription latestVersionDescription) { String curVersionLabel = d.getVersionLabel(); String versionLabel = latestVersionDescription.getVersionLabel(); UpdateEnvironmentRequest request = new UpdateEnvironmentRequest().withEnvironmentId(d.getEnvironmentId()).withVersionLabel(versionLabel); getLog() .info( "Changing versionLabel for Environment[name=" + curEnv.getEnvironmentName() + "; environmentId=" + curEnv.getEnvironmentId() + "] from version " + curVersionLabel + " to version " + latestVersionDescription.getVersionLabel()); if (dryRun) { return null; } return getService().updateEnvironment(request); } }
protected Object executeInternal() throws MojoExecutionException, MojoFailureException { UpdateEnvironmentRequest req = new UpdateEnvironmentRequest(); req.setEnvironmentId(curEnv.getEnvironmentId()); req.setEnvironmentName(curEnv.getEnvironmentName()); if (WhatToSet.versionLabel.equals(whatToSet)) { req.setVersionLabel(versionLabel); } else if (WhatToSet.description.equals(whatToSet)) { req.setDescription(environmentDescription); } else if (WhatToSet.optionSettings.equals(whatToSet)) { req.setOptionSettings(getOptionSettings(optionSettings)); } else if (WhatToSet.templateName.equals(whatToSet)) { req.setTemplateName(lookupTemplateName(applicationName, templateName)); } else if (WhatToSet.optionsToRemove.equals(whatToSet)) { req.setOptionsToRemove(getOptionsToRemove(optionsToRemove)); } return getService().updateEnvironment(req); }