Search in sources :

Example 1 with RuleDTO

use of io.hops.hopsworks.common.featurestore.datavalidation.RuleDTO in project hopsworks by logicalclocks.

the class RulesBuilder method build.

public RuleDTO build(UriInfo uriInfo, ResourceRequest resourceRequest) {
    RuleDTO dto = new RuleDTO();
    uri(dto, uriInfo);
    expand(dto, resourceRequest);
    if (dto.isExpand()) {
        AbstractFacade.CollectionInfo collectionInfo = ruleDefinitionFacade.findAll(resourceRequest.getOffset(), resourceRequest.getLimit(), resourceRequest.getFilter(), resourceRequest.getSort());
        // set the count
        dto.setCount(collectionInfo.getCount());
        collectionInfo.getItems().forEach((validationRule) -> dto.addItem(build(uriInfo, resourceRequest, (ValidationRule) validationRule)));
    }
    return dto;
}
Also used : RuleDTO(io.hops.hopsworks.common.featurestore.datavalidation.RuleDTO) AbstractFacade(io.hops.hopsworks.common.dao.AbstractFacade)

Example 2 with RuleDTO

use of io.hops.hopsworks.common.featurestore.datavalidation.RuleDTO in project hopsworks by logicalclocks.

the class RulesResource method get.

@ApiOperation(value = "Get a specific data validation rule that can be applied to a feature group", response = RuleDTO.class)
@GET
@Path("/{name}")
@Produces(MediaType.APPLICATION_JSON)
@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 rule", required = true) @PathParam("name") Name name, @Context UriInfo uriInfo, @Context SecurityContext sc) throws FeaturestoreException {
    ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.RULES);
    RuleDTO dto = rulesBuilder.build(uriInfo, resourceRequest, name);
    return Response.ok().entity(dto).build();
}
Also used : RuleDTO(io.hops.hopsworks.common.featurestore.datavalidation.RuleDTO) 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)

Example 3 with RuleDTO

use of io.hops.hopsworks.common.featurestore.datavalidation.RuleDTO in project hopsworks by logicalclocks.

the class RulesBuilder method build.

public RuleDTO build(UriInfo uriInfo, ResourceRequest resourceRequest, ValidationRule validationRule) {
    RuleDTO dto = new RuleDTO();
    uri(dto, uriInfo, validationRule);
    expand(dto, resourceRequest);
    if (dto.isExpand()) {
        dto.setName(validationRule.getName());
        dto.setDescription(validationRule.getDescription());
        dto.setPredicate(validationRule.getPredicate());
        dto.setAcceptedType(validationRule.getAcceptedType());
        dto.setFeatureType(validationRule.getFeatureType());
    }
    return dto;
}
Also used : RuleDTO(io.hops.hopsworks.common.featurestore.datavalidation.RuleDTO)

Example 4 with RuleDTO

use of io.hops.hopsworks.common.featurestore.datavalidation.RuleDTO in project hopsworks by logicalclocks.

the class RulesResource method getAll.

@ApiOperation(value = "Get a list of all data validation rules that can be applied to a feature group", response = RuleDTO.class)
@GET
@Produces(MediaType.APPLICATION_JSON)
@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 RulesBeanParam ruleDefinitionsBeanParam, @Context UriInfo uriInfo, @Context SecurityContext sc) {
    ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.RULES);
    resourceRequest.setOffset(pagination.getOffset());
    resourceRequest.setLimit(pagination.getLimit());
    resourceRequest.setSort(ruleDefinitionsBeanParam.getSortBySet());
    RuleDTO dto = rulesBuilder.build(uriInfo, resourceRequest);
    return Response.ok().entity(dto).build();
}
Also used : RuleDTO(io.hops.hopsworks.common.featurestore.datavalidation.RuleDTO) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) 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)

Aggregations

RuleDTO (io.hops.hopsworks.common.featurestore.datavalidation.RuleDTO)4 ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)2 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)2 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)2 ApiOperation (io.swagger.annotations.ApiOperation)2 GET (javax.ws.rs.GET)2 Produces (javax.ws.rs.Produces)2 AbstractFacade (io.hops.hopsworks.common.dao.AbstractFacade)1 Path (javax.ws.rs.Path)1