use of io.hops.hopsworks.persistence.entity.featurestore.storageconnector.s3.FeaturestoreS3Connector in project hopsworks by logicalclocks.
the class FeaturestoreS3ConnectorController method updateFeaturestoreS3Connector.
@TransactionAttribute(TransactionAttributeType.REQUIRED)
@Transactional(rollbackOn = { FeaturestoreException.class, UserException.class, ProjectException.class })
public FeaturestoreS3Connector updateFeaturestoreS3Connector(Users user, Featurestore featurestore, FeaturestoreS3ConnectorDTO featurestoreS3ConnectorDTO, FeaturestoreS3Connector featurestoreS3Connector) throws FeaturestoreException, UserException, ProjectException {
if (storageConnectorUtil.shouldUpdate(featurestoreS3Connector.getBucket(), featurestoreS3ConnectorDTO.getBucket())) {
verifyS3ConnectorBucket(featurestoreS3ConnectorDTO.getBucket());
featurestoreS3Connector.setBucket(featurestoreS3ConnectorDTO.getBucket());
}
if (storageConnectorUtil.shouldUpdate(featurestoreS3Connector.getIamRole(), featurestoreS3ConnectorDTO.getIamRole())) {
featurestoreS3Connector.setIamRole(featurestoreS3ConnectorDTO.getIamRole());
}
Secret secret = null;
FeaturestoreS3ConnectorAccessAndSecretKey keys = storageConnectorUtil.getSecret(featurestoreS3Connector.getSecret(), FeaturestoreS3ConnectorAccessAndSecretKey.class);
if (storageConnectorUtil.shouldUpdate(keys.getAccessKey(), featurestoreS3ConnectorDTO.getAccessKey()) || storageConnectorUtil.shouldUpdate(keys.getSecretKey(), featurestoreS3ConnectorDTO.getSecretKey())) {
secret = updateSecret(user, featurestoreS3ConnectorDTO, featurestore, featurestoreS3Connector);
}
String currentEncryptionAlgorithm = featurestoreS3Connector.getServerEncryptionAlgorithm() != null ? featurestoreS3Connector.getServerEncryptionAlgorithm().getAlgorithm() : null;
if (storageConnectorUtil.shouldUpdate(currentEncryptionAlgorithm, featurestoreS3ConnectorDTO.getServerEncryptionAlgorithm())) {
if (featurestoreS3ConnectorDTO.getServerEncryptionAlgorithm() != null) {
FeaturestoreS3ConnectorEncryptionAlgorithm serverEncryptionAlgorithm = getEncryptionAlgorithm(featurestoreS3ConnectorDTO.getServerEncryptionAlgorithm());
featurestoreS3Connector.setServerEncryptionAlgorithm(serverEncryptionAlgorithm);
if (serverEncryptionAlgorithm != null && serverEncryptionAlgorithm.isRequiresKey()) {
verifyS3ConnectorServerEncryptionKey(featurestoreS3ConnectorDTO.getServerEncryptionKey());
featurestoreS3Connector.setServerEncryptionKey(featurestoreS3ConnectorDTO.getServerEncryptionKey());
} else {
featurestoreS3Connector.setServerEncryptionKey(null);
}
} else if (!Strings.isNullOrEmpty(featurestoreS3ConnectorDTO.getServerEncryptionKey())) {
throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.ILLEGAL_S3_CONNECTOR_SERVER_ENCRYPTION_ALGORITHM, Level.FINE, "Illegal server encryption algorithm, encryption algorithm not provided");
} else {
featurestoreS3Connector.setServerEncryptionAlgorithm(null);
featurestoreS3Connector.setServerEncryptionKey(null);
}
}
// verify if key or iam role is set
verifyKeyAndIAMRole(featurestoreS3Connector.getIamRole(), featurestoreS3Connector.getSecret());
if (featurestoreS3Connector.getSecret() == null && secret != null) {
secretsFacade.deleteSecret(secret.getId());
}
return featurestoreS3Connector;
}
use of io.hops.hopsworks.persistence.entity.featurestore.storageconnector.s3.FeaturestoreS3Connector in project hopsworks by logicalclocks.
the class FeaturestoreS3ConnectorController method createFeaturestoreS3Connector.
/**
* Stores an S3 connection as a backend for a feature store
*
* @param user the user making the request
* @param featurestore the featurestore
* @param featurestoreS3ConnectorDTO the data to use when creating the storage connector
* @return DTO of the created entity
* @throws FeaturestoreException
*/
public FeaturestoreS3Connector createFeaturestoreS3Connector(Users user, Featurestore featurestore, FeaturestoreS3ConnectorDTO featurestoreS3ConnectorDTO) throws FeaturestoreException, UserException, ProjectException {
FeaturestoreS3ConnectorEncryptionAlgorithm encryptionAlgorithm = getEncryptionAlgorithm(featurestoreS3ConnectorDTO.getServerEncryptionAlgorithm());
verifyUserInput(featurestoreS3ConnectorDTO);
FeaturestoreS3Connector featurestoreS3Connector = new FeaturestoreS3Connector();
featurestoreS3Connector.setBucket(featurestoreS3ConnectorDTO.getBucket());
featurestoreS3Connector.setServerEncryptionAlgorithm(encryptionAlgorithm);
featurestoreS3Connector.setServerEncryptionKey(featurestoreS3ConnectorDTO.getServerEncryptionKey());
featurestoreS3Connector.setIamRole(featurestoreS3ConnectorDTO.getIamRole());
setSecret(user, featurestoreS3ConnectorDTO, featurestoreS3Connector, featurestore);
return featurestoreS3Connector;
}
Aggregations