Search in sources :

Example 1 with GcsProject

use of bio.terra.service.filedata.google.gcs.GcsProject in project jade-data-repo by DataBiosphere.

the class GoogleResourceService method newBucket.

/**
 * Create a new bucket cloud resource.
 * Note this method does not create any associated metadata in the bucket_resource table.
 * @param bucketRequest
 * @return a reference to the bucket as a GCS Bucket object
 */
private Bucket newBucket(GoogleBucketRequest bucketRequest) {
    String bucketName = bucketRequest.getBucketName();
    GoogleProjectResource projectResource = bucketRequest.getGoogleProjectResource();
    String googleProjectId = projectResource.getGoogleProjectId();
    GcsProject gcsProject = gcsProjectFactory.get(googleProjectId);
    BucketInfo bucketInfo = BucketInfo.newBuilder(bucketName).setStorageClass(StorageClass.REGIONAL).setLocation(bucketRequest.getRegion()).build();
    // the project will have been created before this point, so no need to fetch it
    logger.info("Creating bucket '{}' in project '{}'", bucketName, googleProjectId);
    return gcsProject.getStorage().create(bucketInfo);
}
Also used : GcsProject(bio.terra.service.filedata.google.gcs.GcsProject) BucketInfo(com.google.cloud.storage.BucketInfo)

Aggregations

GcsProject (bio.terra.service.filedata.google.gcs.GcsProject)1 BucketInfo (com.google.cloud.storage.BucketInfo)1