Skip to content

Commit 147bec6

Browse files
Merge pull request #79 from skyflowapi/SK-737-readme-and-changelog-changes-for-redaction-type-in-reveal-and-detokenize-in-python-sdk
SK-737 readme changes for redaction type in reveal and detokenize in python sdk
2 parents 926f086 + 69e2285 commit 147bec6

3 files changed

Lines changed: 46 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [1.9.1] - 2023-06-07
6+
### Fixed
7+
- Fixed bug in metrics
8+
9+
## [1.9.0] - 2023-06-07
10+
### Added
11+
- Added redaction type in detokenize
12+
513
## [1.8.1] - 2023-03-17
614
### Removed
715
- removed grace period logic in bearer token generation

README.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,26 @@ This Python SDK is designed to help developers easily implement Skyflow into the
77

88

99
## Table of Contents
10-
- [Description](#description)
10+
- [Skyflow-python](#skyflow-python)
11+
- [Description](#description)
1112
- [Table of Contents](#table-of-contents)
1213
- [Features](#features)
1314
- [Installation](#installation)
1415
- [Requirements](#requirements)
1516
- [Configuration](#configuration)
1617
- [Service Account Bearer Token Generation](#service-account-bearer-token-generation)
1718
- [Vault APIs](#vault-apis)
18-
- [Insert](#insert-data-into-the-vault)
19+
- [Insert data into the vault](#insert-data-into-the-vault)
1920
- [Detokenize](#detokenize)
2021
- [Get](#get)
2122
- [Get By Id](#get-by-id)
22-
- [Update](#update-data)
23+
- [Redaction Types](#redaction-types)
24+
- [Update](#update)
2325
- [Invoke Connection](#invoke-connection)
2426
- [Logging](#logging)
2527
- [Reporting a Vulnerability](#reporting-a-vulnerability)
28+
- [Get](#get-1)
29+
- [Update](#update-1)
2630

2731
## Features
2832

@@ -259,11 +263,13 @@ In order to retrieve data from your vault using tokens that you have previously
259263
{
260264
"records":[
261265
{
262-
"token": str #token for the record to be fetched
266+
"token": str , # Token for the record to fetch
267+
"redaction": Skyflow.RedactionType # Optional. Redaction to apply for retrieved data. E.g. RedactionType.MASKED
263268
}
264269
]
265270
}
266271
```
272+
Note: `redaction` defaults to [RedactionType.PLAIN_TEXT](#redaction-types).
267273

268274
An [example](https://github.com/skyflowapi/skyflow-python/blob/main/samples/detokenize_sample.py) of a detokenize call:
269275

@@ -272,8 +278,16 @@ try:
272278
client.detokenize(
273279
{
274280
"records": [
275-
{"token": "45012507-f72b-4f5c-9bf9-86b133bae719"},
276-
{'token': 'invalid-token'}
281+
{
282+
"token": "45012507-f72b-4f5c-9bf9-86b133bae719"
283+
},
284+
{
285+
"token": '1r434532-6f76-4319-bdd3-96281e051051',
286+
"redaction": Skyflow.RedactionType.MASKED
287+
},
288+
{
289+
"token": "invalid-token"
290+
}
277291
]
278292
}
279293
)
@@ -292,6 +306,10 @@ Sample response:
292306
{
293307
"token": "131e70dc-6f76-4319-bdd3-96281e051051",
294308
"value": "1990-01-01"
309+
},
310+
{
311+
"token": "1r434532-6f76-4319-bdd3-96281e051051",
312+
"value": "xxxxxxer",
295313
}
296314
],
297315
"errors": [
@@ -337,7 +355,7 @@ Note: You can use either Skyflow IDs or `unique` values to retrieve records. Yo
337355
```
338356
Sample usage
339357

340-
The following snippet shows how to use the `get()` method. For details, see [get_sample.py].(https://github.com/skyflowapi/skyflow-python/blob/main/samples/get_sample.py),
358+
The following snippet shows how to use the `get()` method. For details, see [get_sample.py](https://github.com/skyflowapi/skyflow-python/blob/main/samples/get_sample.py),
341359

342360
```python
343361
from skyflow.vault import RedactionType
@@ -420,6 +438,7 @@ For retrieving using SkyflowID's, use the get_by_id(records: dict) method. The r
420438
}
421439
```
422440

441+
#### Redaction Types
423442
There are 4 accepted values in Skyflow.RedactionTypes:
424443

425444
- `PLAIN_TEXT`

samples/detokenize_sample.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from skyflow.errors import SkyflowError
55
from skyflow.service_account import generate_bearer_token, is_expired
66
from skyflow.vault import Client, Configuration
7+
from skyflow.vault import RedactionType
78

89
# cache token for reuse
910
bearerToken = ''
@@ -23,7 +24,17 @@ def token_provider():
2324
'<YOUR_VAULT_ID>', '<YOUR_VAULT_URL>', token_provider)
2425
client = Client(config)
2526

26-
data = {"records": [{"<FIELD_NAME>": '<TOKEN>'}]}
27+
data = {
28+
"records": [
29+
{
30+
"token": '<TOKEN>',
31+
"redaction": RedactionType.MASKED
32+
},
33+
{
34+
"token": '<TOKEN>',
35+
}
36+
]
37+
}
2738
response = client.detokenize(data)
2839
print('Response:', response)
2940
except SkyflowError as e:

0 commit comments

Comments
 (0)