use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class FeatureGroupPartitionResource method getPartitions.
@ApiOperation(value = "Get feature group partitions", response = PartitionDTO.class)
@GET
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getPartitions(@BeanParam Pagination pagination, @Context UriInfo uriInfo, @Context SecurityContext sc) throws FeaturestoreException {
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.PARTITIONS);
resourceRequest.setOffset(pagination.getOffset());
resourceRequest.setLimit(pagination.getLimit());
PartitionDTO partitionDTO = partitionBuilder.build(uriInfo, resourceRequest, project, featuregroup);
return Response.ok().entity(partitionDTO).build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class LibraryResource method install.
@ApiOperation(value = "Install a python library in the environment")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("{library}")
@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 install(LibrarySpecification librarySpecification, @PathParam("library") String library, @Context UriInfo uriInfo, @Context HttpServletRequest req, @Context SecurityContext sc) throws ServiceException, GenericException, PythonException, DatasetException {
Users user = jwtHelper.getUserPrincipal(req);
environmentController.checkCondaEnabled(project, pythonVersion, true);
PackageSource packageSource = librarySpecification.getPackageSource();
if (packageSource == null) {
throw new PythonException(RESTCodes.PythonErrorCode.INSTALL_TYPE_NOT_SUPPORTED, Level.FINE);
}
switch(packageSource) {
case PIP:
validateLibrary(librarySpecification, library);
librarySpecification.setChannelUrl("pypi");
break;
case CONDA:
validateLibrary(librarySpecification, library);
break;
case EGG:
case WHEEL:
case REQUIREMENTS_TXT:
case ENVIRONMENT_YAML:
validateBundledDependency(user, librarySpecification);
break;
case GIT:
validateGitURL(librarySpecification.getDependencyUrl());
break;
default:
throw new PythonException(RESTCodes.PythonErrorCode.INSTALL_TYPE_NOT_SUPPORTED, Level.FINE);
}
environmentController.checkCondaEnvExists(project, user);
PythonDep dep = libraryController.installLibrary(project, user, CondaInstallType.valueOf(packageSource.name().toUpperCase()), librarySpecification.getChannelUrl(), library, librarySpecification.getVersion(), librarySpecification.getDependencyUrl(), librarySpecification.getGitBackend(), librarySpecification.getGitApiKey());
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.LIBRARIES);
LibraryDTO libraryDTO = librariesBuilder.build(uriInfo, resourceRequest, dep, project);
return Response.created(libraryDTO.getHref()).entity(libraryDTO).build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class LibraryResource method uninstall.
@ApiOperation(value = "Uninstall a python library from the environment")
@DELETE
@Produces(MediaType.APPLICATION_JSON)
@Path("{library}")
@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 uninstall(@Context SecurityContext sc, @PathParam("library") String library) throws ServiceException, GenericException, PythonException {
validatePattern(library);
Users user = jwtHelper.getUserPrincipal(sc);
environmentController.checkCondaEnabled(project, pythonVersion, true);
if (settings.getImmutablePythonLibraryNames().contains(library)) {
throw new ServiceException(RESTCodes.ServiceErrorCode.ANACONDA_DEP_REMOVE_FORBIDDEN, Level.INFO, "library: " + library);
}
environmentController.checkCondaEnvExists(project, user);
commandsController.deleteCommands(project, library);
libraryController.uninstallLibrary(project, user, library);
return Response.noContent().build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class LibraryResource method get.
@ApiOperation(value = "Get the python libraries installed in this environment", response = LibraryDTO.class)
@GET
@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 get(@BeanParam Pagination pagination, @BeanParam LibrariesBeanParam librariesBeanParam, @Context UriInfo uriInfo, @Context SecurityContext sc) throws PythonException {
environmentController.checkCondaEnabled(project, pythonVersion, true);
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.LIBRARIES);
resourceRequest.setOffset(pagination.getOffset());
resourceRequest.setLimit(pagination.getLimit());
resourceRequest.setSort(librariesBeanParam.getSortBySet());
resourceRequest.setFilter(librariesBeanParam.getFilter());
if (librariesBeanParam.getExpansions() != null) {
resourceRequest.setExpansions(librariesBeanParam.getExpansions().getResources());
}
LibraryDTO libraryDTO = librariesBuilder.buildItems(uriInfo, resourceRequest, project);
return Response.ok().entity(libraryDTO).build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class LibraryCommandsResource method get.
@ApiOperation(value = "Get all commands for this library", response = CommandDTO.class)
@GET
@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 get(@PathParam("library") String library, @BeanParam Pagination pagination, @BeanParam CommandBeanParam libraryCommandBeanParam, @Context UriInfo uriInfo, @Context SecurityContext sc) throws PythonException {
environmentController.checkCondaEnabled(project, pythonVersion, true);
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.COMMANDS);
resourceRequest.setOffset(pagination.getOffset());
resourceRequest.setLimit(pagination.getLimit());
resourceRequest.setSort(libraryCommandBeanParam.getSortBySet());
resourceRequest.setFilter(libraryCommandBeanParam.getFilter());
CommandDTO dto = commandBuilder.buildItems(uriInfo, resourceRequest, project, library);
return Response.ok().entity(dto).build();
}
Aggregations