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();
}
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();
}
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();
}
Aggregations