use of bio.terra.workspace.generated.model.ApiCreatedControlledGcpBigQueryDataset in project terra-workspace-manager by DataBiosphere.
the class ControlledGcpResourceApiController method createBigQueryDataset.
@Override
public ResponseEntity<ApiCreatedControlledGcpBigQueryDataset> createBigQueryDataset(UUID workspaceId, ApiCreateControlledGcpBigQueryDatasetRequestBody body) {
final AuthenticatedUserRequest userRequest = getAuthenticatedInfo();
ControlledResourceFields commonFields = toCommonFields(workspaceId, body.getCommon(), userRequest);
// We need to retrieve the project id so it can be used in the BQ dataset attributes.
String projectId = workspaceService.getAuthorizedRequiredGcpProject(workspaceId, userRequest);
ControlledBigQueryDatasetResource resource = ControlledBigQueryDatasetResource.builder().datasetName(Optional.ofNullable(body.getDataset().getDatasetId()).orElse(body.getCommon().getName())).projectId(projectId).common(commonFields).build();
final ControlledBigQueryDatasetResource createdDataset = controlledResourceService.createControlledResourceSync(resource, commonFields.getIamRole(), userRequest, body.getDataset()).castByEnum(WsmResourceType.CONTROLLED_GCP_BIG_QUERY_DATASET);
var response = new ApiCreatedControlledGcpBigQueryDataset().resourceId(createdDataset.getResourceId()).bigQueryDataset(createdDataset.toApiResource());
return new ResponseEntity<>(response, HttpStatus.OK);
}
Aggregations