diff --git a/README.md b/README.md index b64a0bc..24cf7e9 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Invoking connections to call downstream third party APIs without directly handli ### Requirements -- Python 3.7.0 and above +- Python 3.8.0 and above ### Configuration @@ -57,542 +57,620 @@ The [Service Account](https://github.com/skyflowapi/skyflow-python/tree/main/sky The `generate_bearer_token(filepath)` function takes the credentials file path for token generation, alternatively, you can also send the entire credentials as string, by using `generate_bearer_token_from_creds(credentials)` -[Example using filepath](https://github.com/skyflowapi/skyflow-python/blob/main/samples/sa_token_sample.py): +[Example using filepath](https://github.com/skyflowapi/skyflow-python/blob/SK-1749-readme/samples/service_account/token_generation_example.py): ```python -from skyflow.errors import SkyflowError +from skyflow.error import SkyflowError from skyflow.service_account import generate_bearer_token, is_expired # cache token for reuse -bearerToken = '' -tokenType = '' +bearer_token = '' +token_type = '' def token_provider(): - global bearerToken - global tokenType + global bearer_token + global token_type - if is_expired(bearerToken): - bearerToken, tokenType = generate_bearer_token('') - return bearerToken, tokenType + if is_expired(bearer_token): + bearer_token, token_type = generate_bearer_toke('') + return bearer_token, token_type try: - accessToken, tokenType = token_provider() - print("Access Token:", accessToken) - print("Type of token:", tokenType) + bearer_token, token_type = token_provider() + print("Access Token:", bearer_token) + print("Type of token:", token_type) except SkyflowError as e: print(e) ``` -[Example using credentials string](https://github.com/skyflowapi/skyflow-python/blob/main/samples/generate_bearer_token_from_creds_sample.py): +[Example using credentials string](https://github.com/skyflowapi/skyflow-python/blob/SK-1749-readme/samples/service_account/token_generation_example.py): ```python -from skyflow.errors import SkyflowError -from skyflow.service_account import generate_bearer_token_from_creds, is_expired +from skyflow.error import SkyflowError +from skyflow.service_account import generate_bearer_token, generate_bearer_token_from_creds, is_expired # cache token for reuse -bearerToken = '' -tokenType = '' +bearer_token = '' +token_type = '' def token_provider(): - global bearerToken - global tokenType + global bearer_token + global token_type # As an example - credentials = { - "clientID": "", - "clientName": "", - "keyID": "", - "tokenURI": '', - "privateKey": "" - } - jsonString = json.dumps(credentials) - if is_expired(bearerToken): - bearerToken, tokenType = generate_bearer_token_from_creds( - credentials=jsonString) - return bearerToken, tokenType + skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' + if is_expired(bearer_token): + bearer_token, token_type = generate_bearer_token_from_creds(skyflow_credentials_string) + return bearer_token, token_type try: - accessToken, tokenType = token_provider() - print("Access Token:", accessToken) - print("Type of token:", tokenType) + bearer_token, token_type = token_provider() + print("Access Token:", bearer_token) + print("Type of token:", token_type) except SkyflowError as e: print(e) ``` -## Vault APIs +## Service Account Scoped Token Generation -The [Vault](https://github.com/skyflowapi/skyflow-python/tree/main/skyflow/vault) python module is used to perform operations on the vault such as inserting records, detokenizing tokens, retrieving tokens for a skyflow_id and to invoke a connection. +[Example using filepath](https://github.com/skyflowapi/skyflow-python/blob/SK-1749-readme/samples/service_account/scoped_token_generation_example.py): + +```python +from skyflow.error import SkyflowError +from skyflow.service_account import generate_bearer_token, is_expired + +# cache token for reuse +bearer_token = '' +token_type = '' +options = { + "role_ids": ["ROLE_ID1", "ROLE_ID2"] +} +def token_provider(): + global bearer_token + global token_type + + if is_expired(bearer_token): + bearer_token, token_type = generate_bearer_token('', options) + return bearer_token, token_type + +try: + bearer_token, token_type = token_provider() + print("Access Token:", bearer_token) + print("Type of token:", token_type) +except SkyflowError as e: + print(e) + +``` + + +[Example using credentials string](https://github.com/skyflowapi/skyflow-python/blob/SK-1749-readme/samples/service_account/scoped_token_generation_example.py): + +```python +from skyflow.error import SkyflowError +from skyflow.service_account import generate_bearer_token, generate_bearer_token_from_creds, is_expired + +# cache token for reuse +bearer_token = '' +token_type = '' +options = { + "role_ids": ["ROLE_ID1", "ROLE_ID2"] +} +def token_provider(): + global bearer_token + global token_type + # As an example + skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' + if is_expired(bearer_token): + bearer_token, token_type = generate_bearer_token_from_creds(skyflow_credentials_string, options) + return bearer_token, token_type + +try: + bearer_token, token_type = token_provider() + print("Access Token:", bearer_token) + print("Type of token:", token_type) +except SkyflowError as e: + print(e) + +``` + +## Service Account Token Generation With Context + +[Example using filepath](https://github.com/skyflowapi/skyflow-python/blob/SK-1749-readme/samples/service_account/token_generation_with_context_example.py): + +```python +from skyflow.error import SkyflowError +from skyflow.service_account import generate_bearer_token, is_expired + +# cache token for reuse +bearer_token = '' +token_type = '' +options = { + "ctx": "" +} +def token_provider(): + global bearer_token + global token_type + + if is_expired(bearer_token): + bearer_token, token_type = generate_bearer_token('', options) + return bearer_token, token_type + +try: + bearer_token, token_type = token_provider() + print("Access Token:", bearer_token) + print("Type of token:", token_type) +except SkyflowError as e: + print(e) + +``` -To use this module, the skyflow client must first be initialized as follows. + +[Example using credentials string](https://github.com/skyflowapi/skyflow-python/blob/SK-1749-readme/samples/service_account/token_generation_with_context_example.py): + +```python +from skyflow.error import SkyflowError +from skyflow.service_account import generate_bearer_token, generate_bearer_token_from_creds, is_expired + +# cache token for reuse +bearer_token = '' +token_type = '' +options = { + "ctx": "" +} +def token_provider(): + global bearer_token + global token_type + # As an example + skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' + if is_expired(bearer_token): + bearer_token, token_type = generate_bearer_token_from_creds(skyflow_credentials_string, options) + return bearer_token, token_type + +try: + bearer_token, token_type = token_provider() + print("Access Token:", bearer_token) + print("Type of token:", token_type) +except SkyflowError as e: + print(e) + +``` + +## Service Account Signed Token Generation + +[Example using filepath](https://github.com/skyflowapi/skyflow-python/blob/SK-1749-readme/samples/service_account/signed_token_generation_example.py): ```python -from skyflow.vault import Client, Configuration +from skyflow.error import SkyflowError from skyflow.service_account import generate_bearer_token, is_expired -# cache for reuse -bearerToken = '' +# cache token for reuse +bearer_token = '' +token_type = '' +options = { + "ctx": "CONTEX_ID", + "data_tokens": ["DATA_TOKEN1", "DATA_TOKEN2"], + "time_to_live": 90 # in seconds +} +def token_provider(): + global bearer_token + global token_type + + if is_expired(bearer_token): + bearer_token, token_type = generate_bearer_token('', options) + return bearer_token, token_type + +try: + bearer_token, token_type = token_provider() + print("Access Token:", bearer_token) + print("Type of token:", token_type) +except SkyflowError as e: + print(e) + +``` + + +[Example using credentials string](https://github.com/skyflowapi/skyflow-python/blob/SK-1749-readme/samples/service_account/signed_token_generation_example.py): + +```python +from skyflow.error import SkyflowError +from skyflow.service_account import generate_bearer_token, generate_bearer_token_from_creds, is_expired -# User defined function to provide access token to the vault apis +# cache token for reuse +bearer_token = '' +token_type = '' +options = { + "ctx": "CONTEX_ID", + "data_tokens": ["DATA_TOKEN1", "DATA_TOKEN2"], + "time_to_live": 90 # in seconds +} def token_provider(): - global bearerToken - if !(is_expired(bearerToken)): - return bearerToken - bearerToken, _ = generate_bearer_token('') - return bearerToken + global bearer_token + global token_type + # As an example + skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' + if is_expired(bearer_token): + bearer_token, token_type = generate_bearer_token_from_creds(skyflow_credentials_string, options) + return bearer_token, token_type + +try: + bearer_token, token_type = token_provider() + print("Access Token:", bearer_token) + print("Type of token:", token_type) +except SkyflowError as e: + print(e) + +``` + +## Vault APIs + +The vault python module is used to perform operations on the vault such as inserting records, detokenizing tokens, retrieving tokens for a skyflow_id and to invoke a connection. -#Initializing a Skyflow Client instance with a SkyflowConfiguration object -config = Configuration('', '', token_provider) -client = Client(config) +To use this module, the skyflow client must first be initialized as follows. + +```python +from skyflow import Env +from skyflow import Skyflow, LogLevel + +# To generate Bearer Token from credentials string. +skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' + +# Pass one of api_key, token, credentials_string & path as credentials +credentials = { + "token": "BEARER_TOKEN", # bearer token + # api_key: "API_KEY", # API_KEY + # path: "PATH", # path to credentials file + # credentials_string: skyflow_credentials_string, # credentials as string +} + +client = ( + Skyflow.builder() + .add_vault_config({ + "vault_id": "VAULT_ID", # primary vault + "cluster_id": "CLUSTER_ID", # ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com + "env": Env.PROD, # Env by default it is set to PROD + "credentials": credentials # individual credentials + }) + .add_skyflow_credentials(credentials) # skyflow credentials will be used if no individual credentials are passed + .set_log_level(LogLevel.INFO) # set log level by default it is set to ERROR + .build() +) ``` All Vault APIs must be invoked using a client instance. ### Insert data into the vault -To insert data into your vault use the `insert(records: dict, options: InsertOptions)` method. The `records` parameter is a dictionary that requires a `records` key and takes an array of records to insert into the vault. The `options` parameter takes a dictionary of optional parameters for the insertion. This includes an option to return tokenized data, upsert records and continue on error. +To insert data into your vault, use the `insert` method. The `InsertRequest` class is used to create an insert request, which contains the data to be inserted in the form of a dictionary of records. Additionally, you can provide options in the insert request, such as returning tokenized data, upserting records, and continuing on error. +Insert call schema ```python -# Optional, indicates whether you return tokens for inserted data. Defaults to 'true'. -tokens: bool -# Optional, indicates Upsert support in the vault. -upsert: [UpsertOption] -# Optional, decides whether to continue if error encountered or not -continueOnError: bool +#Initialize Client +from skyflow.vault.data import InsertRequest + +try: + insert_data = [ + {"": ''}, + {"": ''} + ] + + + insert_request = InsertRequest( + table_name='', + values=insert_data, + ) + + response = skyflow_client.vault('VAULT_ID').insert(insert_request) + print("Response:", response) +except SkyflowError as e: + print("Error Occurred:", e) ``` -Insert call schema +**Insert call [example](https://github.com/skyflowapi/skyflow-python/blob/SK-1749-readme/samples/vault_api/insert_records.py)** + ```python -from skyflow.vault import InsertOptions, UpsertOption -from skyflow.errors import SkyflowError +from skyflow.vault.data import InsertRequest -#Initialize Client try: - # Create an Upsert option. - upsertOption = UpsertOption(table="",column="") - options = InsertOptions(tokens=True, upsert=[upsertOption], continueOnError=False) + insert_data = [ + {"card_number": '4111111111111111'}, + ] - data = { - "records": [ - { - "table": "", - "fields": { - "": "" - } - } - ] - } - response = client.insert(data, options=options) + insert_request = InsertRequest( + table_name='table1', + values=insert_data, + return_tokens=True # returns tokens + ) + + response = client.vault('d3dd9bbb7abc4c779b72f32cb7ee5d14').insert(insert_request) print("Response:", response) except SkyflowError as e: print("Error Occurred:", e) + ``` -**Insert call [example](https://github.com/skyflowapi/skyflow-python/blob/main/samples/insert_sample.py)** +Skyflow returns tokens for the record you just inserted. ```python -client.insert( - { - "records": [ +InsertResponse( + inserted_fields= + [ { - "table": "cards", - "fields": { - "cardNumber": "41111111111", - "cvv": "123", - }, + 'skyflow_id': 'a8f3ed5d-55eb-4f32-bf7e-2dbf4b9d9097', + 'card_number': '5479-4229-4622-1393' } - ] - }, - InsertOptions(True), + ], + error=[] ) ``` -Skyflow returns tokens for the record you just inserted. +**Insert call example with `continue_on_error` option** -```json -{ - "records": [ - { - "table": "cards", - "fields": { - "cardNumber": "f3907186-e7e2-466f-91e5-48e12c2bcbc1", - "cvv": "1989cb56-63da-4482-a2df-1f74cd0dd1a5", - "skyflow_id": "d863633c-8c75-44fc-b2ed-2b58162d1117" - }, - "request_index": 0 - } +```python +from skyflow.vault.data import InsertRequest + +try: + insert_data = [ + {"card_number": '4111111111111111'}, + {"card_numbe": '4111111111111111'}, # Intentional typo ] -} + + insert_request = InsertRequest( + table_name='table1', + values=insert_data, + return_tokens=True, # returns tokens + continue_on_error=True + ) + + response = client.vault('d3dd9bbb7abc4c779b72f32cb7ee5d14').insert(insert_request) + print("Response:", response) +except SkyflowError as e: + print("Error Occurred:", e) + ``` -**Insert call [example](https://github.com/skyflowapi/skyflow-python/blob/main/samples/insert_with_continue_on_error_sample.py) with `continueOnError` option** +Sample Response ```python -client.insert( - { - "records": [ +InsertResponse( + inserted_fields= + [ { - "table": "cards", - "fields": { - "card_number": "4111111111111111", - "full_name": "john doe" - } - }, - { - "table": "pii_field", - "fields": { - "card_number": "4242424242424200" - "full_name": "jane doe" - } + 'skyflow_id': '89c125d1-3bec-4360-b701-a032dda16500', + 'request_index': 0, + 'card_number': '5479-4229-4622-1393' } + ], + error= + [ + { + 'request_index': 1, + 'error': 'Insert failed. Column card_numbe is invalid. Specify a valid column.'} ] - }, InsertOptions(tokens=True, continueOnError=True) ) + ``` -Sample Response +**Insert call example with `upsert` options** -```json -{ - "records": [ - { - "table": "cards", - "fields": { - "card_number": "f37186-e7e2-466f-91e5-48e2bcbc1", - "full_name": "1989cb56-63a-4482-adf-1f74cd1a5", - "skyflow_id": "3daf1a7f-bc7f-4fc9-8c56-a6e4e93231e6" - }, - "request_index": 0 - } - ], - "errors": [ - { - "error": { - "code": 404, - "description": "Object Name pii_field was not found for Vault - requestId : af4aad11-f276-474d-b626-c75c8b35d49e", - "request_index": 1 - } - } - ] -} +```python +from skyflow.vault.data import InsertRequest + +try: + insert_data = [ + {"name": 'sample name'}, + ] + + insert_request = InsertRequest( + table_name='table1', + values=insert_data, + return_tokens=True, # returns tokens + upsert="name" # unique column name + ) + response = client.vault('d3dd9bbb7abc4c779b72f32cb7ee5d14').insert(insert_request) + print("Response:", response) +except SkyflowError as e: + print("Error Occurred:", e) ``` -**Insert call [example](https://github.com/skyflowapi/skyflow-python/blob/main/samples/insert_upsert_sample.py) with `upsert` options** +Skyflow returns tokens, with `upsert` support, for the record you just inserted. ```python -upsertOption = UpsertOption(table="cards",column="cardNumber") -client.insert( - { - "records": [ +InsertResponse( + inserted_fields= + [ { - "table": "cards", - "fields": { - "cardNumber": "41111111111", - "cvv": "123", - }, + 'skyflow_id': 'a8f3ed5d-55eb-4f32-bf7e-2dbf4b9d9097', + 'name': '3f27b3d7-6bf0-432a-acf9-789c0470e2da' } - ] - }, - InsertOptions(tokens=True,upsert=[upsertOption]), + ], + error=[] ) ``` -Skyflow returns tokens, with `upsert` support, for the record you just inserted. - -```json -{ - "records": [ - { - "table": "cards", - "fields": { - "cardNumber": "f3907186-e7e2-466f-91e5-48e12c2bcbc1", - "cvv": "1989cb56-63da-4482-a2df-1f74cd0dd1a5", - "skyflow_id": "60b32788-12ec-4dd7-9da5-0146c3afbe11" - }, - "request_index": 0 - } - ] -} -``` - ### Detokenize -To retrieve tokens from your vault, you can use the `Detokenize(records: dict, options: DetokenizeOptions)` method.The records parameter takes a dictionary that contains the `records` key that takes an array of records to return. The options parameter is a `DetokenizeOptions` object that provides further options, including `continueOnError` operation, for your detokenize call, as shown below: +To retrieve tokens from your vault, you can use the `detokenize` method. The `DetokenizeRequest` class requires a list of detokenization data to be provided as input. Additionally, the redaction type and continue on error are optional parameters. ```python -{ - "records":[ - { - "token": str , # Token for the record to fetch - "redaction": Skyflow.RedactionType # Optional. Redaction to apply for retrieved data. E.g. RedactionType.MASKED - } - ] -} +from skyflow.vault.tokens import DetokenizeRequest + +try: + detokenize_data = ["", "", ""] + + detokenize_request = DetokenizeRequest( + tokens=detokenize_data, + continue_on_error=False, # optional + redaction_type='plain-text' # optional + ) + + response = skyflow_client.vault('').detokenize(detokenize_request) + print("Response:", response) +except SkyflowError as e: + print("Error Occurred:", e) + ``` Notes: -- `redaction` defaults to [RedactionType.PLAIN_TEXT](#redaction-types). -- `continueOnError` in DetokenizeOptions will default to `True`. +- `redaction` defaults to `plain-text`. +- `continue_on_error` default valus is `False`. -An [example](https://github.com/skyflowapi/skyflow-python/blob/main/samples/detokenize_sample.py) of a detokenize call: +An [example](https://github.com/skyflowapi/skyflow-python/blob/SK-1749-readme/samples/vault_api/detokenize_records.py) of a detokenize call: ```python +from skyflow.vault.tokens import DetokenizeRequest + try: - client.detokenize( - { - "records": [ - { - "token": "45012507-f72b-4f5c-9bf9-86b133bae719" - }, - { - "token": '1r434532-6f76-4319-bdd3-96281e051051', - "redaction": Skyflow.RedactionType.MASKED - }, - { - "token": "invalid-token" - } - ] - } + detokenize_data = ["9738-1683-0486-1480", "6184-6357-8409-6668", "4914-9088-2814-3840"] + + detokenize_request = DetokenizeRequest( + tokens=detokenize_data, + continue_on_error=False, # optional + redaction_type='plain-text' # optional ) + + response = skyflow_client.vault('d3dd9bbb7abc4c779b72f32cb7ee5d14').detokenize(detokenize_request) + print("Response:", response) except SkyflowError as e: - if e.data: - print(e.data) # see note below - else: - print(e) + print("Error Occurred:", e) + ``` Sample response: ```python -{ - "records": [ - { - "token": "131e70dc-6f76-4319-bdd3-96281e051051", - "value": "1990-01-01" - }, - { - "token": "1r434532-6f76-4319-bdd3-96281e051051", - "value": "xxxxxxer", - } - ], - "errors": [ - { - "token": "invalid-token", - "error": { - "code": 404, - "description": "Tokens not found for invalid-token" - } - } - ] -} +DetokenizeResponse( + detokenized_fields=[ + {'token': '9738-1683-0486-1480', 'value': '4111111111111115', 'type': 'STRING'}, + {'token': '6184-6357-8409-6668', 'value': '4111111111111119', 'type': 'STRING'}, + {'token': '4914-9088-2814-3840', 'value': '4111111111111118', 'type': 'STRING'} + ], + errors=[] +) ``` -An [example](https://github.com/skyflowapi/skyflow-python/blob/main/samples/detokenize_with_continue_on_error_sample.py) of a detokenize call with continueOnError: +An example of a detokenize call with continue_on_error: ```python +from skyflow.vault.tokens import DetokenizeRequest + try: - client.detokenize( - { - "records": [ - { - "token": "45012507-f72b-4f5c-9bf9-86b133bae719" - }, - { - "token": '1r434532-6f76-4319-bdd3-96281e051051', - "redaction": Skyflow.RedactionType.MASKED - } - ] - }, DetokenizeOptions(continueOnError=False) + detokenize_data = ["9738-1683-0486-1480", "6184-6357-8409-6668", "4914-9088-2814-384"] + + detokenize_request = DetokenizeRequest( + tokens=detokenize_data, + continue_on_error=True, # optional + redaction_type='plain-text' # optional ) + + response = skyflow_client.vault('d3dd9bbb7abc4c779b72f32cb7ee5d14').detokenize(detokenize_request) + print("Response:", response) except SkyflowError as e: - if e.data: - print(e.data) # see note below - else: - print(e) + print("Error Occurred:", e) + ``` Sample response: ```python -{ - "records": [ - { - "token": "131e70dc-6f76-4319-bdd3-96281e051051", - "value": "1990-01-01" - }, - { - "token": "1r434532-6f76-4319-bdd3-96281e051051", - "value": "xxxxxxer", - } - ] -} +DetokenizeResponse( + detokenized_fields=[ + { + 'token': '9738-1683-0486-1480', + 'value': '4111111111111115', + 'type': 'STRING' + }, + { + 'token': '6184-6357-8409-6668', + 'value': '4111111111111119', + 'type': 'STRING' + } + ], + errors=[ + { + 'token': '4914-9088-2814-384', + 'error': 'Token Not Found' + } + ] +) + ``` ### Get -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. +To retrieve data using Skyflow IDs or unique column values, use the `get` method. The `GetRequest` class is used to create a get request, where you specify parameters such as the table name, redaction type, Skyflow IDs, column names, column values, and return tokens. If Skyflow IDs are provided, column names and column values cannot be used. Similarly, if column names or column values are provided, Skyflow IDs cannot be used. -Note: +```python +from skyflow.vault.data import GetRequest - - 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. +GetRequest( + table = '', + ids = ['SKYFLOW_ID1>', 'SKYFLOW_ID2>'], + return_tokens = True, + redaction_type='plain-text' +) -```python -{ - 'records': [ - { - 'columnName': str, # Name of the unique column. - 'columnValues': [str], # List of unique column values. - 'table': str, # Name of table holding the data. - 'redaction': Skyflow.RedactionType, # Redaction applied to retrieved data. - } - ] -} - or -{ - 'records': [ - { - 'ids': [str], # List of Skyflow IDs. - 'table': str, # Name of table holding the data. - 'redaction': Skyflow.RedactionType, # Redaction applied to retrieved data. - } - ] -} +# or +GetRequest( + table = '', + column_name="", + column_values=['COLUMN_VALUE1>', 'COLUMN_VALUE2>'], + redaction_type='plain-text' +) ``` Sample usage -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), - -```python -from skyflow.vault import RedactionType - -skyflowIDs = ['f8d8a622-b557-4c6b-a12c-c5ebe0b0bfd9'] -record = {'ids': skyflowIDs, 'table': 'cards', 'redaction':RedactionType.PLAIN_TEXT} -recordsWithUniqueColumn = - { - 'table': 'test_table', - 'columnName': 'card_number', - 'columnValues': ['123456'], - 'redaction': RedactionType.PLAIN_TEXT - } - -invalidID = ['invalid skyflow ID'] -badRecord = {'ids': invalidID, 'table': 'cards', 'redaction': RedactionType.PLAIN_TEXT} - -records = {'records': [record, badRecord]} - -try: - client.get(records) -except SkyflowError as e: - if e.data: - print(e.data) - else: - print(e) -``` - -Sample response: +The following snippet shows how to use the `get` method. For details, see [get_column_values.py](https://github.com/skyflowapi/skyflow-python/blob/SK-1749-readme/samples/vault_api/get_column_values.py), ```python -{ - 'records': [ - { - 'fields': { - 'card_number': '4111111111111111', - 'cvv': '127', - 'expiry_date': '11/35', - 'fullname': 'monica', - 'skyflow_id': 'f8d8a622-b557-4c6b-a12c-c5ebe0b0bfd9' - }, - 'table': 'cards' - }, - { - 'fields': { - 'card_number': '123456', - 'cvv': '317', - 'expiry_date': '10/23', - 'fullname': 'sam', - 'skyflow_id': 'da26de53-95d5-4bdb-99db-8d8c66a35ff9' - }, - 'table': 'cards' - } - ], - 'errors': [ - { - 'error': { - 'code': '404', - 'description': 'No Records Found' - }, - 'skyflow_ids': ['invalid skyflow id'] - } - ] -} -``` +from skyflow.vault.data import GetRequest -The following snippet shows how to use the `get()` method with GetOptions. +try: + column_values = [ + '123456' + ] -```python -from skyflow.vault import GetOptions + get_request = GetRequest( + table='table1', + column_name="card_number", + column_values=column_values, + redaction_type='plain-text' + ) -{ - 'records': [ - { - 'ids': ['56513264-fc45-41fa-9cb0-d1ad3602bc49','da26de53-95d5-4bdb-99db-8d8c66a35ff9'], - 'table': 'cards', - } - ] -} - -try: - client.get(records, GetOptions(True)) + response = skyflow_client.vault('d3dd9bbb7abc4c779b72f32cb7ee5d14').get(get_request) + print("Response:", response) except SkyflowError as e: - if e.data: - print(e.data) - else: - print(e) + print("Error Occurred:", 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': [] -} +GetResponse( + data=[ + { + 'card_number': '123456', + 'skyflow_id': '4f7af9f9-09e0-4f47-af8e-04c9b1ee1968' + } + ], + error=[] +) + ``` -### Get By Id +### Get By Skyflow Ids -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: ```python -{ - "records": [ - { - "ids": [str], # List of SkyflowID's of the records to be fetched - "table": str, # name of table holding the above skyflow_id's - "redaction": Skyflow.RedactionType, # redaction to be applied to retrieved data - } - ] -} +from skyflow.vault.data import GetRequest + +GetRequest( + table = '', + ids = ['SKYFLOW_ID1>', 'SKYFLOW_ID2>'], + return_tokens = True, + redaction_type='plain-text' +) ``` #### Redaction Types @@ -603,245 +681,238 @@ There are 4 accepted values in Skyflow.RedactionTypes: - `REDACTED` - `DEFAULT` -An [example](https://github.com/skyflowapi/skyflow-python/blob/main/samples/get_by_ids_sample.py) of get_by_id call: +An [example](https://github.com/skyflowapi/skyflow-python/blob/SK-1749-readme/samples/vault_api/get_records.py) of get by skyflow ids call: ```python -from skyflow.vault import RedactionType +from skyflow.vault.data import GetRequest -skyflowIDs = [ - "f8d8a622-b557-4c6b-a12c-c5ebe0b0bfd9", - "da26de53-95d5-4bdb-99db-8d8c66a35ff9" -] -record = {"ids": skyflowIDs, "table": "cards", "redaction": RedactionType.PLAIN_TEXT} +try: + get_request = GetRequest( + table='table1', + ids=["aea64577-12b1-4682-aad5-a183194c3f3d", "b385c565-86eb-4af2-b959-8376f9b0754b"], + redaction_type="plain-text" + ) -invalidID = ["invalid skyflow ID"] -badRecord = {"ids": invalidID, "table": "cards", "redaction": RedactionType.PLAIN_TEXT} + response = client.vault('d3dd9bbb7abc4c779b72f32cb7ee5d14').get(get_request) + print("Response:", response) +except SkyflowError as e: + print("Error Occurred:", e) -records = {"records": [record, badRecord]} -try: - client.get_by_id(records) -except SkyflowError as e: - if e.data: - print(e.data) # see note below - else: - print(e) ``` Sample response: ```python -{ - "records": [ - { - "fields": { - "card_number": "4111111111111111", - "cvv": "127", - "expiry_date": "11/35", - "fullname": "myname", - "skyflow_id": "f8d8a622-b557-4c6b-a12c-c5ebe0b0bfd9" - }, - "table": "cards" - }, - { - "fields": { - "card_number": "4111111111111111", - "cvv": "317", - "expiry_date": "10/23", - "fullname": "sam", - "skyflow_id": "da26de53-95d5-4bdb-99db-8d8c66a35ff9" - }, - "table": "cards" - } - ], - "errors": [ - { - "error": { - "code": "404", - "description": "No Records Found" - }, - "skyflow_ids": ["invalid skyflow id"] - } - ] -} +GetResponse( + data=[ + { + 'card_number': '4555555555555553', + 'skyflow_id': 'aea64577-12b1-4682-aad5-a183194c3f3d' + }, + { + 'card_number': '4555555555555559', + 'skyflow_id': 'b385c565-86eb-4af2-b959-8376f9b0754b' + } + ], + error=[] +) + ``` -`Note:` While using detokenize and get_by_id methods, there is a possibility that some or all of the tokens might be invalid. In such cases, the data from response consists of both errors and detokenized records. In the SDK, this will raise a SkyflowError Exception and you can retrieve the data from this Exception object as shown above. -### Update +The following snippet shows how to use the `get()` method with return_tokens true. -To update data in your vault, use the `update(records: dict, options: UpdateOptions)` method. The `records` parameter takes a Dictionary that contains records to fetch. If `UpdateTokens` is `True`, Skyflow returns tokens for the record you just updated. If `UpdateOptions` is `False`, Skyflow returns IDs for the record you updated. +```python +from skyflow.vault.data import GetRequest + +try: + get_request = GetRequest( + table='table1', + ids=["aea64577-12b1-4682-aad5-a183194c3f3d", "b385c565-86eb-4af2-b959-8376f9b0754b"], + return_tokens=True + ) + + response = client.vault('d3dd9bbb7abc4c779b72f32cb7ee5d14').get(get_request) + print("Response:", response) +except SkyflowError as e: + print("Error Occurred:", e) + +``` + +Sample response: ```python -# Optional, indicates whether to return all fields for updated data. Defaults to 'true'. -options: UpdateOptions +GetResponse( + data=[ + { + 'card_number': '3562-0140-8820-7499', + 'skyflow_id': 'aea64577-12b1-4682-aad5-a183194c3f3d' + }, + { + 'card_number': '3998-2139-0328-0697', + 'skyflow_id': 'b385c565-86eb-4af2-b959-8376f9b0754b' + } + ], + error=[] +) ``` +### Update + +To update data in your vault, use the `update` method. The `UpdateRequest` class is used to create an update request, where you specify parameters such as the table name, data (as a dictionary), tokens, return_tokens, and token_strict. If `return_tokens` is set to True, Skyflow returns tokens for the updated records. If `return_tokens` is set to False, Skyflow returns IDs for the updated records. + ```python -{ - 'records': [ - { - 'id': str, # Skyflow ID of the record to be updated. - 'table': str, # Name of table holding the skyflowID. - 'fields': { - str: str # Name of the column and value to update. - } - } - ] -} +from skyflow.vault.data import UpdateRequest + +try: + update_data = { + 'id': '', + '': '' + } + + update_request = UpdateRequest( + table='TABLE_NAME', + data=update_data + ) + + response = skyflow_client.vault('VAULT_ID').update(update_request) + print("Response:", response) +except SkyflowError as e: + print("Error Occurred:", e) ``` Sample usage -The following snippet shows how to use the `update()` method. For details, see [update_sample.py](https://github.com/skyflowapi/skyflow-python/blob/main/samples/update_sample.py), +The following snippet shows how to use the `update()` method. For details, see [update_record.py](https://github.com/skyflowapi/skyflow-python/blob/SK-1749-readme/samples/vault_api/update_record.py), ```python -records = { - 'records': [ - { - 'id': '56513264-fc45-41fa-9cb0-d1ad3602bc49', - 'table': 'cards', - 'fields': { - 'card_number': '45678910234' - } - } - ] - } +from skyflow.vault.data import UpdateRequest + try: - client.update(records, UpdateOptions(True)) + update_data = { + 'id': '3b80c76a-c0d7-4c02-be00-b4128cb0f315', + 'card_number': '4111111111117777' + } + + update_request = UpdateRequest( + table='table1', + data=update_data + ) + + response = skyflow_client.vault('d3dd9bbb7abc4c779b72f32cb7ee5d14').update(update_request) + print("Response:", response) except SkyflowError as e: - if e.data: - print(e.data) - else: - print(e) + print("Error Occurred:", e) ``` Sample response -`UpdateOptions` set to `True` +`return_tokens` set to `True` ```python -{ - 'records':[ - { - 'id':'56513264-fc45-41fa-9cb0-d1ad3602bc49', - 'fields':{ - 'card_number':'0051-6502-5704-9879' - } - } - ], - 'errors':[] -} -``` - -`UpdateOptions` set to `False` +UpdateResponse( + updated_field={ + 'skyflow_id': '3b80c76a-c0d7-4c02-be00-b4128cb0f315', + 'card_number': '4131-1751-0217-8491' + }, + error=[] +) -```python -{ - 'records':[ - { - 'id':'56513264-fc45-41fa-9cb0-d1ad3602bc49' - } - ], - 'errors':[] -} ``` -Sample Error +`return_tokens` set to `False` ```python -{ - 'records':[ - { - 'id':'56513264-fc45-41fa-9cb0-d1ad3602bc49' - } - ], - 'errors':[ - { - 'error':{ - 'code':404, - 'description':'Token for skyflowID doesn"t exist in vault - Request ID: a8def196-9569-9cb7-9974-f899f9e4bd0a' - } - } - ] -} +UpdateResponse( + updated_field={'skyflow_id': '3b80c76a-c0d7-4c02-be00-b4128cb0f315'}, + error=[] +) + ``` ### Delete -For deleting using SkyflowID's, use the delete(records: dict) method. The records parameter takes a Dictionary that contains records to be deleted as shown below: +To delete records using Skyflow IDs, use the `delete` method. The `DeleteRequest` class accepts a list of Skyflow IDs that you want to delete, as shown below: ```python -{ - "records": [ - { - "id": str, # SkyflowID of the records to be deleted - "table": str, # name of table holding the above skyflow_id - }, - { - "id": str, # SkyflowID of the records to be deleted - "table": str, # name of table holding the above skyflow_id - } - ] -} +from skyflow.vault.data import DeleteRequest + +primary_delete_ids = [ + 'SKYFLOW_ID1', + 'SKYFLOW_ID2', + 'SKYFLOW_ID3', +] + +delete_request = DeleteRequest( + table='', + ids = primary_delete_ids +) ``` -An [example](https://github.com/skyflowapi/skyflow-python/blob/main/samples/delete_sample.py) of delete call: +An [example](https://github.com/skyflowapi/skyflow-python/blob/SK-1749-readme/samples/vault_api/delete_records.py) of delete call: ```python +from skyflow.vault.data import DeleteRequest -skyflowID = "b3d52e6d-1d6c-4750-ba28-aa30d04dbf01" -record = {"id": skyflowID, "table": "cards"} - -invalidID = "invalid skyflow ID" -badRecord = {"id": invalidID, "table": "cards"} +try: + delete_ids = [ + "77e093f8-3ace-4295-8683-bb6745d6178e", + "bf5989cc-79e8-4b2f-ad71-cb20b0a76091" + ] -records = {"records": [record, badRecord]} + delete_request = DeleteRequest( + table='table1', + ids=delete_ids + ) -try: - client.delete(records) + response = client.vault('d3dd9bbb7abc4c779b72f32cb7ee5d14').delete(delete_request) + print("Response:", response) except SkyflowError as e: - if e.data: - print(e.data) # see note below - else: - print(e) + print("Error Occurred:", e) + ``` Sample response: ```python -{ - "records":[ - { - "skyflow_id":"b3d52e6d-1d6c-4750-ba28-aa30d04dbf01", - "deleted":true - } - ], - "errors":[ - { - "id":"invalid skyflow ID", - "error":{ - "code":404, - "description":"No Records Found - request id: 239d462c-aa13-9f9d-a349-165b3dd11217" - } - } - ] -} +DeleteResponse( + deleted_ids=[ + "77e093f8-3ace-4295-8683-bb6745d6178e", + "bf5989cc-79e8-4b2f-ad71-cb20b0a76091" + ], + error=[] +) + ``` ### Invoke Connection -Using Skyflow Connection, end-user applications can integrate checkout/card issuance flow with their apps/systems. To invoke connection, use the invoke_connection(config: Skyflow.ConnectionConfig) method of the Skyflow client. +Using Skyflow Connection, end-user applications can integrate checkout/card issuance flow with their apps/systems. To invoke connection, use the `invoke` method of the Skyflow client. ```python -config = ConnectionConfig( - connectionURL: str, # connection url received when creating a skyflow connection integration - methodName: Skyflow.RequestMethod, - pathParams: dict, # optional - queryParams: dict, # optional - requestHeader: dict, # optional - requestBody: dict, # optional +from skyflow.vault.connection import InvokeConnectionRequest + +body = { + "KEY1": "VALUE1", + "KEY2": "VALUE2" +} +headers = { + "KEY1": "VALUE1" +} +path_params = { + "KEY1": "VALUE1" +} +query_params = { + "KEY1": "VALUE1" +} + +invoke_connection_request = InvokeConnectionRequest( + method=Method.POST, + body=body, + request_headers = headers, # optional + path_params = path_params, # optional + query_params=query_params # optional ) -client.invokeConnection(config) ``` `methodName` supports the following methods: @@ -852,71 +923,80 @@ client.invokeConnection(config) - PATCH - DELETE -**pathParams, queryParams, requestHeader, requestBody** are the JSON objects represented as dictionaries that will be sent through the connection integration url. +**path_params, query_params, request_header, request_body** are the JSON objects represented as dictionaries that will be sent through the connection integration url. -An [example](https://github.com/skyflowapi/skyflow-python/blob/main/samples/invoke_connection_sample.py) of invoke_connection: +An [example](https://github.com/skyflowapi/skyflow-python/blob/SK-1749-readme/samples/vault_api/invoke_connection.py) of invoke_connection: ```python -from skyflow.vault import ConnectionConfig, Configuration, RequestMethod +from skyflow import Skyflow +from skyflow import LogLevel +from skyflow.utils.enums import Method +from skyflow.vault.connection import InvokeConnectionRequest -bearerToken = '' -def token_provider(): - global bearerToken - if !(is_expired(bearerToken)): - return bearerToken - bearerToken, _ = generate_bearer_token('') - return bearerToken +credentials = { + "path": '/home/saib/skyflow/skyflow-python/credentials.json', +} -try: - config = Configuration('', '', token_provider) - connectionConfig = ConnectionConfig('', RequestMethod.POST, - requestHeader={ - 'Content-Type': 'application/json', - 'Authorization': '' - }, - requestBody= # For third party integration - { - "expirationDate": { - "mm": "12", - "yy": "22" - } +client = ( + Skyflow.builder() + .add_connection_config({ + "connection_id": "ef34fc6b0b914ad59a1754c06f10b24c", + "connection_url": "https://sb.area51.gateway.skyflowapis.dev/v1/gateway/inboundRoutes/ef34fc6b0b914ad59a1754c06f10b24c/test", + "credentials": credentials + }) + .set_log_level(LogLevel.OFF) + .build() +) + +invoke_connection_request = InvokeConnectionRequest( + method=Method.POST, + body={ + "card_number": "4337-1696-5866-0865", + "ssn": "524-41-4248" }, - pathParams={'cardID': ''}) # param as in the example - client = Client(config) + request_headers = { + 'Content-Type': 'application/json' + } +) + +response = client.connection('ef34fc6b0b914ad59a1754c06f10b24c').invoke(invoke_connection_request) + +print(response) - response = client.invoke_connection(connectionConfig) - print('Response:', response) -except SkyflowError as e: - print('Error Occurred:', e) ``` Sample response: ```python -{ - "receivedTimestamp": "2021-11-05 13:43:12.534", - "processingTimeinMs": 12, - "resource": { - "cvv2": "558" +ConnectionResponse( + { + 'card_number': '4337-1696-5866-0865', + 'ssn': '524-41-4248', + 'request_id': '84796a11-0b7d-4cb0-a348-cf9fefb5886f,84796a11-0b7d-4cb0-a348-cf9fefb5886f' } -} +) + ``` ### Query -To retrieve data with SQL queries, use the `query(queryInput, options)` method. `queryInput` is an object that takes the `query` parameter as follows: +To retrieve data with SQL queries, use the `query` method. `QueryRequest` is class that takes the `query` parameter as follows: ```python -{ - query: str # SQL query statement -} +from skyflow.vault.data import QueryRequest + +query_request = QueryRequest( + query= "" +) ``` See [Query your data](https://docs.skyflow.com/query-data/) and [Execute Query](https://docs.skyflow.com/record/#QueryService_ExecuteQuery) for guidelines and restrictions on supported SQL statements, operators, and keywords. -An [example](https://github.com/skyflowapi/skyflow-python/blob/main/samples/query_sample.py) of Query call: +An [example](https://github.com/skyflowapi/skyflow-python/blob/SK-1749-readme/samples/vault_api/query_records.py) of Query call: ```python +from skyflow.vault.data import QueryRequest + queryInput = { query: "SELECT * FROM cards WHERE skyflow_id='3ea3861-x107-40w8-la98-106sp08ea83f'" } @@ -933,37 +1013,48 @@ except SkyflowError as e: Sample Response ```python -{ - "records": [ - { - "fields": { - "card_number": "XXXXXXXXXXXX1111", - "card_pin": "*REDACTED*", - "cvv": "", - "expiration_date": "*REDACTED*", - "expiration_month": "*REDACTED*", - "expiration_year": "*REDACTED*", - "name": "a***te", - "skyflow_id": "3ea3861-x107-40w8-la98-106sp08ea83f", - "ssn": "XXX-XX-6789", - "zip_code": None - }, - "tokens": None - } - ] -} +QueryResponse( + fields=[ + { + "fields": { + "card_number": "XXXXXXXXXXXX1111", + "card_pin": "*REDACTED*", + "cvv": "", + "expiration_date": "*REDACTED*", + "expiration_month": "*REDACTED*", + "expiration_year": "*REDACTED*", + "name": "a***te", + "skyflow_id": "3ea3861-x107-40w8-la98-106sp08ea83f", + "ssn": "XXX-XX-6789", + "zip_code": None + }, + } + ], + error=[] +) ``` ## Logging -The skyflow python SDK provides useful logging using python's inbuilt `logging` library. By default the logging level of the SDK is set to `LogLevel.ERROR`. This can be changed by using `set_log_level(logLevel)` as shown below: +The skyflow python SDK provides useful logging using python's inbuilt `logging` library. By default the logging level of the SDK is set to `LogLevel.ERROR`. This can be changed by using `set_log_level(log_level)` as shown below: ```python -import logging -from skyflow import set_log_level, LogLevel - -logging.basicConfig() # You can set the basic config here -set_log_level(LogLevel.INFO) # sets the skyflow SDK log level to INFO +from skyflow import Skyflow +from skyflow import LogLevel +from skyflow import Env + +client = ( + Skyflow.builder() + .add_vault_config({ + "vault_id": "VAULT_ID", # primary vault + "cluster_id": "CLUSTER_ID", # ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com + "env": Env.PROD, # Env by default it is set to PROD + "credentials": credentials # individual credentials + }) + .add_skyflow_credentials(credentials) # skyflow credentials will be used if no individual credentials are passed + .set_log_level(LogLevel.INFO) # set log level by default it is set to ERROR + .build() +) ``` Current the following 5 log levels are supported: diff --git a/samples/vault_api/credentials_options.py b/samples/vault_api/credentials_options.py index 06108b8..9250571 100644 --- a/samples/vault_api/credentials_options.py +++ b/samples/vault_api/credentials_options.py @@ -6,9 +6,9 @@ credentials = { "token": "BEARER_TOKEN", # bearer token - # api_key: "API_KEY", //API_KEY - # path: "PATH", //path to credentials file - # credentials_string: "CREDENTIAL_STRING", // credentials as string + # api_key: "API_KEY", # API_KEY + # path: "PATH", # path to credentials file + # credentials_string: "CREDENTIAL_STRING", # credentials as string } skyflow_client = ( diff --git a/samples/vault_api/delete_records.py b/samples/vault_api/delete_records.py index b03122a..a82969a 100644 --- a/samples/vault_api/delete_records.py +++ b/samples/vault_api/delete_records.py @@ -10,9 +10,9 @@ # please pass one of api_key, token, credentials_string & path as credentials credentials = { "token": "BEARER_TOKEN", # bearer token - # api_key: "API_KEY", //API_KEY - # path: "PATH", //path to credentials file - # credentials_string: "CREDENTIAL_STRING", // credentials as string + # api_key: "API_KEY", # API_KEY + # path: "PATH", # path to credentials file + # credentials_string: "CREDENTIAL_STRING", # credentials as string } client = ( diff --git a/samples/vault_api/get_column_values.py b/samples/vault_api/get_column_values.py index 2b0577a..1316f58 100644 --- a/samples/vault_api/get_column_values.py +++ b/samples/vault_api/get_column_values.py @@ -1,7 +1,6 @@ from skyflow import Env from skyflow import Skyflow, LogLevel from skyflow.vault.data import GetRequest -from skyflow.vault.tokens import DetokenizeRequest # To generate Bearer Token from credentials string. skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' @@ -9,9 +8,9 @@ # please pass one of api_key, token, credentials_string & path as credentials credentials = { "token": "BEARER_TOKEN", # bearer token - # api_key: "API_KEY", //API_KEY - # path: "PATH", //path to credentials file - # credentials_string: skyflow_credentials_string, // credentials as string + # api_key: "API_KEY", # API_KEY + # path: "PATH", # path to credentials file + # credentials_string: skyflow_credentials_string, # credentials as string } client = ( diff --git a/samples/vault_api/get_records.py b/samples/vault_api/get_records.py index 0429a7f..b697a23 100644 --- a/samples/vault_api/get_records.py +++ b/samples/vault_api/get_records.py @@ -1,7 +1,6 @@ from skyflow import Env from skyflow import Skyflow, LogLevel from skyflow.vault.data import GetRequest -from skyflow.vault.tokens import DetokenizeRequest # To generate Bearer Token from credentials string. skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' @@ -9,9 +8,9 @@ # please pass one of api_key, token, credentials_string & path as credentials credentials = { "token": "BEARER_TOKEN", # bearer token - # api_key: "API_KEY", //API_KEY - # path: "PATH", //path to credentials file - # credentials_string: skyflow_credentials_string, // credentials as string + # api_key: "API_KEY", # API_KEY + # path: "PATH", # path to credentials file + # credentials_string: skyflow_credentials_string, # credentials as string } client = ( diff --git a/samples/vault_api/insert_byot.py b/samples/vault_api/insert_byot.py index f0b20eb..abded0e 100644 --- a/samples/vault_api/insert_byot.py +++ b/samples/vault_api/insert_byot.py @@ -2,8 +2,7 @@ from skyflow import Skyflow, LogLevel from skyflow.error import SkyflowError from skyflow.utils.enums import TokenStrict -from skyflow.vault.data import GetRequest, InsertRequest -from skyflow.vault.tokens import DetokenizeRequest +from skyflow.vault.data import InsertRequest # To generate Bearer Token from credentials string. skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' @@ -11,9 +10,9 @@ # please pass one of api_key, token, credentials_string & path as credentials credentials = { "token": "BEARER_TOKEN", # bearer token - # api_key: "API_KEY", //API_KEY - # path: "PATH", //path to credentials file - # credentials_string: skyflow_credentials_string, // credentials as string + # api_key: "API_KEY", # API_KEY + # path: "PATH", # path to credentials file + # credentials_string: skyflow_credentials_string, # credentials as string } skyflow_client = ( diff --git a/samples/vault_api/insert_records.py b/samples/vault_api/insert_records.py index da8f2a3..a01e39f 100644 --- a/samples/vault_api/insert_records.py +++ b/samples/vault_api/insert_records.py @@ -1,7 +1,6 @@ from skyflow import Env from skyflow import Skyflow, LogLevel -from skyflow.vault.data import GetRequest, InsertRequest -from skyflow.vault.tokens import DetokenizeRequest +from skyflow.vault.data import InsertRequest # To generate Bearer Token from credentials string. skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' @@ -9,9 +8,9 @@ # please pass one of api_key, token, credentials_string & path as credentials credentials = { "token": "BEARER_TOKEN", # bearer token - # api_key: "API_KEY", //API_KEY - # path: "PATH", //path to credentials file - # credentials_string: skyflow_credentials_string, // credentials as string + # api_key: "API_KEY", # API_KEY + # path: "PATH", # path to credentials file + # credentials_string: skyflow_credentials_string, # credentials as string } skyflow_client = ( diff --git a/samples/vault_api/invoke_connection.py b/samples/vault_api/invoke_connection.py index 84cc76d..51eeded 100644 --- a/samples/vault_api/invoke_connection.py +++ b/samples/vault_api/invoke_connection.py @@ -2,8 +2,6 @@ from skyflow import Skyflow, LogLevel from skyflow.utils.enums import Method from skyflow.vault.connection import InvokeConnectionRequest -from skyflow.vault.data import GetRequest, InsertRequest -from skyflow.vault.tokens import DetokenizeRequest # To generate Bearer Token from credentials string. skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' @@ -11,9 +9,9 @@ # please pass one of api_key, token, credentials_string & path as credentials credentials = { "token": "BEARER_TOKEN", # bearer token - # api_key: "API_KEY", //API_KEY - # path: "PATH", //path to credentials file - # credentials_string: skyflow_credentials_string, // credentials as string + # api_key: "API_KEY", # API_KEY + # path: "PATH", # path to credentials file + # credentials_string: skyflow_credentials_string, # credentials as string } skyflow_client = ( diff --git a/samples/vault_api/query_records.py b/samples/vault_api/query_records.py index f1449ef..3def104 100644 --- a/samples/vault_api/query_records.py +++ b/samples/vault_api/query_records.py @@ -1,9 +1,6 @@ from skyflow import Env from skyflow import Skyflow, LogLevel -from skyflow.utils.enums import Method -from skyflow.vault.connection import InvokeConnectionRequest -from skyflow.vault.data import GetRequest, InsertRequest, QueryRequest -from skyflow.vault.tokens import DetokenizeRequest +from skyflow.vault.data import QueryRequest # To generate Bearer Token from credentials string. skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' @@ -11,9 +8,9 @@ # please pass one of api_key, token, credentials_string & path as credentials credentials = { "token": "BEARER_TOKEN", # bearer token - # api_key: "API_KEY", //API_KEY - # path: "PATH", //path to credentials file - # credentials_string: skyflow_credentials_string, // credentials as string + # api_key: "API_KEY", # API_KEY + # path: "PATH", # path to credentials file + # credentials_string: skyflow_credentials_string, # credentials as string } skyflow_client = ( diff --git a/samples/vault_api/tokenize_records.py b/samples/vault_api/tokenize_records.py index 6628716..00582cf 100644 --- a/samples/vault_api/tokenize_records.py +++ b/samples/vault_api/tokenize_records.py @@ -1,9 +1,6 @@ from skyflow import Env from skyflow import Skyflow, LogLevel -from skyflow.utils.enums import Method -from skyflow.vault.connection import InvokeConnectionRequest -from skyflow.vault.data import GetRequest, InsertRequest, QueryRequest -from skyflow.vault.tokens import DetokenizeRequest, TokenizeRequest +from skyflow.vault.tokens import TokenizeRequest # To generate Bearer Token from credentials string. skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' @@ -11,9 +8,9 @@ # please pass one of api_key, token, credentials_string & path as credentials credentials = { "token": "BEARER_TOKEN", # bearer token - # api_key: "API_KEY", //API_KEY - # path: "PATH", //path to credentials file - # credentials_string: skyflow_credentials_string, // credentials as string + # api_key: "API_KEY", # API_KEY + # path: "PATH", # path to credentials file + # credentials_string: skyflow_credentials_string, # credentials as string } skyflow_client = ( diff --git a/samples/vault_api/update_record.py b/samples/vault_api/update_record.py index 2179abf..59563ed 100644 --- a/samples/vault_api/update_record.py +++ b/samples/vault_api/update_record.py @@ -1,9 +1,6 @@ from skyflow import Env from skyflow import Skyflow, LogLevel -from skyflow.utils.enums import Method -from skyflow.vault.connection import InvokeConnectionRequest -from skyflow.vault.data import GetRequest, InsertRequest, QueryRequest, UpdateRequest -from skyflow.vault.tokens import DetokenizeRequest, TokenizeRequest +from skyflow.vault.data import UpdateRequest # To generate Bearer Token from credentials string. skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' @@ -11,9 +8,9 @@ # please pass one of api_key, token, credentials_string & path as credentials credentials = { "token": "BEARER_TOKEN", # bearer token - # api_key: "API_KEY", //API_KEY - # path: "PATH", //path to credentials file - # credentials_string: skyflow_credentials_string, // credentials as string + # api_key: "API_KEY", # API_KEY + # path: "PATH", # path to credentials file + # credentials_string: skyflow_credentials_string, # credentials as string } skyflow_client = (