Search in sources :

Example 1 with GcpGcsBucketCreationParameters

use of bio.terra.workspace.model.GcpGcsBucketCreationParameters in project terra-workspace-manager by DataBiosphere.

the class GcsBucketUtils method makeControlledGcsBucket.

// Fully parameterized version; category-specific versions below
public static CreatedControlledGcpGcsBucket makeControlledGcsBucket(ControlledGcpResourceApi resourceApi, UUID workspaceId, String name, @Nullable String bucketName, AccessScope accessScope, ManagedBy managedBy, CloningInstructionsEnum cloningInstructions, @Nullable PrivateResourceUser privateUser) throws Exception {
    var body = new CreateControlledGcpGcsBucketRequestBody().common(new ControlledResourceCommonFields().accessScope(accessScope).managedBy(managedBy).cloningInstructions(cloningInstructions).description("Description of " + name).name(name).privateResourceUser(privateUser)).gcsBucket(new GcpGcsBucketCreationParameters().name(bucketName).defaultStorageClass(GcpGcsBucketDefaultStorageClass.STANDARD).lifecycle(new GcpGcsBucketLifecycle().rules(BUCKET_LIFECYCLE_RULES)));
    logger.info("Creating {} {} bucket in workspace {}", managedBy.name(), accessScope.name(), workspaceId);
    return resourceApi.createBucket(body, workspaceId);
}
Also used : ControlledResourceCommonFields(bio.terra.workspace.model.ControlledResourceCommonFields) GcpGcsBucketCreationParameters(bio.terra.workspace.model.GcpGcsBucketCreationParameters) CreateControlledGcpGcsBucketRequestBody(bio.terra.workspace.model.CreateControlledGcpGcsBucketRequestBody) GcpGcsBucketLifecycle(bio.terra.workspace.model.GcpGcsBucketLifecycle)

Example 2 with GcpGcsBucketCreationParameters

use of bio.terra.workspace.model.GcpGcsBucketCreationParameters in project terra-cli by DataBiosphere.

the class WorkspaceManagerService method createControlledGcsBucket.

/**
 * Call the Workspace Manager POST
 * "/api/workspaces/v1/{workspaceId}/resources/controlled/gcp/buckets" endpoint to add a GCS
 * bucket as a controlled resource in the workspace.
 *
 * @param workspaceId the workspace to add the resource to
 * @param createParams creation parameters
 * @return the GCS bucket resource object
 */
public GcpGcsBucketResource createControlledGcsBucket(UUID workspaceId, CreateGcsBucketParams createParams) {
    // convert the CLI lifecycle rule object into the WSM request objects
    List<GcpGcsBucketLifecycleRule> lifecycleRules = fromCLIObject(createParams.lifecycle);
    // convert the CLI object to a WSM request object
    CreateControlledGcpGcsBucketRequestBody createRequest = new CreateControlledGcpGcsBucketRequestBody().common(createCommonFields(createParams.resourceFields)).gcsBucket(new GcpGcsBucketCreationParameters().name(createParams.bucketName).defaultStorageClass(createParams.defaultStorageClass).lifecycle(new GcpGcsBucketLifecycle().rules(lifecycleRules)).location(createParams.location));
    return callWithRetries(() -> new ControlledGcpResourceApi(apiClient).createBucket(createRequest, workspaceId).getGcpBucket(), "Error creating controlled GCS bucket in the workspace.");
}
Also used : GcpGcsBucketCreationParameters(bio.terra.workspace.model.GcpGcsBucketCreationParameters) GcpGcsBucketLifecycleRule(bio.terra.workspace.model.GcpGcsBucketLifecycleRule) CreateControlledGcpGcsBucketRequestBody(bio.terra.workspace.model.CreateControlledGcpGcsBucketRequestBody) ControlledGcpResourceApi(bio.terra.workspace.api.ControlledGcpResourceApi) GcpGcsBucketLifecycle(bio.terra.workspace.model.GcpGcsBucketLifecycle)

Aggregations

CreateControlledGcpGcsBucketRequestBody (bio.terra.workspace.model.CreateControlledGcpGcsBucketRequestBody)2 GcpGcsBucketCreationParameters (bio.terra.workspace.model.GcpGcsBucketCreationParameters)2 GcpGcsBucketLifecycle (bio.terra.workspace.model.GcpGcsBucketLifecycle)2 ControlledGcpResourceApi (bio.terra.workspace.api.ControlledGcpResourceApi)1 ControlledResourceCommonFields (bio.terra.workspace.model.ControlledResourceCommonFields)1 GcpGcsBucketLifecycleRule (bio.terra.workspace.model.GcpGcsBucketLifecycleRule)1