Skip to content

Commit 6727625

Browse files
docs: add v2.1.0 upgrade banner and migration guide to v1 README (#310)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5ce9c9e commit 6727625

2 files changed

Lines changed: 254 additions & 0 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Skyflow Java
22

3+
> **Java V2.1.0 IS NOW AVAILABLE:** A new, improved version of the Skyflow SDK is ready with flexible authentication, multi-vault support, builder patterns, and richer error diagnostics. V1 is in maintenance mode (security patches only) and will reach End of Life on October 31, 2026. We recommend upgrading to v2.1.0 — see the **[Migration Guide](docs/migrate_to_v2.md)** for step-by-step instructions.
4+
35
The Skyflow Java SDK is designed to help with integrating Skyflow into a Java backend.
46

57
[![CI](https://img.shields.io/static/v1?label=CI&message=passing&color=green?style=plastic&logo=github)](https://github.com/skyflowapi/skyflow-java/actions)

docs/migrate_to_v2.md

Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
# Skyflow Java SDK — V1 to V2 Migration Guide
2+
3+
This guide covers the steps to migrate the Skyflow Java SDK from v1 to v2.
4+
5+
---
6+
7+
## Authentication options
8+
9+
In V2, multiple authentication options are available. You can now provide credentials in the following ways:
10+
11+
- Environment variable (`SKYFLOW_CREDENTIALS`) _(Recommended)_
12+
- API Key
13+
- Path to credentials JSON file
14+
- Stringified JSON of credentials
15+
- Bearer token
16+
17+
**V1 (Old)**
18+
19+
```java
20+
static class DemoTokenProvider implements TokenProvider {
21+
@Override
22+
public String getBearerToken() throws Exception {
23+
ResponseToken res = null;
24+
try {
25+
String filePath = "<YOUR_CREDENTIALS_FILE_HERE>";
26+
res = Token.generateBearerToken(filePath);
27+
} catch (SkyflowException e) {
28+
e.printStackTrace();
29+
}
30+
return res.getAccessToken();
31+
}
32+
}
33+
```
34+
35+
**V2 (New): Choose one of the following:**
36+
37+
```java
38+
// Option 1: API Key (Recommended)
39+
Credentials skyflowCredentials = new Credentials();
40+
skyflowCredentials.setApiKey("<YOUR_API_KEY>");
41+
42+
// Option 2: Environment Variable (Recommended)
43+
// Set SKYFLOW_CREDENTIALS in your environment
44+
45+
// Option 3: Credentials File
46+
skyflowCredentials.setPath("<YOUR_CREDENTIALS_FILE_PATH>");
47+
48+
// Option 4: Stringified JSON
49+
skyflowCredentials.setCredentialsString("<YOUR_CREDENTIALS_STRING>");
50+
51+
// Option 5: Bearer Token
52+
skyflowCredentials.setToken("<BEARER_TOKEN>");
53+
```
54+
55+
> **Notes:**
56+
> - Use only ONE authentication method per credentials object.
57+
> - API Key or environment variable are recommended for production.
58+
> - For priority order see [Quickstart — Initialize the client](../README.md#initialize-the-client).
59+
60+
---
61+
62+
## Initializing the client
63+
64+
V2 introduces a builder pattern for client initialization with multi-vault support.
65+
66+
**Key changes:**
67+
- `vaultUrl` replaced with `clusterId` (derived from vault URL)
68+
- Added `env` specification (e.g. `Env.PROD`, `Env.SANDBOX`)
69+
- Log level is now per-client-instance
70+
71+
**V1 (Old)**
72+
73+
```java
74+
DemoTokenProvider demoTokenProvider = new DemoTokenProvider();
75+
SkyflowConfiguration skyflowConfig = new SkyflowConfiguration(
76+
"<VAULT_ID>", "<VAULT_URL>", demoTokenProvider
77+
);
78+
Skyflow skyflowClient = Skyflow.init(skyflowConfig);
79+
```
80+
81+
**V2 (New)**
82+
83+
```java
84+
Credentials credentials = new Credentials();
85+
credentials.setPath("<YOUR_CREDENTIALS_FILE_PATH>");
86+
87+
VaultConfig config = new VaultConfig();
88+
config.setVaultId("<YOUR_VAULT_ID>");
89+
config.setClusterId("<YOUR_CLUSTER_ID>");
90+
config.setEnv(Env.PROD);
91+
config.setCredentials(credentials);
92+
93+
Skyflow skyflowClient = Skyflow.builder()
94+
.setLogLevel(LogLevel.DEBUG)
95+
.addVaultConfig(config)
96+
.build();
97+
```
98+
99+
---
100+
101+
## Request and response structure
102+
103+
V2 removes third-party JSON objects in favour of native `ArrayList` and `HashMap` with a builder pattern for requests.
104+
105+
**V1 (Old) — Request**
106+
107+
```java
108+
JSONObject recordsJson = new JSONObject();
109+
JSONArray recordsArrayJson = new JSONArray();
110+
JSONObject recordJson = new JSONObject();
111+
recordJson.put("table", "cards");
112+
JSONObject fieldsJson = new JSONObject();
113+
fieldsJson.put("cardNumber", "41111111111");
114+
fieldsJson.put("cvv", "123");
115+
recordJson.put("fields", fieldsJson);
116+
recordsArrayJson.add(recordJson);
117+
recordsJson.put("records", recordsArrayJson);
118+
try {
119+
JSONObject insertResponse = skyflowClient.insert(records);
120+
} catch (SkyflowException e) {
121+
System.out.println(e);
122+
}
123+
```
124+
125+
**V2 (New) — Request**
126+
127+
```java
128+
HashMap<String, Object> value = new HashMap<>();
129+
value.put("<COLUMN_NAME_1>", "<COLUMN_VALUE_1>");
130+
value.put("<COLUMN_NAME_2>", "<COLUMN_VALUE_2>");
131+
ArrayList<HashMap<String, Object>> values = new ArrayList<>();
132+
values.add(value);
133+
134+
InsertRequest insertRequest = InsertRequest.builder()
135+
.table("<TABLE_NAME>")
136+
.values(values)
137+
.returnTokens(true)
138+
.build();
139+
140+
InsertResponse response = skyflowClient.vault().insert(insertRequest);
141+
```
142+
143+
**V1 (Old) — Response**
144+
145+
```json
146+
{
147+
"records": [
148+
{
149+
"table": "cards",
150+
"fields": {
151+
"skyflow_id": "16419435-aa63-4823-aae7-19c6a2d6a19f",
152+
"cardNumber": "f3907186-e7e2-466f-91e5-48e12c2bcbc1",
153+
"cvv": "1989cb56-63da-4482-a2df-1f74cd0dd1a5"
154+
}
155+
}
156+
]
157+
}
158+
```
159+
160+
**V2 (New) — Response**
161+
162+
```json
163+
{
164+
"insertedFields": [
165+
{
166+
"skyflowId": "9fac9201-7b8a-4446-93f8-5244e1213bd1",
167+
"card_number": "5484-7829-1702-9110",
168+
"cardholder_name": "b2308e2a-c1f5-469b-97b7-1f193159399b"
169+
}
170+
],
171+
"errors": null
172+
}
173+
```
174+
175+
---
176+
177+
## Request options
178+
179+
V2 builder pattern replaces V1 options objects.
180+
181+
**V1 (Old)**
182+
183+
```java
184+
InsertOptions insertOptions = new InsertOptions(true);
185+
```
186+
187+
**V2 (New)**
188+
189+
```java
190+
InsertRequest request = InsertRequest.builder()
191+
.table("<TABLE_NAME>")
192+
.values(values)
193+
.continueOnError(false)
194+
.tokenMode(TokenMode.DISABLE)
195+
.returnTokens(false)
196+
.upsert("<UPSERT_COLUMN>")
197+
.build();
198+
```
199+
200+
---
201+
202+
## Error structure
203+
204+
V2 provides richer error details for easier debugging.
205+
206+
**V1 (Old)**
207+
208+
```json
209+
{
210+
"code": "<http_code>",
211+
"description": "<description>"
212+
}
213+
```
214+
215+
**V2 (New)**
216+
217+
```json
218+
{
219+
"httpStatus": "<http_status>",
220+
"grpcCode": "<grpc_code>",
221+
"httpCode": "<http_code>",
222+
"message": "<message>",
223+
"requestId": "<request_id>",
224+
"details": ["<details>"]
225+
}
226+
```
227+
228+
---
229+
230+
## Credential field names (v2.1+)
231+
232+
The credentials JSON file field names are updated to follow Java camelCase conventions. Both old and new forms are permanently accepted.
233+
234+
| Old form (still accepted) | New form (preferred) |
235+
|---|---|
236+
| `clientID` | `clientId` |
237+
| `keyID` | `keyId` |
238+
| `tokenURI` | `tokenUri` |
239+
240+
---
241+
242+
## Response field names (v2.1+)
243+
244+
Response maps now return `skyflowId` (camelCase). The legacy `skyflow_id` key is still present for backward compatibility but is deprecated.
245+
246+
| Deprecated (still returned) | Preferred |
247+
|---|---|
248+
| `skyflow_id` | `skyflowId` |
249+
250+
---
251+
252+
For the full list of changes see [CHANGELOG.md](../CHANGELOG.md).

0 commit comments

Comments
 (0)