-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDeleteExample.java
More file actions
72 lines (57 loc) · 2.15 KB
/
DeleteExample.java
File metadata and controls
72 lines (57 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
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(
"<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;
}
}
}