use of bio.terra.workspace.generated.model.ApiCloneReferencedGcpGcsObjectResourceResult in project terra-workspace-manager by DataBiosphere.
the class ReferencedGcpResourceController method cloneGcpGcsObjectReference.
@Override
public ResponseEntity<ApiCloneReferencedGcpGcsObjectResourceResult> cloneGcpGcsObjectReference(UUID workspaceId, UUID resourceId, @Valid ApiCloneReferencedResourceRequestBody body) {
AuthenticatedUserRequest userRequest = getAuthenticatedInfo();
final ReferencedResource sourceReferencedResource = referenceResourceService.getReferenceResource(workspaceId, resourceId, userRequest);
final CloningInstructions effectiveCloningInstructions = Optional.ofNullable(body.getCloningInstructions()).map(CloningInstructions::fromApiModel).orElse(sourceReferencedResource.getCloningInstructions());
if (CloningInstructions.COPY_REFERENCE != effectiveCloningInstructions) {
// Nothing to clone here
final var emptyResult = new ApiCloneReferencedGcpGcsObjectResourceResult().effectiveCloningInstructions(effectiveCloningInstructions.toApiModel()).sourceResourceId(sourceReferencedResource.getResourceId()).sourceWorkspaceId(sourceReferencedResource.getWorkspaceId()).resource(null);
return new ResponseEntity<>(emptyResult, HttpStatus.OK);
}
// Clone the reference
final ReferencedGcsObjectResource clonedReferencedResource = referenceResourceService.cloneReferencedResource(sourceReferencedResource, body.getDestinationWorkspaceId(), body.getName(), body.getDescription(), userRequest).castByEnum(WsmResourceType.REFERENCED_GCP_GCS_OBJECT);
// Build the correct response type
final var result = new ApiCloneReferencedGcpGcsObjectResourceResult().resource(clonedReferencedResource.toApiResource()).sourceWorkspaceId(sourceReferencedResource.getWorkspaceId()).sourceResourceId(sourceReferencedResource.getResourceId()).effectiveCloningInstructions(effectiveCloningInstructions.toApiModel());
return new ResponseEntity<>(result, HttpStatus.OK);
}
Aggregations