Search in sources :

Example 1 with ApiCreatedControlledGcpBigQueryDataset

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);
}
Also used : ApiCreatedControlledGcpBigQueryDataset(bio.terra.workspace.generated.model.ApiCreatedControlledGcpBigQueryDataset) ResponseEntity(org.springframework.http.ResponseEntity) AuthenticatedUserRequest(bio.terra.workspace.service.iam.AuthenticatedUserRequest) ControlledResourceFields(bio.terra.workspace.service.resource.controlled.model.ControlledResourceFields) ControlledBigQueryDatasetResource(bio.terra.workspace.service.resource.controlled.cloud.gcp.bqdataset.ControlledBigQueryDatasetResource)

Aggregations

ApiCreatedControlledGcpBigQueryDataset (bio.terra.workspace.generated.model.ApiCreatedControlledGcpBigQueryDataset)1 AuthenticatedUserRequest (bio.terra.workspace.service.iam.AuthenticatedUserRequest)1 ControlledBigQueryDatasetResource (bio.terra.workspace.service.resource.controlled.cloud.gcp.bqdataset.ControlledBigQueryDatasetResource)1 ControlledResourceFields (bio.terra.workspace.service.resource.controlled.model.ControlledResourceFields)1 ResponseEntity (org.springframework.http.ResponseEntity)1