use of bio.terra.workspace.generated.model.ApiResourceMetadata in project terra-workspace-manager by DataBiosphere.
the class MakeApiResourceDescriptionTest method validateWsmResource.
public void validateWsmResource(ApiResourceDescription resourceDescription) {
ApiResourceMetadata metadata = resourceDescription.getMetadata();
assertEquals(metadata.getWorkspaceId(), workspaceId);
assertEquals(metadata.getResourceId(), resourceId);
assertEquals(metadata.getName(), resourceName);
assertEquals(metadata.getDescription(), description);
assertEquals(metadata.getCloningInstructions(), cloning.toApiModel());
}
use of bio.terra.workspace.generated.model.ApiResourceMetadata in project terra-workspace-manager by DataBiosphere.
the class ResourceController method makeApiResourceDescription.
// Convert a WsmResource into the API format for enumeration
@VisibleForTesting
public ApiResourceDescription makeApiResourceDescription(WsmResource wsmResource) {
ApiResourceMetadata common = wsmResource.toApiMetadata();
ApiResourceAttributesUnion union = wsmResource.toApiAttributesUnion();
return new ApiResourceDescription().metadata(common).resourceAttributes(union);
}
use of bio.terra.workspace.generated.model.ApiResourceMetadata in project terra-workspace-manager by DataBiosphere.
the class AwaitCloneControlledGcpBigQueryDatasetResourceFlightStep method doStep.
@Override
public StepResult doStep(FlightContext context) throws InterruptedException, RetryException {
// wait for the flight
try {
final FlightState subflightState = context.getStairway().waitForFlight(subflightId, FLIGHT_POLL_SECONDS, FLIGHT_POLL_CYCLES);
final WsmResourceCloneDetails cloneDetails = new WsmResourceCloneDetails();
final WsmCloneResourceResult cloneResult = WorkspaceCloneUtils.flightStatusToCloneResult(subflightState.getFlightStatus(), resource);
cloneDetails.setResult(cloneResult);
final FlightMap resultMap = FlightUtils.getResultMapRequired(subflightState);
final var clonedDataset = resultMap.get(JobMapKeys.RESPONSE.getKeyName(), ApiClonedControlledGcpBigQueryDataset.class);
cloneDetails.setStewardshipType(StewardshipType.CONTROLLED);
cloneDetails.setResourceType(WsmResourceType.CONTROLLED_GCP_BIG_QUERY_DATASET);
cloneDetails.setCloningInstructions(resource.getCloningInstructions());
cloneDetails.setSourceResourceId(resource.getResourceId());
cloneDetails.setDestinationResourceId(Optional.ofNullable(clonedDataset).map(ApiClonedControlledGcpBigQueryDataset::getDataset).map(ApiGcpBigQueryDatasetResource::getMetadata).map(ApiResourceMetadata::getResourceId).orElse(null));
String errorMessage = FlightUtils.getFlightErrorMessage(subflightState);
cloneDetails.setErrorMessage(errorMessage);
cloneDetails.setName(resource.getName());
cloneDetails.setDescription(resource.getDescription());
// add to the map
final var resourceIdToResult = Optional.ofNullable(context.getWorkingMap().get(ControlledResourceKeys.RESOURCE_ID_TO_CLONE_RESULT, new TypeReference<Map<UUID, WsmResourceCloneDetails>>() {
})).orElseGet(HashMap::new);
resourceIdToResult.put(resource.getResourceId(), cloneDetails);
context.getWorkingMap().put(ControlledResourceKeys.RESOURCE_ID_TO_CLONE_RESULT, resourceIdToResult);
} catch (DatabaseOperationException | FlightWaitTimedOutException e) {
// Retry for database issues or expired wait loop
return new StepResult(StepStatus.STEP_RESULT_FAILURE_RETRY, e);
}
validateRequiredEntries(context.getWorkingMap(), ControlledResourceKeys.RESOURCE_ID_TO_CLONE_RESULT);
return StepResult.getStepResultSuccess();
}
use of bio.terra.workspace.generated.model.ApiResourceMetadata in project terra-workspace-manager by DataBiosphere.
the class ControlledResource method toApiMetadata.
@Override
public ApiResourceMetadata toApiMetadata() {
ApiResourceMetadata metadata = super.toApiMetadata();
var controlled = new ApiControlledResourceMetadata().accessScope(accessScope.toApiModel()).managedBy(managedBy.toApiModel()).privateResourceUser(// TODO: PF-616 figure out how to supply the assigned user's role
new ApiPrivateResourceUser().userName(assignedUser)).privateResourceState(getPrivateResourceState().map(PrivateResourceState::toApiModel).orElse(null));
metadata.controlledResourceMetadata(controlled);
return metadata;
}
Aggregations