org.openmetadata.service.secrets.converter.LookerConnectionClassConverter Maven / Gradle / Ivy
package org.openmetadata.service.secrets.converter;
import java.util.List;
import org.openmetadata.schema.security.credentials.BitBucketCredentials;
import org.openmetadata.schema.security.credentials.GitHubCredentials;
import org.openmetadata.schema.services.connections.dashboard.LookerConnection;
import org.openmetadata.service.util.JsonUtils;
public class LookerConnectionClassConverter extends ClassConverter {
private static final List> CREDENTIALS_CLASSES =
List.of(GitHubCredentials.class, BitBucketCredentials.class);
public LookerConnectionClassConverter() {
super(LookerConnection.class);
}
@Override
public Object convert(Object object) {
LookerConnection lookerConnection =
(LookerConnection) JsonUtils.convertValue(object, this.clazz);
tryToConvertOrFail(lookerConnection.getGitCredentials(), CREDENTIALS_CLASSES)
.ifPresent(lookerConnection::setGitCredentials);
return lookerConnection;
}
}