use of bio.terra.workspace.service.resource.referenced.cloud.gcp.bqdatatable.ReferencedBigQueryDataTableResource in project terra-workspace-manager by DataBiosphere.
the class ReferencedGcpResourceController method getBigQueryDataTableReferenceByName.
@Override
public ResponseEntity<ApiGcpBigQueryDataTableResource> getBigQueryDataTableReferenceByName(UUID id, String name) {
AuthenticatedUserRequest userRequest = getAuthenticatedInfo();
ReferencedBigQueryDataTableResource referenceResource = referenceResourceService.getReferenceResourceByName(id, name, userRequest).castByEnum(WsmResourceType.REFERENCED_GCP_BIG_QUERY_DATA_TABLE);
return new ResponseEntity<>(referenceResource.toApiResource(), HttpStatus.OK);
}
use of bio.terra.workspace.service.resource.referenced.cloud.gcp.bqdatatable.ReferencedBigQueryDataTableResource in project terra-workspace-manager by DataBiosphere.
the class ReferencedGcpResourceController method getBigQueryDataTableReference.
@Override
public ResponseEntity<ApiGcpBigQueryDataTableResource> getBigQueryDataTableReference(UUID id, UUID referenceId) {
AuthenticatedUserRequest userRequest = getAuthenticatedInfo();
ReferencedBigQueryDataTableResource referenceResource = referenceResourceService.getReferenceResource(id, referenceId, userRequest).castByEnum(WsmResourceType.REFERENCED_GCP_BIG_QUERY_DATA_TABLE);
return new ResponseEntity<>(referenceResource.toApiResource(), HttpStatus.OK);
}
use of bio.terra.workspace.service.resource.referenced.cloud.gcp.bqdatatable.ReferencedBigQueryDataTableResource in project terra-workspace-manager by DataBiosphere.
the class ReferencedGcpResourceController method createBigQueryDataTableReference.
// -- BigQuery DataTable -- //
@Override
public ResponseEntity<ApiGcpBigQueryDataTableResource> createBigQueryDataTableReference(UUID id, @Valid ApiCreateGcpBigQueryDataTableReferenceRequestBody body) {
var resource = ReferencedBigQueryDataTableResource.builder().workspaceId(id).name(body.getMetadata().getName()).description(body.getMetadata().getDescription()).cloningInstructions(CloningInstructions.fromApiModel(body.getMetadata().getCloningInstructions())).projectId(body.getDataTable().getProjectId()).datasetId(body.getDataTable().getDatasetId()).dataTableId(body.getDataTable().getDataTableId()).build();
ReferencedBigQueryDataTableResource referenceResource = referenceResourceService.createReferenceResource(resource, getAuthenticatedInfo()).castByEnum(WsmResourceType.REFERENCED_GCP_BIG_QUERY_DATA_TABLE);
return new ResponseEntity<>(referenceResource.toApiResource(), HttpStatus.OK);
}
use of bio.terra.workspace.service.resource.referenced.cloud.gcp.bqdatatable.ReferencedBigQueryDataTableResource in project terra-workspace-manager by DataBiosphere.
the class MakeApiResourceDescriptionTest method mapReferencedBigQueryDataTableTest.
@Test
public void mapReferencedBigQueryDataTableTest() throws Exception {
String projectId = RandomStringUtils.randomAlphabetic(12);
String datasetName = RandomStringUtils.randomAlphabetic(12);
String datatableName = RandomStringUtils.randomAlphabetic(12);
var resource = new ReferencedBigQueryDataTableResource(workspaceId, resourceId, resourceName, description, cloning, projectId, datasetName, datatableName);
ApiResourceDescription resourceDescription = resourceController.makeApiResourceDescription(resource);
validateWsmResource(resourceDescription);
ApiResourceAttributesUnion union = resourceDescription.getResourceAttributes();
ApiGcpBigQueryDataTableAttributes attributes = union.getGcpBqDataTable();
assertThat(attributes, is(notNullValue()));
assertEquals(attributes.getDatasetId(), datasetName);
assertEquals(attributes.getProjectId(), projectId);
assertEquals(attributes.getDataTableId(), datatableName);
}
use of bio.terra.workspace.service.resource.referenced.cloud.gcp.bqdatatable.ReferencedBigQueryDataTableResource in project terra-workspace-manager by DataBiosphere.
the class ReferencedGcpResourceController method cloneGcpBigQueryDataTableReference.
@Override
public ResponseEntity<ApiCloneReferencedGcpBigQueryDataTableResourceResult> cloneGcpBigQueryDataTableReference(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 ApiCloneReferencedGcpBigQueryDataTableResourceResult().effectiveCloningInstructions(effectiveCloningInstructions.toApiModel()).sourceResourceId(sourceReferencedResource.getResourceId()).sourceWorkspaceId(sourceReferencedResource.getWorkspaceId()).resource(null);
return new ResponseEntity<>(emptyResult, HttpStatus.OK);
}
// Clone the reference
final ReferencedBigQueryDataTableResource clonedReferencedResource = referenceResourceService.cloneReferencedResource(sourceReferencedResource, body.getDestinationWorkspaceId(), body.getName(), body.getDescription(), userRequest).castByEnum(WsmResourceType.REFERENCED_GCP_BIG_QUERY_DATA_TABLE);
// Build the correct response type
final var result = new ApiCloneReferencedGcpBigQueryDataTableResourceResult().resource(clonedReferencedResource.toApiResource()).sourceWorkspaceId(sourceReferencedResource.getWorkspaceId()).sourceResourceId(sourceReferencedResource.getResourceId()).effectiveCloningInstructions(effectiveCloningInstructions.toApiModel());
return new ResponseEntity<>(result, HttpStatus.OK);
}
Aggregations