Java 类com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentsResult 实例源码

项目:aws-beanstalk-publisher    文件:ByUrl.java   
@Override
public List<EnvironmentDescription> getEnvironments(AbstractBuild<?, ?> build, BuildListener listener, AWSElasticBeanstalk awseb, String applicationName) {
    DescribeEnvironmentsRequest request = new DescribeEnvironmentsRequest();
    request.withApplicationName(applicationName);
    request.withIncludeDeleted(false);

    DescribeEnvironmentsResult result = awseb.describeEnvironments(request);

    List<EnvironmentDescription> environments = new ArrayList<EnvironmentDescription>();

    List<String> resolvedUrls = new ArrayList<String>(urlList.size());

    for (String url : urlList) {
        resolvedUrls.add(AWSEBUtils.replaceMacros(build, listener, url));
    }

    for (EnvironmentDescription environment : result.getEnvironments()) {
        String envUrl = environment.getCNAME();
        if (resolvedUrls.contains(envUrl)) {
            environments.add(environment);
        }
    }

    return environments;
}
项目:aws-ant-tasks    文件:TestSuccessfulBeanstalkDeploymentTask.java   
public void execute() {
    checkParams();
    AWSElasticBeanstalkClient bcClient = getOrCreateClient(AWSElasticBeanstalkClient.class);
    DescribeEnvironmentsRequest deRequest = new DescribeEnvironmentsRequest()
            .withEnvironmentNames(environmentName);
    DescribeEnvironmentsResult result = bcClient
            .describeEnvironments(deRequest);
    if (result.getEnvironments().size() < 1) {
        throw new BuildException(
                "No environments found with the specified name "
                        + environmentName);
    }
    try {
        AWSTestUtils.waitForEnvironmentToTransitionToStateAndHealth(
                environmentName, EnvironmentStatus.Ready, null, bcClient);
    } catch (InterruptedException e) {
        throw new BuildException(e.getMessage());
    }
}
项目:jcabi-beanstalk-maven-plugin    文件:Environment.java   
/**
 * Get environment description of this.
 * @return The description
 */
private EnvironmentDescription description() {
    final DescribeEnvironmentsResult res = this.client.describeEnvironments(
        new DescribeEnvironmentsRequest()
            .withEnvironmentIds(this.eid)
    );
    if (res.getEnvironments().isEmpty()) {
        throw new DeploymentException(
            String.format("environment '%s' not found", this.eid)
        );
    }
    final EnvironmentDescription desc = res.getEnvironments().get(0);
    Logger.debug(
        this,
        // @checkstyle LineLength (1 line)
        "ID=%s, env=%s, app=%s, CNAME=%s, label=%s, template=%s, status=%s, health=%s",
        desc.getEnvironmentId(), desc.getEnvironmentName(),
        desc.getApplicationName(), desc.getCNAME(),
        desc.getVersionLabel(), desc.getTemplateName(), desc.getStatus(),
        desc.getHealth()
    );
    return desc;
}
项目:aws-beanstalk-publisher    文件:AWSEBUtils.java   
public static List<EnvironmentDescription> getEnvironments(AWSCredentialsProvider credentials, Regions region, String appName) {
    AWSElasticBeanstalk awseb = getElasticBeanstalk(credentials, Region.getRegion(region));

    DescribeEnvironmentsRequest request = new DescribeEnvironmentsRequest().withApplicationName(appName);

    DescribeEnvironmentsResult result = awseb.describeEnvironments(request);
    return result.getEnvironments();
}
项目:jcabi-beanstalk-maven-plugin    文件:Application.java   
/**
 * Get all environments in this app.
 * @return Collection of envs
 */
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
private Collection<Environment> environments() {
    final DescribeEnvironmentsResult res = this.client.describeEnvironments(
        new DescribeEnvironmentsRequest().withApplicationName(this.name)
    );
    final Collection<Environment> envs = new LinkedList<Environment>();
    for (final EnvironmentDescription desc : res.getEnvironments()) {
        envs.add(new Environment(this.client, desc.getEnvironmentId()));
    }
    return envs;
}
项目:jcabi-beanstalk-maven-plugin    文件:EnvironmentTest.java   
/**
 * Environment can check readiness of environment.
 * @throws Exception If something is wrong
 */
@Test
public void checksReadinessOfEnvironment() throws Exception {
    final String eid = "some-env-id";
    final AWSElasticBeanstalk ebt = Mockito.mock(AWSElasticBeanstalk.class);
    Mockito.doReturn(
        new DescribeConfigurationSettingsResult().withConfigurationSettings(
            new ArrayList<ConfigurationSettingsDescription>(0)
        )
    ).when(ebt)
        .describeConfigurationSettings(
            Mockito.any(DescribeConfigurationSettingsRequest.class)
        );
    Mockito.doReturn(
        new DescribeEnvironmentsResult().withEnvironments(
            Arrays.asList(
                new EnvironmentDescription()
                    .withStatus("Ready")
                    .withHealth("Red")
            )
        )
    ).when(ebt)
        .describeEnvironments(
            Mockito.any(DescribeEnvironmentsRequest.class)
        );
    final Environment env = new Environment(ebt, eid);
    MatcherAssert.assertThat(
        env.green(),
        Matchers.equalTo(false)
    );
}
项目:awseb-deployment-plugin    文件:DeployerCommand.java   
@Override
public boolean perform() throws Exception {
    DescribeEnvironmentsRequest req = new DescribeEnvironmentsRequest().
            withApplicationName(getApplicationName()).
            withEnvironmentNames(Lists.<String>newArrayList(getEnvironmentName().replaceAll("\\s", "").split(","))).
            withIncludeDeleted(false);

    DescribeEnvironmentsResult result = getAwseb().describeEnvironments(req);


    if (result.getEnvironments().size() < 1) {
        log("Unable to lookup environmentId. Skipping Update.");

        return true;
    }
    StringBuilder csEnvironmentIds = new StringBuilder();
    for (ListIterator<EnvironmentDescription> i = result.getEnvironments().listIterator(); i.hasNext(); ) {
        EnvironmentDescription element = i.next();
        final String environmentLabel = element.getVersionLabel();
        if (null != environmentLabel && environmentLabel.equals(getVersionLabel())) {
            log("The version to deploy and currently used are the same. Even if you overwrite, AWSEB won't allow you to update." +
                    "Skipping.");
            csEnvironmentIds.append(element.getEnvironmentId());
            if (i.hasNext()) {
                csEnvironmentIds.append(",");
            }
            continue;
        }

        final String environmentId = element.getEnvironmentId();

        log("Using environmentId '%s'", environmentId);
        csEnvironmentIds.append(environmentId);
        if (i.hasNext()) {
            csEnvironmentIds.append(",");
        }
    }

    setEnvironmentId(csEnvironmentIds.toString());
    return false;
}
项目:awseb-deployment-plugin    文件:DeployerCommand.java   
@Override
public boolean perform() throws Exception {
    final DescribeEnvironmentsRequest req = new DescribeEnvironmentsRequest().
            withApplicationName(getApplicationName()).
            withEnvironmentIds(Lists.<String>newArrayList(getEnvironmentId().split(","))).
            withIncludeDeleted(false);

    final DescribeEnvironmentsResult result = getAwseb().describeEnvironments(req);

    if (result.getEnvironments().size() < 1) {
        log("Environment w/ environmentId '%s' not found. Aborting.", getEnvironmentId());

        return true;
    }

    // If there are any abortable environment updates set to true.
    boolean abort = false;

    for (Integer i = 0; i < result.getEnvironments().size(); i++) {
        String resultingStatus = result.getEnvironments().get(i).getStatus();
        boolean abortableP = result.getEnvironments().get(i).getAbortableOperationInProgress();
        String environmentId = result.getEnvironments().get(i).getEnvironmentId();

        if (!STATUS_READY.equals(resultingStatus)) {
            if (abortableP) {
                log("AWS Abortable Environment Update Found. Calling abort on AWSEB Service");

                getAwseb().abortEnvironmentUpdate(new AbortEnvironmentUpdateRequest().withEnvironmentId(environmentId));

                log("Environment Update Aborted. Proceeding.");
                abort = true;
            }

        } else {
            log("No pending Environment Updates. Proceeding.");
        }
    }

    // Call wait for status if found an abortable env update.
    if (abort) {
        WaitForEnvironment waitForStatus = new WaitForEnvironment(WaitFor.Status).withoutVersionCheck();

        waitForStatus.setDeployerContext(c);

        return waitForStatus.perform();
    }


    return false;
}
项目:jcabi-beanstalk-maven-plugin    文件:ApplicationTest.java   
/**
 * Application can create a new environment.
 * @throws Exception If something is wrong
 */
@Test
public void createsNewEnvironment() throws Exception {
    final String name = "some-app-name";
    final String template = "some-template";
    final Version version = Mockito.mock(Version.class);
    final AWSElasticBeanstalk ebt = Mockito.mock(AWSElasticBeanstalk.class);
    Mockito.doReturn(
        new CheckDNSAvailabilityResult().withAvailable(true)
    ).when(ebt)
        .checkDNSAvailability(
            Mockito.any(CheckDNSAvailabilityRequest.class)
        );
    Mockito.doReturn(
        new CreateEnvironmentResult()
            .withApplicationName(name)
            .withEnvironmentId("f4g5h6j7")
            .withEnvironmentName(name)
    ).when(ebt)
        .createEnvironment(
            Mockito.any(CreateEnvironmentRequest.class)
        );
    Mockito.doReturn(
        new DescribeConfigurationSettingsResult().withConfigurationSettings(
            new ArrayList<ConfigurationSettingsDescription>(0)
        )
    ).when(ebt)
        .describeConfigurationSettings(
            Mockito.any(DescribeConfigurationSettingsRequest.class)
        );
    Mockito.doReturn(
        new DescribeEnvironmentsResult().withEnvironments(
            Arrays.asList(
                new EnvironmentDescription()
                    .withCNAME("")
                    .withEnvironmentName("some-env")
                    .withEnvironmentId("a1b2c3d4")
                    .withStatus("Ready")
            )
        )
    ).when(ebt)
        .describeEnvironments(
            Mockito.any(DescribeEnvironmentsRequest.class)
        );
    Mockito.doReturn(new TerminateEnvironmentResult())
        .when(ebt)
        .terminateEnvironment(
            Mockito.any(TerminateEnvironmentRequest.class)
        );
    final Application app = new Application(ebt, name);
    app.clean(false);
    MatcherAssert.assertThat(
        app.candidate(version, template),
        Matchers.notNullValue()
    );
}
项目:elasticbeanstalk-dashboard    文件:ElasticBeanstalkService.java   
public List<EnvironmentDescription> describeEnvironments(){
    awsElasticBeanstalkAsyncClient.setRegion(region);
    DescribeEnvironmentsResult result =  awsElasticBeanstalkAsyncClient.describeEnvironments();
    return result.getEnvironments();
}