-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from skyflowapi/SK-899-update-readme-changelog…
…-samples-delete-by-skyflow-id-in-java-sdk SK-899-update-readme-changelog-samples-delete-by-skyflow-id-in-java-sdk
- Loading branch information
Showing
4 changed files
with
141 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
Copyright (c) 2023 Skyflow, Inc. | ||
*/ | ||
import com.skyflow.entities.ResponseToken; | ||
import com.skyflow.entities.SkyflowConfiguration; | ||
import com.skyflow.entities.TokenProvider; | ||
import com.skyflow.errors.SkyflowException; | ||
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("<your_vaultID>", | ||
"<your_vaultURL>", new DemoTokenProvider()); | ||
Skyflow skyflowClient = Skyflow.init(config); | ||
JSONObject records = new JSONObject(); | ||
JSONArray recordsArray = new JSONArray(); | ||
|
||
JSONObject record = new JSONObject(); | ||
|
||
record.put("id", "<your_skyflowId>"); | ||
record.put("table", "<you_table_name>"); | ||
recordsArray.add(record); | ||
JSONObject record2 = new JSONObject(); | ||
|
||
record2.put("id", "<your_skyflowId>"); | ||
record2.put("table", "<you_table_name>"); | ||
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 = "<YOUR_CREDENTIALS_FILE_PATH>"; | ||
if(Token.isExpired(bearerToken)) { | ||
response = Token.generateBearerToken(filePath); | ||
bearerToken = response.getAccessToken(); | ||
} | ||
} catch (SkyflowException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
return bearerToken; | ||
} | ||
} | ||
} |