Skip to content

Commit

Permalink
Merge pull request #89 from skyflowapi/SK-899-update-readme-changelog…
Browse files Browse the repository at this point in the history
…-samples-delete-by-skyflow-id-in-java-sdk

 SK-899-update-readme-changelog-samples-delete-by-skyflow-id-in-java-sdk
  • Loading branch information
yaswanth-pula-skyflow authored Aug 9, 2023
2 parents 64f1baa + 552842e commit 3a04710
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Changelog
All notable changes to this project will be documented in this file.

## [1.10.0] - 2023-08-09
- Added `delete` vault API support.
## [1.9.0] - 2023-06-08
### Added
- `redaction` key for detokenize method for column group support.
Expand Down
84 changes: 72 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ The Skyflow Java SDK is designed to help with integrating Skyflow into a Java ba
- [Service Account Scoped Bearer Token Generation](#service-account-scoped-bearer-token-generation)
- [Signed Data Tokens Generation](#signed-data-tokens-generation)
- [Vault APIs](#vault-apis)
- [Insert](#insert)
- [Detokenize](#detokenize)
- [Get](#get)
- [Use Skyflow IDs](#use-skyflow-ids)
- [Use column name and values](#use-column-name-and-values)
- [Redaction types](#redaction-types)
- [Examples](#examples)
- [GetById](#getbyid)
- [Update](#update)
- [Invoke Connection](#invoke-connection)
- [Insert](#insert)
- [Detokenize](#detokenize)
- [Get](#get)
- [Use Skyflow IDs](#use-skyflow-ids)
- [Use column name and values](#use-column-name-and-values)
- [Redaction types](#redaction-types)
- [Examples](#examples)
- [GetById](#getbyid)
- [Update](#update)
- [Delete](#delete)
- [Invoke Connection](#invoke-connection)
- [Logging](#logging)
- [Reporting a Vulnerability](#reporting-a-vulnerability)

Expand All @@ -50,7 +51,7 @@ The Skyflow Java SDK is designed to help with integrating Skyflow into a Java ba

Add this dependency to your project's build file:
```
implementation 'com.skyflow:skyflow-java:1.8.2'
implementation 'com.skyflow:skyflow-java:1.10.0'
```

#### Maven users
Expand All @@ -60,7 +61,7 @@ Add this dependency to your project's POM:
<dependency>
<groupId>com.skyflow</groupId>
<artifactId>skyflow-java</artifactId>
<version>1.9.0</version>
<version>1.10.0</version>
</dependency>
```
---
Expand Down Expand Up @@ -833,6 +834,65 @@ Response:
}
```

## Delete
To delete data from the vault, use the `delete(records, options?)` method of the Skyflow client. The `records` parameter takes an array of records to delete in the following format. The `options` parameter is optional and takes an object of deletion parameters. Currently, there are no supported deletion parameters.

Call schema:

```java
JSONObject records = new JSONObject();
JSONArray recordsArray = new JSONArray();

JSONObject record = new JSONObject();

record.put("id", "<SKYFLOW_ID_1>");
record.put("table", "<TABLE_NAME>");
recordsArray.add(record);
records.put("records", recordsArray);

skyflowClient.delete(records);
```

An example of delete call:
```java
JSONObject records = new JSONObject();
JSONArray recordsArray = new JSONArray();

JSONObject record = new JSONObject();
record.put("id", "71be4592-b9af-4dec-8669-5b9c926afb4c");
record.put("table", "cards");
recordsArray.add(record);

JSONObject record2 = new JSONObject();
record2.put("id", "2adf32e7-9a04-408e-b8bb-5b0a852422e0");
record2.put("table", "cards");
recordsArray.add(record2);

records.put("records", recordsArray);

try {
JSONObject response = skyflowClient.delete(records);
} catch (SkyflowException e) {
e.printStackTrace();
System.out.println("error"+ e.getData());
}
```
Response:
```json
{
"records": [
{
"skyflow_id": "71be4592-b9af-4dec-8669-5b9c926afb4c",
"deleted": true,
},
{
"skyflow_id": "2adf32e7-9a04-408e-b8bb-5b0a852422e0",
"deleted": true,
}
]
}
```

## Invoke Connection

Using the InvokeConnection method, you can integrate their server-side application with third party APIs and services without directly handling sensitive data. Prior to invoking the `InvokeConnection` method, you must have created a connection and have a connectionURL already generated. Once you have the connectionURL, you can invoke a connection by using the **invokeConnection(JSONObject config)** method. The JSONObject config parameter must include a `connectionURL` and `methodName`. The other fields are optional.
Expand Down
2 changes: 1 addition & 1 deletion samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<dependency>
<groupId>com.skyflow</groupId>
<artifactId>skyflow-java</artifactId>
<version>1.9.0</version>
<version>1.10.0</version>
</dependency>

</dependencies>
Expand Down
66 changes: 66 additions & 0 deletions samples/src/main/java/com/example/DeleteExample.java
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;
}
}
}

0 comments on commit 3a04710

Please sign in to comment.