use of io.hops.hopsworks.jwt.annotation.JWTRequired in project hopsworks by logicalclocks.
the class TrainingDatasetService method getAll.
/**
* Endpoint for getting a list of all training datasets in the feature store.
*
* @return a JSON representation of the training datasets in the features store
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiOperation(value = "Get the list of training datasets for a featurestore", response = TrainingDatasetDTO.class, responseContainer = "List")
public Response getAll(@Context SecurityContext sc) throws ServiceException, FeaturestoreException {
Users user = jWTHelper.getUserPrincipal(sc);
List<TrainingDatasetDTO> trainingDatasetDTOs = trainingDatasetController.getTrainingDatasetsForFeaturestore(user, project, featurestore);
GenericEntity<List<TrainingDatasetDTO>> trainingDatasetsGeneric = new GenericEntity<List<TrainingDatasetDTO>>(trainingDatasetDTOs) {
};
return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(trainingDatasetsGeneric).build();
}
use of io.hops.hopsworks.jwt.annotation.JWTRequired in project hopsworks by logicalclocks.
the class TrainingDatasetService method getTag.
@ApiOperation(value = "Get tag attached to a training dataset", response = TagsDTO.class)
@GET
@Path("/{trainingDatasetId}/tags/{name}")
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_SCIENTIST, AllowedProjectRoles.DATA_OWNER })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getTag(@Context SecurityContext sc, @Context UriInfo uriInfo, @ApiParam(value = "Id of the training dataset", required = true) @PathParam("trainingDatasetId") Integer trainingDatasetId, @ApiParam(value = "Name of the tag", required = true) @PathParam("name") String name, @BeanParam TagsExpansionBeanParam tagsExpansionBeanParam) throws DatasetException, MetadataException, FeaturestoreException, SchematizedTagException {
verifyIdProvided(trainingDatasetId);
Users user = jWTHelper.getUserPrincipal(sc);
TrainingDataset trainingDataset = trainingDatasetController.getTrainingDatasetById(featurestore, trainingDatasetId);
Map<String, String> result = new HashMap<>();
result.put(name, tagController.get(project, user, featurestore, trainingDataset, name));
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.TAGS);
resourceRequest.setExpansions(tagsExpansionBeanParam.getResources());
TagsDTO dto = tagBuilder.build(uriInfo, resourceRequest, project, featurestore.getId(), ResourceRequest.Name.TRAININGDATASETS.name(), trainingDatasetId, result);
return Response.status(Response.Status.OK).entity(dto).build();
}
use of io.hops.hopsworks.jwt.annotation.JWTRequired in project hopsworks by logicalclocks.
the class TrainingDatasetService method deleteTags.
@ApiOperation(value = "Delete all attached tags to training dataset")
@DELETE
@Path("/{trainingDatasetId}/tags")
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_SCIENTIST, AllowedProjectRoles.DATA_OWNER })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response deleteTags(@Context SecurityContext sc, @ApiParam(value = "Id of the training dataset", required = true) @PathParam("trainingDatasetId") Integer trainingDatasetId) throws DatasetException, MetadataException, SchematizedTagException, FeaturestoreException {
verifyIdProvided(trainingDatasetId);
Users user = jWTHelper.getUserPrincipal(sc);
TrainingDataset trainingDataset = trainingDatasetController.getTrainingDatasetById(featurestore, trainingDatasetId);
tagController.deleteAll(project, user, featurestore, trainingDataset);
return Response.noContent().build();
}
use of io.hops.hopsworks.jwt.annotation.JWTRequired in project hopsworks by logicalclocks.
the class TrainingDatasetService method getQuery.
@ApiOperation(value = "Get the query used to generated the training dataset", response = FsQueryDTO.class)
@GET
@Path("/{trainingdatasetid}/query")
@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 getQuery(@Context SecurityContext sc, @Context UriInfo uriInfo, @ApiParam(value = "Id of the trainingdatasetid", required = true) @PathParam("trainingdatasetid") Integer trainingdatasetid, @ApiParam(value = "get query with label features", example = "true") @QueryParam("withLabel") @DefaultValue("true") boolean withLabel, @ApiParam(value = "get query in hive format", example = "true") @QueryParam("hiveQuery") @DefaultValue("false") boolean isHiveQuery) throws FeaturestoreException, ServiceException {
verifyIdProvided(trainingdatasetid);
Users user = jWTHelper.getUserPrincipal(sc);
FsQueryDTO fsQueryDTO = fsQueryBuilder.build(uriInfo, project, user, featurestore, trainingdatasetid, withLabel, isHiveQuery);
return Response.ok().entity(fsQueryDTO).build();
}
use of io.hops.hopsworks.jwt.annotation.JWTRequired in project hopsworks by logicalclocks.
the class TrainingDatasetService method getTags.
@ApiOperation(value = "Get all tags attached to a training dataset", response = TagsDTO.class)
@GET
@Path("/{trainingDatasetId}/tags")
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_SCIENTIST, AllowedProjectRoles.DATA_OWNER })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getTags(@Context SecurityContext sc, @Context UriInfo uriInfo, @ApiParam(value = "Id of the training dataset", required = true) @PathParam("trainingDatasetId") Integer trainingDatasetId, @BeanParam TagsExpansionBeanParam tagsExpansionBeanParam) throws DatasetException, MetadataException, FeaturestoreException, SchematizedTagException {
verifyIdProvided(trainingDatasetId);
Users user = jWTHelper.getUserPrincipal(sc);
TrainingDataset trainingDataset = trainingDatasetController.getTrainingDatasetById(featurestore, trainingDatasetId);
Map<String, String> result = tagController.getAll(project, user, featurestore, trainingDataset);
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.TAGS);
resourceRequest.setExpansions(tagsExpansionBeanParam.getResources());
TagsDTO dto = tagBuilder.build(uriInfo, resourceRequest, project, featurestore.getId(), ResourceRequest.Name.TRAININGDATASETS.name(), trainingDatasetId, result);
return Response.status(Response.Status.OK).entity(dto).build();
}
Aggregations