-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDeleteExample.java
More file actions
64 lines (56 loc) · 3.08 KB
/
DeleteExample.java
File metadata and controls
64 lines (56 loc) · 3.08 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
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;
/**
* This example demonstrates how to use the Skyflow SDK to delete records from one or more vaults
* by specifying the vault configurations, credentials, and record IDs to delete.
* <p>
* Steps include:
* 1. Setting up Skyflow credentials.
* 2. Configuring the vault.
* 3. Creating a Skyflow client.
* 4. Setting the log level for debugging and error tracking.
* 5. Deleting records from the specified vault(s) using record IDs and table names.
*/
public class DeleteExample {
public static void main(String[] args) throws SkyflowException {
// Step 1: Set up Skyflow credentials
Credentials credentials = new Credentials();
credentials.setPath("<YOUR_CREDENTIALS_FILE_PATH>"); // Replace with the actual path to the credentials file
// Step 2: Configure the vault
VaultConfig vaultConfig = new VaultConfig();
vaultConfig.setVaultId("<YOUR_VAULT_ID_1>"); // Replace with the ID of the first vault
vaultConfig.setClusterId("<YOUR_CLUSTER_ID_1>"); // Replace with the cluster ID of the first vault
vaultConfig.setEnv(Env.PROD); // Set the environment (e.g., DEV, STAGE, PROD)
vaultConfig.setCredentials(credentials); // Associate the credentials with the vault
// Step 3: Set up credentials for the Skyflow client
Credentials skyflowCredentials = new Credentials();
skyflowCredentials.setCredentialsString("<YOUR_CREDENTIALS_STRING>"); // Replace with credentials string
// Step 4: Create a Skyflow client and add vault configurations
Skyflow skyflowClient = Skyflow.builder()
.setLogLevel(LogLevel.ERROR) // Set log level for debugging and error tracking
.addVaultConfig(vaultConfig) // Add the vault configuration
.addSkyflowCredentials(skyflowCredentials) // Add general Skyflow credentials
.build();
// Step 5: Delete a record from the vault
try {
ArrayList<String> ids = new ArrayList<>();
ids.add("<YOUR_SKYFLOW_ID_VALUE>"); // Replace with the ID of the record to delete
DeleteRequest deleteRequest = DeleteRequest.builder()
.ids(ids) // Specify the record IDs to delete
.table("<TABLE_NAME>") // Replace with the table name
.build();
DeleteResponse deleteResponse = skyflowClient.vault().delete(deleteRequest); // Perform the delete operation
System.out.println("Delete Response: " + deleteResponse);
} catch (SkyflowException e) {
System.out.println("Error during delete operation in Vault: " + e);
}
}
}