Search in sources :

Example 61 with ApiKeyRequired

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();
}
Also used : FeatureView(io.hops.hopsworks.persistence.entity.featurestore.featureview.FeatureView) Users(io.hops.hopsworks.persistence.entity.user.Users) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) 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)

Example 62 with ApiKeyRequired

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();
}
Also used : Users(io.hops.hopsworks.persistence.entity.user.Users) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) 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)

Example 63 with ApiKeyRequired

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);
    }
}
Also used : ProvenanceException(io.hops.hopsworks.exceptions.ProvenanceException) SQLException(java.sql.SQLException) GenericEntity(javax.ws.rs.core.GenericEntity) Users(io.hops.hopsworks.persistence.entity.user.Users) IOException(java.io.IOException) FeaturestoreException(io.hops.hopsworks.exceptions.FeaturestoreException) FeaturegroupDTO(io.hops.hopsworks.common.featurestore.featuregroup.FeaturegroupDTO) HopsSecurityException(io.hops.hopsworks.exceptions.HopsSecurityException) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) 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)

Example 64 with ApiKeyRequired

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();
}
Also used : TransformationFunctionDTO(io.hops.hopsworks.common.featurestore.transformationFunction.TransformationFunctionDTO) Users(io.hops.hopsworks.persistence.entity.user.Users) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) TransformationFunction(io.hops.hopsworks.persistence.entity.featurestore.transformationFunction.TransformationFunction) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) 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)

Example 65 with ApiKeyRequired

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();
}
Also used : Users(io.hops.hopsworks.persistence.entity.user.Users) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) FeaturestoreStatistic(io.hops.hopsworks.persistence.entity.featurestore.statistics.FeaturestoreStatistic) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) 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

ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)175 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)171 ApiOperation (io.swagger.annotations.ApiOperation)169 Produces (javax.ws.rs.Produces)165 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)159 Path (javax.ws.rs.Path)124 Users (io.hops.hopsworks.persistence.entity.user.Users)116 GET (javax.ws.rs.GET)96 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)94 Consumes (javax.ws.rs.Consumes)45 DatasetPath (io.hops.hopsworks.common.dataset.util.DatasetPath)38 POST (javax.ws.rs.POST)32 DELETE (javax.ws.rs.DELETE)26 GenericEntity (javax.ws.rs.core.GenericEntity)25 PUT (javax.ws.rs.PUT)23 TagsDTO (io.hops.hopsworks.common.tags.TagsDTO)15 Featuregroup (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup)11 UriBuilder (javax.ws.rs.core.UriBuilder)11 Project (io.hops.hopsworks.persistence.entity.project.Project)10 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)9