use of bio.terra.workspace.service.job.JobBuilder in project terra-workspace-manager by DataBiosphere.
the class ControlledResourceService method deleteControlledResourceSync.
/**
* Synchronously delete a controlled resource.
*/
public void deleteControlledResourceSync(UUID workspaceId, UUID resourceId, AuthenticatedUserRequest userRequest) {
JobBuilder deleteJob = commonDeletionJobBuilder(UUID.randomUUID().toString(), workspaceId, resourceId, null, userRequest);
// Delete flight does not produce a result, so the resultClass parameter here is never used.
deleteJob.submitAndWait(Void.class);
}
use of bio.terra.workspace.service.job.JobBuilder in project terra-workspace-manager by DataBiosphere.
the class ControlledResourceService method updateBqDataset.
/**
* Starts an update controlled BigQuery dataset resource, blocking until its job is finished.
*/
public ControlledBigQueryDatasetResource updateBqDataset(ControlledBigQueryDatasetResource resource, @Nullable ApiGcpBigQueryDatasetUpdateParameters updateParameters, AuthenticatedUserRequest userRequest, @Nullable String resourceName, @Nullable String resourceDescription) {
controlledResourceMetadataManager.validateControlledResourceAndAction(userRequest, resource.getWorkspaceId(), resource.getResourceId(), SamControlledResourceActions.EDIT_ACTION);
final String jobDescription = String.format("Update controlled BigQuery Dataset name %s ; resource id %s; resource name %s", resource.getDatasetName(), resource.getResourceId(), resource.getName());
final JobBuilder jobBuilder = jobService.newJob().description(jobDescription).flightClass(UpdateControlledBigQueryDatasetResourceFlight.class).resource(resource).userRequest(userRequest).operationType(OperationType.UPDATE).resourceType(resource.getResourceType()).resourceName(resource.getName()).workspaceId(resource.getWorkspaceId().toString()).stewardshipType(resource.getStewardshipType()).addParameter(ControlledResourceKeys.UPDATE_PARAMETERS, updateParameters).addParameter(ResourceKeys.RESOURCE_NAME, resourceName).addParameter(ResourceKeys.RESOURCE_DESCRIPTION, resourceDescription);
return jobBuilder.submitAndWait(ControlledBigQueryDatasetResource.class);
}
use of bio.terra.workspace.service.job.JobBuilder in project terra-workspace-manager by DataBiosphere.
the class ReferencedResourceService method createReferenceResource.
@Traced
public ReferencedResource createReferenceResource(ReferencedResource resource, AuthenticatedUserRequest userRequest) {
workspaceService.validateWorkspaceAndAction(userRequest, resource.getWorkspaceId(), SamConstants.SamWorkspaceAction.CREATE_REFERENCE);
String jobDescription = String.format("Create reference %s; id %s; name %s", resource.getResourceType(), resource.getResourceId(), resource.getName());
// The reason for separately passing in the ResourceType is to retrieve the class for this
// particular request. In the flight, when we get the request object from the input parameters,
// we can supply the right target class.
JobBuilder createJob = jobService.newJob().description(jobDescription).flightClass(CreateReferenceResourceFlight.class).resource(resource).userRequest(userRequest).operationType(OperationType.CREATE).workspaceId(resource.getWorkspaceId().toString()).resourceType(resource.getResourceType()).stewardshipType(StewardshipType.REFERENCED);
UUID resourceIdResult = createJob.submitAndWait(UUID.class);
if (!resourceIdResult.equals(resource.getResourceId())) {
throw new InvalidMetadataException("Input and output resource ids do not match");
}
return getReferenceResource(resource.getWorkspaceId(), resourceIdResult, userRequest);
}
use of bio.terra.workspace.service.job.JobBuilder in project terra-workspace-manager by DataBiosphere.
the class WsmApplicationService method commonAbleJob.
// Common method to launch and wait for enable and disable flights.
private WsmWorkspaceApplication commonAbleJob(AuthenticatedUserRequest userRequest, UUID workspaceId, UUID applicationId, AbleEnum ableEnum) {
Workspace workspace = workspaceService.validateWorkspaceAndAction(userRequest, workspaceId, SamConstants.SamWorkspaceAction.OWN);
stageService.assertMcWorkspace(workspace, (ableEnum == AbleEnum.ENABLE) ? "enableWorkspaceApplication" : "disableWorkspaceApplication");
String description = String.format("%s application %s on workspace %s", ableEnum.name().toLowerCase(), applicationId.toString(), workspaceId.toString());
JobBuilder job = jobService.newJob().description(description).flightClass(ApplicationAbleFlight.class).userRequest(userRequest).workspaceId(workspaceId.toString()).addParameter(WorkspaceFlightMapKeys.APPLICATION_ID, applicationId).addParameter(WsmApplicationKeys.APPLICATION_ABLE_ENUM, ableEnum);
return job.submitAndWait(WsmWorkspaceApplication.class);
}
use of bio.terra.workspace.service.job.JobBuilder in project terra-workspace-manager by DataBiosphere.
the class WorkspaceService method deleteWorkspace.
/**
* Delete an existing workspace by ID.
*/
@Traced
public void deleteWorkspace(UUID id, AuthenticatedUserRequest userRequest) {
Workspace workspace = validateWorkspaceAndAction(userRequest, id, SamWorkspaceAction.DELETE);
String description = "Delete workspace " + id;
JobBuilder deleteJob = jobService.newJob().description(description).flightClass(WorkspaceDeleteFlight.class).operationType(OperationType.DELETE).workspaceId(id.toString()).userRequest(userRequest).addParameter(WorkspaceFlightMapKeys.WORKSPACE_STAGE, workspace.getWorkspaceStage().name());
// Skip access check, which can't succeed after the workspace is deleted
deleteJob.submitAndWait(null, false);
}
Aggregations