Search in sources :

Example 11 with FeaturegroupDTO

use of io.hops.hopsworks.common.featurestore.featuregroup.FeaturegroupDTO in project hopsworks by logicalclocks.

the class TestFeatureStoreInputValidation method testVerifyDescription.

@Test
public void testVerifyDescription() throws Exception {
    FeaturegroupDTO featuregroupDTO = new FeaturegroupDTO(1, "featurestore", 1, "wrong_name", 1, "online_topic_name");
    // description is too long
    featuregroupDTO.setDescription(StringUtils.repeat("a", 260));
    thrown.expect(FeaturestoreException.class);
    featurestoreInputValidation.verifyUserInput(featuregroupDTO);
}
Also used : FeaturegroupDTO(io.hops.hopsworks.common.featurestore.featuregroup.FeaturegroupDTO) Test(org.junit.Test)

Example 12 with FeaturegroupDTO

use of io.hops.hopsworks.common.featurestore.featuregroup.FeaturegroupDTO in project hopsworks by logicalclocks.

the class FeaturegroupService method getFeatureGroup.

/**
 * Retrieve a specific feature group based name. Allow filtering on version.
 *
 * @param name name of the featuregroup
 * @param version queryParam with the desired version
 * @return JSON representation of the featuregroup
 */
@GET
// Anything else that is not just number should use this endpoint
@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 a list of feature groups with a specific name, filter by version", response = FeaturegroupDTO.class)
public Response getFeatureGroup(@ApiParam(value = "Name of the feature group", required = true) @PathParam("name") String name, @ApiParam(value = "Filter by a specific version") @QueryParam("version") Integer version, @Context SecurityContext sc) throws FeaturestoreException, ServiceException {
    Users user = jWTHelper.getUserPrincipal(sc);
    verifyNameProvided(name);
    List<FeaturegroupDTO> featuregroupDTO;
    if (version == null) {
        featuregroupDTO = featuregroupController.getFeaturegroupWithNameAndFeaturestore(featurestore, name, project, user);
    } else {
        featuregroupDTO = Arrays.asList(featuregroupController.getFeaturegroupWithNameVersionAndFeaturestore(featurestore, name, version, project, user));
    }
    GenericEntity<List<FeaturegroupDTO>> featuregroupGeneric = new GenericEntity<List<FeaturegroupDTO>>(featuregroupDTO) {
    };
    return Response.ok().entity(featuregroupGeneric).build();
}
Also used : GenericEntity(javax.ws.rs.core.GenericEntity) List(java.util.List) Users(io.hops.hopsworks.persistence.entity.user.Users) FeaturegroupDTO(io.hops.hopsworks.common.featurestore.featuregroup.FeaturegroupDTO) Path(javax.ws.rs.Path) DatasetPath(io.hops.hopsworks.common.dataset.util.DatasetPath) 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 13 with FeaturegroupDTO

use of io.hops.hopsworks.common.featurestore.featuregroup.FeaturegroupDTO in project hopsworks by logicalclocks.

the class FeaturegroupService method getFeaturegroupsForFeaturestore.

/**
 * Endpoint for getting all featuregroups of a featurestore
 *
 * @return list of JSON featuregroups
 */
@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 feature groups for a featurestore", response = FeaturegroupDTO.class, responseContainer = "List")
public Response getFeaturegroupsForFeaturestore(@BeanParam FeatureGroupBeanParam featureGroupBeanParam, @Context SecurityContext sc) throws FeaturestoreException, ServiceException {
    Users user = jWTHelper.getUserPrincipal(sc);
    List<FeaturegroupDTO> featuregroups = featuregroupController.getFeaturegroupsForFeaturestore(featurestore, project, user, featureGroupBeanParam.getFilterValues());
    GenericEntity<List<FeaturegroupDTO>> featuregroupsGeneric = new GenericEntity<List<FeaturegroupDTO>>(featuregroups) {
    };
    return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(featuregroupsGeneric).build();
}
Also used : GenericEntity(javax.ws.rs.core.GenericEntity) List(java.util.List) Users(io.hops.hopsworks.persistence.entity.user.Users) FeaturegroupDTO(io.hops.hopsworks.common.featurestore.featuregroup.FeaturegroupDTO) 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 14 with FeaturegroupDTO

use of io.hops.hopsworks.common.featurestore.featuregroup.FeaturegroupDTO in project hopsworks by logicalclocks.

the class FeaturegroupService method getFeatureGroup.

/**
 * Endpoint for retrieving a featuregroup with a specified id in a specified featurestore
 *
 * @param featuregroupId id of the featuregroup
 * @return JSON representation of the featuregroup
 */
@Deprecated
@GET
@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 = "Get specific featuregroup from a specific featurestore", response = FeaturegroupDTO.class)
public Response getFeatureGroup(@ApiParam(value = "Id of the featuregroup", required = true) @PathParam("featuregroupId") Integer featuregroupId, @Context SecurityContext sc) throws FeaturestoreException, ServiceException {
    Users user = jWTHelper.getUserPrincipal(sc);
    verifyIdProvided(featuregroupId);
    FeaturegroupDTO featuregroupDTO = featuregroupController.getFeaturegroupWithIdAndFeaturestore(featurestore, featuregroupId, project, user);
    GenericEntity<FeaturegroupDTO> featuregroupGeneric = new GenericEntity<FeaturegroupDTO>(featuregroupDTO) {
    };
    return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(featuregroupGeneric).build();
}
Also used : GenericEntity(javax.ws.rs.core.GenericEntity) Users(io.hops.hopsworks.persistence.entity.user.Users) FeaturegroupDTO(io.hops.hopsworks.common.featurestore.featuregroup.FeaturegroupDTO) Path(javax.ws.rs.Path) DatasetPath(io.hops.hopsworks.common.dataset.util.DatasetPath) 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)

Aggregations

FeaturegroupDTO (io.hops.hopsworks.common.featurestore.featuregroup.FeaturegroupDTO)14 Test (org.junit.Test)7 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)6 ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)6 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)6 Users (io.hops.hopsworks.persistence.entity.user.Users)6 ApiOperation (io.swagger.annotations.ApiOperation)6 Produces (javax.ws.rs.Produces)6 GenericEntity (javax.ws.rs.core.GenericEntity)5 DatasetPath (io.hops.hopsworks.common.dataset.util.DatasetPath)4 JoinDTO (io.hops.hopsworks.common.featurestore.query.join.JoinDTO)4 Featuregroup (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup)4 List (java.util.List)4 Path (javax.ws.rs.Path)4 FeatureGroupFeatureDTO (io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO)3 GET (javax.ws.rs.GET)3 QueryDTO (io.hops.hopsworks.common.featurestore.query.QueryDTO)2 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)2 HopsSecurityException (io.hops.hopsworks.exceptions.HopsSecurityException)2 ProvenanceException (io.hops.hopsworks.exceptions.ProvenanceException)2