Example usage for com.amazonaws.services.rds AmazonRDS restoreDBClusterToPointInTime

List of usage examples for com.amazonaws.services.rds AmazonRDS restoreDBClusterToPointInTime

Introduction

In this page you can find the example usage for com.amazonaws.services.rds AmazonRDS restoreDBClusterToPointInTime.

Prototype

DBCluster restoreDBClusterToPointInTime(
        RestoreDBClusterToPointInTimeRequest restoreDBClusterToPointInTimeRequest);

Source Link

Document

Restores a DB cluster to an arbitrary point in time.

Usage

From source file:jp.classmethod.aws.gradle.rds.AmazonRDSRestoreDbClusterToPointInTimeTask.java

License:Apache License

@TaskAction
public void restoreDbClusterToPointInTime() { // NOPMD
    // to enable conventionMappings feature
    String dbClusterIdentifier = getDbClusterIdentifier();

    if (dbClusterIdentifier == null) {
        throw new GradleException("dbClusterIdentifier is not specified");
    }/*from www  . jav  a2s .co m*/

    AmazonRDSPluginExtension ext = getProject().getExtensions().getByType(AmazonRDSPluginExtension.class);
    AmazonRDS rds = ext.getClient();

    RestoreDBClusterToPointInTimeRequest request = new RestoreDBClusterToPointInTimeRequest()
            .withDBClusterIdentifier(dbClusterIdentifier).withDBSubnetGroupName(getDbSubnetGroupName())
            .withKmsKeyId(getKmsKeyId()).withRestoreType(getRestoreType()).withRestoreToTime(getRestoreToTime())
            .withSourceDBClusterIdentifier(getSourceDBClusterIdentifier())
            .withUseLatestRestorableTime(getUseLatestRestorableTime())
            .withVpcSecurityGroupIds(getVpcSecurityGroupIds())
            .withTags(getTags().entrySet().stream()
                    .map(it -> new Tag().withKey(it.getKey().toString()).withValue(it.getValue().toString()))
                    .collect(Collectors.toList()));
    if (getPort() != 0) {
        request.setPort(getPort());
    }
    dbCluster = rds.restoreDBClusterToPointInTime(request);
    getLogger().info("Restored an RDS cluster to point in time: {}", dbCluster.getDBClusterIdentifier());

}