Skip to content

Commit b0d17e8

Browse files
SK-2071: Fern Integration and Detect Support (#179)
* SK-2071: Fern integration and detect support
1 parent f656d60 commit b0d17e8

File tree

343 files changed

+36937
-19180
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

343 files changed

+36937
-19180
lines changed

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
echo TEST_REUSABLE_TOKEN=${{ secrets.TEST_REUSABLE_TOKEN }} >> .env
4141
4242
- name: Build & Run tests with Maven
43-
run: mvn -B package -f pom.xml
43+
run: mvn -B package -f pom.xml -Dmaven.javadoc.skip=true
4444

4545
- name: Codecov
4646
uses: codecov/codecov-action@v2.1.0

pom.xml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,30 @@
4545
</properties>
4646

4747
<dependencies>
48+
<dependency>
49+
<groupId>com.squareup.okhttp3</groupId>
50+
<artifactId>okhttp</artifactId>
51+
<version>4.12.0</version>
52+
<scope>compile</scope>
53+
</dependency>
54+
<dependency>
55+
<groupId>com.fasterxml.jackson.core</groupId>
56+
<artifactId>jackson-databind</artifactId>
57+
<version>2.17.2</version>
58+
<scope>compile</scope>
59+
</dependency>
60+
<dependency>
61+
<groupId>com.fasterxml.jackson.datatype</groupId>
62+
<artifactId>jackson-datatype-jdk8</artifactId>
63+
<version>2.17.2</version>
64+
<scope>compile</scope>
65+
</dependency>
66+
<dependency>
67+
<groupId>com.fasterxml.jackson.datatype</groupId>
68+
<artifactId>jackson-datatype-jsr310</artifactId>
69+
<version>2.17.2</version>
70+
<scope>compile</scope>
71+
</dependency>
4872
<!-- newly added v2 dependencies -->
4973
<dependency>
5074
<groupId>io.github.cdimascio</groupId>
@@ -117,6 +141,12 @@
117141
<version>2.0.9</version>
118142
<scope>test</scope>
119143
</dependency>
144+
<dependency>
145+
<groupId>org.junit.jupiter</groupId>
146+
<artifactId>junit-jupiter</artifactId>
147+
<version>RELEASE</version>
148+
<scope>compile</scope>
149+
</dependency>
120150
</dependencies>
121151

122152
<build>
@@ -276,5 +306,4 @@
276306
</distributionManagement>
277307
</profile>
278308
</profiles>
279-
280309
</project>

src/main/java/com/skyflow/Skyflow.java

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.skyflow.utils.logger.LogUtil;
1515
import com.skyflow.utils.validations.Validations;
1616
import com.skyflow.vault.controller.ConnectionController;
17+
import com.skyflow.vault.controller.DetectController;
1718
import com.skyflow.vault.controller.VaultController;
1819

1920
import java.util.LinkedHashMap;
@@ -101,25 +102,57 @@ public VaultController vault(String vaultId) throws SkyflowException {
101102
return controller;
102103
}
103104

104-
public ConnectionController connection() {
105-
String connectionId = (String) this.builder.connectionsMap.keySet().toArray()[0];
105+
106+
public ConnectionController connection() throws SkyflowException {
107+
Object[] array = this.builder.connectionsMap.keySet().toArray();
108+
if (array.length < 1) {
109+
LogUtil.printErrorLog(ErrorLogs.CONNECTION_CONFIG_DOES_NOT_EXIST.getLog());
110+
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.ConnectionIdNotInConfigList.getMessage());
111+
}
112+
String connectionId = (String) array[0];
106113
return this.connection(connectionId);
107114
}
108115

109-
public ConnectionController connection(String connectionId) {
110-
return this.builder.connectionsMap.get(connectionId);
116+
public ConnectionController connection(String connectionId) throws SkyflowException {
117+
ConnectionController controller = this.builder.connectionsMap.get(connectionId);
118+
if (controller == null) {
119+
LogUtil.printErrorLog(ErrorLogs.CONNECTION_CONFIG_DOES_NOT_EXIST.getLog());
120+
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.ConnectionIdNotInConfigList.getMessage());
121+
}
122+
return controller;
123+
}
124+
125+
public DetectController detect() throws SkyflowException {
126+
Object[] array = this.builder.detectClientsMap.keySet().toArray();
127+
if (array.length < 1) {
128+
LogUtil.printErrorLog(ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog());
129+
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage());
130+
}
131+
String detectId = (String) array[0];
132+
return this.detect(detectId);
133+
}
134+
135+
public DetectController detect(String vaultId) throws SkyflowException {
136+
DetectController controller = this.builder.detectClientsMap.get(vaultId);
137+
if (controller == null) {
138+
LogUtil.printErrorLog(ErrorLogs.VAULT_CONFIG_DOES_NOT_EXIST.getLog());
139+
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.VaultIdNotInConfigList.getMessage());
140+
}
141+
return controller;
111142
}
112143

113144
public static final class SkyflowClientBuilder {
114145
private final LinkedHashMap<String, ConnectionController> connectionsMap;
115146
private final LinkedHashMap<String, VaultController> vaultClientsMap;
147+
private final LinkedHashMap<String, DetectController> detectClientsMap;
116148
private final LinkedHashMap<String, VaultConfig> vaultConfigMap;
117149
private final LinkedHashMap<String, ConnectionConfig> connectionConfigMap;
118150
private Credentials skyflowCredentials;
119151
private LogLevel logLevel;
120152

121153
public SkyflowClientBuilder() {
122154
this.vaultClientsMap = new LinkedHashMap<>();
155+
this.detectClientsMap = new LinkedHashMap<>();
123156
this.vaultConfigMap = new LinkedHashMap<>();
124157
this.connectionsMap = new LinkedHashMap<>();
125158
this.connectionConfigMap = new LinkedHashMap<>();
@@ -139,8 +172,11 @@ public SkyflowClientBuilder addVaultConfig(VaultConfig vaultConfig) throws Skyfl
139172
} else {
140173
this.vaultConfigMap.put(vaultConfig.getVaultId(), vaultConfig);
141174
this.vaultClientsMap.put(vaultConfig.getVaultId(), new VaultController(vaultConfig, this.skyflowCredentials));
175+
this.detectClientsMap.put(vaultConfig.getVaultId(), new DetectController(vaultConfig, this.skyflowCredentials));
142176
LogUtil.printInfoLog(Utils.parameterizedString(
143177
InfoLogs.VAULT_CONTROLLER_INITIALIZED.getLog(), vaultConfig.getVaultId()));
178+
LogUtil.printInfoLog(Utils.parameterizedString(
179+
InfoLogs.DETECT_CONTROLLER_INITIALIZED.getLog(), vaultConfig.getVaultId()));
144180
}
145181
return this;
146182
}
@@ -226,6 +262,9 @@ public SkyflowClientBuilder addSkyflowCredentials(Credentials credentials) throw
226262
for (VaultController vault : this.vaultClientsMap.values()) {
227263
vault.setCommonCredentials(this.skyflowCredentials);
228264
}
265+
for (DetectController detect : this.detectClientsMap.values()) {
266+
detect.setCommonCredentials(this.skyflowCredentials);
267+
}
229268
for (ConnectionController connection : this.connectionsMap.values()) {
230269
connection.setCommonCredentials(this.skyflowCredentials);
231270
}

0 commit comments

Comments
 (0)