Search in sources :

Example 6 with ReferencedBigQueryDataTableResource

use of bio.terra.workspace.service.resource.referenced.cloud.gcp.bqdatatable.ReferencedBigQueryDataTableResource in project terra-workspace-manager by DataBiosphere.

the class ReferencedGcpResourceController method updateBigQueryDataTableReferenceResource.

@Override
public ResponseEntity<Void> updateBigQueryDataTableReferenceResource(UUID workspaceId, UUID referenceId, ApiUpdateBigQueryDataTableReferenceRequestBody body) {
    AuthenticatedUserRequest userRequest = getAuthenticatedInfo();
    String updatedProjectId = body.getProjectId();
    String updatedDatasetId = body.getDatasetId();
    String updatedDataTableId = body.getDataTableId();
    if (StringUtils.isEmpty(updatedProjectId) && StringUtils.isEmpty(updatedDatasetId) && StringUtils.isEmpty(updatedDataTableId)) {
        referenceResourceService.updateReferenceResource(workspaceId, referenceId, body.getName(), body.getDescription(), userRequest);
    } else {
        ReferencedBigQueryDataTableResource referencedResource = referenceResourceService.getReferenceResource(workspaceId, referenceId, userRequest).castByEnum(WsmResourceType.REFERENCED_GCP_BIG_QUERY_DATA_TABLE);
        ReferencedBigQueryDataTableResource.Builder updateBqTableResource = referencedResource.toBuilder();
        if (!StringUtils.isEmpty(updatedProjectId)) {
            updateBqTableResource.projectId(updatedProjectId);
        }
        if (!StringUtils.isEmpty(updatedDatasetId)) {
            updateBqTableResource.datasetId(updatedDatasetId);
        }
        if (!StringUtils.isEmpty(updatedDataTableId)) {
            updateBqTableResource.dataTableId(updatedDataTableId);
        }
        referenceResourceService.updateReferenceResource(workspaceId, referenceId, body.getName(), body.getDescription(), updateBqTableResource.build(), userRequest);
    }
    return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) AuthenticatedUserRequest(bio.terra.workspace.service.iam.AuthenticatedUserRequest) ReferencedBigQueryDataTableResource(bio.terra.workspace.service.resource.referenced.cloud.gcp.bqdatatable.ReferencedBigQueryDataTableResource)

Aggregations

ReferencedBigQueryDataTableResource (bio.terra.workspace.service.resource.referenced.cloud.gcp.bqdatatable.ReferencedBigQueryDataTableResource)6 ResponseEntity (org.springframework.http.ResponseEntity)5 AuthenticatedUserRequest (bio.terra.workspace.service.iam.AuthenticatedUserRequest)4 BaseUnitTest (bio.terra.workspace.common.BaseUnitTest)1 ApiCloneReferencedGcpBigQueryDataTableResourceResult (bio.terra.workspace.generated.model.ApiCloneReferencedGcpBigQueryDataTableResourceResult)1 ApiGcpBigQueryDataTableAttributes (bio.terra.workspace.generated.model.ApiGcpBigQueryDataTableAttributes)1 ApiResourceAttributesUnion (bio.terra.workspace.generated.model.ApiResourceAttributesUnion)1 ApiResourceDescription (bio.terra.workspace.generated.model.ApiResourceDescription)1 CloningInstructions (bio.terra.workspace.service.resource.model.CloningInstructions)1 ReferencedResource (bio.terra.workspace.service.resource.referenced.cloud.gcp.ReferencedResource)1 Test (org.junit.jupiter.api.Test)1