Search in sources :

Example 6 with GoogleBucketRequest

use of bio.terra.service.resourcemanagement.google.GoogleBucketRequest in project jade-data-repo by DataBiosphere.

the class BucketResourceTest method buildBucketRequest.

private GoogleBucketRequest buildBucketRequest(String bucketName) throws Exception {
    // build project request
    String role = "roles/bigquery.jobUser";
    String stewardsGroupEmail = "group:JadeStewards-dev@dev.test.firecloud.org";
    List<String> stewardsGroupEmailList = Lists.newArrayList();
    stewardsGroupEmailList.add(stewardsGroupEmail);
    Map<String, List<String>> roleToStewardMap = new HashMap();
    roleToStewardMap.put(role, stewardsGroupEmailList);
    GoogleProjectRequest projectRequest = new GoogleProjectRequest().projectId(resourceConfiguration.getProjectId() + "-data").profileId(UUID.fromString(profile.getId())).serviceIds(DataLocationService.DATA_PROJECT_SERVICE_IDS).roleIdentityMapping(roleToStewardMap);
    // create project metadata
    GoogleProjectResource projectResource = resourceService.getOrCreateProject(projectRequest);
    // create the bucket request
    BillingProfile billingProfile = profileService.getProfileById(UUID.fromString(profile.getId()));
    GoogleBucketRequest googleBucketRequest = new GoogleBucketRequest().googleProjectResource(projectResource).bucketName(bucketName).profileId(billingProfile.getId()).region(billingProfile.getGcsRegion());
    return googleBucketRequest;
}
Also used : GoogleProjectResource(bio.terra.service.resourcemanagement.google.GoogleProjectResource) HashMap(java.util.HashMap) GoogleProjectRequest(bio.terra.service.resourcemanagement.google.GoogleProjectRequest) ArrayList(java.util.ArrayList) List(java.util.List) GoogleBucketRequest(bio.terra.service.resourcemanagement.google.GoogleBucketRequest)

Aggregations

GoogleBucketRequest (bio.terra.service.resourcemanagement.google.GoogleBucketRequest)6 GoogleBucketResource (bio.terra.service.resourcemanagement.google.GoogleBucketResource)4 Test (org.junit.Test)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 GoogleProjectResource (bio.terra.service.resourcemanagement.google.GoogleProjectResource)2 CorruptMetadataException (bio.terra.service.snapshot.exception.CorruptMetadataException)2 GoogleResourceNotFoundException (bio.terra.service.resourcemanagement.exception.GoogleResourceNotFoundException)1 GoogleProjectRequest (bio.terra.service.resourcemanagement.google.GoogleProjectRequest)1 Bucket (com.google.cloud.storage.Bucket)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1