Skip to content

Commit e47a6fe

Browse files
SK-2707: add inline example responses to each README operation
Each vault, token, connection, and Detect operation now shows an "Example response" block with the printed response object, so the response shape is visible at the point of use instead of only via the API reference link. Shapes verified against the response parsers and existing tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 1663c6b commit e47a6fe

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ insert_response = skyflow_client.vault('<VAULT_ID>').insert(insert_request)
189189
print('Insert response:', insert_response)
190190
```
191191

192+
Returns an `InsertResponse` (`inserted_fields`, `errors`). With `return_tokens=True`, each entry includes the `skyflow_id` and a token per column:
193+
194+
```text
195+
Insert response: InsertResponse(inserted_fields=[{'skyflow_id': 'a8f0c2e1-7b3d-4f9a-8c21-1d2e3f4a5b6c', 'card_number': '5391-4629-3722-7102', 'cardholder_name': '0f6b8a2c-90ab-4cde-9def-567890abcdef'}], errors=None)
196+
```
197+
192198
## Upgrade from v1 to v2
193199

194200
Upgrade from `skyflow-python` v1 using the dedicated guide in [docs/migrate_to_v2.md](docs/migrate_to_v2.md).
@@ -223,6 +229,14 @@ response = skyflow_client.vault('<VAULT_ID>').insert(insert_request)
223229
print('Insert response:', response)
224230
```
225231

232+
Returns an `InsertResponse`:
233+
234+
```text
235+
Insert response: InsertResponse(inserted_fields=[{'skyflow_id': 'a8f0c2e1-7b3d-4f9a-8c21-1d2e3f4a5b6c', '<FIELD_NAME_1>': '<TOKEN_1>', '<FIELD_NAME_2>': '<TOKEN_2>'}], errors=None)
236+
```
237+
238+
> With `continue_on_error=True`, each entry also carries a `request_index`, and `errors` is a list of `{request_index, request_id, error, http_code}` for the rows that failed.
239+
226240
#### Insert example with `continue_on_error` option
227241

228242
Set the `continue_on_error` flag to `True` to allow insert operations to proceed despite encountering partial errors.
@@ -270,6 +284,12 @@ response = skyflow_client.vault('<VAULT_ID>').detokenize(detokenize_request)
270284
print('Detokenization response:', response)
271285
```
272286

287+
Returns a `DetokenizeResponse` (`detokenized_fields`, `errors`); each field has `token`, `value`, and `type`:
288+
289+
```text
290+
Detokenization response: DetokenizeResponse(detokenized_fields=[{'token': 'token1', 'value': '4111111111111111', 'type': 'STRING'}, {'token': 'token2', 'value': 'John Doe', 'type': 'STRING'}], errors=None)
291+
```
292+
273293
> [!TIP]
274294
> See the full example in the samples directory: [detokenize_records.py](samples/vault_api/detokenize_records.py)
275295
@@ -297,6 +317,12 @@ response = skyflow_client.vault('<VAULT_ID>').get(get_request)
297317
print('Get response:', response)
298318
```
299319

320+
Returns a `GetResponse` (`data`, `errors`), where `data` is a list of record dicts:
321+
322+
```text
323+
Get response: GetResponse(data=[{'skyflow_id': 'a8f0c2e1-7b3d-4f9a-8c21-1d2e3f4a5b6c', 'card_number': '4111111111111111', 'cardholder_name': 'John Doe'}], errors=None)
324+
```
325+
300326
#### Get by Skyflow IDs
301327

302328
Retrieve specific records using Skyflow IDs. Use this method when you know the exact record IDs.
@@ -316,6 +342,10 @@ response = skyflow_client.vault('<VAULT_ID>').get(get_request)
316342
print('Data retrieval successful:', response)
317343
```
318344

345+
```text
346+
Data retrieval successful: GetResponse(data=[{'skyflow_id': '<SKYFLOW_ID1>', 'card_number': '4111111111111111', 'cardholder_name': 'John Doe'}], errors=None)
347+
```
348+
319349
#### Get tokens for records
320350

321351
Return tokens for records to securely process sensitive data while maintaining data privacy.
@@ -387,6 +417,12 @@ response = skyflow_client.vault('<VAULT_ID>').update(update_request)
387417
print('Update response:', response)
388418
```
389419

420+
Returns an `UpdateResponse` (`updated_field`, `errors`). With the default `return_tokens=False`, only the `skyflow_id` is returned; with `return_tokens=True`, tokens for the updated columns are included:
421+
422+
```text
423+
Update response: UpdateResponse(updated_field={'skyflow_id': '<SKYFLOW_ID>'}, errors=None)
424+
```
425+
390426
> [!TIP]
391427
> See the full example in the samples directory: [update_record.py](samples/vault_api/update_record.py)
392428
@@ -406,6 +442,12 @@ response = skyflow_client.vault('<VAULT_ID>').delete(delete_request)
406442
print('Delete response:', response)
407443
```
408444

445+
Returns a `DeleteResponse` (`deleted_ids`, `errors`):
446+
447+
```text
448+
Delete response: DeleteResponse(deleted_ids=['<SKYFLOW_ID1>', '<SKYFLOW_ID2>', '<SKYFLOW_ID3>'], errors=None)
449+
```
450+
409451
> [!TIP]
410452
> See the full example in the samples directory: [delete_records.py](samples/vault_api/delete_records.py)
411453
@@ -424,6 +466,12 @@ response = skyflow_client.vault('<VAULT_ID>').query(query_request)
424466
print('Query response:', response)
425467
```
426468

469+
Returns a `QueryResponse` (`fields`, `errors`), where `fields` is a list of matching record dicts (each also includes a `tokenized_data` map):
470+
471+
```text
472+
Query response: QueryResponse(fields=[{'card_number': '4111111111111111', 'cardholder_name': 'John Doe', 'tokenized_data': {}}], errors=None)
473+
```
474+
427475
> [!TIP]
428476
> See the full example in the samples directory: [query_records.py](samples/vault_api/query_records.py)
429477
@@ -465,6 +513,12 @@ with open('path/to/file.pdf', 'rb') as file_obj:
465513
print('File upload:', response)
466514
```
467515

516+
Both forms return a `FileUploadResponse` (`skyflow_id`, `errors`) with the ID of the record the file was attached to (or the newly created record):
517+
518+
```text
519+
File upload: FileUploadResponse(skyflow_id='a8f0c2e1-7b3d-4f9a-8c21-1d2e3f4a5b6c', errors=None)
520+
```
521+
468522
> [!TIP]
469523
> See the full example in the samples directory: [upload_file.py](samples/vault_api/upload_file.py)
470524
@@ -488,6 +542,12 @@ response = skyflow_client.vault('<VAULT_ID>').tokenize(tokenize_request)
488542
print('Tokenization result:', response)
489543
```
490544

545+
Returns a `TokenizeResponse` (`tokenized_fields`, `errors`); each field carries its `token`:
546+
547+
```text
548+
Tokenization result: TokenizeResponse(tokenized_fields=[{'token': 'a1b2c3d4-...'}, {'token': 'e5f6g7h8-...'}], errors=None)
549+
```
550+
491551
> [!TIP]
492552
> See the full example in the samples directory: [tokenize_records.py](samples/vault_api/tokenize_records.py)
493553
@@ -522,6 +582,12 @@ response = skyflow_client.detect('<VAULT_ID>').deidentify_text(request)
522582
print('De-identify Text Response:', response)
523583
```
524584

585+
Returns a `DeidentifyTextResponse` (`processed_text`, `entities`, `word_count`, `char_count`, `errors`). `entities` is a list of [`EntityInfo`](docs/api_reference.md#entityinfo) describing each detected entity:
586+
587+
```text
588+
De-identify Text Response: DeidentifyTextResponse(processed_text='My SSN is [SSN_1].', entities=[...], word_count=4, char_count=18, errors=None)
589+
```
590+
525591
> [!TIP]
526592
> See the full example in the samples directory: [deidentify_text.py](samples/detect_api/deidentify_text.py)
527593
@@ -544,6 +610,12 @@ response = skyflow_client.detect().reidentify_text(request)
544610
print('Re-identify Text Response:', response)
545611
```
546612

613+
Returns a `ReidentifyTextResponse` (`processed_text`, `errors`):
614+
615+
```text
616+
Re-identify Text Response: ReidentifyTextResponse(processed_text='John lives in NYC', errors=None)
617+
```
618+
547619
> [!TIP]
548620
> See the full example in the samples directory: [reidentify_text.py](samples/detect_api/reidentify_text.py)
549621
@@ -569,6 +641,12 @@ with open('path/to/file.pdf', 'rb') as file_obj:
569641
print('De-identify File Response:', response)
570642
```
571643

644+
Returns a `DeidentifyFileResponse` with the processed file plus metadata (`file`, `type`, `extension`, `word_count`, `char_count`, `size_in_kb`, `entities`, `run_id`, `status`, `errors`, and more — see the [API Reference](docs/api_reference.md#response-objects)). If processing exceeds `wait_time`, only `run_id` and `status` are returned (poll with `get_detect_run`):
645+
646+
```text
647+
De-identify File Response: DeidentifyFileResponse(file_base64=None, file=<File ...>, type='application/pdf', extension='pdf', ..., run_id='r-9c1f2a3b', status='SUCCESS', errors=None)
648+
```
649+
572650
**Supported file types:**
573651

574652
- Documents: `doc`, `docx`, `pdf`
@@ -603,6 +681,12 @@ response = skyflow_client.detect().get_detect_run(request)
603681
print('Get Detect Run Response:', response)
604682
```
605683

684+
Returns a `DeidentifyFileResponse` with the current `status` for the run (and the processed file once `status` is complete):
685+
686+
```text
687+
Get Detect Run Response: DeidentifyFileResponse(file_base64=None, file=None, ..., run_id='r-9c1f2a3b', status='IN_PROGRESS', errors=None)
688+
```
689+
606690
> [!TIP]
607691
> See the full example in the samples directory: [get_detect_run.py](samples/detect_api/get_detect_run.py)
608692
@@ -635,6 +719,12 @@ response = skyflow_client.connection().invoke(invoke_request)
635719
print('Connection response:', response)
636720
```
637721

722+
Returns an `InvokeConnectionResponse` (`data`, `metadata`, `errors`), where `data` is the connection's response body:
723+
724+
```text
725+
Connection response: InvokeConnectionResponse(data={'message': 'success'}, metadata={'request_id': 'b7d3...'}, errors=None)
726+
```
727+
638728
`method` supports the following methods (see [`RequestMethod`](docs/api_reference.md#requestmethod)):
639729

640730
- `GET`

0 commit comments

Comments
 (0)