Example usage for com.amazonaws.services.elasticbeanstalk AWSElasticBeanstalk deleteApplicationVersion

List of usage examples for com.amazonaws.services.elasticbeanstalk AWSElasticBeanstalk deleteApplicationVersion

Introduction

In this page you can find the example usage for com.amazonaws.services.elasticbeanstalk AWSElasticBeanstalk deleteApplicationVersion.

Prototype

DeleteApplicationVersionResult deleteApplicationVersion(
        DeleteApplicationVersionRequest deleteApplicationVersionRequest);

Source Link

Document

Deletes the specified version from the specified application.

Usage

From source file:jp.classmethod.aws.gradle.elasticbeanstalk.AWSElasticBeanstalkCleanupApplicationVersionTask.java

License:Apache License

@TaskAction
public void deleteVersion() {
    // to enable conventionMappings feature
    String appName = getAppName();
    boolean deleteSourceBundle = isDeleteSourceBundle();

    AwsBeanstalkPluginExtension ext = getProject().getExtensions().getByType(AwsBeanstalkPluginExtension.class);
    AWSElasticBeanstalk eb = ext.getClient();

    DescribeEnvironmentsResult der = eb/*w w  w .j  ava 2  s .  c  o  m*/
            .describeEnvironments(new DescribeEnvironmentsRequest().withApplicationName(appName));
    List<String> usingVersions = der.getEnvironments().stream().map(ed -> ed.getVersionLabel())
            .collect(Collectors.toList());

    DescribeApplicationVersionsResult davr = eb
            .describeApplicationVersions(new DescribeApplicationVersionsRequest().withApplicationName(appName));
    List<String> versionLabelsToDelete = davr.getApplicationVersions().stream()
            .filter(avd -> usingVersions.contains(avd.getVersionLabel()) == false
                    && avd.getVersionLabel().contains("-SNAPSHOT-"))
            .map(avd -> avd.getVersionLabel()).collect(Collectors.toList());

    versionLabelsToDelete.forEach(versionLabel -> {
        getLogger().info("version " + versionLabel + " deleted");
        eb.deleteApplicationVersion(new DeleteApplicationVersionRequest().withApplicationName(appName)
                .withVersionLabel(versionLabel).withDeleteSourceBundle(deleteSourceBundle));
    });
}

From source file:jp.classmethod.aws.gradle.elasticbeanstalk.AWSElasticBeanstalkDeleteApplicationVersionTask.java

License:Apache License

@TaskAction
public void deleteVersion() {
    // to enable conventionMappings feature
    String applicationName = getApplicationName();
    String versionLabel = getVersionLabel();
    boolean deleteSourceBundle = isDeleteSourceBundle();

    AwsBeanstalkPluginExtension ext = getProject().getExtensions().getByType(AwsBeanstalkPluginExtension.class);
    AWSElasticBeanstalk eb = ext.getClient();

    eb.deleteApplicationVersion(new DeleteApplicationVersionRequest().withApplicationName(applicationName)
            .withVersionLabel(versionLabel).withDeleteSourceBundle(deleteSourceBundle));
    getLogger().info("version " + versionLabel + " deleted");
}