use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired 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.api.filter.apiKey.ApiKeyRequired 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.api.filter.apiKey.ApiKeyRequired 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);
}
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class TransformationFunctionResource method register.
@POST
@Consumes(MediaType.APPLICATION_JSON)
@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 = "Register transformation function in to a featurestore", response = TransformationFunctionDTO.class)
public Response register(@Context UriInfo uriInfo, @Context SecurityContext sc, TransformationFunctionDTO transformationFunctionDTO) throws IOException, FeaturestoreException {
Users user = jWTHelper.getUserPrincipal(sc);
TransformationFunction transformationFunction = transformationFunctionController.register(user, project, featurestore, transformationFunctionDTO);
TransformationFunctionDTO newTransformationFunctionDTO = transformationFunctionBuilder.build(uriInfo, new ResourceRequest(ResourceRequest.Name.TRANSFORMATIONFUNCTIONS), user, project, featurestore, transformationFunction);
return Response.ok().entity(newTransformationFunctionDTO).build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class StatisticsResource method register.
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Register new statistics")
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.DATASET_VIEW, ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response register(@Context UriInfo uriInfo, @Context SecurityContext sc, StatisticsDTO statisticsDTO) throws FeaturestoreException, DatasetException, HopsSecurityException, IOException {
Users user = jWTHelper.getUserPrincipal(sc);
FeaturestoreStatistic statistics;
StatisticsDTO dto;
if (featuregroup != null) {
statistics = statisticsController.registerStatistics(project, user, statisticsDTO.getCommitTime(), statisticsDTO.getFeatureGroupCommitId(), statisticsDTO.getContent(), featuregroup);
dto = statisticsBuilder.build(uriInfo, new ResourceRequest(ResourceRequest.Name.STATISTICS), project, user, featuregroup, statistics);
} else {
if (statisticsDTO.getSplitStatistics() != null && !statisticsDTO.getForTransformation()) {
Map<String, String> splitStatistics = statisticsDTO.getSplitStatistics().stream().collect(Collectors.toMap(SplitStatisticsDTO::getName, SplitStatisticsDTO::getContent));
statistics = statisticsController.registerStatistics(project, user, statisticsDTO.getCommitTime(), null, trainingDataset, splitStatistics, false);
} else {
statistics = statisticsController.registerStatistics(project, user, statisticsDTO.getCommitTime(), statisticsDTO.getContent(), trainingDataset, null, statisticsDTO.getForTransformation());
}
dto = statisticsBuilder.build(uriInfo, new ResourceRequest(ResourceRequest.Name.STATISTICS), project, user, trainingDataset, statistics);
}
return Response.ok().entity(dto).build();
}
Aggregations