com.amazonaws.services.s3.model.DeleteBucketRequest Java Examples
The following examples show how to use
com.amazonaws.services.s3.model.DeleteBucketRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractS3IT.java From localization_nifi with Apache License 2.0 | 5 votes |
@AfterClass public static void oneTimeTearDown() { // Empty the bucket before deleting it. try { ObjectListing objectListing = client.listObjects(BUCKET_NAME); while (true) { for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) { client.deleteObject(BUCKET_NAME, objectSummary.getKey()); } if (objectListing.isTruncated()) { objectListing = client.listNextBatchOfObjects(objectListing); } else { break; } } DeleteBucketRequest dbr = new DeleteBucketRequest(BUCKET_NAME); client.deleteBucket(dbr); } catch (final AmazonS3Exception e) { System.err.println("Unable to delete bucket " + BUCKET_NAME + e.toString()); } if (client.doesBucketExist(BUCKET_NAME)) { Assert.fail("Incomplete teardown, subsequent tests might fail"); } }
Example #2
Source File: AbstractS3IT.java From nifi with Apache License 2.0 | 5 votes |
@AfterClass public static void oneTimeTearDown() { // Empty the bucket before deleting it. try { ObjectListing objectListing = client.listObjects(BUCKET_NAME); while (true) { for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) { client.deleteObject(BUCKET_NAME, objectSummary.getKey()); } if (objectListing.isTruncated()) { objectListing = client.listNextBatchOfObjects(objectListing); } else { break; } } DeleteBucketRequest dbr = new DeleteBucketRequest(BUCKET_NAME); client.deleteBucket(dbr); } catch (final AmazonS3Exception e) { System.err.println("Unable to delete bucket " + BUCKET_NAME + e.toString()); } if (client.doesBucketExist(BUCKET_NAME)) { Assert.fail("Incomplete teardown, subsequent tests might fail"); } }
Example #3
Source File: AmazonS3FileSystem.java From iaf with Apache License 2.0 | 5 votes |
/** * Deletes a bucket on Amazon S3. */ public String deleteBucket() throws SenderException { try { bucketDoesNotExist(bucketName); DeleteBucketRequest deleteBucketRequest = new DeleteBucketRequest(bucketName); s3Client.deleteBucket(deleteBucketRequest); log.debug("Bucket with bucketName [" + bucketName + "] is deleted."); } catch (AmazonServiceException e) { log.warn("Failed to delete bucket with bucketName [" + bucketName + "]."); throw new SenderException("Failed to delete bucket with bucketName [" + bucketName + "]."); } return bucketName; }
Example #4
Source File: S3Client.java From Scribengin with GNU Affero General Public License v3.0 | 5 votes |
public void deleteBucket(String bucketName, boolean recursive) throws AmazonClientException, AmazonServiceException { if(recursive) { deleteKeyWithPrefix(bucketName, ""); } DeleteBucketRequest request = new DeleteBucketRequest(bucketName) ; s3Client.deleteBucket(request); }
Example #5
Source File: S3Utils.java From amazon-kinesis-connectors with Apache License 2.0 | 5 votes |
/** * Deletes an Amazon S3 bucket if it exists. * * @param client The {@link AmazonS3Client} with read and write permissions * @param bucketName The Amazon S3 bucket to delete */ public static void deleteBucket(AmazonS3Client client, String bucketName) { if (bucketExists(client, bucketName)) { DeleteBucketRequest deleteBucketRequest = new DeleteBucketRequest(bucketName); client.deleteBucket(deleteBucketRequest); LOG.info("Deleted bucket " + bucketName); } else { LOG.warn("Bucket " + bucketName + " does not exist"); } }
Example #6
Source File: ContentHelperTest.java From aws-photosharing-example with Apache License 2.0 | 4 votes |
@AfterClass private void cleanUp() throws Exception { DeleteBucketRequest deleteBucketRequest = new DeleteBucketRequest(bucketName); s3Client.deleteBucket(deleteBucketRequest); }
Example #7
Source File: DummyS3Client.java From ignite with Apache License 2.0 | 4 votes |
/** Unsupported Operation. */ @Override public void deleteBucket(DeleteBucketRequest delBucketReq) throws SdkClientException { throw new UnsupportedOperationException("Operation not supported"); }
Example #8
Source File: BucketClass.java From cloudExplorer with GNU General Public License v3.0 | 4 votes |
String deleteBucket(String access_key, String secret_key, String bucket, String endpoint ) { String message = null; AWSCredentials credentials = new BasicAWSCredentials(access_key, secret_key); AmazonS3 s3Client = new AmazonS3Client(credentials, new ClientConfiguration()); if (endpoint.contains("amazonaws.com")) { String aws_endpoint = s3Client.getBucketLocation(new GetBucketLocationRequest(bucket)); if (aws_endpoint.contains("US")) { s3Client.setEndpoint("https://s3.amazonaws.com"); } else if (aws_endpoint.contains("us-west")) { s3Client.setEndpoint("https://s3-" + aws_endpoint + ".amazonaws.com"); } else if (aws_endpoint.contains("eu-west")) { s3Client.setEndpoint("https://s3-" + aws_endpoint + ".amazonaws.com"); } else if (aws_endpoint.contains("ap-")) { s3Client.setEndpoint("https://s3-" + aws_endpoint + ".amazonaws.com"); } else if (aws_endpoint.contains("sa-east-1")) { s3Client.setEndpoint("https://s3-" + aws_endpoint + ".amazonaws.com"); } else { s3Client.setEndpoint("https://s3." + aws_endpoint + ".amazonaws.com"); } } else { s3Client.setS3ClientOptions(S3ClientOptions.builder().setPathStyleAccess(true).build()); s3Client.setEndpoint(endpoint); } message = ("\nDeleting bucket: " + bucket); try { s3Client.deleteBucket(new DeleteBucketRequest(bucket)); } catch (Exception Delete) { if (terminal) { System.out.print("\n\n\n" + Delete.getMessage() + "\n\n\n"); } else { message = message + "\n" + Delete.getMessage(); } } if (message == null) { message = "\nDelete operation failed."; } return message; }
Example #9
Source File: AmazonS3Mock.java From Scribengin with GNU Affero General Public License v3.0 | 4 votes |
@Override public void deleteBucket(DeleteBucketRequest deleteBucketRequest) throws AmazonClientException, AmazonServiceException { // TODO Auto-generated method stub }