use of com.amazonaws.services.s3.model.HeadBucketRequest in project aws-doc-sdk-examples by awsdocs.
the class S3ObjectOperations method createBucket.
// Create a bucket by using a S3Waiter object
public static void createBucket(S3Client s3Client, String bucketName, Region region) {
S3Waiter s3Waiter = s3Client.waiter();
try {
CreateBucketRequest bucketRequest = CreateBucketRequest.builder().bucket(bucketName).createBucketConfiguration(CreateBucketConfiguration.builder().locationConstraint(region.id()).build()).build();
s3Client.createBucket(bucketRequest);
HeadBucketRequest bucketRequestWait = HeadBucketRequest.builder().bucket(bucketName).build();
// Wait until the bucket is created and print out the response
WaiterResponse<HeadBucketResponse> waiterResponse = s3Waiter.waitUntilBucketExists(bucketRequestWait);
waiterResponse.matched().response().ifPresent(System.out::println);
System.out.println(bucketName + " is ready");
} catch (S3Exception e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
use of com.amazonaws.services.s3.model.HeadBucketRequest in project aws-doc-sdk-examples by awsdocs.
the class CreateBucket method createBucket.
// snippet-start:[s3.java2.create_bucket_waiters.main]
public static void createBucket(S3Client s3Client, String bucketName) {
try {
S3Waiter s3Waiter = s3Client.waiter();
CreateBucketRequest bucketRequest = CreateBucketRequest.builder().bucket(bucketName).build();
s3Client.createBucket(bucketRequest);
HeadBucketRequest bucketRequestWait = HeadBucketRequest.builder().bucket(bucketName).build();
// Wait until the bucket is created and print out the response.
WaiterResponse<HeadBucketResponse> waiterResponse = s3Waiter.waitUntilBucketExists(bucketRequestWait);
waiterResponse.matched().response().ifPresent(System.out::println);
System.out.println(bucketName + " is ready");
} catch (S3Exception e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
use of com.amazonaws.services.s3.model.HeadBucketRequest in project aws-doc-sdk-examples by awsdocs.
the class MovieLensDatasetProvider method createBucket.
// Create a bucket by using a S3Waiter object
public static void createBucket(S3Client s3Client, String bucketName) {
try {
S3Waiter s3Waiter = s3Client.waiter();
CreateBucketRequest bucketRequest = CreateBucketRequest.builder().bucket(bucketName).build();
s3Client.createBucket(bucketRequest);
HeadBucketRequest bucketRequestWait = HeadBucketRequest.builder().bucket(bucketName).build();
// Wait until the bucket is created and print out the response
WaiterResponse<HeadBucketResponse> waiterResponse = s3Waiter.waitUntilBucketExists(bucketRequestWait);
waiterResponse.matched().response().ifPresent(System.out::println);
System.out.println(bucketName + " is ready");
} catch (S3Exception e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
use of com.amazonaws.services.s3.model.HeadBucketRequest in project wildfly-camel by wildfly-extras.
the class S3Utils method createBucket.
@SuppressWarnings("unchecked")
public static void createBucket(AmazonS3Client client, String bucketName) throws Exception {
client.createBucket(bucketName);
HeadBucketRequest request = new HeadBucketRequest(bucketName);
Waiter<HeadBucketRequest> waiter = client.waiters().bucketExists();
Future<Void> future = waiter.runAsync(new WaiterParameters<HeadBucketRequest>(request), new NoOpWaiterHandler());
future.get(1, TimeUnit.MINUTES);
}
use of com.amazonaws.services.s3.model.HeadBucketRequest in project flink by apache.
the class AWSServicesTestUtils method createBucket.
public static void createBucket(S3AsyncClient s3Client, String bucketName) throws ExecutionException, InterruptedException {
CreateBucketRequest bucketRequest = CreateBucketRequest.builder().bucket(bucketName).build();
s3Client.createBucket(bucketRequest);
HeadBucketRequest bucketRequestWait = HeadBucketRequest.builder().bucket(bucketName).build();
try (final S3AsyncWaiter waiter = s3Client.waiter()) {
waiter.waitUntilBucketExists(bucketRequestWait).get();
}
}
Aggregations