Search in sources :

Example 1 with ApiCreatedControlledAzureDisk

use of bio.terra.workspace.generated.model.ApiCreatedControlledAzureDisk in project terra-workspace-manager by DataBiosphere.

the class ControlledAzureResourceApiController method createAzureDisk.

@Override
public ResponseEntity<ApiCreatedControlledAzureDisk> createAzureDisk(UUID workspaceId, ApiCreateControlledAzureDiskRequestBody body) {
    features.azureEnabledCheck();
    final AuthenticatedUserRequest userRequest = getAuthenticatedInfo();
    ControlledResourceFields commonFields = toCommonFields(workspaceId, body.getCommon(), userRequest);
    ControlledAzureDiskResource resource = ControlledAzureDiskResource.builder().common(commonFields).diskName(body.getAzureDisk().getName()).region(body.getAzureDisk().getRegion()).size(body.getAzureDisk().getSize()).build();
    // TODO: make createDisk call async once we have things working e2e
    final ControlledAzureDiskResource createdDisk = controlledResourceService.createControlledResourceSync(resource, commonFields.getIamRole(), userRequest, body.getAzureDisk()).castByEnum(WsmResourceType.CONTROLLED_AZURE_DISK);
    var response = new ApiCreatedControlledAzureDisk().resourceId(createdDisk.getResourceId()).azureDisk(createdDisk.toApiResource());
    return new ResponseEntity<>(response, HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ApiCreatedControlledAzureDisk(bio.terra.workspace.generated.model.ApiCreatedControlledAzureDisk) ControlledAzureDiskResource(bio.terra.workspace.service.resource.controlled.cloud.azure.disk.ControlledAzureDiskResource) AuthenticatedUserRequest(bio.terra.workspace.service.iam.AuthenticatedUserRequest) ControlledResourceFields(bio.terra.workspace.service.resource.controlled.model.ControlledResourceFields)

Aggregations

ApiCreatedControlledAzureDisk (bio.terra.workspace.generated.model.ApiCreatedControlledAzureDisk)1 AuthenticatedUserRequest (bio.terra.workspace.service.iam.AuthenticatedUserRequest)1 ControlledAzureDiskResource (bio.terra.workspace.service.resource.controlled.cloud.azure.disk.ControlledAzureDiskResource)1 ControlledResourceFields (bio.terra.workspace.service.resource.controlled.model.ControlledResourceFields)1 ResponseEntity (org.springframework.http.ResponseEntity)1