Search in sources :

Example 1 with ExpectationDTO

use of io.hops.hopsworks.api.featurestore.datavalidation.expectations.ExpectationDTO in project hopsworks by logicalclocks.

the class FeatureGroupExpectationsResource method getAll.

@ApiOperation(value = "Fetch expectations of the feature group", response = ExpectationDTO.class)
@GET
@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.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getAll(@BeanParam Pagination pagination, @BeanParam FeatureGroupExpectationsBeanParam featureGroupExpectationsBeanParam, @Context SecurityContext sc, @Context UriInfo uriInfo) {
    ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.EXPECTATIONS);
    resourceRequest.setOffset(pagination.getOffset());
    resourceRequest.setLimit(pagination.getLimit());
    resourceRequest.setSort(featureGroupExpectationsBeanParam.getSortBySet());
    resourceRequest.setExpansions(featureGroupExpectationsBeanParam.getExpansions().getResources());
    resourceRequest.setField(featureGroupExpectationsBeanParam.getFieldSet());
    ExpectationDTO dto = featureStoreExpectationsBuilder.build(uriInfo, resourceRequest, project, featuregroup);
    return Response.ok().entity(dto).build();
}
Also used : ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) ExpectationDTO(io.hops.hopsworks.api.featurestore.datavalidation.expectations.ExpectationDTO) 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 2 with ExpectationDTO

use of io.hops.hopsworks.api.featurestore.datavalidation.expectations.ExpectationDTO in project hopsworks by logicalclocks.

the class FeatureStoreExpectationsBuilder method build.

public ExpectationDTO build(UriInfo uriInfo, ResourceRequest resourceRequest, Project project, Featuregroup featuregroup, FeatureGroupExpectation featureGroupExpectation) {
    ExpectationDTO dto = new ExpectationDTO();
    uri(dto, uriInfo, project, featuregroup, featureGroupExpectation.getFeatureStoreExpectation());
    expand(dto, resourceRequest);
    if (dto.isExpand()) {
        setDtoFields(resourceRequest, dto, featureGroupExpectation.getFeatureStoreExpectation());
    }
    return dto;
}
Also used : ExpectationDTO(io.hops.hopsworks.api.featurestore.datavalidation.expectations.ExpectationDTO)

Example 3 with ExpectationDTO

use of io.hops.hopsworks.api.featurestore.datavalidation.expectations.ExpectationDTO in project hopsworks by logicalclocks.

the class FeatureStoreExpectationsBuilder method build.

public ExpectationDTO build(UriInfo uriInfo, ResourceRequest resourceRequest, Project project, Featurestore featureStore, FeatureStoreExpectation featureStoreExpectation) {
    ExpectationDTO dto = new ExpectationDTO();
    uri(dto, uriInfo, project, featureStore, featureStoreExpectation);
    expand(dto, resourceRequest);
    if (dto.isExpand()) {
        setDtoFields(resourceRequest, dto, featureStoreExpectation);
    }
    return dto;
}
Also used : ExpectationDTO(io.hops.hopsworks.api.featurestore.datavalidation.expectations.ExpectationDTO)

Example 4 with ExpectationDTO

use of io.hops.hopsworks.api.featurestore.datavalidation.expectations.ExpectationDTO in project hopsworks by logicalclocks.

the class FeatureGroupExpectationsResource method attachExpectation.

@ApiOperation(value = "Attach an expectation to a feature group.", response = ExpectationDTO.class)
@PUT
@Path("/{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.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response attachExpectation(@ApiParam(value = "name of the expectation", required = true) @PathParam("name") String name, @Context SecurityContext sc, @Context UriInfo uriInfo) throws FeaturestoreException {
    Users user = jWTHelper.getUserPrincipal(sc);
    FeatureGroupExpectation expectation = featureGroupValidationsController.attachExpectation(featuregroup, name, project, user);
    ExpectationDTO dto = featureStoreExpectationsBuilder.build(uriInfo, new ResourceRequest(ResourceRequest.Name.EXPECTATIONS), project, featurestore, expectation.getFeatureStoreExpectation());
    return Response.ok().entity(dto).build();
}
Also used : FeatureGroupExpectation(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.FeatureGroupExpectation) Users(io.hops.hopsworks.persistence.entity.user.Users) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) ExpectationDTO(io.hops.hopsworks.api.featurestore.datavalidation.expectations.ExpectationDTO) Path(javax.ws.rs.Path) 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) PUT(javax.ws.rs.PUT)

Example 5 with ExpectationDTO

use of io.hops.hopsworks.api.featurestore.datavalidation.expectations.ExpectationDTO in project hopsworks by logicalclocks.

the class FeatureGroupExpectationsResource method get.

@ApiOperation(value = "Fetch a specific data validation rule", response = ExpectationDTO.class)
@GET
@Path("/{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.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response get(@ApiParam(value = "name of the expectation", required = true) @PathParam("name") String name, @BeanParam FeatureGroupExpectationsBeanParam featureGroupExpectationsBeanParam, @Context SecurityContext sc, @Context UriInfo uriInfo) throws FeaturestoreException {
    FeatureGroupExpectation expectation = featureGroupValidationsController.getFeatureGroupExpectation(featuregroup, name);
    ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.EXPECTATIONS);
    resourceRequest.setField(featureGroupExpectationsBeanParam.getFieldSet());
    ExpectationDTO dto = featureStoreExpectationsBuilder.build(uriInfo, resourceRequest, project, featuregroup, expectation);
    return Response.ok().entity(dto).build();
}
Also used : FeatureGroupExpectation(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.FeatureGroupExpectation) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) ExpectationDTO(io.hops.hopsworks.api.featurestore.datavalidation.expectations.ExpectationDTO) 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)

Aggregations

ExpectationDTO (io.hops.hopsworks.api.featurestore.datavalidation.expectations.ExpectationDTO)10 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)6 ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)6 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)6 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)6 ApiOperation (io.swagger.annotations.ApiOperation)6 Produces (javax.ws.rs.Produces)6 GET (javax.ws.rs.GET)5 Path (javax.ws.rs.Path)4 FeatureGroupExpectation (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.FeatureGroupExpectation)3 FeatureStoreExpectation (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.FeatureStoreExpectation)3 AbstractFacade (io.hops.hopsworks.common.dao.AbstractFacade)2 PUT (javax.ws.rs.PUT)2 Audience (io.hops.hopsworks.api.filter.Audience)1 Pagination (io.hops.hopsworks.api.util.Pagination)1 FeaturestoreController (io.hops.hopsworks.common.featurestore.FeaturestoreController)1 FeaturestoreDTO (io.hops.hopsworks.common.featurestore.FeaturestoreDTO)1 Expectation (io.hops.hopsworks.common.featurestore.datavalidation.Expectation)1 FeatureGroupValidationsController (io.hops.hopsworks.common.featurestore.datavalidation.FeatureGroupValidationsController)1 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)1