Skip to content

Commit

Permalink
Merge pull request #113 from skyflowapi/SK-1192-samples-readme-and-ch…
Browse files Browse the repository at this point in the history
…angelog-update-for-token-options

SK-1192 README and changelog update for token options in get interface
  • Loading branch information
skyflow-bharti authored Dec 1, 2023
2 parents 295f0ce + 9c95f45 commit a3ce588
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

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

## [1.15.0] - 2023-10-30
## Added
- options tokens support for Get method.

## [1.14.0] - 2023-09-29
## Added
- Support for different BYOT modes in Insert method.
Expand Down
58 changes: 56 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,14 @@ Sample response:

### Get

To retrieve data using Skyflow IDs or unique column values, use the `get(records: dict)` method. The `records` parameter takes a Dictionary that contains either an array of Skyflow IDs or a unique column name and values.
To retrieve data using Skyflow IDs or unique column values, use the `get(records: dict,options: GetOptions)` method. The `records` parameter takes a Dictionary that contains either an array of Skyflow IDs or a unique column name and values.The second parameter options is a GetOptions object that retrieves tokens of Skyflow IDs.

Note: You can use either Skyflow IDs or `unique` values to retrieve records. You can't use both at the same time.
Note:

- You can use either Skyflow IDs or `unique` values to retrieve records. You can't use both at the same time.
- GetOptions parameter applicable only for retrieving tokens using Skyflow ID.
- You can't pass GetOptions along with the redaction type.
- `tokens` defaults to false.

```python
{
Expand Down Expand Up @@ -525,6 +530,55 @@ Sample response:
}
```

The following snippet shows how to use the `get()` method with GetOptions.

```python
from skyflow.vault import GetOptions

{
'records': [
{
'ids': ['56513264-fc45-41fa-9cb0-d1ad3602bc49','da26de53-95d5-4bdb-99db-8d8c66a35ff9'],
'table': 'cards',
}
]
}

try:
client.get(records, GetOptions(True))
except SkyflowError as e:
if e.data:
print(e.data)
else:
print(e)
```

Sample response:

```python
{
'records': [
{
'fields': {
'card_number': '4555-5176-5936-1930',
'cvv': '6ad5f708-2061-453e-9491-618a1f29a688',
'skyflow_id': '56513264-fc45-41fa-9cb0-d1ad3602bc49'
},
'table': 'cards'
},
{
'fields': {
'card_number': '8882-7418-2776-6660',
'cvv': '25260679-e339-4b33-a5b0-c8b08df77af7',
'skyflow_id': 'da26de53-95d5-4bdb-99db-8d8c66a35ff9'
},
'table': 'cards'
}
],
'errors': []
}
```

### Get By Id

For retrieving using SkyflowID's, use the get_by_id(records: dict) method. The records parameter takes a Dictionary that contains records to be fetched as shown below:
Expand Down
6 changes: 4 additions & 2 deletions samples/get_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'''
from skyflow.errors import SkyflowError
from skyflow.service_account import generate_bearer_token, is_expired
from skyflow.vault import Client, Configuration, RedactionType
from skyflow.vault import Client, Configuration, RedactionType, GetOptions


# cache token for reuse
Expand All @@ -22,6 +22,8 @@ def token_provider():
'<YOUR_VAULT_ID>', '<YOUR_VAULT_URL>', token_provider)
client = Client(config)

options = GetOptions(False)

data = {"records": [
{
"ids": ["<SKYFLOW_ID1>", "<SKYFLOW_ID2>", "<SKYFLOW_ID3>"],
Expand All @@ -37,7 +39,7 @@ def token_provider():
}
]}

response = client.get(data)
response = client.get(data,options=options)
print('Response:', response)
except SkyflowError as e:
print('Error Occurred:', e)

0 comments on commit a3ce588

Please sign in to comment.