Search in sources :

Example 11 with PythonException

use of io.hops.hopsworks.exceptions.PythonException 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

PythonException (io.hops.hopsworks.exceptions.PythonException)11 PackageSource (io.hops.hopsworks.common.python.library.PackageSource)4 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)3 ProjectException (io.hops.hopsworks.exceptions.ProjectException)3 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)3 Project (io.hops.hopsworks.persistence.entity.project.Project)3 ApiOperation (io.swagger.annotations.ApiOperation)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 Path (org.apache.hadoop.fs.Path)3 ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)2 DistributedFileSystemOps (io.hops.hopsworks.common.hdfs.DistributedFileSystemOps)2 ProcessDescriptor (io.hops.hopsworks.common.util.ProcessDescriptor)2 ProcessResult (io.hops.hopsworks.common.util.ProcessResult)2 DatasetException (io.hops.hopsworks.exceptions.DatasetException)2 GenericException (io.hops.hopsworks.exceptions.GenericException)2 ProvenanceException (io.hops.hopsworks.exceptions.ProvenanceException)2 ServiceException (io.hops.hopsworks.exceptions.ServiceException)2