use of io.hops.hopsworks.jwt.annotation.JWTRequired in project hopsworks by logicalclocks.
the class FeaturegroupService method deleteFeatureGroup.
/**
* Endpoint for deleting a featuregroup with a specified id in a specified featurestore
*
* @param featuregroupId id of the featuregroup
* @return JSON representation of the deleted featuregroup
* @throws FeaturestoreException
* @throws HopsSecurityException
*/
@DELETE
@Path("/{featuregroupId: [0-9]+}")
@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" })
@ApiOperation(value = "Delete specific featuregroup from a specific featurestore")
public Response deleteFeatureGroup(@Context SecurityContext sc, @ApiParam(value = "Id of the featuregroup", required = true) @PathParam("featuregroupId") Integer featuregroupId) throws FeaturestoreException, ServiceException, SchemaException, KafkaException {
verifyIdProvided(featuregroupId);
Users user = jWTHelper.getUserPrincipal(sc);
// Verify that the user has the data-owner role or is the creator of the featuregroup
Featuregroup featuregroup = featuregroupController.getFeaturegroupById(featurestore, featuregroupId);
try {
featuregroupController.deleteFeaturegroup(featuregroup, project, user);
return Response.ok().build();
} catch (SQLException | IOException e) {
throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.COULD_NOT_DELETE_FEATUREGROUP, Level.SEVERE, "project: " + project.getName() + ", featurestoreId: " + featurestore.getId() + ", featuregroupId: " + featuregroupId, e.getMessage(), e);
}
}
use of io.hops.hopsworks.jwt.annotation.JWTRequired in project hopsworks by logicalclocks.
the class FeatureViewResource method create.
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(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" })
@ApiOperation(value = "Create Feature View metadata.", response = FeatureViewDTO.class)
public Response create(@Context SecurityContext sc, @Context HttpServletRequest req, FeatureViewDTO featureViewDTO) throws FeaturestoreException {
Users user = jWTHelper.getUserPrincipal(sc);
FeatureView featureView = featureViewController.convertFromDTO(project, featurestore, user, featureViewDTO);
featureView = featureViewController.createFeatureView(featureView, featurestore);
activityFacade.persistActivity(ActivityFacade.CREATED_FEATURE_VIEW + featureView.getName(), project, user, ActivityFlag.SERVICE);
return Response.ok().entity(featureViewBuilder.convertToDTO(featureView)).build();
}
use of io.hops.hopsworks.jwt.annotation.JWTRequired in project hopsworks by logicalclocks.
the class FeatureViewResource method getByName.
@GET
@Path("/{name: [a-z0-9_]*(?=[a-z])[a-z0-9_]+}")
@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" })
@ApiOperation(value = "Get Feature View metadata by name.", response = FeatureViewDTO.class)
public Response getByName(@Context SecurityContext sc, @Context HttpServletRequest req, @Context UriInfo uriInfo, @BeanParam FeatureViewBeanParam param, @ApiParam(value = "Name of the feature view", required = true) @PathParam("name") String name) throws FeaturestoreException, ServiceException, IOException, MetadataException, DatasetException, SchematizedTagException {
Users user = jWTHelper.getUserPrincipal(sc);
ResourceRequest resourceRequest = makeResourceRequest(param);
List<FeatureView> featureViews = featureViewController.getByNameAndFeatureStore(name, featurestore, resourceRequest);
return Response.ok().entity(featureViewBuilder.build(featureViews, resourceRequest, project, user, uriInfo)).build();
}
use of io.hops.hopsworks.jwt.annotation.JWTRequired in project hopsworks by logicalclocks.
the class FeatureViewResource method deleteNameVersion.
@DELETE
@Path("/{name: [a-z0-9_]*(?=[a-z])[a-z0-9_]+}/version/{version: [0-9]+}")
@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" })
@ApiOperation(value = "Delete Feature View metadata by name and version.")
public Response deleteNameVersion(@Context SecurityContext sc, @Context HttpServletRequest req, @ApiParam(value = "Name of the feature view", required = true) @PathParam("name") String name, @PathParam("version") Integer version) throws FeaturestoreException {
Users user = jWTHelper.getUserPrincipal(sc);
featureViewController.delete(user, project, featurestore, name, version);
activityFacade.persistActivity(ActivityFacade.DELETED_FEATURE_VIEW + name, project, user, ActivityFlag.SERVICE);
return Response.ok().build();
}
use of io.hops.hopsworks.jwt.annotation.JWTRequired in project hopsworks by logicalclocks.
the class FeaturegroupService method createFeaturegroup.
/**
* Endpoint for creating a new featuregroup in a featurestore
*
* @param featuregroupDTO JSON payload for the new featuregroup
* @return JSON information about the created featuregroup
* @throws HopsSecurityException
*/
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(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" })
@ApiOperation(value = "Create feature group in a featurestore", response = FeaturegroupDTO.class)
public Response createFeaturegroup(@Context SecurityContext sc, FeaturegroupDTO featuregroupDTO) throws FeaturestoreException, ServiceException, KafkaException, SchemaException, ProjectException, UserException {
Users user = jWTHelper.getUserPrincipal(sc);
if (featuregroupDTO == null) {
throw new IllegalArgumentException("Input JSON for creating a new Feature Group cannot be null");
}
try {
if (featuregroupController.featuregroupExists(featurestore, featuregroupDTO)) {
throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.FEATUREGROUP_EXISTS, Level.INFO, "project: " + project.getName() + ", featurestoreId: " + featurestore.getId());
}
FeaturegroupDTO createdFeaturegroup = featuregroupController.createFeaturegroup(featurestore, featuregroupDTO, project, user);
GenericEntity<FeaturegroupDTO> featuregroupGeneric = new GenericEntity<FeaturegroupDTO>(createdFeaturegroup) {
};
return noCacheResponse.getNoCacheResponseBuilder(Response.Status.CREATED).entity(featuregroupGeneric).build();
} catch (SQLException | ProvenanceException | IOException | HopsSecurityException e) {
throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.COULD_NOT_CREATE_FEATUREGROUP, Level.SEVERE, "project: " + project.getName() + ", featurestoreId: " + featurestore.getId(), e.getMessage(), e);
}
}
Aggregations