use of bio.terra.workspace.generated.model.ApiStewardshipType in project terra-workspace-manager by DataBiosphere.
the class Alpha1ApiController method enumerateJobs.
@Override
public ResponseEntity<ApiEnumerateJobsResult> enumerateJobs(UUID workspaceId, Integer limit, String pageToken, ApiResourceType resource, ApiStewardshipType stewardship, String name, ApiJobStateFilter jobState) {
// Make sure Alpha1 is enabled
features.alpha1EnabledCheck();
// Prepare the inputs
final AuthenticatedUserRequest userRequest = getAuthenticatedInfo();
ControllerValidationUtils.validatePaginationParams(0, limit);
ResourceValidationUtils.validateOptionalResourceName(name);
// Make sure the caller has read access to the workspace
workspaceService.validateWorkspaceAndAction(userRequest, workspaceId, SamWorkspaceAction.READ);
// Do the enumeration
EnumeratedJobs enumeratedJobs = alpha1Service.enumerateJobs(workspaceId, userRequest, limit, pageToken, WsmResourceFamily.fromApiOptional(resource), StewardshipType.fromApiOptional(stewardship), name, JobStateFilter.fromApi(jobState));
// Convert the result to API-speak
List<ApiEnumeratedJob> apiJobList = new ArrayList<>();
for (EnumeratedJob enumeratedJob : enumeratedJobs.getResults()) {
ApiJobReport jobReport = jobService.mapFlightStateToApiJobReport(enumeratedJob.getFlightState());
Optional<WsmResource> optResource = enumeratedJob.getResource();
ApiEnumeratedJob apiJob = new ApiEnumeratedJob().jobReport(jobReport).errorReport(enumeratedJob.getFlightState().getException().map(ErrorReportUtils::buildApiErrorReport).orElse(null)).jobDescription(enumeratedJob.getJobDescription()).operationType(enumeratedJob.getOperationType().toApiModel()).resourceType(optResource.map(r -> r.getResourceType().toApiModel()).orElse(null)).resource(optResource.map(WsmResource::toApiResourceUnion).orElse(null));
apiJobList.add(apiJob);
}
ApiEnumerateJobsResult result = new ApiEnumerateJobsResult().pageToken(enumeratedJobs.getPageToken()).totalResults(enumeratedJobs.getTotalResults()).results(apiJobList);
return new ResponseEntity<>(result, HttpStatus.OK);
}
use of bio.terra.workspace.generated.model.ApiStewardshipType 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);
}
Aggregations