Search in sources :

Example 6 with FeaturestoreStorageConnectorDTO

use of io.hops.hopsworks.common.featurestore.storageconnectors.FeaturestoreStorageConnectorDTO in project hopsworks by logicalclocks.

the class FeaturestoreStorageConnectorService method getOnlineFeaturestoreStorageConnector.

/**
 * This method returns the JDBC connector for the online featurestore for this user.
 * The JDBC connector is generated from the MySQL Server host:port, the user's username
 * and password (from the SecretsController).
 *
 * @param sc
 * @return
 * @throws FeaturestoreException
 */
@GET
@Path("/onlinefeaturestore")
@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 online featurestore storage connector for this feature store", response = FeaturestoreStorageConnectorDTO.class)
public Response getOnlineFeaturestoreStorageConnector(@Context SecurityContext sc) throws FeaturestoreException {
    if (!settings.isOnlineFeaturestore()) {
        throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.FEATURESTORE_ONLINE_NOT_ENABLED, Level.FINE, "Online Featurestore is not enabled for this Hopsworks cluster.");
    }
    if (!onlineFeaturestoreController.checkIfDatabaseExists(onlineFeaturestoreController.getOnlineFeaturestoreDbName(featurestore.getProject()))) {
        throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.FEATURESTORE_ONLINE_NOT_ENABLED, Level.FINE, "Online Featurestore is not enabled for this project. To enable online feature store," + " talk to an administrator.");
    }
    Users user = jWTHelper.getUserPrincipal(sc);
    FeaturestoreStorageConnectorDTO featurestoreJdbcConnectorDTO = storageConnectorController.getOnlineFeaturestoreConnector(user, project, featurestore);
    GenericEntity<FeaturestoreStorageConnectorDTO> featurestoreStorageConnectorDTOGenericEntity = new GenericEntity<FeaturestoreStorageConnectorDTO>(featurestoreJdbcConnectorDTO) {
    };
    return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(featurestoreStorageConnectorDTOGenericEntity).build();
}
Also used : GenericEntity(javax.ws.rs.core.GenericEntity) FeaturestoreStorageConnectorDTO(io.hops.hopsworks.common.featurestore.storageconnectors.FeaturestoreStorageConnectorDTO) Users(io.hops.hopsworks.persistence.entity.user.Users) FeaturestoreException(io.hops.hopsworks.exceptions.FeaturestoreException) 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 7 with FeaturestoreStorageConnectorDTO

use of io.hops.hopsworks.common.featurestore.storageconnectors.FeaturestoreStorageConnectorDTO in project hopsworks by logicalclocks.

the class FeaturestoreStorageConnectorService method getStorageConnector.

@GET
@Path("{connectorName}")
@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 storage connector with a specific name and from a featurestore", response = FeaturestoreStorageConnectorDTO.class)
public Response getStorageConnector(@Context SecurityContext sc, @ApiParam(value = "Name of the storage connector", required = true) @PathParam("connectorName") String connectorName) throws FeaturestoreException {
    Users user = jWTHelper.getUserPrincipal(sc);
    verifyStorageConnectorName(connectorName);
    FeaturestoreStorageConnectorDTO featurestoreStorageConnectorDTO = storageConnectorController.getConnectorWithName(user, project, featurestore, connectorName);
    GenericEntity<FeaturestoreStorageConnectorDTO> featurestoreStorageConnectorDTOGenericEntity = new GenericEntity<FeaturestoreStorageConnectorDTO>(featurestoreStorageConnectorDTO) {
    };
    return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(featurestoreStorageConnectorDTOGenericEntity).build();
}
Also used : GenericEntity(javax.ws.rs.core.GenericEntity) FeaturestoreStorageConnectorDTO(io.hops.hopsworks.common.featurestore.storageconnectors.FeaturestoreStorageConnectorDTO) Users(io.hops.hopsworks.persistence.entity.user.Users) 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 8 with FeaturestoreStorageConnectorDTO

use of io.hops.hopsworks.common.featurestore.storageconnectors.FeaturestoreStorageConnectorDTO in project hopsworks by logicalclocks.

the class FeaturestoreStorageConnectorService method updateStorageConnector.

/**
 * Endpoint for updating a storage connector with a particular type and id in a feature store
 *
 * @param connectorName
 *   the id of the storage connector
 * @return a JSON representation of the updated connector
 * @throws FeaturestoreException
 */
@PUT
@Path("/{connectorName}")
@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 = "Get a storage connector with a specific name and from a featurestore", response = FeaturestoreStorageConnectorDTO.class)
public Response updateStorageConnector(@ApiParam(value = "Name of the storage connector", required = true) @PathParam("connectorName") String connectorName, FeaturestoreStorageConnectorDTO featurestoreStorageConnectorInputDTO, @Context SecurityContext sc) throws FeaturestoreException, UserException, ProjectException {
    if (featurestoreStorageConnectorInputDTO == null) {
        throw new IllegalArgumentException("Input JSON for updating a Feature Store Storage Connector Cannot be " + "null");
    }
    Users user = jWTHelper.getUserPrincipal(sc);
    verifyStorageConnectorName(connectorName);
    storageConnectorController.updateStorageConnector(user, project, featurestore, featurestoreStorageConnectorInputDTO, connectorName);
    FeaturestoreStorageConnectorDTO featurestoreStorageConnectorDTO = storageConnectorController.getConnectorWithName(user, project, featurestore, connectorName);
    GenericEntity<FeaturestoreStorageConnectorDTO> featurestoreStorageConnectorDTOGenericEntity = new GenericEntity<FeaturestoreStorageConnectorDTO>(featurestoreStorageConnectorDTO) {
    };
    return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(featurestoreStorageConnectorDTOGenericEntity).build();
}
Also used : GenericEntity(javax.ws.rs.core.GenericEntity) FeaturestoreStorageConnectorDTO(io.hops.hopsworks.common.featurestore.storageconnectors.FeaturestoreStorageConnectorDTO) Users(io.hops.hopsworks.persistence.entity.user.Users) Path(javax.ws.rs.Path) 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) PUT(javax.ws.rs.PUT)

Aggregations

FeaturestoreStorageConnectorDTO (io.hops.hopsworks.common.featurestore.storageconnectors.FeaturestoreStorageConnectorDTO)8 Users (io.hops.hopsworks.persistence.entity.user.Users)6 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)5 ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)5 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)5 ApiOperation (io.swagger.annotations.ApiOperation)5 Produces (javax.ws.rs.Produces)5 GenericEntity (javax.ws.rs.core.GenericEntity)5 ServiceDiscoveryException (com.logicalclocks.servicediscoverclient.exceptions.ServiceDiscoveryException)3 GET (javax.ws.rs.GET)3 Path (javax.ws.rs.Path)3 OnDemandFeaturegroupDTO (io.hops.hopsworks.common.featurestore.featuregroup.ondemand.OnDemandFeaturegroupDTO)2 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)2 ServiceException (io.hops.hopsworks.exceptions.ServiceException)2 ProjectTeamFacade (io.hops.hopsworks.common.dao.project.team.ProjectTeamFacade)1 ActivityFacade (io.hops.hopsworks.common.dao.user.activity.ActivityFacade)1 DatasetController (io.hops.hopsworks.common.dataset.DatasetController)1 FeaturegroupFacade (io.hops.hopsworks.common.featurestore.featuregroup.FeaturegroupFacade)1 CachedFeaturegroupDTO (io.hops.hopsworks.common.featurestore.featuregroup.cached.CachedFeaturegroupDTO)1 OnlineFeaturestoreController (io.hops.hopsworks.common.featurestore.online.OnlineFeaturestoreController)1