Search in sources :

Example 66 with ApiKeyRequired

use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.

the class FeatureGroupDetailsResource method getDetails.

@ApiOperation(value = "Get feature group details", response = DetailsDTO.class)
@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" })
public Response getDetails(@ApiParam(value = "Storage for which to retrieve the details") @QueryParam("storage") @DefaultValue("OFFLINE") Storage storage, @Context UriInfo uriInfo, @Context SecurityContext sc) throws FeaturestoreException, HopsSecurityException {
    Users user = jwtHelper.getUserPrincipal(sc);
    if (!featuregroup.getFeaturegroupType().equals(FeaturegroupType.CACHED_FEATURE_GROUP)) {
        throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.CANNOT_FETCH_HIVE_SCHEMA_FOR_ON_DEMAND_FEATUREGROUPS, Level.FINE, "Hive schema is available only for Cached feature groups, " + featuregroup.getName() + " is on demand");
    }
    DetailsDTO detailsDTO = detailsBuilder.build(uriInfo, user, project, featuregroup, storage);
    return Response.ok().entity(detailsDTO).build();
}
Also used : Users(io.hops.hopsworks.persistence.entity.user.Users) FeaturestoreException(io.hops.hopsworks.exceptions.FeaturestoreException) 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 67 with ApiKeyRequired

use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.

the class FeaturestoreStorageConnectorService method getStorageConnectors.

/**
 * Endpoint for getting all storage connectors in a featurestore
 *
 * @return a JSON representation of all the storage connectors in the feature store
 */
@GET
@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 all storage connectors of a feature store", response = FeaturestoreStorageConnectorDTO.class, responseContainer = "List")
public Response getStorageConnectors(@Context SecurityContext sc) throws FeaturestoreException {
    Users user = jWTHelper.getUserPrincipal(sc);
    List<FeaturestoreStorageConnectorDTO> featurestoreStorageConnectorDTOS = storageConnectorController.getConnectorsForFeaturestore(user, project, featurestore);
    GenericEntity<List<FeaturestoreStorageConnectorDTO>> featurestoreStorageConnectorsGeneric = new GenericEntity<List<FeaturestoreStorageConnectorDTO>>(featurestoreStorageConnectorDTOS) {
    };
    return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(featurestoreStorageConnectorsGeneric).build();
}
Also used : GenericEntity(javax.ws.rs.core.GenericEntity) FeaturestoreStorageConnectorDTO(io.hops.hopsworks.common.featurestore.storageconnectors.FeaturestoreStorageConnectorDTO) List(java.util.List) Users(io.hops.hopsworks.persistence.entity.user.Users) 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 68 with ApiKeyRequired

use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired 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 69 with ApiKeyRequired

use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.

the class KafkaResource method getSubjectVersions.

@ApiOperation(value = "Get list of versions of a registered subject.")
@GET
@Path("/subjects/{subject}/versions")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.TEXT_PLAIN)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.KAFKA }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getSubjectVersions(@PathParam("subject") String subject, @Context SecurityContext sc) {
    try {
        List<Integer> versions = subjectsController.getSubjectVersions(project, subject);
        String array = Arrays.toString(versions.toArray());
        GenericEntity<String> entity = new GenericEntity<String>(array) {
        };
        return Response.ok().entity(entity).build();
    } catch (SchemaException e) {
        SchemaRegistryError error = new SchemaRegistryError(e.getErrorCode().getCode(), e.getErrorCode().getMessage());
        return Response.status(e.getErrorCode().getRespStatus()).entity(error).build();
    }
}
Also used : SchemaException(io.hops.hopsworks.exceptions.SchemaException) GenericEntity(javax.ws.rs.core.GenericEntity) SchemaRegistryError(io.hops.hopsworks.common.dao.kafka.schemas.SchemaRegistryError) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) 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 70 with ApiKeyRequired

use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.

the class KafkaResource method deleteSubject.

@ApiOperation(value = "Delete a subject with all its versions and its compatibility if exists.")
@DELETE
@Path("/subjects/{subject}")
@Produces({ MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON })
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.KAFKA }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response deleteSubject(@PathParam("subject") String subject, @Context SecurityContext sc) throws KafkaException {
    try {
        List<Integer> versions = subjectsController.deleteSubject(project, subject);
        String array = Arrays.toString(versions.toArray());
        GenericEntity<String> entity = new GenericEntity<String>(array) {
        };
        return Response.ok().entity(entity).build();
    } catch (SchemaException e) {
        SchemaRegistryError error = new SchemaRegistryError(e.getErrorCode().getCode(), e.getErrorCode().getMessage());
        return Response.status(e.getErrorCode().getRespStatus()).entity(error).build();
    }
}
Also used : SchemaException(io.hops.hopsworks.exceptions.SchemaException) GenericEntity(javax.ws.rs.core.GenericEntity) SchemaRegistryError(io.hops.hopsworks.common.dao.kafka.schemas.SchemaRegistryError) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) 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