diff --git a/.github/workflows/internal-release.yml b/.github/workflows/internal-release.yml
new file mode 100644
index 00000000..5d82fda1
--- /dev/null
+++ b/.github/workflows/internal-release.yml
@@ -0,0 +1,69 @@
+name: Publish package to the JFROG Artifactory
+on:
+ push:
+ tags: '*.*.*'
+ paths-ignore:
+ - "pom.xml"
+ - "*.md"
+ branches:
+ - release/*
+
+jobs:
+ publish:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ ref: ${{ github.ref_name }}
+ fetch-depth: 0
+
+ - name: Set up Jfrog artifactory
+ uses: actions/setup-java@v1
+ with:
+ java-version: '1.8'
+ distribution: 'adopt'
+ server-id: central
+ server-username: JFROG_USERNAME
+ server-password: JFROG_PASSWORD
+ gpg-private-key: ${{ secrets.JFROG_GPG_KEY }} # Value of the GPG private key to import
+ gpg-passphrase: JFROG_GPG_PASSPHRASE # env variable for GPG private key passphrase
+
+ - name: Get Previous tag
+ id: previoustag
+ uses: WyriHaximus/github-action-get-previous-tag@v1
+ with:
+ fallback: 1.0.0
+
+ - name: Bump Version
+ run: |
+ chmod +x ./scripts/bump_version.sh
+ ./scripts/bump_version.sh "${{ steps.previoustag.outputs.tag }}" "$(git rev-parse --short "$GITHUB_SHA")"
+
+ - name: Commit changes
+ run: |
+ git config user.name ${{ github.actor }}
+ git config user.email ${{ github.actor }}@users.noreply.github.com
+ git add pom.xml
+ git commit -m "[AUTOMATED] Private Release ${{ steps.previoustag.outputs.tag }}-dev.$(git rev-parse --short $GITHUB_SHA)"
+ git push origin -f
+
+ - name: Create env
+ id: create-env
+ run: |
+ touch .env
+ echo SKYFLOW_CREDENTIALS=${{ secrets.SKYFLOW_CREDENTIALS }} >> .env
+ echo TEST_EXPIRED_TOKEN=${{ secrets.TEST_EXPIRED_TOKEN }} >> .env
+
+ - name: Create credentials json
+ id: create-json
+ uses: jsdaniell/create-json@1.1.2
+ with:
+ name: "credentials.json"
+ json: ${{ secrets.TEST_CREDENTIALS_FILE_STRING }}
+
+ - name: Publish package to Jfrog Artifactory
+ run: mvn clean deploy -P jfrog
+ env:
+ JFROG_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
+ JFROG_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
+ JFROG_GPG_PASSPHRASE: ${{ secrets.JFROG_GPG_PASSPHRASE }}
\ No newline at end of file
diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml
index c3a33dc8..a2d39562 100644
--- a/.github/workflows/pr.yml
+++ b/.github/workflows/pr.yml
@@ -1,6 +1,6 @@
name: PR CI Checks
-on: [ pull_request ]
+on: [pull_request]
jobs:
check-commit-message:
@@ -11,18 +11,18 @@ jobs:
uses: gsactions/commit-message-checker@v1
with:
pattern: '\[?[A-Z]{1,5}-[1-9][0-9]*.+$'
- flags: 'gm'
- excludeDescription: 'true'
- checkAllCommitMessages: 'true'
+ flags: "gm"
+ excludeDescription: "true"
+ checkAllCommitMessages: "true"
accessToken: ${{ secrets.PAT_ACTIONS }}
- error: 'One of your your commit messages is not matching the format with JIRA ID Ex: ( SDK-123 commit message )'
+ error: "One of your your commit messages is not matching the format with JIRA ID Ex: ( SDK-123 commit message )"
Test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
- java-version: '1.8'
+ java-version: "1.8"
- name: create-json
id: create-json
@@ -31,6 +31,13 @@ jobs:
name: "credentials.json"
json: ${{ secrets.TEST_CREDENTIALS_FILE_STRING }}
+ - name: create env
+ id: create-env
+ run: |
+ touch .env
+ echo SKYFLOW_CREDENTIALS=${{ secrets.SKYFLOW_CREDENTIALS }} >> .env
+ echo TEST_EXPIRED_TOKEN=${{ secrets.TEST_EXPIRED_TOKEN }} >> .env
+
- name: Build & Run tests with Maven
run: mvn -B package -DTEST_EXPIRED_TOKEN=${{ secrets.TEST_EXPIRED_TOKEN }} -DTEST_DATA_CREDENTIALS_FILE=${{ secrets.TEST_DATA_CREDENTIALS_FILE }} -f pom.xml
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 02c7b612..f30dda26 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -26,7 +26,7 @@ jobs:
json: ${{ secrets.TEST_CREDENTIALS_FILE_STRING }}
- name: Publish package to Maven Central
- run: mvn --batch-mode deploy
+ run: mvn --batch-mode deploy -P maven-central
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
diff --git a/pom.xml b/pom.xml
index 1b5060b0..08afca20 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,63 +32,77 @@
- 7
- 7
+ 8
+ 8
+ 4.12.0
+ 2.10.1
+ 1.9.0
+ UTF-8
+ 4.12.0
+ 4.13.2
+ 2.3.1
+ 1.3.5
-
-
- ossrh
- https://s01.oss.sonatype.org/content/repositories/snapshots
-
-
- ossrh
- https://s01.oss.sonatype.org/service/local/staging/deploy/maven2
-
-
-
+
- com.fasterxml.jackson.core
- jackson-core
- 2.13.0
+ io.github.cdimascio
+ dotenv-java
+ 2.2.0
- com.googlecode.json-simple
- json-simple
- 1.1.1
+ com.google.code.findbugs
+ jsr305
+ 3.0.2
- io.jsonwebtoken
- jjwt
- 0.9.1
+ io.gsonfire
+ gson-fire
+ ${gson-fire-version}
+
+
+ com.google.code.gson
+ gson
+ ${gson-version}
+
+ com.squareup.okhttp3
+ okhttp
+ ${okhttp-version}
+
+
+ com.squareup.okhttp3
+ logging-interceptor
+ ${okhttp-version}
+
+
commons-codec
commons-codec
1.15
- javax.xml.bind
- jaxb-api
- 2.3.1
+ io.jsonwebtoken
+ jjwt
+ 0.12.6
- io.jsonwebtoken
- jjwt-impl
- 0.11.2
- runtime
+ jakarta.annotation
+ jakarta.annotation-api
+ ${jakarta-annotation-version}
+ provided
- io.jsonwebtoken
- jjwt-jackson
- 0.11.2
- runtime
+ javax.xml.bind
+ jaxb-api
+ ${javax-xml-bind-version}
+
junit
junit
- 4.13.2
+ ${junit-version}
test
@@ -107,17 +121,17 @@
-
- org.sonatype.plugins
- nexus-staging-maven-plugin
- 1.6.7
- true
-
- ossrh
- https://s01.oss.sonatype.org/
- true
-
-
+
+
+
+
+
+
+
+
+
+
+
org.apache.maven.plugins
maven-source-plugin
@@ -135,6 +149,14 @@
org.apache.maven.plugins
maven-javadoc-plugin
3.2.0
+
+
+ :com.skyflow.generated.rest
+ :com.skyflow.generated.rest.api
+ :com.skyflow.generated.rest.auth
+ :com.skyflow.generated.rest.models
+
+
attach-javadocs
@@ -153,11 +175,6 @@
org.jacoco
jacoco-maven-plugin
0.8.7
-
-
- **/example/*
-
-
prepare-agent
@@ -173,6 +190,26 @@
+
+
+ **/example/*
+ **/generated/**
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.3.0
+
+
+
+ test-jar
+
+
+
+
+
org.apache.maven.plugins
@@ -197,5 +234,43 @@
+
+
+ maven_central
+ Maven Central
+ https://repo.maven.apache.org/maven2/
+
+
+
+
+
+ maven-central
+
+
+ ossrh
+ https://s01.oss.sonatype.org/service/local/staging/deploy/maven2
+
+
+ ossrh
+ https://s01.oss.sonatype.org/content/repositories/snapshots
+
+
+
+
+ jfrog
+
+
+ central
+ prekarilabs.jfrog.io-releases
+ https://prekarilabs.jfrog.io/artifactory/skyflow-java
+
+
+ snapshots
+ prekarilabs.jfrog.io-snapshots
+ https://prekarilabs.jfrog.io/artifactory/skyflow-java
+
+
+
+
-
\ No newline at end of file
+
diff --git a/samples/src/main/java/com/example/BearerTokenGenerationUsingThreadsExample.java b/samples/src/main/java/com/example/BearerTokenGenerationUsingThreadsExample.java
deleted file mode 100644
index 718aa21e..00000000
--- a/samples/src/main/java/com/example/BearerTokenGenerationUsingThreadsExample.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- Copyright (c) 2022 Skyflow, Inc.
-*/
-package com.example;
-
-import com.skyflow.errors.SkyflowException;
-import com.skyflow.serviceaccount.util.BearerToken;
-
-import java.io.File;
-
-public class BearerTokenGenerationUsingThreadsExample {
- public static void main(String args[]) {
-
- String bearerToken = null;
-
- // Generate BearerToken with context by specifying credentials.json file path
- try {
- String filePath = "";
- final BearerToken token = new BearerToken.BearerTokenBuilder()
- .setCredentials(new File(filePath))
- .setCtx("abc")
- .build();
-
- Thread t = new Thread(new Runnable() {
- @Override
- public void run() {
-
- for (int i = 0; i < 5; i++) {
- try {
- System.out.println(token.getBearerToken());
- } catch (SkyflowException e) {
- Thread.currentThread().interrupt();
- throw new RuntimeException(e);
-
- }
-
- }
- }
- });
-
- t.start();
-
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- }
-}
diff --git a/samples/src/main/java/com/example/DeleteExample.java b/samples/src/main/java/com/example/DeleteExample.java
deleted file mode 100644
index 9ee0fc28..00000000
--- a/samples/src/main/java/com/example/DeleteExample.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- Copyright (c) 2023 Skyflow, Inc.
-*/
-package com.example;
-
-import com.skyflow.entities.ResponseToken;
-import com.skyflow.entities.SkyflowConfiguration;
-import com.skyflow.entities.TokenProvider;
-import com.skyflow.errors.SkyflowException;
-import com.skyflow.serviceaccount.util.Token;
-import com.skyflow.vault.Skyflow;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-
-
-public class DeleteExample {
-
- public static void main(String[] args) {
-
- try {
- SkyflowConfiguration config = new SkyflowConfiguration(
- "",
- "",
- new DemoTokenProvider()
- );
- Skyflow skyflowClient = Skyflow.init(config);
- JSONObject records = new JSONObject();
- JSONArray recordsArray = new JSONArray();
-
- JSONObject record = new JSONObject();
-
- record.put("id", "");
- record.put("table", "");
- recordsArray.add(record);
- JSONObject record2 = new JSONObject();
-
- record2.put("id", "");
- record2.put("table", "");
- recordsArray.add(record2);
-
- records.put("records", recordsArray);
-
- JSONObject response = skyflowClient.delete(records);
- System.out.println(response);
- } catch (SkyflowException e) {
- e.printStackTrace();
- System.out.println("error" + e.getData());
- }
-
- }
-
- static class DemoTokenProvider implements TokenProvider {
-
- private String bearerToken = null;
-
- @Override
- public String getBearerToken() throws Exception {
- ResponseToken response = null;
- try {
- String filePath = "";
- if (Token.isExpired(bearerToken)) {
- response = Token.generateBearerToken(filePath);
- bearerToken = response.getAccessToken();
- }
- } catch (SkyflowException e) {
- e.printStackTrace();
- }
-
- return bearerToken;
- }
- }
-}
diff --git a/samples/src/main/java/com/example/DetokenizeExample.java b/samples/src/main/java/com/example/DetokenizeExample.java
deleted file mode 100644
index acc29287..00000000
--- a/samples/src/main/java/com/example/DetokenizeExample.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- Copyright (c) 2022 Skyflow, Inc.
-*/
-package com.example;
-
-import com.skyflow.entities.RedactionType;
-import com.skyflow.entities.ResponseToken;
-import com.skyflow.entities.SkyflowConfiguration;
-import com.skyflow.entities.TokenProvider;
-import com.skyflow.errors.SkyflowException;
-import com.skyflow.serviceaccount.util.Token;
-import com.skyflow.vault.Skyflow;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-
-
-public class DetokenizeExample {
-
- public static void main(String[] args) {
-
- try {
- SkyflowConfiguration config = new SkyflowConfiguration(
- "",
- "",
- new DemoTokenProvider()
- );
- Skyflow skyflowClient = Skyflow.init(config);
- JSONObject records = new JSONObject();
- JSONArray recordsArray = new JSONArray();
-
- JSONObject record1 = new JSONObject();
- record1.put("token", "");
- record1.put("redaction", RedactionType.MASKED.toString());
-
- JSONObject record2 = new JSONObject();
- record2.put("token", ""); // default Redaction "PLAIN_TEXT" will be applied for record2
-
- recordsArray.add(record1);
- recordsArray.add(record2);
- records.put("records", recordsArray);
-
- JSONObject response = skyflowClient.detokenize(records);
- System.out.println(response);
- } catch (SkyflowException e) {
- e.printStackTrace();
- System.out.println(e.getData());
- }
-
- }
-
- static class DemoTokenProvider implements TokenProvider {
-
- private String bearerToken = null;
-
- @Override
- public String getBearerToken() throws Exception {
- ResponseToken response = null;
- try {
- String filePath = "";
- if(Token.isExpired(bearerToken)) {
- response = Token.generateBearerToken(filePath);
- bearerToken = response.getAccessToken();
- }
- } catch (SkyflowException e) {
- e.printStackTrace();
- }
-
- return bearerToken;
- }
- }
-}
diff --git a/samples/src/main/java/com/example/GetByIdExample.java b/samples/src/main/java/com/example/GetByIdExample.java
deleted file mode 100644
index b3576fb3..00000000
--- a/samples/src/main/java/com/example/GetByIdExample.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- Copyright (c) 2022 Skyflow, Inc.
-*/
-package com.example;
-
-import com.skyflow.entities.RedactionType;
-import com.skyflow.entities.ResponseToken;
-import com.skyflow.entities.SkyflowConfiguration;
-import com.skyflow.entities.TokenProvider;
-import com.skyflow.errors.SkyflowException;
-import com.skyflow.serviceaccount.util.Token;
-import com.skyflow.vault.Skyflow;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-
-
-public class GetByIdExample {
-
- public static void main(String[] args) {
-
- try {
- SkyflowConfiguration config = new SkyflowConfiguration("",
- "", new DemoTokenProvider());
- Skyflow skyflowClient = Skyflow.init(config);
- JSONObject records = new JSONObject();
- JSONArray recordsArray = new JSONArray();
-
- JSONObject record = new JSONObject();
- JSONArray ids = new JSONArray();
- ids.add("");
-
- record.put("ids", ids);
- record.put("table", "");
- record.put("redaction", RedactionType.PLAIN_TEXT.toString());
- recordsArray.add(record);
- records.put("records", recordsArray);
-
- JSONObject response = skyflowClient.getById(records);
- } catch (SkyflowException e) {
- e.printStackTrace();
- System.out.println(e.getData());
- }
-
- }
-
- static class DemoTokenProvider implements TokenProvider {
-
- private String bearerToken = null;
-
- @Override
- public String getBearerToken() throws Exception {
- ResponseToken response = null;
- try {
- String filePath = "";
- if(Token.isExpired(bearerToken)) {
- response = Token.generateBearerToken(filePath);
- bearerToken = response.getAccessToken();
- }
- } catch (SkyflowException e) {
- e.printStackTrace();
- }
-
- return bearerToken;
- }
- }
-}
diff --git a/samples/src/main/java/com/example/GetExample.java b/samples/src/main/java/com/example/GetExample.java
deleted file mode 100644
index 76cf826a..00000000
--- a/samples/src/main/java/com/example/GetExample.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package com.example;
-
-import com.skyflow.entities.RedactionType;
-import com.skyflow.entities.ResponseToken;
-import com.skyflow.entities.SkyflowConfiguration;
-import com.skyflow.entities.TokenProvider;
-import com.skyflow.errors.SkyflowException;
-import com.skyflow.serviceaccount.util.Token;
-import com.skyflow.vault.Skyflow;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-
-public class GetExample {
- public static void main(String[] args) {
-
- try {
- SkyflowConfiguration config = new SkyflowConfiguration("",
- "", new DemoTokenProvider());
- Skyflow skyflowClient = Skyflow.init(config);
-
- JSONObject records = new JSONObject();
- JSONArray recordsArray = new JSONArray();
-
- JSONObject firstRecord = new JSONObject();
-
- JSONArray ids = new JSONArray();
- ids.add("");
-
- firstRecord.put("ids", ids);
- firstRecord.put("table", "");
- firstRecord.put("redaction", RedactionType.PLAIN_TEXT.toString());
-
- JSONObject secondRecord = new JSONObject();
-
- JSONArray valuesArray = new JSONArray();
- valuesArray.add("");
-
- secondRecord.put("table", "");
- secondRecord.put("columnName", "");
- secondRecord.put("columnValues", valuesArray);
- secondRecord.put("redaction", RedactionType.PLAIN_TEXT.toString());
-
- recordsArray.add(firstRecord);
- recordsArray.add(secondRecord);
- records.put("records", recordsArray);
-
- JSONObject response = skyflowClient.get(records);
- } catch (SkyflowException e) {
- e.printStackTrace();
- System.out.println(e.getData());
- }
-
- }
-
- static class DemoTokenProvider implements TokenProvider {
- private String bearerToken = null;
-
- @Override
- public String getBearerToken() throws Exception {
- ResponseToken response = null;
- try {
- String filePath = "";
- if (Token.isExpired(bearerToken)) {
- response = Token.generateBearerToken(filePath);
- bearerToken = response.getAccessToken();
- }
- } catch (SkyflowException e) {
- e.printStackTrace();
- }
-
- return bearerToken;
- }
- }
-}
\ No newline at end of file
diff --git a/samples/src/main/java/com/example/InsertBulkExample.java b/samples/src/main/java/com/example/InsertBulkExample.java
deleted file mode 100644
index bb191c7c..00000000
--- a/samples/src/main/java/com/example/InsertBulkExample.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package com.example;
-
-import com.skyflow.entities.*;
-import com.skyflow.errors.SkyflowException;
-import com.skyflow.serviceaccount.util.Token;
-import com.skyflow.vault.Skyflow;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-public class InsertBulkExample {
-
- public static void main(String[] args) {
-
- try {
- SkyflowConfiguration config = new SkyflowConfiguration("",
- "", new DemoTokenProvider());
- Skyflow skyflowClient = Skyflow.init(config);
- JSONObject records = new JSONObject();
- JSONArray recordsArray = new JSONArray();
-
- JSONObject record = new JSONObject();
- record.put("table", "");
-
- JSONObject fields = new JSONObject();
- fields.put("", "");
- record.put("fields", fields);
- recordsArray.add(record);
- records.put("records", recordsArray);
-
- JSONObject res = skyflowClient.insertBulk(records);
-
- System.out.println(res);
- } catch (SkyflowException e) {
- e.printStackTrace();
- }
-
- }
-
- static class DemoTokenProvider implements TokenProvider {
-
- private String bearerToken = null;
-
- @Override
- public String getBearerToken() throws Exception {
- ResponseToken response = null;
- try {
- String filePath = "";
- if(Token.isExpired(bearerToken)) {
- response = Token.generateBearerToken(filePath);
- bearerToken = response.getAccessToken();
- }
- } catch (SkyflowException e) {
- e.printStackTrace();
- }
-
- return bearerToken;
- }
- }
-}
\ No newline at end of file
diff --git a/samples/src/main/java/com/example/InsertBulkWithUpsertExample.java b/samples/src/main/java/com/example/InsertBulkWithUpsertExample.java
deleted file mode 100644
index 57272e15..00000000
--- a/samples/src/main/java/com/example/InsertBulkWithUpsertExample.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package com.example;
-
-import com.skyflow.entities.*;
-import com.skyflow.errors.SkyflowException;
-import com.skyflow.serviceaccount.util.Token;
-import com.skyflow.vault.Skyflow;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-
-
-public class InsertBulkWithUpsertExample {
-
- public static void main(String[] args) {
-
- try {
- SkyflowConfiguration config = new SkyflowConfiguration("",
- "", new DemoTokenProvider());
- Skyflow skyflowClient = Skyflow.init(config);
-
- JSONObject records = new JSONObject();
- JSONArray recordsArray = new JSONArray();
-
- JSONObject record = new JSONObject();
- record.put("table", "");
-
- JSONObject fields = new JSONObject();
- fields.put("");
-
- record.put("fields", fields);
- recordsArray.add(record);
-
- records.put("records", recordsArray);
-
- // create an upsert option and insert in UpsertOptions array.
- UpsertOption[] upsertOptions = new UpsertOption[1];
- upsertOptions[0] = new UpsertOption("", "");
-
- // pass upsert options in insert method options.
- InsertBulkOptions insertOptions = new InsertBulkOptions(true, upsertOptions);
- JSONObject res = skyflowClient.insertBulk(records, insertOptions);
-
- System.out.println(res);
- } catch (SkyflowException e) {
- e.printStackTrace();
- }
-
- }
-
- static class DemoTokenProvider implements TokenProvider {
-
- private String bearerToken = null;
-
- @Override
- public String getBearerToken() throws Exception {
- ResponseToken response = null;
- try {
- String filePath = "";
- if (Token.isExpired(bearerToken)) {
- response = Token.generateBearerToken(filePath);
- bearerToken = response.getAccessToken();
- }
- } catch (SkyflowException e) {
- e.printStackTrace();
- }
-
- return bearerToken;
- }
- }
-}
diff --git a/samples/src/main/java/com/example/InsertExample.java b/samples/src/main/java/com/example/InsertExample.java
deleted file mode 100644
index faada157..00000000
--- a/samples/src/main/java/com/example/InsertExample.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- Copyright (c) 2022 Skyflow, Inc.
-*/
-package com.example;
-
-import com.skyflow.entities.InsertOptions;
-import com.skyflow.entities.ResponseToken;
-import com.skyflow.entities.SkyflowConfiguration;
-import com.skyflow.entities.TokenProvider;
-import com.skyflow.errors.SkyflowException;
-import com.skyflow.serviceaccount.util.Token;
-import com.skyflow.vault.Skyflow;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-
-public class InsertExample {
-
- public static void main(String[] args) {
-
- try {
- SkyflowConfiguration config = new SkyflowConfiguration("",
- "", new DemoTokenProvider());
- Skyflow skyflowClient = Skyflow.init(config);
- JSONObject records = new JSONObject();
- JSONArray recordsArray = new JSONArray();
-
- JSONObject record = new JSONObject();
- record.put("table", "");
-
- JSONObject fields = new JSONObject();
- fields.put("", "");
- record.put("fields", fields);
- recordsArray.add(record);
- records.put("records", recordsArray);
-
- InsertOptions insertOptions = new InsertOptions();
- JSONObject res = skyflowClient.insert(records, insertOptions);
-
- System.out.println(res);
- } catch (SkyflowException e) {
- e.printStackTrace();
- }
-
- }
-
- static class DemoTokenProvider implements TokenProvider {
-
- private String bearerToken = null;
-
- @Override
- public String getBearerToken() throws Exception {
- ResponseToken response = null;
- try {
- String filePath = "";
- if(Token.isExpired(bearerToken)) {
- response = Token.generateBearerToken(filePath);
- bearerToken = response.getAccessToken();
- }
- } catch (SkyflowException e) {
- e.printStackTrace();
- }
-
- return bearerToken;
- }
- }
-}
diff --git a/samples/src/main/java/com/example/InsertWithContinueOnErrorExample.java b/samples/src/main/java/com/example/InsertWithContinueOnErrorExample.java
deleted file mode 100644
index 21e7df2f..00000000
--- a/samples/src/main/java/com/example/InsertWithContinueOnErrorExample.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- Copyright (c) 2024 Skyflow, Inc.
-*/
-import com.skyflow.entities.*;
-import com.skyflow.errors.SkyflowException;
-import com.skyflow.serviceaccount.util.Token;
-import com.skyflow.vault.Skyflow;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-
-public class InsertWithContinueOnErrorExample {
-
- public static void main(String[] args) {
-
- try {
- SkyflowConfiguration config = new SkyflowConfiguration(
- "",
- "",
- new DemoTokenProvider());
- Skyflow skyflowClient = Skyflow.init(config);
- JSONObject records = new JSONObject();
- JSONArray recordsArray = new JSONArray();
-
- JSONObject record1 = new JSONObject();
- record1.put("table", "");
- JSONObject fields = new JSONObject();
- fields.put("", "");
- record1.put("fields", fields);
-
- JSONObject record2 = new JSONObject();
- record2.put("table", "");
- JSONObject fields2 = new JSONObject();
- fields2.put("", "");
- record2.put("fields", fields2);
-
- recordsArray.add(record1);
- recordsArray.add(record2);
- records.put("records", recordsArray);
-
- InsertOptions insertOptions = new InsertOptions(true,true);
- JSONObject insertResponse = skyflowClient.insert(records, insertOptions);
- System.out.println(insertResponse);
- } catch (SkyflowException e) {
- System.out.println(e);
- e.printStackTrace();
- }
- }
-
- static class DemoTokenProvider implements TokenProvider {
-
- private String bearerToken = null;
-
- @Override
- public String getBearerToken() throws Exception {
- ResponseToken response = null;
- try {
- String filePath = "";
- if (Token.isExpired(bearerToken)) {
- response = Token.generateBearerToken(filePath);
- bearerToken = response.getAccessToken();
- }
- } catch (SkyflowException e) {
- e.printStackTrace();
- }
-
- return bearerToken;
- }
- }
-}
diff --git a/samples/src/main/java/com/example/InsertWithUpsertExample.java b/samples/src/main/java/com/example/InsertWithUpsertExample.java
deleted file mode 100644
index 3ae13357..00000000
--- a/samples/src/main/java/com/example/InsertWithUpsertExample.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- Copyright (c) 2022 Skyflow, Inc.
-*/
-package com.example;
-
-import com.skyflow.entities.*;
-import com.skyflow.errors.SkyflowException;
-import com.skyflow.serviceaccount.util.Token;
-import com.skyflow.vault.Skyflow;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-
-public class InsertWithUpsertExample {
-
- public static void main(String[] args) {
-
- try {
- SkyflowConfiguration config = new SkyflowConfiguration("",
- "", new DemoTokenProvider());
- Skyflow skyflowClient = Skyflow.init(config);
-
- JSONObject records = new JSONObject();
- JSONArray recordsArray = new JSONArray();
-
- JSONObject record = new JSONObject();
- record.put("table", "");
-
- JSONObject fields = new JSONObject();
- fields.put("");
-
- record.put("fields", fields);
- recordsArray.add(record);
-
- records.put("records", recordsArray);
-
- // create an upsert option and insert in UpsertOptions array.
- UpsertOption[] upsertOptions = new UpsertOption[1];
- upsertOptions[0] = new UpsertOption("", "");
-
- // pass upsert options in insert method options.
- InsertOptions insertOptions = new InsertOptions(true, upsertOptions);
- JSONObject res = skyflowClient.insert(records, insertOptions);
-
- System.out.println(res);
- } catch (SkyflowException e) {
- e.printStackTrace();
- }
-
- }
-
- static class DemoTokenProvider implements TokenProvider {
-
- private String bearerToken = null;
-
- @Override
- public String getBearerToken() throws Exception {
- ResponseToken response = null;
- try {
- String filePath = "";
- if (Token.isExpired(bearerToken)) {
- response = Token.generateBearerToken(filePath);
- bearerToken = response.getAccessToken();
- }
- } catch (SkyflowException e) {
- e.printStackTrace();
- }
-
- return bearerToken;
- }
- }
-}
diff --git a/samples/src/main/java/com/example/InvokeConnectionExample.java b/samples/src/main/java/com/example/InvokeConnectionExample.java
deleted file mode 100644
index 8f5eac28..00000000
--- a/samples/src/main/java/com/example/InvokeConnectionExample.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- Copyright (c) 2022 Skyflow, Inc.
-*/
-import com.skyflow.entities.*;
-import com.skyflow.vault.Skyflow;
-import com.skyflow.errors.SkyflowException;
-import com.skyflow.serviceaccount.util.Token;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-
-public class InvokeConnectionExample {
- static class DemoTokenProvider implements TokenProvider {
-
- private String bearerToken = null;
-
- @Override
- public String getBearerToken() throws Exception {
- ResponseToken response = null;
- try {
- String filePath = "";
- if(Token.isExpired(bearerToken)) {
- response = Token.generateBearerToken(filePath);
- bearerToken = response.getAccessToken();
- }
- } catch (SkyflowException e) {
- e.printStackTrace();
- }
-
- return bearerToken;
- }
- }
-
- public static void main(String[] args) {
- try {
- SkyflowConfiguration config = new SkyflowConfiguration("",
- "", new DemoTokenProvider());
- Skyflow skyflowClient = Skyflow.init(config);
- JSONObject testConfig = new JSONObject();
- testConfig.put("connectionURL", "");
- testConfig.put("methodName", RequestMethod.POST);
-
- JSONObject pathParamsJson = new JSONObject();
- pathParamsJson.put("", "");
- testConfig.put("pathParams", pathParamsJson);
-
- JSONObject queryParamsJson = new JSONObject();
- queryParamsJson.put("", "");
- testConfig.put("queryParams", queryParamsJson);
-
- JSONObject requestHeadersJson = new JSONObject();
- requestHeadersJson.put("", "");
- testConfig.put("requestHeader", requestHeadersJson);
-
- JSONObject requestBodyJson = new JSONObject();
- requestBodyJson.put("", "");
- testConfig.put("requestBody", requestBodyJson);
-
- JSONObject gatewayResponse = skyflowClient.invokeConnection(testConfig);
- System.out.println(gatewayResponse);
-
- } catch (SkyflowException exception) {
- exception.printStackTrace();
- }
- }
-}
\ No newline at end of file
diff --git a/samples/src/main/java/com/example/QueryExample.java b/samples/src/main/java/com/example/QueryExample.java
deleted file mode 100644
index 31d577c7..00000000
--- a/samples/src/main/java/com/example/QueryExample.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- Copyright (c) 2022 Skyflow, Inc.
-*/
-package com.example;
-
-import com.skyflow.entities.ResponseToken;
-import com.skyflow.entities.SkyflowConfiguration;
-import com.skyflow.entities.TokenProvider;
-import com.skyflow.errors.SkyflowException;
-import com.skyflow.serviceaccount.util.Token;
-import com.skyflow.vault.Skyflow;
-import org.json.simple.JSONObject;
-
-public class QueryExample {
-
- public static void main(String[] args) {
-
- try {
- SkyflowConfiguration config = new SkyflowConfiguration("",
- "", new DemoTokenProvider());
- Skyflow skyflowClient = Skyflow.init(config);
-
- JSONObject queryInput = new JSONObject();
-
- queryInput.put("query", "");
-
- JSONObject res = skyflowClient.query(queryInput);
-
- System.out.println(res);
- } catch (SkyflowException e) {
- System.out.println(e.getData());
- e.printStackTrace();
- }
-
- }
-
- static class DemoTokenProvider implements TokenProvider {
-
- private String bearerToken = null;
-
- @Override
- public String getBearerToken() throws Exception {
- ResponseToken response = null;
- try {
- String filePath = "";
- if(Token.isExpired(bearerToken)) {
- response = Token.generateBearerToken(filePath);
- bearerToken = response.getAccessToken();
- }
- } catch (SkyflowException e) {
- e.printStackTrace();
- }
-
- return bearerToken;
- }
- }
-}
\ No newline at end of file
diff --git a/samples/src/main/java/com/example/ScopedTokenGenerationExample.java b/samples/src/main/java/com/example/ScopedTokenGenerationExample.java
deleted file mode 100644
index ed4dda5f..00000000
--- a/samples/src/main/java/com/example/ScopedTokenGenerationExample.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- Copyright (c) 2022 Skyflow, Inc.
-*/
-package com.example;
-
-import com.skyflow.serviceaccount.util.BearerToken;
-import java.io.File;
-
-public class ScopedTokenGenerationExample {
- public static void main(String args[]) {
-
- String scopedToken = null;
-
- // Generate Scoped Token by specifying credentials.json file path
- try {
- String filePath = "";
- BearerToken token = new BearerToken.BearerTokenBuilder()
- .setCredentials(new File(filePath))
- .setRoles(new String[]{"roleID"})
- .build();
-
- scopedToken = token.getBearerToken();
- System.out.println(scopedToken);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/samples/src/main/java/com/example/TokenGenerationExample.java b/samples/src/main/java/com/example/TokenGenerationExample.java
deleted file mode 100644
index b4de6b87..00000000
--- a/samples/src/main/java/com/example/TokenGenerationExample.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- Copyright (c) 2022 Skyflow, Inc.
-*/
-package com.example;
-
-import com.skyflow.entities.ResponseToken;
-import com.skyflow.errors.SkyflowException;
-import com.skyflow.serviceaccount.util.Token;
-
-public class TokenGenerationExample {
- public static void main(String args[]) {
-
- String bearerToken = null;
-
- // Generate BearerToken by specifying credentials.json file path
- try {
- String filePath = "";
- if(Token.isExpired(bearerToken)) {
- ResponseToken res = Token.generateBearerToken(filePath);
- bearerToken = res.getAccessToken();
- }
- System.out.println(bearerToken);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- // Generate BearerToken by specifying credentials.json as string
- try {
- String fileContents = "";
- if(Token.isExpired(bearerToken)) {
- ResponseToken res = Token.generateBearerTokenFromCreds(fileContents);
- bearerToken = res.getAccessToken();
- }
- System.out.println(bearerToken);
- } catch (SkyflowException e) {
- e.printStackTrace();
- }
-
- }
-}
diff --git a/samples/src/main/java/com/example/UpdateExample.java b/samples/src/main/java/com/example/UpdateExample.java
deleted file mode 100644
index 5e67d7ec..00000000
--- a/samples/src/main/java/com/example/UpdateExample.java
+++ /dev/null
@@ -1,59 +0,0 @@
-import com.skyflow.entities.*;
-import com.skyflow.errors.SkyflowException;
-import com.skyflow.serviceaccount.util.Token;
-import com.skyflow.vault.Skyflow;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-
-public class UpdateExample {
- public static void main(String[] args) {
-
- try {
- SkyflowConfiguration config = new SkyflowConfiguration("",
- "", new DemoTokenProvider());
- Skyflow skyflowClient = Skyflow.init(config);
-
- JSONObject records = new JSONObject();
- JSONArray recordsArray = new JSONArray();
- JSONObject record = new JSONObject();
-
- record.put("table", "");
- record.put("id", "");
-
- JSONObject fields = new JSONObject();
- fields.put("", "");
- record.put("fields", fields);
- recordsArray.add(record);
- records.put("records", recordsArray);
-
- UpdateOptions updateOptions = new UpdateOptions(true);
- JSONObject res = skyflowClient.update(records, updateOptions);
-
- }
- catch (SkyflowException e) {
- System.out.println(e.getData());
- e.printStackTrace();
- }
- }
- static class DemoTokenProvider implements TokenProvider {
-
- private String bearerToken = null;
-
- @Override
- public String getBearerToken() throws Exception {
- ResponseToken response = null;
- try {
- String filePath = "";
- if(Token.isExpired(bearerToken)) {
- response = Token.generateBearerToken(filePath);
- bearerToken = response.getAccessToken();
- }
- } catch (SkyflowException e) {
- e.printStackTrace();
- }
-
- return bearerToken;
- }
- }
-}
-
diff --git a/samples/src/main/java/com/example/connection/InvokeConnectionExample.java b/samples/src/main/java/com/example/connection/InvokeConnectionExample.java
new file mode 100644
index 00000000..431fd79d
--- /dev/null
+++ b/samples/src/main/java/com/example/connection/InvokeConnectionExample.java
@@ -0,0 +1,68 @@
+package com.example.connection;
+
+import com.skyflow.Skyflow;
+import com.skyflow.config.ConnectionConfig;
+import com.skyflow.config.Credentials;
+import com.skyflow.enums.LogLevel;
+import com.skyflow.enums.RequestMethod;
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.vault.connection.InvokeConnectionRequest;
+import com.skyflow.vault.connection.InvokeConnectionResponse;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class InvokeConnectionExample {
+ public static void main(String[] args) throws SkyflowException {
+ Credentials credentials = new Credentials();
+ credentials.setPath("");
+
+ ConnectionConfig connectionConfig1 = new ConnectionConfig();
+ connectionConfig1.setConnectionId("");
+ connectionConfig1.setConnectionUrl("");
+ connectionConfig1.setCredentials(credentials);
+
+ ConnectionConfig connectionConfig2 = new ConnectionConfig();
+ connectionConfig2.setConnectionId("");
+ connectionConfig2.setConnectionUrl("");
+
+ Credentials skyflowCredentials = new Credentials();
+ skyflowCredentials.setPath("");
+
+ Skyflow skyflowClient = Skyflow.builder()
+ .setLogLevel(LogLevel.DEBUG)
+ .addConnectionConfig(connectionConfig1)
+ .addConnectionConfig(connectionConfig2)
+ .addSkyflowCredentials(skyflowCredentials)
+ .build();
+
+ Map requestBody = new HashMap<>();
+ requestBody.put("", "");
+ requestBody.put("", "");
+ Map requestHeaders = new HashMap<>();
+ requestHeaders.put("", "");
+ requestHeaders.put("", "");
+ InvokeConnectionRequest invokeConnectionRequest1 = InvokeConnectionRequest.builder()
+ .methodName(RequestMethod.POST)
+ .requestBody(requestBody)
+ .requestHeaders(requestHeaders)
+ .build();
+ InvokeConnectionResponse invokeConnectionResponse1 = skyflowClient.connection().invoke(invokeConnectionRequest1);
+ System.out.println(invokeConnectionResponse1);
+
+ Map pathParams = new HashMap<>();
+ pathParams.put("", "");
+ pathParams.put("", "");
+ Map queryParams = new HashMap<>();
+ queryParams.put("", "");
+ queryParams.put("", "");
+ InvokeConnectionRequest invokeConnectionRequest2 = InvokeConnectionRequest.builder()
+ .methodName(RequestMethod.GET)
+ .pathParams(pathParams)
+ .queryParams(queryParams)
+ .build();
+ InvokeConnectionResponse invokeConnectionResponse2 = skyflowClient
+ .connection("").invoke(invokeConnectionRequest2);
+ System.out.println(invokeConnectionResponse2);
+ }
+}
diff --git a/samples/src/main/java/com/example/serviceaccount/BearerTokenGenerationExample.java b/samples/src/main/java/com/example/serviceaccount/BearerTokenGenerationExample.java
new file mode 100644
index 00000000..5dbd6372
--- /dev/null
+++ b/samples/src/main/java/com/example/serviceaccount/BearerTokenGenerationExample.java
@@ -0,0 +1,37 @@
+package com.example.serviceaccount;
+
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.serviceaccount.util.BearerToken;
+import com.skyflow.serviceaccount.util.Token;
+
+import java.io.File;
+
+public class BearerTokenGenerationExample {
+ public static void main(String[] args) {
+ String token = null;
+
+ // Generate BearerToken by specifying credentials.json file path
+ try {
+ String filePath = "";
+ if (Token.isExpired(token)) {
+ BearerToken bearerToken = BearerToken.builder().setCredentials(new File(filePath)).build();
+ token = bearerToken.getBearerToken();
+ }
+ System.out.println(token);
+ } catch (SkyflowException e) {
+ e.printStackTrace();
+ }
+
+ // Generate BearerToken by specifying credentials.json as string
+ try {
+ String fileContents = "";
+ if (Token.isExpired(token)) {
+ BearerToken bearerToken = BearerToken.builder().setCredentials(fileContents).build();
+ token = bearerToken.getBearerToken();
+ }
+ System.out.println(token);
+ } catch (SkyflowException e) {
+ e.printStackTrace();
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/src/main/java/com/example/serviceaccount/BearerTokenGenerationUsingThreadsExample.java b/samples/src/main/java/com/example/serviceaccount/BearerTokenGenerationUsingThreadsExample.java
new file mode 100644
index 00000000..8cfba8fa
--- /dev/null
+++ b/samples/src/main/java/com/example/serviceaccount/BearerTokenGenerationUsingThreadsExample.java
@@ -0,0 +1,60 @@
+package com.example.serviceaccount;
+
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.serviceaccount.util.BearerToken;
+
+import java.io.File;
+
+public class BearerTokenGenerationUsingThreadsExample {
+ public static void main(String[] args) {
+ // Generate BearerToken with context by specifying credentials.json file path
+ try {
+ String filePath = "";
+ final BearerToken bearerToken = BearerToken.builder()
+ .setCredentials(new File(filePath))
+ .setCtx("abc")
+ .build();
+
+ Thread t = new Thread(() -> {
+ for (int i = 0; i < 5; i++) {
+ try {
+ System.out.println(bearerToken.getBearerToken());
+ } catch (SkyflowException e) {
+ Thread.currentThread().interrupt();
+ throw new RuntimeException(e);
+
+ }
+
+ }
+ });
+ t.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Generate BearerToken with context by specifying credentials.json as string
+ try {
+ String fileContents = "";
+ final BearerToken bearerToken = BearerToken.builder()
+ .setCredentials(fileContents)
+ .setCtx("abc")
+ .build();
+
+ Thread t = new Thread(() -> {
+ for (int i = 0; i < 5; i++) {
+ try {
+ System.out.println(bearerToken.getBearerToken());
+ } catch (SkyflowException e) {
+ Thread.currentThread().interrupt();
+ throw new RuntimeException(e);
+
+ }
+
+ }
+ });
+ t.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/src/main/java/com/example/BearerTokenWithContextGenerationExample.java b/samples/src/main/java/com/example/serviceaccount/BearerTokenGenerationWithContextExample.java
similarity index 76%
rename from samples/src/main/java/com/example/BearerTokenWithContextGenerationExample.java
rename to samples/src/main/java/com/example/serviceaccount/BearerTokenGenerationWithContextExample.java
index 668b7c81..b85de6df 100644
--- a/samples/src/main/java/com/example/BearerTokenWithContextGenerationExample.java
+++ b/samples/src/main/java/com/example/serviceaccount/BearerTokenGenerationWithContextExample.java
@@ -1,46 +1,40 @@
-/*
- Copyright (c) 2022 Skyflow, Inc.
-*/
-package com.example;
+package com.example.serviceaccount;
import com.skyflow.errors.SkyflowException;
import com.skyflow.serviceaccount.util.BearerToken;
import java.io.File;
-public class BearerTokenWithContextGenerationExample {
- public static void main(String args[]) {
-
+public class BearerTokenGenerationWithContextExample {
+ public static void main(String[] args) {
String bearerToken = null;
// Generate BearerToken with context by specifying credentials.json file path
try {
String filePath = "";
- BearerToken token = new BearerToken.BearerTokenBuilder()
+ BearerToken token = BearerToken.builder()
.setCredentials(new File(filePath))
.setCtx("abc")
.build();
bearerToken = token.getBearerToken();
System.out.println(bearerToken);
- } catch (Exception e) {
+ } catch (SkyflowException e) {
e.printStackTrace();
}
// Generate BearerToken with context by specifying credentials.json as string
try {
String fileContents = "";
- BearerToken token = new BearerToken.BearerTokenBuilder()
+ BearerToken token = BearerToken.builder()
.setCredentials(fileContents)
.setCtx("abc")
.build();
bearerToken = token.getBearerToken();
System.out.println(bearerToken);
-
} catch (SkyflowException e) {
e.printStackTrace();
}
-
}
}
diff --git a/samples/src/main/java/com/example/serviceaccount/ScopedTokenGenerationExample.java b/samples/src/main/java/com/example/serviceaccount/ScopedTokenGenerationExample.java
new file mode 100644
index 00000000..3fda1e07
--- /dev/null
+++ b/samples/src/main/java/com/example/serviceaccount/ScopedTokenGenerationExample.java
@@ -0,0 +1,45 @@
+package com.example.serviceaccount;
+
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.serviceaccount.util.BearerToken;
+
+import java.io.File;
+import java.util.ArrayList;
+
+public class ScopedTokenGenerationExample {
+ public static void main(String[] args) {
+ String scopedToken = null;
+
+ // Generate Scoped Token by specifying credentials.json file path
+ try {
+ ArrayList roles = new ArrayList<>();
+ roles.add("YOUR_ROLE_ID");
+ String filePath = "";
+ BearerToken bearerToken = BearerToken.builder()
+ .setCredentials(new File(filePath))
+ .setRoles(roles)
+ .build();
+
+ scopedToken = bearerToken.getBearerToken();
+ System.out.println(scopedToken);
+ } catch (SkyflowException e) {
+ e.printStackTrace();
+ }
+
+ // Generate BearerToken with context by specifying credentials.json as string
+ try {
+ ArrayList roles = new ArrayList<>();
+ roles.add("YOUR_ROLE_ID");
+ String fileContents = "";
+ BearerToken bearerToken = BearerToken.builder()
+ .setCredentials(fileContents)
+ .setRoles(roles)
+ .build();
+
+ scopedToken = bearerToken.getBearerToken();
+ System.out.println(scopedToken);
+ } catch (SkyflowException e) {
+ e.printStackTrace();
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/src/main/java/com/example/SignedTokenGenerationExample.java b/samples/src/main/java/com/example/serviceaccount/SignedTokenGenerationExample.java
similarity index 53%
rename from samples/src/main/java/com/example/SignedTokenGenerationExample.java
rename to samples/src/main/java/com/example/serviceaccount/SignedTokenGenerationExample.java
index 1fde4236..0acca5fe 100644
--- a/samples/src/main/java/com/example/SignedTokenGenerationExample.java
+++ b/samples/src/main/java/com/example/serviceaccount/SignedTokenGenerationExample.java
@@ -1,33 +1,33 @@
-/*
- Copyright (c) 2022 Skyflow, Inc.
-*/
-package com.example;
+package com.example.serviceaccount;
import com.skyflow.errors.SkyflowException;
import com.skyflow.serviceaccount.util.SignedDataTokenResponse;
import com.skyflow.serviceaccount.util.SignedDataTokens;
import java.io.File;
+import java.util.ArrayList;
import java.util.List;
public class SignedTokenGenerationExample {
- public static void main(String args[]) {
-
- List signedTokenValue;
+ public static void main(String[] args) {
+ List signedTokenValues;
// Generate Signed data token with context by specifying credentials.json file path
try {
String filePath = "";
String context = "abc";
- SignedDataTokens signedToken = new SignedDataTokens.SignedDataTokensBuilder()
+ ArrayList dataTokens = new ArrayList<>();
+ dataTokens.add("YOUR_DATA_TOKEN_1");
+ SignedDataTokens signedToken = SignedDataTokens.builder()
.setCredentials(new File(filePath))
.setCtx(context)
.setTimeToLive(30) // in seconds
- .setDataTokens(new String[]{"dataToken1"}).build();
+ .setDataTokens(dataTokens)
+ .build();
- signedTokenValue = signedToken.getSignedDataTokens();
- System.out.println(signedTokenValue);
- } catch (Exception e) {
+ signedTokenValues = signedToken.getSignedDataTokens();
+ System.out.println(signedTokenValues);
+ } catch (SkyflowException e) {
e.printStackTrace();
}
@@ -35,19 +35,21 @@ public static void main(String args[]) {
try {
String fileContents = "";
String context = "abc";
- SignedDataTokens signedToken = new SignedDataTokens.SignedDataTokensBuilder()
+ ArrayList dataTokens = new ArrayList<>();
+ dataTokens.add("YOUR_DATA_TOKEN_1");
+ SignedDataTokens signedToken = SignedDataTokens.builder()
.setCredentials(fileContents)
.setCtx(context)
.setTimeToLive(30) // in seconds
- .setDataTokens(new String[]{"dataToken1"}).build();
+ .setDataTokens(dataTokens)
+ .build();
- signedTokenValue = signedToken.getSignedDataTokens();
- System.out.println(signedTokenValue);
+ signedTokenValues = signedToken.getSignedDataTokens();
+ System.out.println(signedTokenValues);
} catch (SkyflowException e) {
e.printStackTrace();
}
-
-
}
}
+
diff --git a/samples/src/main/java/com/example/vault/DeleteExample.java b/samples/src/main/java/com/example/vault/DeleteExample.java
new file mode 100644
index 00000000..d14554ce
--- /dev/null
+++ b/samples/src/main/java/com/example/vault/DeleteExample.java
@@ -0,0 +1,52 @@
+package com.example.vault;
+
+import com.skyflow.Skyflow;
+import com.skyflow.config.Credentials;
+import com.skyflow.config.VaultConfig;
+import com.skyflow.enums.Env;
+import com.skyflow.enums.LogLevel;
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.vault.data.DeleteRequest;
+import com.skyflow.vault.data.DeleteResponse;
+
+import java.util.ArrayList;
+
+public class DeleteExample {
+ public static void main(String[] args) throws SkyflowException {
+ Credentials credentials = new Credentials();
+ credentials.setPath("");
+
+ VaultConfig blitzConfig = new VaultConfig();
+ blitzConfig.setVaultId("");
+ blitzConfig.setClusterId("");
+ blitzConfig.setEnv(Env.DEV);
+ blitzConfig.setCredentials(credentials);
+
+ VaultConfig stageConfig = new VaultConfig();
+ stageConfig.setVaultId("");
+ stageConfig.setClusterId("");
+ stageConfig.setEnv(Env.STAGE);
+
+ Credentials skyflowCredentials = new Credentials();
+ skyflowCredentials.setPath("");
+
+ Skyflow skyflowClient = Skyflow.builder()
+ .setLogLevel(LogLevel.DEBUG)
+ .addVaultConfig(blitzConfig)
+ .addVaultConfig(stageConfig)
+ .addSkyflowCredentials(skyflowCredentials)
+ .build();
+
+ ArrayList ids1 = new ArrayList<>();
+ ids1.add("");
+ DeleteRequest deleteRequest1 = DeleteRequest.builder().ids(ids1).table("").build();
+ DeleteResponse deleteResponse1 = skyflowClient.vault().delete(deleteRequest1);
+ System.out.println(deleteResponse1);
+
+ ArrayList ids2 = new ArrayList<>();
+ ids2.add("");
+ DeleteRequest deleteRequest2 = DeleteRequest.builder().ids(ids2).table("").build();
+ DeleteResponse deleteResponse2 = skyflowClient.vault("").delete(deleteRequest2);
+ System.out.println(deleteResponse2);
+ }
+}
diff --git a/samples/src/main/java/com/example/vault/DetokenizeExample.java b/samples/src/main/java/com/example/vault/DetokenizeExample.java
new file mode 100644
index 00000000..cd6d38ad
--- /dev/null
+++ b/samples/src/main/java/com/example/vault/DetokenizeExample.java
@@ -0,0 +1,57 @@
+package com.example.vault;
+
+import com.skyflow.Skyflow;
+import com.skyflow.config.Credentials;
+import com.skyflow.config.VaultConfig;
+import com.skyflow.enums.Env;
+import com.skyflow.enums.LogLevel;
+import com.skyflow.enums.RedactionType;
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.vault.tokens.DetokenizeRequest;
+import com.skyflow.vault.tokens.DetokenizeResponse;
+
+import java.util.ArrayList;
+
+public class DetokenizeExample {
+ public static void main(String[] args) throws SkyflowException {
+ Credentials credentials = new Credentials();
+ credentials.setPath("");
+
+ VaultConfig blitzConfig = new VaultConfig();
+ blitzConfig.setVaultId("");
+ blitzConfig.setClusterId("");
+ blitzConfig.setEnv(Env.DEV);
+ blitzConfig.setCredentials(credentials);
+
+ VaultConfig stageConfig = new VaultConfig();
+ stageConfig.setVaultId("");
+ stageConfig.setClusterId("");
+ stageConfig.setEnv(Env.STAGE);
+
+ Credentials skyflowCredentials = new Credentials();
+ skyflowCredentials.setPath("");
+
+ Skyflow skyflowClient = Skyflow.builder()
+ .setLogLevel(LogLevel.DEBUG)
+ .addVaultConfig(blitzConfig)
+ .addVaultConfig(stageConfig)
+ .addSkyflowCredentials(skyflowCredentials)
+ .build();
+
+ ArrayList tokens1 = new ArrayList<>();
+ tokens1.add("");
+ tokens1.add("");
+ DetokenizeRequest detokenizeRequest1 = DetokenizeRequest.builder().tokens(tokens1).continueOnError(true).build();
+ DetokenizeResponse detokenizeResponse1 = skyflowClient.vault().detokenize(detokenizeRequest1);
+ System.out.println(detokenizeResponse1);
+
+ ArrayList tokens2 = new ArrayList<>();
+ tokens2.add("");
+ tokens2.add("");
+
+ DetokenizeRequest detokenizeRequest2 = DetokenizeRequest.builder()
+ .tokens(tokens2).continueOnError(false).redactionType(RedactionType.DEFAULT).build();
+ DetokenizeResponse detokenizeResponse2 = skyflowClient.vault("").detokenize(detokenizeRequest2);
+ System.out.println(detokenizeResponse2);
+ }
+}
diff --git a/samples/src/main/java/com/example/vault/GetExample.java b/samples/src/main/java/com/example/vault/GetExample.java
new file mode 100644
index 00000000..5dda25d3
--- /dev/null
+++ b/samples/src/main/java/com/example/vault/GetExample.java
@@ -0,0 +1,58 @@
+package com.example.vault;
+
+import com.skyflow.Skyflow;
+import com.skyflow.config.Credentials;
+import com.skyflow.config.VaultConfig;
+import com.skyflow.enums.Env;
+import com.skyflow.enums.LogLevel;
+import com.skyflow.enums.RedactionType;
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.vault.data.GetRequest;
+import com.skyflow.vault.data.GetResponse;
+
+import java.util.ArrayList;
+
+public class GetExample {
+ public static void main(String[] args) throws SkyflowException {
+ Credentials credentials = new Credentials();
+ credentials.setPath("");
+
+ VaultConfig blitzConfig = new VaultConfig();
+ blitzConfig.setVaultId("");
+ blitzConfig.setClusterId("");
+ blitzConfig.setEnv(Env.DEV);
+ blitzConfig.setCredentials(credentials);
+
+ VaultConfig stageConfig = new VaultConfig();
+ stageConfig.setVaultId("");
+ stageConfig.setClusterId("");
+ stageConfig.setEnv(Env.STAGE);
+
+ Credentials skyflowCredentials = new Credentials();
+ skyflowCredentials.setPath("");
+
+ Skyflow skyflowClient = Skyflow.builder()
+ .setLogLevel(LogLevel.DEBUG)
+ .addVaultConfig(blitzConfig)
+ .addVaultConfig(stageConfig)
+ .addSkyflowCredentials(skyflowCredentials)
+ .build();
+
+ ArrayList ids = new ArrayList<>();
+ ids.add("");
+ GetRequest getByIdRequest = GetRequest.builder().returnTokens(true).ids(ids).table("").build();
+ GetResponse getByIdResponse = skyflowClient.vault().get(getByIdRequest);
+ System.out.println(getByIdResponse);
+
+ ArrayList columnValues = new ArrayList<>();
+ columnValues.add("");
+ GetRequest getByColumnRequest = GetRequest.builder()
+ .table("")
+ .columnName("")
+ .columnValues(columnValues)
+ .redactionType(RedactionType.PLAIN_TEXT)
+ .build();
+ GetResponse getByColumnResponse = skyflowClient.vault("").get(getByColumnRequest);
+ System.out.println(getByColumnResponse);
+ }
+}
diff --git a/samples/src/main/java/com/example/vault/InsertExample.java b/samples/src/main/java/com/example/vault/InsertExample.java
new file mode 100644
index 00000000..20070e83
--- /dev/null
+++ b/samples/src/main/java/com/example/vault/InsertExample.java
@@ -0,0 +1,81 @@
+package com.example.vault;
+
+import com.skyflow.Skyflow;
+import com.skyflow.config.Credentials;
+import com.skyflow.config.VaultConfig;
+import com.skyflow.enums.Byot;
+import com.skyflow.enums.Env;
+import com.skyflow.enums.LogLevel;
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.vault.data.InsertRequest;
+import com.skyflow.vault.data.InsertResponse;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+public class InsertExample {
+ public static void main(String[] args) throws SkyflowException {
+ Credentials credentials = new Credentials();
+ credentials.setPath("");
+
+ VaultConfig blitzConfig = new VaultConfig();
+ blitzConfig.setVaultId("");
+ blitzConfig.setClusterId("");
+ blitzConfig.setEnv(Env.DEV);
+ blitzConfig.setCredentials(credentials);
+
+ VaultConfig stageConfig = new VaultConfig();
+ stageConfig.setVaultId("");
+ stageConfig.setClusterId("");
+ stageConfig.setEnv(Env.STAGE);
+
+ Credentials skyflowCredentials = new Credentials();
+ skyflowCredentials.setPath("");
+
+ Skyflow skyflowClient = Skyflow.builder()
+ .setLogLevel(LogLevel.DEBUG)
+ .addVaultConfig(blitzConfig)
+ .addVaultConfig(stageConfig)
+ .addSkyflowCredentials(skyflowCredentials)
+ .build();
+
+ ArrayList> values1 = new ArrayList<>();
+ HashMap value1 = new HashMap<>();
+ value1.put("", "");
+ value1.put("", "");
+ values1.add(value1);
+
+ ArrayList> tokens = new ArrayList<>();
+ HashMap token = new HashMap<>();
+ token.put("", "");
+ tokens.add(token);
+
+ InsertRequest insertRequest = InsertRequest.builder()
+ .table("")
+ .continueOnError(true)
+ .tokenStrict(Byot.ENABLE)
+ .values(values1)
+ .tokens(tokens)
+ .returnTokens(true)
+ .build();
+ InsertResponse insertResponse = skyflowClient.vault().insert(insertRequest);
+ System.out.println(insertResponse);
+
+ ArrayList> values2 = new ArrayList<>();
+ HashMap value2 = new HashMap<>();
+ value2.put("", "");
+ value2.put("", "");
+ values2.add(value2);
+
+ InsertRequest upsertRequest = InsertRequest.builder()
+ .table("")
+ .continueOnError(false)
+ .tokenStrict(Byot.DISABLE)
+ .values(values2)
+ .returnTokens(false)
+ .upsert("")
+ .build();
+ InsertResponse upsertResponse = skyflowClient.vault("").insert(upsertRequest);
+ System.out.println(upsertResponse);
+ }
+}
diff --git a/samples/src/main/java/com/example/vault/QueryExample.java b/samples/src/main/java/com/example/vault/QueryExample.java
new file mode 100644
index 00000000..d5928cd5
--- /dev/null
+++ b/samples/src/main/java/com/example/vault/QueryExample.java
@@ -0,0 +1,49 @@
+package com.example.vault;
+
+import com.skyflow.Skyflow;
+import com.skyflow.config.Credentials;
+import com.skyflow.config.VaultConfig;
+import com.skyflow.enums.Env;
+import com.skyflow.enums.LogLevel;
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.vault.data.QueryRequest;
+import com.skyflow.vault.data.QueryResponse;
+
+public class QueryExample {
+ public static void main(String[] args) throws SkyflowException {
+ Credentials credentials = new Credentials();
+ credentials.setPath("");
+
+ VaultConfig blitzConfig = new VaultConfig();
+ blitzConfig.setVaultId("");
+ blitzConfig.setClusterId("");
+ blitzConfig.setEnv(Env.DEV);
+ blitzConfig.setCredentials(credentials);
+
+ VaultConfig stageConfig = new VaultConfig();
+ stageConfig.setVaultId("");
+ stageConfig.setClusterId("");
+ stageConfig.setEnv(Env.STAGE);
+
+ Credentials skyflowCredentials = new Credentials();
+ skyflowCredentials.setPath("");
+
+ Skyflow skyflowClient = Skyflow.builder()
+ .setLogLevel(LogLevel.DEBUG)
+ .addVaultConfig(blitzConfig)
+ .addVaultConfig(stageConfig)
+ .addSkyflowCredentials(skyflowCredentials)
+ .build();
+
+ String query1 = "";
+ QueryRequest queryRequest1 = QueryRequest.builder().query(query1).build();
+ QueryResponse queryResponse1 = skyflowClient.vault().query(queryRequest1);
+ System.out.println(queryResponse1);
+
+ String query2 = "";
+ QueryRequest queryRequest2 = QueryRequest.builder().query(query2).build();
+ QueryResponse queryResponse2 = skyflowClient.vault("").query(queryRequest2);
+ System.out.println(queryResponse2);
+
+ }
+}
diff --git a/samples/src/main/java/com/example/vault/TokenizeExample.java b/samples/src/main/java/com/example/vault/TokenizeExample.java
new file mode 100644
index 00000000..578e7ced
--- /dev/null
+++ b/samples/src/main/java/com/example/vault/TokenizeExample.java
@@ -0,0 +1,59 @@
+package com.example.vault;
+
+import com.skyflow.Skyflow;
+import com.skyflow.config.Credentials;
+import com.skyflow.config.VaultConfig;
+import com.skyflow.enums.Env;
+import com.skyflow.enums.LogLevel;
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.vault.tokens.ColumnValue;
+import com.skyflow.vault.tokens.TokenizeRequest;
+import com.skyflow.vault.tokens.TokenizeResponse;
+
+import java.util.ArrayList;
+
+public class TokenizeExample {
+ public static void main(String[] args) throws SkyflowException {
+ Credentials credentials = new Credentials();
+ credentials.setPath("");
+
+ VaultConfig blitzConfig = new VaultConfig();
+ blitzConfig.setVaultId("");
+ blitzConfig.setClusterId("");
+ blitzConfig.setEnv(Env.DEV);
+ blitzConfig.setCredentials(credentials);
+
+ VaultConfig stageConfig = new VaultConfig();
+ stageConfig.setVaultId("");
+ stageConfig.setClusterId("");
+ stageConfig.setEnv(Env.STAGE);
+
+ Credentials skyflowCredentials = new Credentials();
+ skyflowCredentials.setPath("");
+
+ Skyflow skyflowClient = Skyflow.builder()
+ .setLogLevel(LogLevel.DEBUG)
+ .addVaultConfig(blitzConfig)
+ .addVaultConfig(stageConfig)
+ .addSkyflowCredentials(skyflowCredentials)
+ .build();
+
+ ArrayList columnValues1 = new ArrayList<>();
+ ColumnValue value1 = ColumnValue.builder().value("").columnGroup("").build();
+ ColumnValue value2 = ColumnValue.builder().value("").columnGroup("").build();
+ columnValues1.add(value1);
+ columnValues1.add(value2);
+ TokenizeRequest tokenizeRequest1 = TokenizeRequest.builder().values(columnValues1).build();
+ TokenizeResponse tokenizeResponse1 = skyflowClient.vault().tokenize(tokenizeRequest1);
+ System.out.println(tokenizeResponse1);
+
+ ArrayList columnValues2 = new ArrayList<>();
+ ColumnValue value3 = ColumnValue.builder().value("").columnGroup("").build();
+ ColumnValue value4 = ColumnValue.builder().value("").columnGroup("").build();
+ columnValues2.add(value3);
+ columnValues2.add(value4);
+ TokenizeRequest tokenizeRequest2 = TokenizeRequest.builder().values(columnValues2).build();
+ TokenizeResponse tokenizeResponse2 = skyflowClient.vault("").tokenize(tokenizeRequest2);
+ System.out.println(tokenizeResponse2);
+ }
+}
diff --git a/samples/src/main/java/com/example/vault/UpdateExample.java b/samples/src/main/java/com/example/vault/UpdateExample.java
new file mode 100644
index 00000000..1508fc25
--- /dev/null
+++ b/samples/src/main/java/com/example/vault/UpdateExample.java
@@ -0,0 +1,73 @@
+package com.example.vault;
+
+import com.skyflow.Skyflow;
+import com.skyflow.config.Credentials;
+import com.skyflow.config.VaultConfig;
+import com.skyflow.enums.Byot;
+import com.skyflow.enums.Env;
+import com.skyflow.enums.LogLevel;
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.vault.data.UpdateRequest;
+import com.skyflow.vault.data.UpdateResponse;
+
+import java.util.HashMap;
+
+public class UpdateExample {
+ public static void main(String[] args) throws SkyflowException {
+ Credentials credentials = new Credentials();
+ credentials.setPath("");
+
+ VaultConfig blitzConfig = new VaultConfig();
+ blitzConfig.setVaultId("");
+ blitzConfig.setClusterId("");
+ blitzConfig.setEnv(Env.DEV);
+ blitzConfig.setCredentials(credentials);
+
+ VaultConfig stageConfig = new VaultConfig();
+ stageConfig.setVaultId("");
+ stageConfig.setClusterId("");
+ stageConfig.setEnv(Env.STAGE);
+
+ Credentials skyflowCredentials = new Credentials();
+ skyflowCredentials.setPath("");
+
+ Skyflow skyflowClient = Skyflow.builder()
+ .setLogLevel(LogLevel.DEBUG)
+ .addVaultConfig(blitzConfig)
+ .addVaultConfig(stageConfig)
+ .addSkyflowCredentials(skyflowCredentials)
+ .build();
+
+ HashMap values1 = new HashMap<>();
+ values1.put("", "");
+ values1.put("", "");
+
+ HashMap tokens = new HashMap<>();
+ tokens.put("", "");
+
+ UpdateRequest updateRequest1 = UpdateRequest.builder()
+ .id("")
+ .table("")
+ .tokenStrict(Byot.ENABLE)
+ .values(values1)
+ .tokens(tokens)
+ .returnTokens(true)
+ .build();
+ UpdateResponse updateResponse1 = skyflowClient.vault().update(updateRequest1);
+ System.out.println(updateResponse1);
+
+ HashMap values2 = new HashMap<>();
+ values2.put("", "");
+ values2.put("", "");
+
+ UpdateRequest updateRequest2 = UpdateRequest.builder()
+ .id("")
+ .table("")
+ .tokenStrict(Byot.DISABLE)
+ .values(values2)
+ .returnTokens(false)
+ .build();
+ UpdateResponse updateResponse2 = skyflowClient.vault("").update(updateRequest2);
+ System.out.println(updateResponse2);
+ }
+}
diff --git a/scripts/bump_version.sh b/scripts/bump_version.sh
new file mode 100755
index 00000000..d729ea63
--- /dev/null
+++ b/scripts/bump_version.sh
@@ -0,0 +1,40 @@
+# Input Arguments
+Version=$1
+CommitHash=$2
+PomFile="$GITHUB_WORKSPACE/pom.xml"
+
+if [ -z "$Version" ]; then
+ echo "Error: Version argument is required."
+ exit 1
+fi
+
+# Update only the main project's
+if [ -z "$CommitHash" ]; then
+ echo "Bumping main project version to $Version"
+
+ awk -v version="$Version" '
+ BEGIN { updated = 0 }
+ // && updated == 0 {
+ sub(/.*<\/version>/, "" version "")
+ updated = 1
+ }
+ { print }
+ ' "$PomFile" > tempfile && cat tempfile > "$PomFile" && rm -f tempfile
+
+ echo "--------------------------"
+ echo "Done. Main project version now at $Version"
+else
+ echo "Bumping main project version to $Version-dev-$CommitHash"
+
+ awk -v version="$Version-dev.$CommitHash" '
+ BEGIN { updated = 0 }
+ // && updated == 0 {
+ sub(/.*<\/version>/, "" version "")
+ updated = 1
+ }
+ { print }
+ ' "$PomFile" > tempfile && cat tempfile > "$PomFile" && rm -f tempfile
+
+ echo "--------------------------"
+ echo "Done. Main project version now at $Version-dev.$CommitHash"
+fi
diff --git a/src/main/java/com/skyflow/Configuration.java b/src/main/java/com/skyflow/Configuration.java
deleted file mode 100644
index fac93b8b..00000000
--- a/src/main/java/com/skyflow/Configuration.java
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- Copyright (c) 2022 Skyflow, Inc.
-*/
-package com.skyflow;
-
-import com.skyflow.common.utils.Helpers;
-import com.skyflow.common.utils.LogUtil;
-import com.skyflow.entities.LogLevel;
-import com.skyflow.logs.InfoLogs;
-
-public final class Configuration {
- public static void setLogLevel(LogLevel level) {
- LogUtil.setupLogger(level);
- LogUtil.printInfoLog(Helpers.parameterizedString(InfoLogs.CurrentLogLevel.getLog(), String.valueOf(level)));
- }
-}
diff --git a/src/main/java/com/skyflow/ConnectionClient.java b/src/main/java/com/skyflow/ConnectionClient.java
new file mode 100644
index 00000000..72a70fef
--- /dev/null
+++ b/src/main/java/com/skyflow/ConnectionClient.java
@@ -0,0 +1,86 @@
+package com.skyflow;
+
+import com.skyflow.config.ConnectionConfig;
+import com.skyflow.config.Credentials;
+import com.skyflow.errors.ErrorCode;
+import com.skyflow.errors.ErrorMessage;
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.logs.InfoLogs;
+import com.skyflow.serviceaccount.util.Token;
+import com.skyflow.utils.Constants;
+import com.skyflow.utils.Utils;
+import com.skyflow.utils.logger.LogUtil;
+import com.skyflow.utils.validations.Validations;
+import io.github.cdimascio.dotenv.Dotenv;
+
+public class ConnectionClient {
+ private final ConnectionConfig connectionConfig;
+ protected String token;
+ protected String apiKey;
+ private Credentials commonCredentials;
+ private Credentials finalCredentials;
+
+ protected ConnectionClient(ConnectionConfig connectionConfig, Credentials credentials) {
+ super();
+ this.connectionConfig = connectionConfig;
+ this.commonCredentials = credentials;
+ }
+
+ protected ConnectionConfig getConnectionConfig() {
+ return connectionConfig;
+ }
+
+ protected void setCommonCredentials(Credentials commonCredentials) {
+ this.commonCredentials = commonCredentials;
+ prioritiseCredentials();
+ }
+
+ protected void updateConnectionConfig(ConnectionConfig connectionConfig) {
+ prioritiseCredentials();
+ }
+
+ protected void setBearerToken() throws SkyflowException {
+ prioritiseCredentials();
+ Validations.validateCredentials(this.finalCredentials);
+ if (this.finalCredentials.getApiKey() != null) {
+ setApiKey();
+ return;
+ } else if (Token.isExpired(token)) {
+ LogUtil.printInfoLog(InfoLogs.BEARER_TOKEN_EXPIRED.getLog());
+ token = Utils.generateBearerToken(this.finalCredentials);
+ } else {
+ LogUtil.printInfoLog(InfoLogs.REUSE_BEARER_TOKEN.getLog());
+ }
+ }
+
+ private void setApiKey() {
+ if (apiKey == null) {
+ apiKey = this.finalCredentials.getApiKey();
+ } else {
+ LogUtil.printInfoLog(InfoLogs.REUSE_API_KEY.getLog());
+ }
+ }
+
+ private void prioritiseCredentials() {
+ try {
+ if (this.connectionConfig.getCredentials() != null) {
+ this.finalCredentials = this.connectionConfig.getCredentials();
+ } else if (this.commonCredentials != null) {
+ this.finalCredentials = this.commonCredentials;
+ } else {
+ Dotenv dotenv = Dotenv.load();
+ String sysCredentials = dotenv.get(Constants.ENV_CREDENTIALS_KEY_NAME);
+ if (sysCredentials == null) {
+ throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(),
+ ErrorMessage.EmptyCredentials.getMessage());
+ } else {
+ this.finalCredentials = new Credentials();
+ this.finalCredentials.setCredentialsString(sysCredentials);
+ }
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
diff --git a/src/main/java/com/skyflow/Skyflow.java b/src/main/java/com/skyflow/Skyflow.java
new file mode 100644
index 00000000..2a2e42cc
--- /dev/null
+++ b/src/main/java/com/skyflow/Skyflow.java
@@ -0,0 +1,258 @@
+package com.skyflow;
+
+import com.skyflow.config.ConnectionConfig;
+import com.skyflow.config.Credentials;
+import com.skyflow.config.VaultConfig;
+import com.skyflow.enums.Env;
+import com.skyflow.enums.LogLevel;
+import com.skyflow.errors.ErrorCode;
+import com.skyflow.errors.ErrorMessage;
+import com.skyflow.errors.SkyflowException;
+import com.skyflow.logs.ErrorLogs;
+import com.skyflow.logs.InfoLogs;
+import com.skyflow.utils.Utils;
+import com.skyflow.utils.logger.LogUtil;
+import com.skyflow.utils.validations.Validations;
+import com.skyflow.vault.controller.ConnectionController;
+import com.skyflow.vault.controller.VaultController;
+
+import java.util.LinkedHashMap;
+
+public final class Skyflow {
+ private final SkyflowClientBuilder builder;
+
+ private Skyflow(SkyflowClientBuilder builder) {
+ this.builder = builder;
+ LogUtil.printInfoLog(InfoLogs.CLIENT_INITIALIZED.getLog());
+ }
+
+ public static SkyflowClientBuilder builder() {
+ return new SkyflowClientBuilder();
+ }
+
+ public Skyflow addVaultConfig(VaultConfig vaultConfig) throws SkyflowException {
+ this.builder.addVaultConfig(vaultConfig);
+ return this;
+ }
+
+ public VaultConfig getVaultConfig(String vaultId) {
+ return this.builder.vaultConfigMap.get(vaultId);
+ }
+
+ public Skyflow updateVaultConfig(VaultConfig vaultConfig) throws SkyflowException {
+ this.builder.updateVaultConfig(vaultConfig);
+ return this;
+ }
+
+ public Skyflow removeVaultConfig(String vaultId) throws SkyflowException {
+ this.builder.removeVaultConfig(vaultId);
+ return this;
+ }
+
+ public Skyflow addConnectionConfig(ConnectionConfig connectionConfig) throws SkyflowException {
+ this.builder.addConnectionConfig(connectionConfig);
+ return this;
+ }
+
+ public ConnectionConfig getConnectionConfig(String connectionId) {
+ return this.builder.connectionConfigMap.get(connectionId);
+ }
+
+ public Skyflow updateConnectionConfig(ConnectionConfig connectionConfig) throws SkyflowException {
+ this.builder.updateConnectionConfig(connectionConfig);
+ return this;
+ }
+
+ public Skyflow removeConnectionConfig(String connectionId) throws SkyflowException {
+ this.builder.removeConnectionConfig(connectionId);
+ return this;
+ }
+
+ public Skyflow updateSkyflowCredentials(Credentials credentials) throws SkyflowException {
+ this.builder.addSkyflowCredentials(credentials);
+ return this;
+ }
+
+ public Skyflow updateLogLevel(LogLevel logLevel) {
+ this.builder.setLogLevel(logLevel);
+ return this;
+ }
+
+ public LogLevel getLogLevel() {
+ return this.builder.logLevel;
+ }
+
+ public VaultController vault() {
+ String vaultId = (String) this.builder.vaultClientsMap.keySet().toArray()[0];
+ return this.vault(vaultId);
+ }
+
+ public VaultController vault(String vaultId) {
+ return this.builder.vaultClientsMap.get(vaultId);
+ }
+
+ public ConnectionController connection() {
+ String connectionId = (String) this.builder.connectionsMap.keySet().toArray()[0];
+ return this.connection(connectionId);
+ }
+
+ public ConnectionController connection(String connectionId) {
+ return this.builder.connectionsMap.get(connectionId);
+ }
+
+ public static final class SkyflowClientBuilder {
+ private final LinkedHashMap connectionsMap;
+ private final LinkedHashMap