Search in sources :

Example 1 with ApiResourceList

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

the class ResourceController method enumerateResources.

@Override
public ResponseEntity<ApiResourceList> enumerateResources(UUID workspaceId, @Valid @RequestParam(value = "offset", required = false, defaultValue = "0") Integer offset, @Valid @RequestParam(value = "limit", required = false, defaultValue = "10") Integer limit, @Valid ApiResourceType resource, @Valid ApiStewardshipType stewardship) {
    AuthenticatedUserRequest userRequest = getAuthenticatedInfo();
    ControllerValidationUtils.validatePaginationParams(offset, limit);
    workspaceService.validateWorkspaceAndAction(userRequest, workspaceId, SamConstants.SamWorkspaceAction.READ);
    List<WsmResource> wsmResources = resourceService.enumerateResources(workspaceId, WsmResourceFamily.fromApiOptional(resource), StewardshipType.fromApiOptional(stewardship), offset, limit, userRequest);
    List<ApiResourceDescription> apiResourceDescriptionList = wsmResources.stream().map(r -> makeApiResourceDescription(r)).collect(Collectors.toList());
    var apiResourceList = new ApiResourceList().resources(apiResourceDescriptionList);
    return new ResponseEntity<>(apiResourceList, HttpStatus.OK);
}
Also used : WsmResource(bio.terra.workspace.service.resource.model.WsmResource) RequestParam(org.springframework.web.bind.annotation.RequestParam) WorkspaceService(bio.terra.workspace.service.workspace.WorkspaceService) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Controller(org.springframework.stereotype.Controller) AuthenticatedUserRequest(bio.terra.workspace.service.iam.AuthenticatedUserRequest) Valid(javax.validation.Valid) SamConstants(bio.terra.workspace.service.iam.model.SamConstants) ReferencedResourceService(bio.terra.workspace.service.resource.referenced.cloud.gcp.ReferencedResourceService) HttpServletRequest(javax.servlet.http.HttpServletRequest) ApiResourceAttributesUnion(bio.terra.workspace.generated.model.ApiResourceAttributesUnion) StewardshipType(bio.terra.workspace.service.resource.model.StewardshipType) ApiStewardshipType(bio.terra.workspace.generated.model.ApiStewardshipType) ControllerValidationUtils(bio.terra.workspace.common.utils.ControllerValidationUtils) ApiResourceMetadata(bio.terra.workspace.generated.model.ApiResourceMetadata) WsmResource(bio.terra.workspace.service.resource.model.WsmResource) ApiResourceList(bio.terra.workspace.generated.model.ApiResourceList) ApiResourceDescription(bio.terra.workspace.generated.model.ApiResourceDescription) Logger(org.slf4j.Logger) UUID(java.util.UUID) ResourceApi(bio.terra.workspace.generated.controller.ResourceApi) Collectors(java.util.stream.Collectors) WsmResourceService(bio.terra.workspace.service.resource.WsmResourceService) AuthenticatedUserRequestFactory(bio.terra.workspace.service.iam.AuthenticatedUserRequestFactory) HttpStatus(org.springframework.http.HttpStatus) List(java.util.List) WsmResourceFamily(bio.terra.workspace.service.resource.model.WsmResourceFamily) ResponseEntity(org.springframework.http.ResponseEntity) VisibleForTesting(com.google.common.annotations.VisibleForTesting) ApiResourceType(bio.terra.workspace.generated.model.ApiResourceType) ResponseEntity(org.springframework.http.ResponseEntity) ApiResourceDescription(bio.terra.workspace.generated.model.ApiResourceDescription) AuthenticatedUserRequest(bio.terra.workspace.service.iam.AuthenticatedUserRequest) ApiResourceList(bio.terra.workspace.generated.model.ApiResourceList)

Aggregations

ControllerValidationUtils (bio.terra.workspace.common.utils.ControllerValidationUtils)1 ResourceApi (bio.terra.workspace.generated.controller.ResourceApi)1 ApiResourceAttributesUnion (bio.terra.workspace.generated.model.ApiResourceAttributesUnion)1 ApiResourceDescription (bio.terra.workspace.generated.model.ApiResourceDescription)1 ApiResourceList (bio.terra.workspace.generated.model.ApiResourceList)1 ApiResourceMetadata (bio.terra.workspace.generated.model.ApiResourceMetadata)1 ApiResourceType (bio.terra.workspace.generated.model.ApiResourceType)1 ApiStewardshipType (bio.terra.workspace.generated.model.ApiStewardshipType)1 AuthenticatedUserRequest (bio.terra.workspace.service.iam.AuthenticatedUserRequest)1 AuthenticatedUserRequestFactory (bio.terra.workspace.service.iam.AuthenticatedUserRequestFactory)1 SamConstants (bio.terra.workspace.service.iam.model.SamConstants)1 WsmResourceService (bio.terra.workspace.service.resource.WsmResourceService)1 StewardshipType (bio.terra.workspace.service.resource.model.StewardshipType)1 WsmResource (bio.terra.workspace.service.resource.model.WsmResource)1 WsmResourceFamily (bio.terra.workspace.service.resource.model.WsmResourceFamily)1 ReferencedResourceService (bio.terra.workspace.service.resource.referenced.cloud.gcp.ReferencedResourceService)1 WorkspaceService (bio.terra.workspace.service.workspace.WorkspaceService)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 List (java.util.List)1 UUID (java.util.UUID)1