use of io.hops.hopsworks.api.python.library.search.LibrarySearchDTO in project hopsworks by logicalclocks.
the class LibraryResource method search.
@ApiOperation(value = "Search for libraries using conda or pip package managers", response = LibrarySearchDTO.class)
@GET
@Path("{search: conda|pip}")
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.PYTHON }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response search(@PathParam("search") String search, @QueryParam("query") String query, @QueryParam("channel") String channel, @Context UriInfo uriInfo, @Context SecurityContext sc) throws ServiceException, PythonException {
validatePattern(query);
environmentController.checkCondaEnabled(project, pythonVersion, true);
LibrarySearchDTO librarySearchDTO;
PackageSource packageSource = PackageSource.fromString(search);
switch(packageSource) {
case CONDA:
validateChannel(channel);
librarySearchDTO = librariesSearchBuilder.buildCondaItems(uriInfo, query, project, channel);
break;
case PIP:
librarySearchDTO = librariesSearchBuilder.buildPipItems(uriInfo, query, project);
break;
default:
throw new PythonException(RESTCodes.PythonErrorCode.PYTHON_SEARCH_TYPE_NOT_SUPPORTED, Level.FINE);
}
return Response.ok().entity(librarySearchDTO).build();
}
Aggregations