Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
echo TEST_REUSABLE_TOKEN=${{ secrets.TEST_REUSABLE_TOKEN }} >> .env

- name: Build & Run tests with Maven
run: mvn -B package -f pom.xml
run: mvn -B package -f pom.xml -Dmaven.javadoc.skip=true

- name: Codecov
uses: codecov/codecov-action@v2.1.0
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/shared-build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ jobs:
json: ${{ secrets.TEST_CREDENTIALS_FILE_STRING }}

- name: Publish package
run: mvn --batch-mode deploy -P ${{ inputs.profile }}
run: mvn --batch-mode deploy -P ${{ inputs.profile }} -Dmaven.javadoc.skip=true

env:
SERVER_USERNAME: ${{ secrets.server-username }}
SERVER_PASSWORD: ${{ secrets.server-password }}
Expand Down
33 changes: 31 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.skyflow</groupId>
<artifactId>skyflow-java</artifactId>
<version>2.0.0-beta.1-dev.ec349a9</version>
<version>2.0.0-beta.1-dev.4537d43</version>
<packaging>jar</packaging>

<name>${project.groupId}:${project.artifactId}</name>
Expand Down Expand Up @@ -45,6 +45,30 @@
</properties>

<dependencies>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.12.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
<version>2.17.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.17.2</version>
<scope>compile</scope>
</dependency>
<!-- newly added v2 dependencies -->
<dependency>
<groupId>io.github.cdimascio</groupId>
Expand Down Expand Up @@ -117,6 +141,12 @@
<version>2.0.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.13.2</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -276,5 +306,4 @@
</distributionManagement>
</profile>
</profiles>

</project>
47 changes: 43 additions & 4 deletions src/main/java/com/skyflow/Skyflow.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.skyflow.utils.logger.LogUtil;
import com.skyflow.utils.validations.Validations;
import com.skyflow.vault.controller.ConnectionController;
import com.skyflow.vault.controller.DetectController;
import com.skyflow.vault.controller.VaultController;

import java.util.LinkedHashMap;
Expand Down Expand Up @@ -101,25 +102,57 @@ public VaultController vault(String vaultId) throws SkyflowException {
return controller;
}

public ConnectionController connection() {
String connectionId = (String) this.builder.connectionsMap.keySet().toArray()[0];

public ConnectionController connection() throws SkyflowException {
Object[] array = this.builder.connectionsMap.keySet().toArray();
if (array.length < 1) {
LogUtil.printErrorLog(ErrorLogs.CONNECTION_CONFIG_DOES_NOT_EXIST.getLog());
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.ConnectionIdNotInConfigList.getMessage());
}
String connectionId = (String) array[0];
return this.connection(connectionId);
}

public ConnectionController connection(String connectionId) {
return this.builder.connectionsMap.get(connectionId);
public ConnectionController connection(String connectionId) throws SkyflowException {
ConnectionController controller = this.builder.connectionsMap.get(connectionId);
if (controller == null) {
LogUtil.printErrorLog(ErrorLogs.CONNECTION_CONFIG_DOES_NOT_EXIST.getLog());
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.ConnectionIdNotInConfigList.getMessage());
}
return controller;
}

public DetectController detect() throws SkyflowException {
Object[] array = this.builder.detectClientsMap.keySet().toArray();
if (array.length < 1) {
LogUtil.printErrorLog(ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog());
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage());
}
String detectId = (String) array[0];
return this.detect(detectId);
}

public DetectController detect(String vaultId) throws SkyflowException {
DetectController controller = this.builder.detectClientsMap.get(vaultId);
if (controller == null) {
LogUtil.printErrorLog(ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog());
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage());
}
return controller;
}

public static final class SkyflowClientBuilder {
private final LinkedHashMap<String, ConnectionController> connectionsMap;
private final LinkedHashMap<String, VaultController> vaultClientsMap;
private final LinkedHashMap<String, DetectController> detectClientsMap;
private final LinkedHashMap<String, VaultConfig> vaultConfigMap;
private final LinkedHashMap<String, ConnectionConfig> connectionConfigMap;
private Credentials skyflowCredentials;
private LogLevel logLevel;

public SkyflowClientBuilder() {
this.vaultClientsMap = new LinkedHashMap<>();
this.detectClientsMap = new LinkedHashMap<>();
this.vaultConfigMap = new LinkedHashMap<>();
this.connectionsMap = new LinkedHashMap<>();
this.connectionConfigMap = new LinkedHashMap<>();
Expand All @@ -139,8 +172,11 @@ public SkyflowClientBuilder addVaultConfig(VaultConfig vaultConfig) throws Skyfl
} else {
this.vaultConfigMap.put(vaultConfig.getVaultId(), vaultConfig);
this.vaultClientsMap.put(vaultConfig.getVaultId(), new VaultController(vaultConfig, this.skyflowCredentials));
this.detectClientsMap.put(vaultConfig.getVaultId(), new DetectController(vaultConfig, this.skyflowCredentials));
LogUtil.printInfoLog(Utils.parameterizedString(
InfoLogs.VAULT_CONTROLLER_INITIALIZED.getLog(), vaultConfig.getVaultId()));
LogUtil.printInfoLog(Utils.parameterizedString(
InfoLogs.DETECT_CONTROLLER_INITIALIZED.getLog(), vaultConfig.getVaultId()));
}
return this;
}
Expand Down Expand Up @@ -226,6 +262,9 @@ public SkyflowClientBuilder addSkyflowCredentials(Credentials credentials) throw
for (VaultController vault : this.vaultClientsMap.values()) {
vault.setCommonCredentials(this.skyflowCredentials);
}
for (DetectController detect : this.detectClientsMap.values()) {
detect.setCommonCredentials(this.skyflowCredentials);
}
for (ConnectionController connection : this.connectionsMap.values()) {
connection.setCommonCredentials(this.skyflowCredentials);
}
Expand Down
Loading