diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fb957c..2a20a8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/README.md b/README.md index 8313322..b64a0bc 100644 --- a/README.md +++ b/README.md @@ -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 { @@ -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: diff --git a/samples/get_sample.py b/samples/get_sample.py index 867d9aa..743f69d 100644 --- a/samples/get_sample.py +++ b/samples/get_sample.py @@ -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 @@ -22,6 +22,8 @@ def token_provider(): '', '', token_provider) client = Client(config) + options = GetOptions(False) + data = {"records": [ { "ids": ["", "", ""], @@ -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)