use of bio.terra.workspace.service.resource.model.WsmResource in project terra-workspace-manager by DataBiosphere.
the class StoreControlledResourceMetadataStepTest method testEntersInfo.
@Test
public void testEntersInfo() throws InterruptedException, RetryException {
// Generate a fake workspace and cloud context so that the
// database insert will pass FK constraints.
UUID workspaceId = UUID.randomUUID();
Workspace workspace = Workspace.builder().workspaceStage(WorkspaceStage.RAWLS_WORKSPACE).workspaceId(workspaceId).build();
workspaceDao.createWorkspace(workspace);
gcpCloudContextService.createGcpCloudContext(workspaceId, new GcpCloudContext("fake-project"), "flight-testentersinfo");
StoreMetadataStep storeGoogleBucketMetadataStep = new StoreMetadataStep(resourceDao);
// Stub the flight map as of this step
ControlledGcsBucketResource bucketResource = ControlledResourceFixtures.makeDefaultControlledGcsBucketBuilder(workspaceId).build();
final FlightMap inputFlightMap = new FlightMap();
inputFlightMap.put(ResourceKeys.RESOURCE, bucketResource);
inputFlightMap.makeImmutable();
doReturn(inputFlightMap).when(mockFlightContext).getInputParameters();
final StepResult result = storeGoogleBucketMetadataStep.doStep(mockFlightContext);
assertThat(result, equalTo(StepResult.getStepResultSuccess()));
WsmResource daoResource = resourceDao.getResource(bucketResource.getWorkspaceId(), bucketResource.getResourceId());
assertThat(daoResource.getResourceType(), equalTo(WsmResourceType.CONTROLLED_GCP_GCS_BUCKET));
ControlledGcsBucketResource daoBucket = (ControlledGcsBucketResource) daoResource;
assertThat(bucketResource, equalTo(daoBucket));
}
use of bio.terra.workspace.service.resource.model.WsmResource in project terra-workspace-manager by DataBiosphere.
the class ResourceController method enumerateResources.
@Override
public ResponseEntity<ApiResourceList> enumerateResources(UUID workspaceId, @Valid @RequestParam(value = "offset", required = false, defaultValue = "0") Integer offset, @Valid @RequestParam(value = "limit", required = false, defaultValue = "10") Integer limit, @Valid ApiResourceType resource, @Valid ApiStewardshipType stewardship) {
AuthenticatedUserRequest userRequest = getAuthenticatedInfo();
ControllerValidationUtils.validatePaginationParams(offset, limit);
workspaceService.validateWorkspaceAndAction(userRequest, workspaceId, SamConstants.SamWorkspaceAction.READ);
List<WsmResource> wsmResources = resourceService.enumerateResources(workspaceId, WsmResourceFamily.fromApiOptional(resource), StewardshipType.fromApiOptional(stewardship), offset, limit, userRequest);
List<ApiResourceDescription> apiResourceDescriptionList = wsmResources.stream().map(r -> makeApiResourceDescription(r)).collect(Collectors.toList());
var apiResourceList = new ApiResourceList().resources(apiResourceDescriptionList);
return new ResponseEntity<>(apiResourceList, HttpStatus.OK);
}
use of bio.terra.workspace.service.resource.model.WsmResource in project terra-workspace-manager by DataBiosphere.
the class SetCreateResponseStep method doStep.
@Override
public StepResult doStep(FlightContext flightContext) throws InterruptedException, RetryException {
WsmResource responseResource = resourceDao.getResource(resource.getWorkspaceId(), resource.getResourceId());
flightContext.getWorkingMap().put(JobMapKeys.RESPONSE.getKeyName(), responseResource);
return StepResult.getStepResultSuccess();
}
Aggregations