Search in sources :

Example 1 with LibrarySearchDTO

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();
}
Also used : LibrarySearchDTO(io.hops.hopsworks.api.python.library.search.LibrarySearchDTO) PackageSource(io.hops.hopsworks.common.python.library.PackageSource) PythonException(io.hops.hopsworks.exceptions.PythonException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) ApiKeyRequired(io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Aggregations

AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)1 ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)1 LibrarySearchDTO (io.hops.hopsworks.api.python.library.search.LibrarySearchDTO)1 PackageSource (io.hops.hopsworks.common.python.library.PackageSource)1 PythonException (io.hops.hopsworks.exceptions.PythonException)1 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)1 ApiOperation (io.swagger.annotations.ApiOperation)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1