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..1c1ee12f --- /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(); + credentials.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..ae1bce1b --- /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 (Exception 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..1d750ade --- /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 = new BearerToken.BearerTokenBuilder() + .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 = new BearerToken.BearerTokenBuilder() + .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 88% rename from samples/src/main/java/com/example/BearerTokenWithContextGenerationExample.java rename to samples/src/main/java/com/example/serviceaccount/BearerTokenGenerationWithContextExample.java index 668b7c81..69e6ff14 100644 --- a/samples/src/main/java/com/example/BearerTokenWithContextGenerationExample.java +++ b/samples/src/main/java/com/example/serviceaccount/BearerTokenGenerationWithContextExample.java @@ -1,16 +1,12 @@ -/* - 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 @@ -37,10 +33,8 @@ public static void main(String args[]) { 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..b8dfbc53 --- /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 = new BearerToken.BearerTokenBuilder() + .setCredentials(new File(filePath)) + .setRoles(roles) + .build(); + + scopedToken = bearerToken.getBearerToken(); + System.out.println(scopedToken); + } catch (Exception 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 = new BearerToken.BearerTokenBuilder() + .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 63% rename from samples/src/main/java/com/example/SignedTokenGenerationExample.java rename to samples/src/main/java/com/example/serviceaccount/SignedTokenGenerationExample.java index 1fde4236..7f030838 100644 --- a/samples/src/main/java/com/example/SignedTokenGenerationExample.java +++ b/samples/src/main/java/com/example/serviceaccount/SignedTokenGenerationExample.java @@ -1,32 +1,32 @@ -/* - 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"; + ArrayList dataTokens = new ArrayList<>(); + dataTokens.add("YOUR_DATA_TOKEN_1"); SignedDataTokens signedToken = new SignedDataTokens.SignedDataTokensBuilder() .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); + signedTokenValues = signedToken.getSignedDataTokens(); + System.out.println(signedTokenValues); } catch (Exception e) { e.printStackTrace(); } @@ -35,19 +35,21 @@ public static void main(String args[]) { try { String fileContents = ""; String context = "abc"; + ArrayList dataTokens = new ArrayList<>(); + dataTokens.add("YOUR_DATA_TOKEN_1"); SignedDataTokens signedToken = new SignedDataTokens.SignedDataTokensBuilder() .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..17887204 --- /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(); + credentials.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..f026e43e --- /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(); + credentials.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..357c3516 --- /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(); + credentials.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..21d9260b --- /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(); + credentials.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..c80a2443 --- /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(); + credentials.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..f7677670 --- /dev/null +++ b/samples/src/main/java/com/example/vault/TokenizeExample.java @@ -0,0 +1,60 @@ +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; +import java.util.List; + +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(); + credentials.setPath(""); + + Skyflow skyflowClient = Skyflow.builder() + .setLogLevel(LogLevel.DEBUG) + .addVaultConfig(blitzConfig) + .addVaultConfig(stageConfig) + .addSkyflowCredentials(skyflowCredentials) + .build(); + + List 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); + + List 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..b782d80d --- /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(); + credentials.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("") + .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("") + .tokenStrict(Byot.DISABLE) + .values(values2) + .returnTokens(false) + .build(); + UpdateResponse updateResponse2 = skyflowClient.vault("").update(updateRequest2); + System.out.println(updateResponse2); + } +}