From 4d5b5515647c6aca1d1a6deef65cc5cd9bcc5428 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 19 Nov 2024 20:43:37 +0530 Subject: [PATCH 1/7] SK-1731-Updated samples and internal release workflow --- .github/workflows/internal-release.yml | 4 +- .../scoped_token_generation_example.py | 6 +-- .../token_generation_example.py | 3 +- .../token_generation_with_context_example.py | 6 +-- samples/vault_api/client_operations.py | 4 +- samples/vault_api/credentials_options.py | 6 +-- samples/vault_api/delete_records.py | 16 +++--- samples/vault_api/detokenize_records.py | 6 +-- samples/vault_api/get_column_values.py | 7 ++- samples/vault_api/get_records.py | 7 ++- samples/vault_api/insert_byot.py | 50 ++++++++++--------- samples/vault_api/insert_records.py | 14 +++--- samples/vault_api/invoke_connection.py | 24 +++++---- samples/vault_api/query_records.py | 13 ++--- samples/vault_api/tokenize_records.py | 11 ++-- samples/vault_api/update_record.py | 11 ++-- skyflow/generated/rest/api/tokens_api.py | 1 + skyflow/vault/data/_get_request.py | 4 +- 18 files changed, 91 insertions(+), 102 deletions(-) diff --git a/.github/workflows/internal-release.yml b/.github/workflows/internal-release.yml index 629fba1c..d4ad9400 100644 --- a/.github/workflows/internal-release.yml +++ b/.github/workflows/internal-release.yml @@ -9,7 +9,7 @@ on: - "*.yml" - "*.md" - "skyflow/utils/_version.py" - - "samples/*" + - "samples/**" branches: - release/* @@ -20,4 +20,4 @@ jobs: ref: ${{ github.ref_name }} is-internal: true secrets: inherit - + \ No newline at end of file diff --git a/samples/service_account/scoped_token_generation_example.py b/samples/service_account/scoped_token_generation_example.py index 1b7e9ed6..492f97b9 100644 --- a/samples/service_account/scoped_token_generation_example.py +++ b/samples/service_account/scoped_token_generation_example.py @@ -8,9 +8,8 @@ # Generate bearer token from credentials file path options = { - "ctx": "" + "role_ids": ["ROLE_ID1", "ROLE_ID2"] } - if is_expired(bearer_token): bearer_token, token_type = generate_bearer_token( "", options @@ -23,5 +22,4 @@ if is_expired(bearer_token): bearer_token, token_type = generate_bearer_token_from_creds(skyflow_credentials_string, options) - print(bearer_token, token_type) - + print(bearer_token, token_type) \ No newline at end of file diff --git a/samples/service_account/token_generation_example.py b/samples/service_account/token_generation_example.py index fb201cae..308babea 100644 --- a/samples/service_account/token_generation_example.py +++ b/samples/service_account/token_generation_example.py @@ -19,5 +19,4 @@ if is_expired(bearer_token): bearer_token, token_type = generate_bearer_token_from_creds(skyflow_credentials_string) - print(bearer_token, token_type) - + print(bearer_token, token_type) \ No newline at end of file diff --git a/samples/service_account/token_generation_with_context_example.py b/samples/service_account/token_generation_with_context_example.py index ea087c59..5e455a5f 100644 --- a/samples/service_account/token_generation_with_context_example.py +++ b/samples/service_account/token_generation_with_context_example.py @@ -8,8 +8,9 @@ # Generate bearer token from credentials file path options = { - "role_ids": ["ROLE_ID1", "ROLE_ID2"] + "ctx": "" } + if is_expired(bearer_token): bearer_token, token_type = generate_bearer_token( "", options @@ -22,5 +23,4 @@ if is_expired(bearer_token): bearer_token, token_type = generate_bearer_token_from_creds(skyflow_credentials_string, options) - print(bearer_token, token_type) - + print(bearer_token, token_type) \ No newline at end of file diff --git a/samples/vault_api/client_operations.py b/samples/vault_api/client_operations.py index a9d59c5d..9d41522b 100644 --- a/samples/vault_api/client_operations.py +++ b/samples/vault_api/client_operations.py @@ -54,6 +54,4 @@ response = skyflow_client.vault('VAULT_ID2').delete(delete_request) # remove vault on the fly -skyflow_client.remove_vault_config("VAULT_ID") - - +skyflow_client.remove_vault_config("VAULT_ID") \ No newline at end of file diff --git a/samples/vault_api/credentials_options.py b/samples/vault_api/credentials_options.py index 06108b8d..9250571a 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 449ff916..fe788bd2 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 = ( @@ -35,14 +35,10 @@ ] delete_request = DeleteRequest( - table='TABLE_NAME', + table='', ids = primary_delete_ids ) -# will return first Vault ID -response = client.vault().delete(delete_request) - -print(response) - - +response = client.vault('').delete(delete_request) +print(response) \ No newline at end of file diff --git a/samples/vault_api/detokenize_records.py b/samples/vault_api/detokenize_records.py index f20d43c1..92e43fda 100644 --- a/samples/vault_api/detokenize_records.py +++ b/samples/vault_api/detokenize_records.py @@ -8,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_column_values.py b/samples/vault_api/get_column_values.py index 2b0577a9..1316f583 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 0429a7fa..b697a23a 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 36135d7c..33fa7870 100644 --- a/samples/vault_api/insert_byot.py +++ b/samples/vault_api/insert_byot.py @@ -1,8 +1,8 @@ from skyflow import Env 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":""}' @@ -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: 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 = ( @@ -28,23 +28,27 @@ .build() ) -# sample data -insert_data = [ - { "card_number": 'CARD_NUMBER1', "card_cvv": 'CVV1' }, - { "card_number": 'CARD_NUMBER2', "card_cvv": 'CVV2' }, -] - -insert_request = InsertRequest( - table_name='TABLE_NAME', - values = insert_data, - continue_on_error=False, # if continue on error is set true we will return request_index for errors - token_strict=TokenStrict.ENABLE, # token strict / byot is enabled, - tokens = [ - { "card_number": 'CARD_NUMBER1', "card_cvv": 'CVV1' }, - { "card_number": 'CARD_NUMBER2', "card_cvv": 'CVV2' }, - ], -) +#Initialize Client + +try: + insert_data = [ + {"": ''}, + {"": ''} + ] + + token_data = [ + {"": ''}, + {"": ''} + ] -response = skyflow_client.vault('VAULT_ID').insert(insert_request) + insert_request = InsertRequest( + table_name='', + values=insert_data, + token_strict=TokenStrict.ENABLE, # token strict is enabled, + tokens=token_data, + ) -print(response) + response = skyflow_client.vault('VAULT_ID').insert(insert_request) + print("Response:", response) +except SkyflowError as e: + print("Error Occurred:", e) \ No newline at end of file diff --git a/samples/vault_api/insert_records.py b/samples/vault_api/insert_records.py index ee89c248..cd9f8398 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 = ( @@ -29,8 +28,7 @@ # sample data insert_data = [ - { "card_number": 'CARD_NUMBER1', "card_cvv": 'CVV1' }, - { "card_number": 'CARD_NUMBER2', "card_cvv": 'CVV2' }, + { "": '', "": '' }, ] insert_request = InsertRequest( @@ -42,4 +40,4 @@ response = skyflow_client.vault('VAULT_ID').insert(insert_request) -print(response) +print(response) \ No newline at end of file diff --git a/samples/vault_api/invoke_connection.py b/samples/vault_api/invoke_connection.py index 1daca5a4..3b93a783 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 = ( @@ -34,21 +32,29 @@ .build() ) + body = { "KEY1": "VALUE1", "KEY2": "VALUE2" } - headers = { -'Content-Type': 'application/json' + "KEY1": "VALUE1" +} +path_params = { + "KEY1": "VALUE1" +} +query_params = { + "KEY1": "VALUE1" } invoke_connection_request = InvokeConnectionRequest( method=Method.POST, body=body, - request_headers = headers + request_headers = headers, # optional + path_params = path_params, # optional + query_params=query_params # optional ) # will return the first connection response = skyflow_client.connection().invoke(invoke_connection_request) -print(response) +print(response) \ No newline at end of file diff --git a/samples/vault_api/query_records.py b/samples/vault_api/query_records.py index f1449efc..2e681966 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 = ( @@ -44,4 +41,4 @@ response = skyflow_client.vault("VAULT_ID").query(query_request) -print(response) +print(response) \ No newline at end of file diff --git a/samples/vault_api/tokenize_records.py b/samples/vault_api/tokenize_records.py index 66287164..00582cf3 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 2179abfb..59563ede 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 = ( diff --git a/skyflow/generated/rest/api/tokens_api.py b/skyflow/generated/rest/api/tokens_api.py index d6bd55e6..e21e7935 100644 --- a/skyflow/generated/rest/api/tokens_api.py +++ b/skyflow/generated/rest/api/tokens_api.py @@ -101,6 +101,7 @@ def record_service_detokenize( _response_types_map: Dict[str, Optional[str]] = { '200': "V1DetokenizeResponse", + '207': "V1DetokenizeResponse", '404': "object", } response_data = self.api_client.call_api( diff --git a/skyflow/vault/data/_get_request.py b/skyflow/vault/data/_get_request.py index e40f9047..f7238deb 100644 --- a/skyflow/vault/data/_get_request.py +++ b/skyflow/vault/data/_get_request.py @@ -5,7 +5,7 @@ class GetRequest: def __init__(self, table, ids = None, - redaction_type = "plain-text", + redaction_type = None, return_tokens = False, fields = None, offset = None, @@ -22,4 +22,4 @@ def __init__(self, self.limit = limit self.download_url = download_url self.column_name = column_name - self.column_values = column_values + self.column_values = column_values \ No newline at end of file From df34d8ce04ec840952dae93f078490b5303206d2 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 19 Nov 2024 21:12:32 +0530 Subject: [PATCH 2/7] SK-1731: Updated credentials string --- .../scoped_token_generation_example.py | 17 ++++++++++++----- .../signed_token_generation_example.py | 13 ++++++++++--- .../service_account/token_generation_example.py | 12 ++++++++++-- .../token_generation_with_context_example.py | 13 ++++++++++--- samples/vault_api/client_operations.py | 13 +++++++++++-- samples/vault_api/credentials_options.py | 12 ++++++++++-- samples/vault_api/delete_records.py | 12 ++++++++++-- samples/vault_api/detokenize_records.py | 12 ++++++++++-- samples/vault_api/get_column_values.py | 12 ++++++++++-- samples/vault_api/get_records.py | 12 ++++++++++-- samples/vault_api/insert_byot.py | 12 ++++++++++-- samples/vault_api/insert_records.py | 13 ++++++++++--- samples/vault_api/invoke_connection.py | 14 +++++++++++--- samples/vault_api/query_records.py | 14 +++++++++++--- samples/vault_api/tokenize_records.py | 14 +++++++++++--- samples/vault_api/update_record.py | 14 +++++++++++--- 16 files changed, 167 insertions(+), 42 deletions(-) diff --git a/samples/service_account/scoped_token_generation_example.py b/samples/service_account/scoped_token_generation_example.py index 492f97b9..b33b4acf 100644 --- a/samples/service_account/scoped_token_generation_example.py +++ b/samples/service_account/scoped_token_generation_example.py @@ -1,12 +1,19 @@ +import json from skyflow.service_account import generate_bearer_token, generate_bearer_token_from_creds, is_expired -file_path = 'CREDENTIALS_FILE_PATH' +file_path = '' bearer_token = '' -skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' - - +skyflow_credentials = { + "clientID":"", + "clientName":"", + "tokenURI":"", + "keyID":"", + "privateKey":"" +} +credentials_string = json.dumps(skyflow_credentials) # Generate bearer token from credentials file path + options = { "role_ids": ["ROLE_ID1", "ROLE_ID2"] } @@ -20,6 +27,6 @@ # Generate bearer token from credentials string if is_expired(bearer_token): - bearer_token, token_type = generate_bearer_token_from_creds(skyflow_credentials_string, options) + bearer_token, token_type = generate_bearer_token_from_creds(credentials_string, options) print(bearer_token, token_type) \ No newline at end of file diff --git a/samples/service_account/signed_token_generation_example.py b/samples/service_account/signed_token_generation_example.py index 5488215d..3b0aeb5e 100644 --- a/samples/service_account/signed_token_generation_example.py +++ b/samples/service_account/signed_token_generation_example.py @@ -1,10 +1,17 @@ +import json from skyflow.service_account import is_expired, generate_signed_data_tokens, generate_signed_data_tokens_from_creds file_path = 'CREDENTIALS_FILE_PATH' bearer_token = '' -skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' - +skyflow_credentials = { + "clientID":"", + "clientName":"", + "tokenURI":"", + "keyID":"", + "privateKey":"" +} +credentials_string = json.dumps(skyflow_credentials) options = { @@ -23,5 +30,5 @@ # Generate bearer token from credentials string if is_expired(bearer_token): actual_token, signed_token = generate_signed_data_tokens_from_creds( - "", options + credentials_string, options ) \ No newline at end of file diff --git a/samples/service_account/token_generation_example.py b/samples/service_account/token_generation_example.py index 308babea..53bb81e7 100644 --- a/samples/service_account/token_generation_example.py +++ b/samples/service_account/token_generation_example.py @@ -1,9 +1,17 @@ +import json from skyflow.service_account import generate_bearer_token, generate_bearer_token_from_creds, is_expired file_path = 'CREDENTIALS_FILE_PATH' bearer_token = '' -skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' +skyflow_credentials = { + "clientID":"", + "clientName":"", + "tokenURI":"", + "keyID":"", + "privateKey":"" +} +credentials_string = json.dumps(skyflow_credentials) # Generate bearer token from credentials file path @@ -17,6 +25,6 @@ # Generate bearer token from credentials string if is_expired(bearer_token): - bearer_token, token_type = generate_bearer_token_from_creds(skyflow_credentials_string) + bearer_token, token_type = generate_bearer_token_from_creds(credentials_string) print(bearer_token, token_type) \ No newline at end of file diff --git a/samples/service_account/token_generation_with_context_example.py b/samples/service_account/token_generation_with_context_example.py index 5e455a5f..7cb781c0 100644 --- a/samples/service_account/token_generation_with_context_example.py +++ b/samples/service_account/token_generation_with_context_example.py @@ -1,10 +1,17 @@ +import json from skyflow.service_account import generate_bearer_token, generate_bearer_token_from_creds, is_expired file_path = 'CREDENTIALS_FILE_PATH' bearer_token = '' -skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' - +skyflow_credentials = { + "clientID":"", + "clientName":"", + "tokenURI":"", + "keyID":"", + "privateKey":"" +} +credentials_string = json.dumps(skyflow_credentials) # Generate bearer token from credentials file path options = { @@ -21,6 +28,6 @@ # Generate bearer token from credentials string if is_expired(bearer_token): - bearer_token, token_type = generate_bearer_token_from_creds(skyflow_credentials_string, options) + bearer_token, token_type = generate_bearer_token_from_creds(credentials_string, options) print(bearer_token, token_type) \ No newline at end of file diff --git a/samples/vault_api/client_operations.py b/samples/vault_api/client_operations.py index 9d41522b..0ea12053 100644 --- a/samples/vault_api/client_operations.py +++ b/samples/vault_api/client_operations.py @@ -1,13 +1,22 @@ +import json from skyflow import Skyflow, LogLevel from skyflow import Env from skyflow.vault.data import DeleteRequest # To generate Bearer Token from credentials string. -skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' +skyflow_credentials = { + "clientID":"", + "clientName":"", + "tokenURI":"", + "keyID":"", + "privateKey":"" +} +credentials_string = json.dumps(skyflow_credentials) # please pass one of api_key, token, credentials_string & path as credentials credentials = { - "token": "" + "token": "", + #"credentials_string": credentials_string } diff --git a/samples/vault_api/credentials_options.py b/samples/vault_api/credentials_options.py index 9250571a..81f397e1 100644 --- a/samples/vault_api/credentials_options.py +++ b/samples/vault_api/credentials_options.py @@ -1,14 +1,22 @@ +import json from skyflow import Skyflow, LogLevel from skyflow import Env from skyflow.vault.data import DeleteRequest -skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' +skyflow_credentials = { + "clientID":"", + "clientName":"", + "tokenURI":"", + "keyID":"", + "privateKey":"" +} +credentials_string = json.dumps(skyflow_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 + # credentials_string: credentials_string, # credentials as string } skyflow_client = ( diff --git a/samples/vault_api/delete_records.py b/samples/vault_api/delete_records.py index fe788bd2..2ac70c2c 100644 --- a/samples/vault_api/delete_records.py +++ b/samples/vault_api/delete_records.py @@ -1,3 +1,4 @@ +import json from skyflow import Skyflow from skyflow import LogLevel from skyflow import Env @@ -5,14 +6,21 @@ # To generate Bearer Token from credentials string. -skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' +skyflow_credentials = { + "clientID":"", + "clientName":"", + "tokenURI":"", + "keyID":"", + "privateKey":"" +} +credentials_string = json.dumps(skyflow_credentials) # 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 + # credentials_string: credentials_string, # credentials as string } client = ( diff --git a/samples/vault_api/detokenize_records.py b/samples/vault_api/detokenize_records.py index 92e43fda..6dc1c038 100644 --- a/samples/vault_api/detokenize_records.py +++ b/samples/vault_api/detokenize_records.py @@ -1,16 +1,24 @@ +import json from skyflow import Env from skyflow import Skyflow, LogLevel from skyflow.vault.tokens import DetokenizeRequest # To generate Bearer Token from credentials string. -skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' +skyflow_credentials = { + "clientID":"", + "clientName":"", + "tokenURI":"", + "keyID":"", + "privateKey":"" +} +credentials_string = json.dumps(skyflow_credentials) # 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 + # credentials_string: credentials_string, #credentials as string } client = ( diff --git a/samples/vault_api/get_column_values.py b/samples/vault_api/get_column_values.py index 1316f583..333e8d0d 100644 --- a/samples/vault_api/get_column_values.py +++ b/samples/vault_api/get_column_values.py @@ -1,16 +1,24 @@ +import json from skyflow import Env from skyflow import Skyflow, LogLevel from skyflow.vault.data import GetRequest # To generate Bearer Token from credentials string. -skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' +skyflow_credentials = { + "clientID":"", + "clientName":"", + "tokenURI":"", + "keyID":"", + "privateKey":"" +} +credentials_string = json.dumps(skyflow_credentials) # 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 + # credentials_string: credentials_string, # credentials as string } client = ( diff --git a/samples/vault_api/get_records.py b/samples/vault_api/get_records.py index b697a23a..65955f0e 100644 --- a/samples/vault_api/get_records.py +++ b/samples/vault_api/get_records.py @@ -1,16 +1,24 @@ +import json from skyflow import Env from skyflow import Skyflow, LogLevel from skyflow.vault.data import GetRequest # To generate Bearer Token from credentials string. -skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' +skyflow_credentials = { + "clientID":"", + "clientName":"", + "tokenURI":"", + "keyID":"", + "privateKey":"" +} +credentials_string = json.dumps(skyflow_credentials) # 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 + # credentials_string: credentials_string, # credentials as string } client = ( diff --git a/samples/vault_api/insert_byot.py b/samples/vault_api/insert_byot.py index 33fa7870..eb76cc7d 100644 --- a/samples/vault_api/insert_byot.py +++ b/samples/vault_api/insert_byot.py @@ -1,3 +1,4 @@ +import json from skyflow import Env from skyflow import Skyflow, LogLevel from skyflow.error import SkyflowError @@ -5,14 +6,21 @@ from skyflow.vault.data import InsertRequest # To generate Bearer Token from credentials string. -skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' +skyflow_credentials = { + "clientID":"", + "clientName":"", + "tokenURI":"", + "keyID":"", + "privateKey":"" +} +credentials_string = json.dumps(skyflow_credentials) # 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 + # credentials_string: credentials_string, # credentials as string } skyflow_client = ( diff --git a/samples/vault_api/insert_records.py b/samples/vault_api/insert_records.py index cd9f8398..6de67e63 100644 --- a/samples/vault_api/insert_records.py +++ b/samples/vault_api/insert_records.py @@ -1,16 +1,23 @@ +import json from skyflow import Env from skyflow import Skyflow, LogLevel from skyflow.vault.data import InsertRequest # To generate Bearer Token from credentials string. -skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' - +skyflow_credentials = { + "clientID":"", + "clientName":"", + "tokenURI":"", + "keyID":"", + "privateKey":"" +} +credentials_string = json.dumps(skyflow_credentials) # 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 + # credentials_string: credentials_string, # credentials as string } skyflow_client = ( diff --git a/samples/vault_api/invoke_connection.py b/samples/vault_api/invoke_connection.py index 3b93a783..26ad0dbc 100644 --- a/samples/vault_api/invoke_connection.py +++ b/samples/vault_api/invoke_connection.py @@ -1,17 +1,25 @@ +import json from skyflow import Env from skyflow import Skyflow, LogLevel from skyflow.utils.enums import Method from skyflow.vault.connection import InvokeConnectionRequest # To generate Bearer Token from credentials string. -skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' - +skyflow_credentials = { + "clientID":"", + "clientName":"", + "tokenURI":"", + "keyID":"", + "privateKey":"" +} +credentials_string = json.dumps(skyflow_credentials) # 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 + # credentials_string: credentials_string, # credentials as string } skyflow_client = ( diff --git a/samples/vault_api/query_records.py b/samples/vault_api/query_records.py index 2e681966..72de5d25 100644 --- a/samples/vault_api/query_records.py +++ b/samples/vault_api/query_records.py @@ -1,16 +1,24 @@ +import json from skyflow import Env from skyflow import Skyflow, LogLevel from skyflow.vault.data import QueryRequest # To generate Bearer Token from credentials string. -skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' - +skyflow_credentials = { + "clientID":"", + "clientName":"", + "tokenURI":"", + "keyID":"", + "privateKey":"" +} +credentials_string = json.dumps(skyflow_credentials) # 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 + # credentials_string: credentials_string, # credentials as string } skyflow_client = ( diff --git a/samples/vault_api/tokenize_records.py b/samples/vault_api/tokenize_records.py index 00582cf3..5d181c3b 100644 --- a/samples/vault_api/tokenize_records.py +++ b/samples/vault_api/tokenize_records.py @@ -1,16 +1,24 @@ +import json from skyflow import Env from skyflow import Skyflow, LogLevel from skyflow.vault.tokens import TokenizeRequest # To generate Bearer Token from credentials string. -skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' - +skyflow_credentials = { + "clientID":"", + "clientName":"", + "tokenURI":"", + "keyID":"", + "privateKey":"" +} +credentials_string = json.dumps(skyflow_credentials) # 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 + # credentials_string: credentials_string, # credentials as string } skyflow_client = ( diff --git a/samples/vault_api/update_record.py b/samples/vault_api/update_record.py index 59563ede..1b9bc4a2 100644 --- a/samples/vault_api/update_record.py +++ b/samples/vault_api/update_record.py @@ -1,16 +1,24 @@ +import json from skyflow import Env from skyflow import Skyflow, LogLevel from skyflow.vault.data import UpdateRequest # To generate Bearer Token from credentials string. -skyflow_credentials_string = '{"clientID":"","clientName":"","tokenURI":"","keyID":"","privateKey":""}' - +skyflow_credentials = { + "clientID":"", + "clientName":"", + "tokenURI":"", + "keyID":"", + "privateKey":"" +} +credentials_string = json.dumps(skyflow_credentials) # 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 + # credentials_string: credentials_string, # credentials as string } skyflow_client = ( From bd44f47b04f27b5c3105a29d6f06f1ded848a04b Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Tue, 19 Nov 2024 22:04:06 +0530 Subject: [PATCH 3/7] SK-1731: Updated samples --- .../scoped_token_generation_example.py | 14 +++---- .../signed_token_generation_example.py | 18 ++++----- .../token_generation_example.py | 12 +++--- .../token_generation_with_context_example.py | 14 +++---- samples/vault_api/client_operations.py | 38 +++++++++--------- samples/vault_api/credentials_options.py | 30 +++++++------- samples/vault_api/delete_records.py | 24 +++++------ samples/vault_api/detokenize_records.py | 26 ++++++------ samples/vault_api/get_column_values.py | 26 ++++++------ samples/vault_api/get_records.py | 24 +++++------ samples/vault_api/insert_byot.py | 36 ++++++++--------- samples/vault_api/invoke_connection.py | 40 +++++++++---------- samples/vault_api/query_records.py | 34 ++++++++-------- samples/vault_api/tokenize_records.py | 34 ++++++++-------- samples/vault_api/update_record.py | 30 +++++++------- 15 files changed, 200 insertions(+), 200 deletions(-) diff --git a/samples/service_account/scoped_token_generation_example.py b/samples/service_account/scoped_token_generation_example.py index b33b4acf..ae6e1d60 100644 --- a/samples/service_account/scoped_token_generation_example.py +++ b/samples/service_account/scoped_token_generation_example.py @@ -5,21 +5,21 @@ bearer_token = '' skyflow_credentials = { - "clientID":"", - "clientName":"", - "tokenURI":"", - "keyID":"", - "privateKey":"" + 'clientID':'', + 'clientName':'', + 'tokenURI':'', + 'keyID':'', + 'privateKey':'' } credentials_string = json.dumps(skyflow_credentials) # Generate bearer token from credentials file path options = { - "role_ids": ["ROLE_ID1", "ROLE_ID2"] + 'role_ids': ['ROLE_ID1', 'ROLE_ID2'] } if is_expired(bearer_token): bearer_token, token_type = generate_bearer_token( - "", options + '', options ) print(bearer_token, token_type) diff --git a/samples/service_account/signed_token_generation_example.py b/samples/service_account/signed_token_generation_example.py index 3b0aeb5e..182b5076 100644 --- a/samples/service_account/signed_token_generation_example.py +++ b/samples/service_account/signed_token_generation_example.py @@ -5,25 +5,25 @@ bearer_token = '' skyflow_credentials = { - "clientID":"", - "clientName":"", - "tokenURI":"", - "keyID":"", - "privateKey":"" + 'clientID':'', + 'clientName':'', + 'tokenURI':'', + 'keyID':'', + 'privateKey':'' } credentials_string = json.dumps(skyflow_credentials) options = { - "ctx": "CONTEX_ID", - "data_tokens": ["DATA_TOKEN1", "DATA_TOKEN2"], - "time_to_live": 90 # in seconds + 'ctx': 'CONTEX_ID', + 'data_tokens': ['DATA_TOKEN1', 'DATA_TOKEN2'], + 'time_to_live': 90 # in seconds } # Generate bearer token from credentials file path if is_expired(bearer_token): actual_token, signed_token = generate_signed_data_tokens( - "", options + '', options ) diff --git a/samples/service_account/token_generation_example.py b/samples/service_account/token_generation_example.py index 53bb81e7..75e5057b 100644 --- a/samples/service_account/token_generation_example.py +++ b/samples/service_account/token_generation_example.py @@ -5,11 +5,11 @@ bearer_token = '' skyflow_credentials = { - "clientID":"", - "clientName":"", - "tokenURI":"", - "keyID":"", - "privateKey":"" + 'clientID':'', + 'clientName':'', + 'tokenURI':'', + 'keyID':'', + 'privateKey':'' } credentials_string = json.dumps(skyflow_credentials) @@ -17,7 +17,7 @@ # Generate bearer token from credentials file path if is_expired(bearer_token): bearer_token, token_type = generate_bearer_token( - "" + '' ) print(bearer_token, token_type) diff --git a/samples/service_account/token_generation_with_context_example.py b/samples/service_account/token_generation_with_context_example.py index 7cb781c0..2f39c419 100644 --- a/samples/service_account/token_generation_with_context_example.py +++ b/samples/service_account/token_generation_with_context_example.py @@ -5,22 +5,22 @@ bearer_token = '' skyflow_credentials = { - "clientID":"", - "clientName":"", - "tokenURI":"", - "keyID":"", - "privateKey":"" + 'clientID':'', + 'clientName':'', + 'tokenURI':'', + 'keyID':'', + 'privateKey':'' } credentials_string = json.dumps(skyflow_credentials) # Generate bearer token from credentials file path options = { - "ctx": "" + 'ctx': '' } if is_expired(bearer_token): bearer_token, token_type = generate_bearer_token( - "", options + '', options ) print(bearer_token, token_type) diff --git a/samples/vault_api/client_operations.py b/samples/vault_api/client_operations.py index 0ea12053..f658d244 100644 --- a/samples/vault_api/client_operations.py +++ b/samples/vault_api/client_operations.py @@ -5,28 +5,28 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - "clientID":"", - "clientName":"", - "tokenURI":"", - "keyID":"", - "privateKey":"" + 'clientID':'', + 'clientName':'', + 'tokenURI':'', + 'keyID':'', + 'privateKey':'' } credentials_string = json.dumps(skyflow_credentials) # please pass one of api_key, token, credentials_string & path as credentials credentials = { - "token": "", - #"credentials_string": credentials_string + 'token': '', + #'credentials_string': credentials_string } skyflow_client = ( Skyflow.builder() .add_vault_config({ - "vault_id": "", # primary vault - "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 + 'vault_id': '', # primary vault + '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 }) .set_log_level(LogLevel.ERROR) # set log level by default it is set to ERROR .build() @@ -37,18 +37,18 @@ skyflow_client.add_vault_config( { - "vault_id": "VAULT_ID2", # secondary vault - "cluster_id": "CLUSTER_ID2", # ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com - "env": Env.PROD, # Env by default it is set to PROD + 'vault_id': 'VAULT_ID2', # secondary vault + 'cluster_id': 'CLUSTER_ID2', # ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com + 'env': Env.PROD, # Env by default it is set to PROD # if you don't specify individual credentials, skyflow credentials will be used } ) skyflow_client.update_vault_config({ - "vault_id": "VAULT_ID2", - "cluster_id": "CLUSTER_ID2", - "credentials": credentials, # update credentials + 'vault_id': 'VAULT_ID2', + 'cluster_id': 'CLUSTER_ID2', + 'credentials': credentials, # update credentials }) @@ -56,11 +56,11 @@ delete_request = DeleteRequest( table='', - ids = ["77e093f8-3ace-4295-8683-bb6745d6178e", "bf5989cc-79e8-4b2f-ad71-cb20b0a76091"] + ids = ['77e093f8-3ace-4295-8683-bb6745d6178e', 'bf5989cc-79e8-4b2f-ad71-cb20b0a76091'] ) # perform delete call if you don't specify vault() it will return the first valid vault response = skyflow_client.vault('VAULT_ID2').delete(delete_request) # remove vault on the fly -skyflow_client.remove_vault_config("VAULT_ID") \ No newline at end of file +skyflow_client.remove_vault_config('VAULT_ID') \ No newline at end of file diff --git a/samples/vault_api/credentials_options.py b/samples/vault_api/credentials_options.py index 81f397e1..ca915d1c 100644 --- a/samples/vault_api/credentials_options.py +++ b/samples/vault_api/credentials_options.py @@ -4,33 +4,33 @@ from skyflow.vault.data import DeleteRequest skyflow_credentials = { - "clientID":"", - "clientName":"", - "tokenURI":"", - "keyID":"", - "privateKey":"" + 'clientID':'', + 'clientName':'', + 'tokenURI':'', + 'keyID':'', + 'privateKey':'' } credentials_string = json.dumps(skyflow_credentials) credentials = { - "token": "BEARER_TOKEN", # bearer token - # api_key: "API_KEY", # API_KEY - # path: "PATH", # path to credentials file + 'token': 'BEARER_TOKEN', # bearer token + # api_key: 'API_KEY', # API_KEY + # path: 'PATH', # path to credentials file # credentials_string: credentials_string, # credentials as string } skyflow_client = ( Skyflow.builder() .add_vault_config({ - "vault_id": "", # primary vault - "cluster_id": "", # ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com - "env": Env.PROD, # Env by default it is set to PROD + 'vault_id': '', # primary vault + 'cluster_id': '', # ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com + 'env': Env.PROD, # Env by default it is set to PROD }) .add_vault_config({ - "vault_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, + 'vault_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, }) .add_skyflow_credentials(credentials) # skyflow credentials will be used if no individual credentials are passed .set_log_level(LogLevel.ERROR) # set log level by default it is set to ERROR diff --git a/samples/vault_api/delete_records.py b/samples/vault_api/delete_records.py index 2ac70c2c..6d649410 100644 --- a/samples/vault_api/delete_records.py +++ b/samples/vault_api/delete_records.py @@ -7,29 +7,29 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - "clientID":"", - "clientName":"", - "tokenURI":"", - "keyID":"", - "privateKey":"" + 'clientID':'', + 'clientName':'', + 'tokenURI':'', + 'keyID':'', + 'privateKey':'' } credentials_string = json.dumps(skyflow_credentials) # 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 + 'token': 'BEARER_TOKEN', # bearer token + # api_key: 'API_KEY', # API_KEY + # path: 'PATH', # path to credentials file # credentials_string: 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 + '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 diff --git a/samples/vault_api/detokenize_records.py b/samples/vault_api/detokenize_records.py index 6dc1c038..a9894468 100644 --- a/samples/vault_api/detokenize_records.py +++ b/samples/vault_api/detokenize_records.py @@ -5,29 +5,29 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - "clientID":"", - "clientName":"", - "tokenURI":"", - "keyID":"", - "privateKey":"" + 'clientID':'', + 'clientName':'', + 'tokenURI':'', + 'keyID':'', + 'privateKey':'' } credentials_string = json.dumps(skyflow_credentials) # 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 + 'token': 'BEARER_TOKEN', # bearer token + # api_key: 'API_KEY', #API_KEY + # path: 'PATH', #path to credentials file # credentials_string: 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 + '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 @@ -35,7 +35,7 @@ ) -detokenize_data = ["TOKEN1", "TOKEN2", "TOKEN3"] +detokenize_data = ['TOKEN1', 'TOKEN2', 'TOKEN3'] detokenize_request = DetokenizeRequest( tokens = detokenize_data, diff --git a/samples/vault_api/get_column_values.py b/samples/vault_api/get_column_values.py index 333e8d0d..d4a270b0 100644 --- a/samples/vault_api/get_column_values.py +++ b/samples/vault_api/get_column_values.py @@ -5,29 +5,29 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - "clientID":"", - "clientName":"", - "tokenURI":"", - "keyID":"", - "privateKey":"" + 'clientID':'', + 'clientName':'', + 'tokenURI':'', + 'keyID':'', + 'privateKey':'' } credentials_string = json.dumps(skyflow_credentials) # 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 + 'token': 'BEARER_TOKEN', # bearer token + # api_key: 'API_KEY', # API_KEY + # path: 'PATH', # path to credentials file # credentials_string: 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 + '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 @@ -44,7 +44,7 @@ get_request = GetRequest( table = 'TABLE_NAME', - column_name = "COLUMN_NAME", + column_name = 'COLUMN_NAME', column_values = column_values ) diff --git a/samples/vault_api/get_records.py b/samples/vault_api/get_records.py index 65955f0e..f9914a07 100644 --- a/samples/vault_api/get_records.py +++ b/samples/vault_api/get_records.py @@ -5,29 +5,29 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - "clientID":"", - "clientName":"", - "tokenURI":"", - "keyID":"", - "privateKey":"" + 'clientID':'', + 'clientName':'', + 'tokenURI':'', + 'keyID':'', + 'privateKey':'' } credentials_string = json.dumps(skyflow_credentials) # 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 + 'token': 'BEARER_TOKEN', # bearer token + # api_key: 'API_KEY', # API_KEY + # path: 'PATH', # path to credentials file # credentials_string: 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 + '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 diff --git a/samples/vault_api/insert_byot.py b/samples/vault_api/insert_byot.py index eb76cc7d..6df681a8 100644 --- a/samples/vault_api/insert_byot.py +++ b/samples/vault_api/insert_byot.py @@ -7,29 +7,29 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - "clientID":"", - "clientName":"", - "tokenURI":"", - "keyID":"", - "privateKey":"" + 'clientID':'', + 'clientName':'', + 'tokenURI':'', + 'keyID':'', + 'privateKey':'' } credentials_string = json.dumps(skyflow_credentials) # 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 + 'token': 'BEARER_TOKEN', # bearer token + # api_key: 'API_KEY', # API_KEY + # path: 'PATH', # path to credentials file # credentials_string: credentials_string, # credentials as string } skyflow_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 + '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 @@ -40,13 +40,13 @@ try: insert_data = [ - {"": ''}, - {"": ''} + {'': ''}, + {'': ''} ] token_data = [ - {"": ''}, - {"": ''} + {'': ''}, + {'': ''} ] insert_request = InsertRequest( @@ -57,6 +57,6 @@ ) response = skyflow_client.vault('VAULT_ID').insert(insert_request) - print("Response:", response) + print('Response:', response) except SkyflowError as e: - print("Error Occurred:", e) \ No newline at end of file + print('Error Occurred:', e) \ No newline at end of file diff --git a/samples/vault_api/invoke_connection.py b/samples/vault_api/invoke_connection.py index 26ad0dbc..56946a0f 100644 --- a/samples/vault_api/invoke_connection.py +++ b/samples/vault_api/invoke_connection.py @@ -6,34 +6,34 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - "clientID":"", - "clientName":"", - "tokenURI":"", - "keyID":"", - "privateKey":"" + 'clientID':'', + 'clientName':'', + 'tokenURI':'', + 'keyID':'', + 'privateKey':'' } credentials_string = json.dumps(skyflow_credentials) # 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 + 'token': 'BEARER_TOKEN', # bearer token + # api_key: 'API_KEY', # API_KEY + # path: 'PATH', # path to credentials file # credentials_string: credentials_string, # credentials as string } skyflow_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 + '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_connection_config({ - "connection_id": "CONNECTION_ID", - "connection_url": "CONNECTION_URL", - "credentials": credentials + 'connection_id': 'CONNECTION_ID', + 'connection_url': 'CONNECTION_URL', + 'credentials': 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 @@ -42,17 +42,17 @@ body = { - "KEY1": "VALUE1", - "KEY2": "VALUE2" + 'KEY1': 'VALUE1', + 'KEY2': 'VALUE2' } headers = { - "KEY1": "VALUE1" + 'KEY1': 'VALUE1' } path_params = { - "KEY1": "VALUE1" + 'KEY1': 'VALUE1' } query_params = { - "KEY1": "VALUE1" + 'KEY1': 'VALUE1' } invoke_connection_request = InvokeConnectionRequest( diff --git a/samples/vault_api/query_records.py b/samples/vault_api/query_records.py index 72de5d25..73f1e66f 100644 --- a/samples/vault_api/query_records.py +++ b/samples/vault_api/query_records.py @@ -5,34 +5,34 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - "clientID":"", - "clientName":"", - "tokenURI":"", - "keyID":"", - "privateKey":"" + 'clientID':'', + 'clientName':'', + 'tokenURI':'', + 'keyID':'', + 'privateKey':'' } credentials_string = json.dumps(skyflow_credentials) # 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 + 'token': 'BEARER_TOKEN', # bearer token + # api_key: 'API_KEY', # API_KEY + # path: 'PATH', # path to credentials file # credentials_string: credentials_string, # credentials as string } skyflow_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 + '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_connection_config({ - "connection_id": "CONNECTION_ID", - "connection_url": "CONNECTION_URL", - "credentials": credentials + 'connection_id': 'CONNECTION_ID', + 'connection_url': 'CONNECTION_URL', + 'credentials': 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 @@ -40,13 +40,13 @@ ) # sample query -query = "select * from TABLE_NAME limit 1" +query = 'select * from TABLE_NAME limit 1' query_request = QueryRequest( query= query ) -response = skyflow_client.vault("VAULT_ID").query(query_request) +response = skyflow_client.vault('VAULT_ID').query(query_request) print(response) \ No newline at end of file diff --git a/samples/vault_api/tokenize_records.py b/samples/vault_api/tokenize_records.py index 5d181c3b..081c6d82 100644 --- a/samples/vault_api/tokenize_records.py +++ b/samples/vault_api/tokenize_records.py @@ -5,34 +5,34 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - "clientID":"", - "clientName":"", - "tokenURI":"", - "keyID":"", - "privateKey":"" + 'clientID':'', + 'clientName':'', + 'tokenURI':'', + 'keyID':'', + 'privateKey':'' } credentials_string = json.dumps(skyflow_credentials) # 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 + 'token': 'BEARER_TOKEN', # bearer token + # api_key: 'API_KEY', # API_KEY + # path: 'PATH', # path to credentials file # credentials_string: credentials_string, # credentials as string } skyflow_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 + '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_connection_config({ - "connection_id": "CONNECTION_ID", - "connection_url": "CONNECTION_URL", - "credentials": credentials + 'connection_id': 'CONNECTION_ID', + 'connection_url': 'CONNECTION_URL', + 'credentials': 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 @@ -42,8 +42,8 @@ # tokenize only supports value and column_group # sample data tokenize_values = [{ - "value": '4111111111111111', - "column_group": "card_number_cg" + 'value': '4111111111111111', + 'column_group': 'card_number_cg' }] tokenize_request = TokenizeRequest( diff --git a/samples/vault_api/update_record.py b/samples/vault_api/update_record.py index 1b9bc4a2..55ec1bd3 100644 --- a/samples/vault_api/update_record.py +++ b/samples/vault_api/update_record.py @@ -5,34 +5,34 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - "clientID":"", - "clientName":"", - "tokenURI":"", - "keyID":"", - "privateKey":"" + 'clientID':'', + 'clientName':'', + 'tokenURI':'', + 'keyID':'', + 'privateKey':'' } credentials_string = json.dumps(skyflow_credentials) # 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 + 'token': 'BEARER_TOKEN', # bearer token + # api_key: 'API_KEY', # API_KEY + # path: 'PATH', # path to credentials file # credentials_string: credentials_string, # credentials as string } skyflow_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 + '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_connection_config({ - "connection_id": "CONNECTION_ID", - "connection_url": "CONNECTION_URL", - "credentials": credentials + 'connection_id': 'CONNECTION_ID', + 'connection_url': 'CONNECTION_URL', + 'credentials': 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 From f9e5dfa977ed7c496d8947a063422be1d340f836 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Wed, 20 Nov 2024 10:49:55 +0530 Subject: [PATCH 4/7] SK-1731: Updated client operations sample --- samples/vault_api/client_operations.py | 2 +- samples/vault_api/query_records.py | 2 +- samples/vault_api/tokenize_records.py | 4 ++-- samples/vault_api/update_record.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/samples/vault_api/client_operations.py b/samples/vault_api/client_operations.py index f658d244..227b3f83 100644 --- a/samples/vault_api/client_operations.py +++ b/samples/vault_api/client_operations.py @@ -56,7 +56,7 @@ delete_request = DeleteRequest( table='', - ids = ['77e093f8-3ace-4295-8683-bb6745d6178e', 'bf5989cc-79e8-4b2f-ad71-cb20b0a76091'] + ids = ['', ''] ) # perform delete call if you don't specify vault() it will return the first valid vault diff --git a/samples/vault_api/query_records.py b/samples/vault_api/query_records.py index 73f1e66f..d47f4a07 100644 --- a/samples/vault_api/query_records.py +++ b/samples/vault_api/query_records.py @@ -40,7 +40,7 @@ ) # sample query -query = 'select * from TABLE_NAME limit 1' +query = '' query_request = QueryRequest( diff --git a/samples/vault_api/tokenize_records.py b/samples/vault_api/tokenize_records.py index 081c6d82..bc0ffcbc 100644 --- a/samples/vault_api/tokenize_records.py +++ b/samples/vault_api/tokenize_records.py @@ -42,8 +42,8 @@ # tokenize only supports value and column_group # sample data tokenize_values = [{ - 'value': '4111111111111111', - 'column_group': 'card_number_cg' + '': '', + '': '' }] tokenize_request = TokenizeRequest( diff --git a/samples/vault_api/update_record.py b/samples/vault_api/update_record.py index 55ec1bd3..680dabc8 100644 --- a/samples/vault_api/update_record.py +++ b/samples/vault_api/update_record.py @@ -42,7 +42,7 @@ # sample data update_data = { 'id': '', - 'card_number': '9999999999999999' + '': '' } update_request = UpdateRequest( From 5d4356049cfc276536a888fecd486db6a0525f59 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Wed, 20 Nov 2024 11:25:47 +0530 Subject: [PATCH 5/7] SK-1731: Fixed formatting --- .../scoped_token_generation_example.py | 32 ++++---- .../signed_token_generation_example.py | 30 ++++---- .../token_generation_example.py | 26 ++++--- .../token_generation_with_context_example.py | 32 ++++---- samples/vault_api/client_operations.py | 54 +++++++------ samples/vault_api/credentials_options.py | 76 +++++++++---------- samples/vault_api/delete_records.py | 53 ++++++------- samples/vault_api/detokenize_records.py | 46 ++++++----- samples/vault_api/get_column_values.py | 52 +++++++------ samples/vault_api/get_records.py | 50 ++++++------ samples/vault_api/insert_byot.py | 58 +++++++------- samples/vault_api/insert_records.py | 52 +++++++------ samples/vault_api/invoke_connection.py | 75 +++++++++--------- samples/vault_api/query_records.py | 60 ++++++++------- samples/vault_api/tokenize_records.py | 63 +++++++-------- samples/vault_api/update_record.py | 64 ++++++++-------- 16 files changed, 426 insertions(+), 397 deletions(-) diff --git a/samples/service_account/scoped_token_generation_example.py b/samples/service_account/scoped_token_generation_example.py index ae6e1d60..f71b6a9f 100644 --- a/samples/service_account/scoped_token_generation_example.py +++ b/samples/service_account/scoped_token_generation_example.py @@ -1,25 +1,27 @@ import json -from skyflow.service_account import generate_bearer_token, generate_bearer_token_from_creds, is_expired +from skyflow.service_account import ( + generate_bearer_token, + generate_bearer_token_from_creds, + is_expired, +) -file_path = '' -bearer_token = '' +file_path = "" +bearer_token = "" skyflow_credentials = { - 'clientID':'', - 'clientName':'', - 'tokenURI':'', - 'keyID':'', - 'privateKey':'' + "clientID": "", + "clientName": "", + "tokenURI": "", + "keyID": "", + "privateKey": "", } credentials_string = json.dumps(skyflow_credentials) # Generate bearer token from credentials file path -options = { - 'role_ids': ['ROLE_ID1', 'ROLE_ID2'] -} +options = {"role_ids": ["ROLE_ID1", "ROLE_ID2"]} if is_expired(bearer_token): bearer_token, token_type = generate_bearer_token( - '', options + "", options ) print(bearer_token, token_type) @@ -27,6 +29,8 @@ # Generate bearer token from credentials string if is_expired(bearer_token): - bearer_token, token_type = generate_bearer_token_from_creds(credentials_string, options) + bearer_token, token_type = generate_bearer_token_from_creds( + credentials_string, options + ) - print(bearer_token, token_type) \ No newline at end of file + print(bearer_token, token_type) diff --git a/samples/service_account/signed_token_generation_example.py b/samples/service_account/signed_token_generation_example.py index 182b5076..3ccef3f5 100644 --- a/samples/service_account/signed_token_generation_example.py +++ b/samples/service_account/signed_token_generation_example.py @@ -1,29 +1,33 @@ import json -from skyflow.service_account import is_expired, generate_signed_data_tokens, generate_signed_data_tokens_from_creds +from skyflow.service_account import ( + is_expired, + generate_signed_data_tokens, + generate_signed_data_tokens_from_creds, +) -file_path = 'CREDENTIALS_FILE_PATH' -bearer_token = '' +file_path = "CREDENTIALS_FILE_PATH" +bearer_token = "" skyflow_credentials = { - 'clientID':'', - 'clientName':'', - 'tokenURI':'', - 'keyID':'', - 'privateKey':'' + "clientID": "", + "clientName": "", + "tokenURI": "", + "keyID": "", + "privateKey": "", } credentials_string = json.dumps(skyflow_credentials) options = { - 'ctx': 'CONTEX_ID', - 'data_tokens': ['DATA_TOKEN1', 'DATA_TOKEN2'], - 'time_to_live': 90 # in seconds + "ctx": "CONTEX_ID", + "data_tokens": ["DATA_TOKEN1", "DATA_TOKEN2"], + "time_to_live": 90, # in seconds } # Generate bearer token from credentials file path if is_expired(bearer_token): actual_token, signed_token = generate_signed_data_tokens( - '', options + "", options ) @@ -31,4 +35,4 @@ if is_expired(bearer_token): actual_token, signed_token = generate_signed_data_tokens_from_creds( credentials_string, options - ) \ No newline at end of file + ) diff --git a/samples/service_account/token_generation_example.py b/samples/service_account/token_generation_example.py index 75e5057b..5d487269 100644 --- a/samples/service_account/token_generation_example.py +++ b/samples/service_account/token_generation_example.py @@ -1,24 +1,26 @@ import json -from skyflow.service_account import generate_bearer_token, generate_bearer_token_from_creds, is_expired +from skyflow.service_account import ( + generate_bearer_token, + generate_bearer_token_from_creds, + is_expired, +) -file_path = 'CREDENTIALS_FILE_PATH' -bearer_token = '' +file_path = "CREDENTIALS_FILE_PATH" +bearer_token = "" skyflow_credentials = { - 'clientID':'', - 'clientName':'', - 'tokenURI':'', - 'keyID':'', - 'privateKey':'' + "clientID": "", + "clientName": "", + "tokenURI": "", + "keyID": "", + "privateKey": "", } credentials_string = json.dumps(skyflow_credentials) # Generate bearer token from credentials file path if is_expired(bearer_token): - bearer_token, token_type = generate_bearer_token( - '' - ) + bearer_token, token_type = generate_bearer_token("") print(bearer_token, token_type) @@ -27,4 +29,4 @@ if is_expired(bearer_token): bearer_token, token_type = generate_bearer_token_from_creds(credentials_string) - print(bearer_token, token_type) \ No newline at end of file + print(bearer_token, token_type) diff --git a/samples/service_account/token_generation_with_context_example.py b/samples/service_account/token_generation_with_context_example.py index 2f39c419..f92d0f7e 100644 --- a/samples/service_account/token_generation_with_context_example.py +++ b/samples/service_account/token_generation_with_context_example.py @@ -1,26 +1,28 @@ import json -from skyflow.service_account import generate_bearer_token, generate_bearer_token_from_creds, is_expired +from skyflow.service_account import ( + generate_bearer_token, + generate_bearer_token_from_creds, + is_expired, +) -file_path = 'CREDENTIALS_FILE_PATH' -bearer_token = '' +file_path = "CREDENTIALS_FILE_PATH" +bearer_token = "" skyflow_credentials = { - 'clientID':'', - 'clientName':'', - 'tokenURI':'', - 'keyID':'', - 'privateKey':'' + "clientID": "", + "clientName": "", + "tokenURI": "", + "keyID": "", + "privateKey": "", } credentials_string = json.dumps(skyflow_credentials) # Generate bearer token from credentials file path -options = { - 'ctx': '' -} +options = {"ctx": ""} if is_expired(bearer_token): bearer_token, token_type = generate_bearer_token( - '', options + "", options ) print(bearer_token, token_type) @@ -28,6 +30,8 @@ # Generate bearer token from credentials string if is_expired(bearer_token): - bearer_token, token_type = generate_bearer_token_from_creds(credentials_string, options) + bearer_token, token_type = generate_bearer_token_from_creds( + credentials_string, options + ) - print(bearer_token, token_type) \ No newline at end of file + print(bearer_token, token_type) diff --git a/samples/vault_api/client_operations.py b/samples/vault_api/client_operations.py index 227b3f83..6cc2c909 100644 --- a/samples/vault_api/client_operations.py +++ b/samples/vault_api/client_operations.py @@ -5,30 +5,32 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - 'clientID':'', - 'clientName':'', - 'tokenURI':'', - 'keyID':'', - 'privateKey':'' + "clientID": "", + "clientName": "", + "tokenURI": "", + "keyID": "", + "privateKey": "", } credentials_string = json.dumps(skyflow_credentials) # please pass one of api_key, token, credentials_string & path as credentials credentials = { - 'token': '', + "token": "", #'credentials_string': credentials_string } skyflow_client = ( Skyflow.builder() - .add_vault_config({ - 'vault_id': '', # primary vault - '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 - }) - .set_log_level(LogLevel.ERROR) # set log level by default it is set to ERROR + .add_vault_config( + { + "vault_id": "", # primary vault + "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 + } + ) + .set_log_level(LogLevel.ERROR) # set log level by default it is set to ERROR .build() ) @@ -37,30 +39,32 @@ skyflow_client.add_vault_config( { - 'vault_id': 'VAULT_ID2', # secondary vault - 'cluster_id': 'CLUSTER_ID2', # ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com - 'env': Env.PROD, # Env by default it is set to PROD + "vault_id": "VAULT_ID2", # secondary vault + "cluster_id": "CLUSTER_ID2", # ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com + "env": Env.PROD, # Env by default it is set to PROD # if you don't specify individual credentials, skyflow credentials will be used } ) -skyflow_client.update_vault_config({ - 'vault_id': 'VAULT_ID2', - 'cluster_id': 'CLUSTER_ID2', - 'credentials': credentials, # update credentials -}) +skyflow_client.update_vault_config( + { + "vault_id": "VAULT_ID2", + "cluster_id": "CLUSTER_ID2", + "credentials": credentials, # update credentials + } +) # perform operations delete_request = DeleteRequest( - table='', - ids = ['', ''] + table = "", + ids = ["", ""] ) # perform delete call if you don't specify vault() it will return the first valid vault -response = skyflow_client.vault('VAULT_ID2').delete(delete_request) +response = skyflow_client.vault("VAULT_ID2").delete(delete_request) # remove vault on the fly -skyflow_client.remove_vault_config('VAULT_ID') \ No newline at end of file +skyflow_client.remove_vault_config("VAULT_ID") diff --git a/samples/vault_api/credentials_options.py b/samples/vault_api/credentials_options.py index ca915d1c..9322fa3d 100644 --- a/samples/vault_api/credentials_options.py +++ b/samples/vault_api/credentials_options.py @@ -4,66 +4,66 @@ from skyflow.vault.data import DeleteRequest skyflow_credentials = { - 'clientID':'', - 'clientName':'', - 'tokenURI':'', - 'keyID':'', - 'privateKey':'' + "clientID": "", + "clientName": "", + "tokenURI": "", + "keyID": "", + "privateKey": "", } credentials_string = json.dumps(skyflow_credentials) credentials = { - 'token': 'BEARER_TOKEN', # bearer token - # api_key: 'API_KEY', # API_KEY - # path: 'PATH', # path to credentials file - # credentials_string: credentials_string, # credentials as string + "token": "BEARER_TOKEN", # bearer token + # api_key: 'API_KEY', # API_KEY + # path: 'PATH', # path to credentials file + # credentials_string: credentials_string, # credentials as string } skyflow_client = ( Skyflow.builder() - .add_vault_config({ - 'vault_id': '', # primary vault - 'cluster_id': '', # ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com - 'env': Env.PROD, # Env by default it is set to PROD - }) - .add_vault_config({ - 'vault_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, - }) - .add_skyflow_credentials(credentials) # skyflow credentials will be used if no individual credentials are passed - .set_log_level(LogLevel.ERROR) # set log level by default it is set to ERROR + .add_vault_config( + { + "vault_id": "", # primary vault + "cluster_id": "", # ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com + "env": Env.PROD, # Env by default it is set to PROD + } + ) + .add_vault_config( + { + "vault_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, + } + ) + .add_skyflow_credentials( + credentials + ) # skyflow credentials will be used if no individual credentials are passed + .set_log_level(LogLevel.ERROR) # set log level by default it is set to ERROR .build() ) primary_delete_ids = [ - 'SKYFLOW_ID1', - 'SKYFLOW_ID2', - 'SKYFLOW_ID3', + "SKYFLOW_ID1", + "SKYFLOW_ID2", + "SKYFLOW_ID3", ] # perform operations -primary_delete_request = DeleteRequest( - table='', - ids = primary_delete_ids -) +primary_delete_request = DeleteRequest(table="", ids=primary_delete_ids) # VAULT_ID1 will use credentials if you don't specify individual credentials at config level -response = skyflow_client.vault('VAULT_ID2').delete(primary_delete_request) +response = skyflow_client.vault("VAULT_ID2").delete(primary_delete_request) secondary_delete_ids = [ - 'SKYFLOW_ID1', - 'SKYFLOW_ID2', - 'SKYFLOW_ID3', + "SKYFLOW_ID1", + "SKYFLOW_ID2", + "SKYFLOW_ID3", ] -secondary_delete_request = DeleteRequest( - table = 'TABLE_NAME', - ids = secondary_delete_ids -) +secondary_delete_request = DeleteRequest(table="TABLE_NAME", ids=secondary_delete_ids) # VAULT_ID2 will use individual credentials at config level -response = skyflow_client.vault('VAULT_ID2').delete(primary_delete_request) \ No newline at end of file +response = skyflow_client.vault("VAULT_ID2").delete(primary_delete_request) diff --git a/samples/vault_api/delete_records.py b/samples/vault_api/delete_records.py index 6d649410..8b8789c1 100644 --- a/samples/vault_api/delete_records.py +++ b/samples/vault_api/delete_records.py @@ -7,46 +7,47 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - 'clientID':'', - 'clientName':'', - 'tokenURI':'', - 'keyID':'', - 'privateKey':'' + "clientID": "", + "clientName": "", + "tokenURI": "", + "keyID": "", + "privateKey": "", } credentials_string = json.dumps(skyflow_credentials) # 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: credentials_string, # credentials as string + "token": "BEARER_TOKEN", # bearer token + # api_key: 'API_KEY', # API_KEY + # path: 'PATH', # path to credentials file + # credentials_string: 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 + .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() ) primary_delete_ids = [ - 'SKYFLOW_ID1', - 'SKYFLOW_ID2', - 'SKYFLOW_ID3', + "SKYFLOW_ID1", + "SKYFLOW_ID2", + "SKYFLOW_ID3", ] -delete_request = DeleteRequest( - table='', - ids = primary_delete_ids -) +delete_request = DeleteRequest(table="", ids=primary_delete_ids) -response = client.vault('').delete(delete_request) +response = client.vault("").delete(delete_request) -print(response) \ No newline at end of file +print(response) diff --git a/samples/vault_api/detokenize_records.py b/samples/vault_api/detokenize_records.py index a9894468..970e0518 100644 --- a/samples/vault_api/detokenize_records.py +++ b/samples/vault_api/detokenize_records.py @@ -5,42 +5,46 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - 'clientID':'', - 'clientName':'', - 'tokenURI':'', - 'keyID':'', - 'privateKey':'' + "clientID": "", + "clientName": "", + "tokenURI": "", + "keyID": "", + "privateKey": "", } credentials_string = json.dumps(skyflow_credentials) # 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: credentials_string, #credentials as string + "token": "BEARER_TOKEN", # bearer token + # api_key: 'API_KEY', #API_KEY + # path: 'PATH', #path to credentials file + # credentials_string: 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 + .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() ) -detokenize_data = ['TOKEN1', 'TOKEN2', 'TOKEN3'] +detokenize_data = ["TOKEN1", "TOKEN2", "TOKEN3"] detokenize_request = DetokenizeRequest( - tokens = detokenize_data, + tokens=detokenize_data, ) -response = client.vault('VAULT_ID').detokenize(detokenize_request) +response = client.vault("VAULT_ID").detokenize(detokenize_request) -print(response) \ No newline at end of file +print(response) diff --git a/samples/vault_api/get_column_values.py b/samples/vault_api/get_column_values.py index d4a270b0..12c20b10 100644 --- a/samples/vault_api/get_column_values.py +++ b/samples/vault_api/get_column_values.py @@ -5,49 +5,51 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - 'clientID':'', - 'clientName':'', - 'tokenURI':'', - 'keyID':'', - 'privateKey':'' + "clientID": "", + "clientName": "", + "tokenURI": "", + "keyID": "", + "privateKey": "", } credentials_string = json.dumps(skyflow_credentials) # 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: credentials_string, # credentials as string + "token": "BEARER_TOKEN", # bearer token + # api_key: 'API_KEY', # API_KEY + # path: 'PATH', # path to credentials file + # credentials_string: 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 + .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() ) column_values = [ - 'VALUE1', - 'VALUE2', + "VALUE1", + "VALUE2", ] -get_ids = ['SKYFLOW_ID1', 'SKYFLOW_ID2'] +get_ids = ["SKYFLOW_ID1", "SKYFLOW_ID2"] get_request = GetRequest( - table = 'TABLE_NAME', - column_name = 'COLUMN_NAME', - column_values = column_values + table="TABLE_NAME", column_name="COLUMN_NAME", column_values=column_values ) -response = client.vault('VAULT_ID').get(get_request) +response = client.vault("VAULT_ID").get(get_request) -print(response) \ No newline at end of file +print(response) diff --git a/samples/vault_api/get_records.py b/samples/vault_api/get_records.py index f9914a07..7f0ca4ef 100644 --- a/samples/vault_api/get_records.py +++ b/samples/vault_api/get_records.py @@ -5,45 +5,45 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - 'clientID':'', - 'clientName':'', - 'tokenURI':'', - 'keyID':'', - 'privateKey':'' + "clientID": "", + "clientName": "", + "tokenURI": "", + "keyID": "", + "privateKey": "", } credentials_string = json.dumps(skyflow_credentials) # 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: credentials_string, # credentials as string + "token": "BEARER_TOKEN", # bearer token + # api_key: 'API_KEY', # API_KEY + # path: 'PATH', # path to credentials file + # credentials_string: 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 + .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() ) -get_ids = ['SKYFLOW_ID1', 'SKYFLOW_ID2'] +get_ids = ["SKYFLOW_ID1", "SKYFLOW_ID2"] -get_request = GetRequest( - table = 'TABLE_NAME', - ids = get_ids, - return_tokens = True -) +get_request = GetRequest(table="TABLE_NAME", ids=get_ids, return_tokens=True) -response = client.vault('VAULT_ID').get(get_request) +response = client.vault("VAULT_ID").get(get_request) -print(response) \ No newline at end of file +print(response) diff --git a/samples/vault_api/insert_byot.py b/samples/vault_api/insert_byot.py index 6df681a8..e9f144c5 100644 --- a/samples/vault_api/insert_byot.py +++ b/samples/vault_api/insert_byot.py @@ -7,56 +7,54 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - 'clientID':'', - 'clientName':'', - 'tokenURI':'', - 'keyID':'', - 'privateKey':'' + "clientID": "", + "clientName": "", + "tokenURI": "", + "keyID": "", + "privateKey": "", } credentials_string = json.dumps(skyflow_credentials) # 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: credentials_string, # credentials as string + "token": "BEARER_TOKEN", # bearer token + # api_key: 'API_KEY', # API_KEY + # path: 'PATH', # path to credentials file + # credentials_string: credentials_string, # credentials as string } skyflow_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 + .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() ) -#Initialize Client +# Initialize Client try: - insert_data = [ - {'': ''}, - {'': ''} - ] + insert_data = [{"": ""}, {"": ""}] - token_data = [ - {'': ''}, - {'': ''} - ] + token_data = [{"": ""}, {"": ""}] insert_request = InsertRequest( - table_name='', + table_name="", values=insert_data, token_strict=TokenStrict.ENABLE, # token strict is enabled, tokens=token_data, ) - response = skyflow_client.vault('VAULT_ID').insert(insert_request) - print('Response:', response) + response = skyflow_client.vault("VAULT_ID").insert(insert_request) + print("Response:", response) except SkyflowError as e: - print('Error Occurred:', e) \ No newline at end of file + print("Error Occurred:", e) diff --git a/samples/vault_api/insert_records.py b/samples/vault_api/insert_records.py index 6de67e63..44a24003 100644 --- a/samples/vault_api/insert_records.py +++ b/samples/vault_api/insert_records.py @@ -5,46 +5,50 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - "clientID":"", - "clientName":"", - "tokenURI":"", - "keyID":"", - "privateKey":"" + "clientID": "", + "clientName": "", + "tokenURI": "", + "keyID": "", + "privateKey": "", } credentials_string = json.dumps(skyflow_credentials) # 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: credentials_string, # credentials as string + "token": "BEARER_TOKEN", # bearer token + # api_key: "API_KEY", # API_KEY + # path: "PATH", # path to credentials file + # credentials_string: credentials_string, # credentials as string } skyflow_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 + .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() ) # sample data insert_data = [ - { "": '', "": '' }, + {"": "", "": ""}, ] insert_request = InsertRequest( - table_name='TABLE_NAME', - values = insert_data, - continue_on_error=False, # if continue on error is set true we will return request_index for errors - return_tokens=True + table_name="TABLE_NAME", + values=insert_data, + continue_on_error=False, # if continue on error is set true we will return request_index for errors + return_tokens=True, ) -response = skyflow_client.vault('VAULT_ID').insert(insert_request) +response = skyflow_client.vault("VAULT_ID").insert(insert_request) -print(response) \ No newline at end of file +print(response) diff --git a/samples/vault_api/invoke_connection.py b/samples/vault_api/invoke_connection.py index 56946a0f..d49666a3 100644 --- a/samples/vault_api/invoke_connection.py +++ b/samples/vault_api/invoke_connection.py @@ -6,63 +6,60 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - 'clientID':'', - 'clientName':'', - 'tokenURI':'', - 'keyID':'', - 'privateKey':'' + "clientID": "", + "clientName": "", + "tokenURI": "", + "keyID": "", + "privateKey": "", } credentials_string = json.dumps(skyflow_credentials) # 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: credentials_string, # credentials as string + "token": "BEARER_TOKEN", # bearer token + # api_key: 'API_KEY', # API_KEY + # path: 'PATH', # path to credentials file + # credentials_string: credentials_string, # credentials as string } skyflow_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_connection_config({ - 'connection_id': 'CONNECTION_ID', - 'connection_url': 'CONNECTION_URL', - 'credentials': 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 + .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_connection_config( + { + "connection_id": "CONNECTION_ID", + "connection_url": "CONNECTION_URL", + "credentials": 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() ) -body = { - 'KEY1': 'VALUE1', - 'KEY2': 'VALUE2' -} -headers = { - 'KEY1': 'VALUE1' -} -path_params = { - 'KEY1': 'VALUE1' -} -query_params = { - 'KEY1': 'VALUE1' -} +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 + request_headers=headers, # optional + path_params=path_params, # optional + query_params=query_params, # optional ) # will return the first connection response = skyflow_client.connection().invoke(invoke_connection_request) -print(response) \ No newline at end of file +print(response) diff --git a/samples/vault_api/query_records.py b/samples/vault_api/query_records.py index d47f4a07..52d5dc45 100644 --- a/samples/vault_api/query_records.py +++ b/samples/vault_api/query_records.py @@ -5,48 +5,52 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - 'clientID':'', - 'clientName':'', - 'tokenURI':'', - 'keyID':'', - 'privateKey':'' + "clientID": "", + "clientName": "", + "tokenURI": "", + "keyID": "", + "privateKey": "", } credentials_string = json.dumps(skyflow_credentials) # 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: credentials_string, # credentials as string + "token": "BEARER_TOKEN", # bearer token + # api_key: 'API_KEY', # API_KEY + # path: 'PATH', # path to credentials file + # credentials_string: credentials_string, # credentials as string } skyflow_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_connection_config({ - 'connection_id': 'CONNECTION_ID', - 'connection_url': 'CONNECTION_URL', - 'credentials': 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 + .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_connection_config( + { + "connection_id": "CONNECTION_ID", + "connection_url": "CONNECTION_URL", + "credentials": 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() ) # sample query -query = '' +query = "" -query_request = QueryRequest( - query= query -) +query_request = QueryRequest(query=query) -response = skyflow_client.vault('VAULT_ID').query(query_request) +response = skyflow_client.vault("VAULT_ID").query(query_request) -print(response) \ No newline at end of file +print(response) diff --git a/samples/vault_api/tokenize_records.py b/samples/vault_api/tokenize_records.py index bc0ffcbc..0ca8e975 100644 --- a/samples/vault_api/tokenize_records.py +++ b/samples/vault_api/tokenize_records.py @@ -5,51 +5,52 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - 'clientID':'', - 'clientName':'', - 'tokenURI':'', - 'keyID':'', - 'privateKey':'' + "clientID": "", + "clientName": "", + "tokenURI": "", + "keyID": "", + "privateKey": "", } credentials_string = json.dumps(skyflow_credentials) # 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: credentials_string, # credentials as string + "token": "BEARER_TOKEN", # bearer token + # api_key: 'API_KEY', # API_KEY + # path: 'PATH', # path to credentials file + # credentials_string: credentials_string, # credentials as string } skyflow_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_connection_config({ - 'connection_id': 'CONNECTION_ID', - 'connection_url': 'CONNECTION_URL', - 'credentials': 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 + .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_connection_config( + { + "connection_id": "CONNECTION_ID", + "connection_url": "CONNECTION_URL", + "credentials": 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() ) # tokenize only supports value and column_group # sample data -tokenize_values = [{ - '': '', - '': '' -}] +tokenize_values = [{"": "", "": ""}] -tokenize_request = TokenizeRequest( - tokenize_parameters=tokenize_values -) +tokenize_request = TokenizeRequest(tokenize_parameters=tokenize_values) -response = skyflow_client.vault('VAULT_ID').tokenize(tokenize_request) +response = skyflow_client.vault("VAULT_ID").tokenize(tokenize_request) -print(response) \ No newline at end of file +print(response) diff --git a/samples/vault_api/update_record.py b/samples/vault_api/update_record.py index 680dabc8..6c591916 100644 --- a/samples/vault_api/update_record.py +++ b/samples/vault_api/update_record.py @@ -5,51 +5,51 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - 'clientID':'', - 'clientName':'', - 'tokenURI':'', - 'keyID':'', - 'privateKey':'' + "clientID": "", + "clientName": "", + "tokenURI": "", + "keyID": "", + "privateKey": "", } credentials_string = json.dumps(skyflow_credentials) # 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: credentials_string, # credentials as string + "token": "BEARER_TOKEN", # bearer token + # api_key: 'API_KEY', # API_KEY + # path: 'PATH', # path to credentials file + # credentials_string: credentials_string, # credentials as string } skyflow_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_connection_config({ - 'connection_id': 'CONNECTION_ID', - 'connection_url': 'CONNECTION_URL', - 'credentials': 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 + .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_connection_config( + { + "connection_id": "CONNECTION_ID", + "connection_url": "CONNECTION_URL", + "credentials": 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() ) # sample data -update_data = { - 'id': '', - '': '' -} +update_data = {"id": "", "": ""} -update_request = UpdateRequest( - table='TABLE_NAME', - data = update_data -) +update_request = UpdateRequest(table="TABLE_NAME", data=update_data) -response = skyflow_client.vault('VAULT_ID').update(update_request) +response = skyflow_client.vault("VAULT_ID").update(update_request) -print(response) \ No newline at end of file +print(response) From bd6956fdc8f650942dfd11920716923a27dae548 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Wed, 20 Nov 2024 11:27:56 +0530 Subject: [PATCH 6/7] SK-1731: Fixed formatting --- .../scoped_token_generation_example.py | 18 ++++---- .../signed_token_generation_example.py | 22 ++++----- .../token_generation_example.py | 16 +++---- .../token_generation_with_context_example.py | 18 ++++---- samples/vault_api/client_operations.py | 40 ++++++++-------- samples/vault_api/credentials_options.py | 46 +++++++++---------- samples/vault_api/delete_records.py | 30 ++++++------ samples/vault_api/detokenize_records.py | 24 +++++----- samples/vault_api/get_column_values.py | 30 ++++++------ samples/vault_api/get_records.py | 26 +++++------ samples/vault_api/insert_byot.py | 32 ++++++------- samples/vault_api/insert_records.py | 30 ++++++------ samples/vault_api/invoke_connection.py | 34 +++++++------- samples/vault_api/query_records.py | 30 ++++++------ samples/vault_api/update_record.py | 32 ++++++------- 15 files changed, 214 insertions(+), 214 deletions(-) diff --git a/samples/service_account/scoped_token_generation_example.py b/samples/service_account/scoped_token_generation_example.py index f71b6a9f..e94f6433 100644 --- a/samples/service_account/scoped_token_generation_example.py +++ b/samples/service_account/scoped_token_generation_example.py @@ -5,23 +5,23 @@ is_expired, ) -file_path = "" -bearer_token = "" +file_path = '' +bearer_token = '' skyflow_credentials = { - "clientID": "", - "clientName": "", - "tokenURI": "", - "keyID": "", - "privateKey": "", + 'clientID': '', + 'clientName': '', + 'tokenURI': '', + 'keyID': '', + 'privateKey': '', } credentials_string = json.dumps(skyflow_credentials) # Generate bearer token from credentials file path -options = {"role_ids": ["ROLE_ID1", "ROLE_ID2"]} +options = {'role_ids': ['ROLE_ID1', 'ROLE_ID2']} if is_expired(bearer_token): bearer_token, token_type = generate_bearer_token( - "", options + '', options ) print(bearer_token, token_type) diff --git a/samples/service_account/signed_token_generation_example.py b/samples/service_account/signed_token_generation_example.py index 3ccef3f5..130cb6e8 100644 --- a/samples/service_account/signed_token_generation_example.py +++ b/samples/service_account/signed_token_generation_example.py @@ -5,29 +5,29 @@ generate_signed_data_tokens_from_creds, ) -file_path = "CREDENTIALS_FILE_PATH" -bearer_token = "" +file_path = 'CREDENTIALS_FILE_PATH' +bearer_token = '' skyflow_credentials = { - "clientID": "", - "clientName": "", - "tokenURI": "", - "keyID": "", - "privateKey": "", + 'clientID': '', + 'clientName': '', + 'tokenURI': '', + 'keyID': '', + 'privateKey': '', } credentials_string = json.dumps(skyflow_credentials) options = { - "ctx": "CONTEX_ID", - "data_tokens": ["DATA_TOKEN1", "DATA_TOKEN2"], - "time_to_live": 90, # in seconds + 'ctx': 'CONTEX_ID', + 'data_tokens': ['DATA_TOKEN1', 'DATA_TOKEN2'], + 'time_to_live': 90, # in seconds } # Generate bearer token from credentials file path if is_expired(bearer_token): actual_token, signed_token = generate_signed_data_tokens( - "", options + '', options ) diff --git a/samples/service_account/token_generation_example.py b/samples/service_account/token_generation_example.py index 5d487269..1c44c0a5 100644 --- a/samples/service_account/token_generation_example.py +++ b/samples/service_account/token_generation_example.py @@ -5,22 +5,22 @@ is_expired, ) -file_path = "CREDENTIALS_FILE_PATH" -bearer_token = "" +file_path = 'CREDENTIALS_FILE_PATH' +bearer_token = '' skyflow_credentials = { - "clientID": "", - "clientName": "", - "tokenURI": "", - "keyID": "", - "privateKey": "", + 'clientID': '', + 'clientName': '', + 'tokenURI': '', + 'keyID': '', + 'privateKey': '', } credentials_string = json.dumps(skyflow_credentials) # Generate bearer token from credentials file path if is_expired(bearer_token): - bearer_token, token_type = generate_bearer_token("") + bearer_token, token_type = generate_bearer_token('') print(bearer_token, token_type) diff --git a/samples/service_account/token_generation_with_context_example.py b/samples/service_account/token_generation_with_context_example.py index f92d0f7e..b2deb714 100644 --- a/samples/service_account/token_generation_with_context_example.py +++ b/samples/service_account/token_generation_with_context_example.py @@ -5,24 +5,24 @@ is_expired, ) -file_path = "CREDENTIALS_FILE_PATH" -bearer_token = "" +file_path = 'CREDENTIALS_FILE_PATH' +bearer_token = '' skyflow_credentials = { - "clientID": "", - "clientName": "", - "tokenURI": "", - "keyID": "", - "privateKey": "", + 'clientID': '', + 'clientName': '', + 'tokenURI': '', + 'keyID': '', + 'privateKey': '', } credentials_string = json.dumps(skyflow_credentials) # Generate bearer token from credentials file path -options = {"ctx": ""} +options = {'ctx': ''} if is_expired(bearer_token): bearer_token, token_type = generate_bearer_token( - "", options + '', options ) print(bearer_token, token_type) diff --git a/samples/vault_api/client_operations.py b/samples/vault_api/client_operations.py index 6cc2c909..ad98d309 100644 --- a/samples/vault_api/client_operations.py +++ b/samples/vault_api/client_operations.py @@ -5,17 +5,17 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - "clientID": "", - "clientName": "", - "tokenURI": "", - "keyID": "", - "privateKey": "", + 'clientID': '', + 'clientName': '', + 'tokenURI': '', + 'keyID': '', + 'privateKey': '', } credentials_string = json.dumps(skyflow_credentials) # please pass one of api_key, token, credentials_string & path as credentials credentials = { - "token": "", + 'token': '', #'credentials_string': credentials_string } @@ -24,10 +24,10 @@ Skyflow.builder() .add_vault_config( { - "vault_id": "", # primary vault - "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 + 'vault_id': '', # primary vault + '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 } ) .set_log_level(LogLevel.ERROR) # set log level by default it is set to ERROR @@ -39,9 +39,9 @@ skyflow_client.add_vault_config( { - "vault_id": "VAULT_ID2", # secondary vault - "cluster_id": "CLUSTER_ID2", # ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com - "env": Env.PROD, # Env by default it is set to PROD + 'vault_id': 'VAULT_ID2', # secondary vault + 'cluster_id': 'CLUSTER_ID2', # ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com + 'env': Env.PROD, # Env by default it is set to PROD # if you don't specify individual credentials, skyflow credentials will be used } ) @@ -49,9 +49,9 @@ skyflow_client.update_vault_config( { - "vault_id": "VAULT_ID2", - "cluster_id": "CLUSTER_ID2", - "credentials": credentials, # update credentials + 'vault_id': 'VAULT_ID2', + 'cluster_id': 'CLUSTER_ID2', + 'credentials': credentials, # update credentials } ) @@ -59,12 +59,12 @@ # perform operations delete_request = DeleteRequest( - table = "", - ids = ["", ""] + table = '', + ids = ['', ''] ) # perform delete call if you don't specify vault() it will return the first valid vault -response = skyflow_client.vault("VAULT_ID2").delete(delete_request) +response = skyflow_client.vault('VAULT_ID2').delete(delete_request) # remove vault on the fly -skyflow_client.remove_vault_config("VAULT_ID") +skyflow_client.remove_vault_config('VAULT_ID') diff --git a/samples/vault_api/credentials_options.py b/samples/vault_api/credentials_options.py index 9322fa3d..09e02061 100644 --- a/samples/vault_api/credentials_options.py +++ b/samples/vault_api/credentials_options.py @@ -4,16 +4,16 @@ from skyflow.vault.data import DeleteRequest skyflow_credentials = { - "clientID": "", - "clientName": "", - "tokenURI": "", - "keyID": "", - "privateKey": "", + 'clientID': '', + 'clientName': '', + 'tokenURI': '', + 'keyID': '', + 'privateKey': '', } credentials_string = json.dumps(skyflow_credentials) credentials = { - "token": "BEARER_TOKEN", # bearer token + 'token': 'BEARER_TOKEN', # bearer token # api_key: 'API_KEY', # API_KEY # path: 'PATH', # path to credentials file # credentials_string: credentials_string, # credentials as string @@ -23,17 +23,17 @@ Skyflow.builder() .add_vault_config( { - "vault_id": "", # primary vault - "cluster_id": "", # ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com - "env": Env.PROD, # Env by default it is set to PROD + 'vault_id': '', # primary vault + 'cluster_id': '', # ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com + 'env': Env.PROD, # Env by default it is set to PROD } ) .add_vault_config( { - "vault_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, + 'vault_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, } ) .add_skyflow_credentials( @@ -44,26 +44,26 @@ ) primary_delete_ids = [ - "SKYFLOW_ID1", - "SKYFLOW_ID2", - "SKYFLOW_ID3", + 'SKYFLOW_ID1', + 'SKYFLOW_ID2', + 'SKYFLOW_ID3', ] # perform operations -primary_delete_request = DeleteRequest(table="", ids=primary_delete_ids) +primary_delete_request = DeleteRequest(table='', ids=primary_delete_ids) # VAULT_ID1 will use credentials if you don't specify individual credentials at config level -response = skyflow_client.vault("VAULT_ID2").delete(primary_delete_request) +response = skyflow_client.vault('VAULT_ID2').delete(primary_delete_request) secondary_delete_ids = [ - "SKYFLOW_ID1", - "SKYFLOW_ID2", - "SKYFLOW_ID3", + 'SKYFLOW_ID1', + 'SKYFLOW_ID2', + 'SKYFLOW_ID3', ] -secondary_delete_request = DeleteRequest(table="TABLE_NAME", ids=secondary_delete_ids) +secondary_delete_request = DeleteRequest(table='TABLE_NAME', ids=secondary_delete_ids) # VAULT_ID2 will use individual credentials at config level -response = skyflow_client.vault("VAULT_ID2").delete(primary_delete_request) +response = skyflow_client.vault('VAULT_ID2').delete(primary_delete_request) diff --git a/samples/vault_api/delete_records.py b/samples/vault_api/delete_records.py index 8b8789c1..d0960629 100644 --- a/samples/vault_api/delete_records.py +++ b/samples/vault_api/delete_records.py @@ -7,17 +7,17 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - "clientID": "", - "clientName": "", - "tokenURI": "", - "keyID": "", - "privateKey": "", + 'clientID': '', + 'clientName': '', + 'tokenURI': '', + 'keyID': '', + 'privateKey': '', } credentials_string = json.dumps(skyflow_credentials) # please pass one of api_key, token, credentials_string & path as credentials credentials = { - "token": "BEARER_TOKEN", # bearer token + 'token': 'BEARER_TOKEN', # bearer token # api_key: 'API_KEY', # API_KEY # path: 'PATH', # path to credentials file # credentials_string: credentials_string, # credentials as string @@ -27,10 +27,10 @@ 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 + '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( @@ -41,13 +41,13 @@ ) primary_delete_ids = [ - "SKYFLOW_ID1", - "SKYFLOW_ID2", - "SKYFLOW_ID3", + 'SKYFLOW_ID1', + 'SKYFLOW_ID2', + 'SKYFLOW_ID3', ] -delete_request = DeleteRequest(table="", ids=primary_delete_ids) +delete_request = DeleteRequest(table='', ids=primary_delete_ids) -response = client.vault("").delete(delete_request) +response = client.vault('').delete(delete_request) print(response) diff --git a/samples/vault_api/detokenize_records.py b/samples/vault_api/detokenize_records.py index 970e0518..2c931c2a 100644 --- a/samples/vault_api/detokenize_records.py +++ b/samples/vault_api/detokenize_records.py @@ -5,17 +5,17 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - "clientID": "", - "clientName": "", - "tokenURI": "", - "keyID": "", - "privateKey": "", + 'clientID': '', + 'clientName': '', + 'tokenURI': '', + 'keyID': '', + 'privateKey': '', } credentials_string = json.dumps(skyflow_credentials) # please pass one of api_key, token, credentials_string & path as credentials credentials = { - "token": "BEARER_TOKEN", # bearer token + 'token': 'BEARER_TOKEN', # bearer token # api_key: 'API_KEY', #API_KEY # path: 'PATH', #path to credentials file # credentials_string: credentials_string, #credentials as string @@ -25,10 +25,10 @@ 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 + '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( @@ -39,12 +39,12 @@ ) -detokenize_data = ["TOKEN1", "TOKEN2", "TOKEN3"] +detokenize_data = ['TOKEN1', 'TOKEN2', 'TOKEN3'] detokenize_request = DetokenizeRequest( tokens=detokenize_data, ) -response = client.vault("VAULT_ID").detokenize(detokenize_request) +response = client.vault('VAULT_ID').detokenize(detokenize_request) print(response) diff --git a/samples/vault_api/get_column_values.py b/samples/vault_api/get_column_values.py index 12c20b10..29272614 100644 --- a/samples/vault_api/get_column_values.py +++ b/samples/vault_api/get_column_values.py @@ -5,17 +5,17 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - "clientID": "", - "clientName": "", - "tokenURI": "", - "keyID": "", - "privateKey": "", + 'clientID': '', + 'clientName': '', + 'tokenURI': '', + 'keyID': '', + 'privateKey': '', } credentials_string = json.dumps(skyflow_credentials) # please pass one of api_key, token, credentials_string & path as credentials credentials = { - "token": "BEARER_TOKEN", # bearer token + 'token': 'BEARER_TOKEN', # bearer token # api_key: 'API_KEY', # API_KEY # path: 'PATH', # path to credentials file # credentials_string: credentials_string, # credentials as string @@ -25,10 +25,10 @@ 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 + '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( @@ -39,17 +39,17 @@ ) column_values = [ - "VALUE1", - "VALUE2", + 'VALUE1', + 'VALUE2', ] -get_ids = ["SKYFLOW_ID1", "SKYFLOW_ID2"] +get_ids = ['SKYFLOW_ID1', 'SKYFLOW_ID2'] get_request = GetRequest( - table="TABLE_NAME", column_name="COLUMN_NAME", column_values=column_values + table='TABLE_NAME', column_name='COLUMN_NAME', column_values=column_values ) -response = client.vault("VAULT_ID").get(get_request) +response = client.vault('VAULT_ID').get(get_request) print(response) diff --git a/samples/vault_api/get_records.py b/samples/vault_api/get_records.py index 7f0ca4ef..718bdd1a 100644 --- a/samples/vault_api/get_records.py +++ b/samples/vault_api/get_records.py @@ -5,17 +5,17 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - "clientID": "", - "clientName": "", - "tokenURI": "", - "keyID": "", - "privateKey": "", + 'clientID': '', + 'clientName': '', + 'tokenURI': '', + 'keyID': '', + 'privateKey': '', } credentials_string = json.dumps(skyflow_credentials) # please pass one of api_key, token, credentials_string & path as credentials credentials = { - "token": "BEARER_TOKEN", # bearer token + 'token': 'BEARER_TOKEN', # bearer token # api_key: 'API_KEY', # API_KEY # path: 'PATH', # path to credentials file # credentials_string: credentials_string, # credentials as string @@ -25,10 +25,10 @@ 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 + '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( @@ -39,11 +39,11 @@ ) -get_ids = ["SKYFLOW_ID1", "SKYFLOW_ID2"] +get_ids = ['SKYFLOW_ID1', 'SKYFLOW_ID2'] -get_request = GetRequest(table="TABLE_NAME", ids=get_ids, return_tokens=True) +get_request = GetRequest(table='TABLE_NAME', ids=get_ids, return_tokens=True) -response = client.vault("VAULT_ID").get(get_request) +response = client.vault('VAULT_ID').get(get_request) print(response) diff --git a/samples/vault_api/insert_byot.py b/samples/vault_api/insert_byot.py index e9f144c5..f2ec4773 100644 --- a/samples/vault_api/insert_byot.py +++ b/samples/vault_api/insert_byot.py @@ -7,17 +7,17 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - "clientID": "", - "clientName": "", - "tokenURI": "", - "keyID": "", - "privateKey": "", + 'clientID': '', + 'clientName': '', + 'tokenURI': '', + 'keyID': '', + 'privateKey': '', } credentials_string = json.dumps(skyflow_credentials) # please pass one of api_key, token, credentials_string & path as credentials credentials = { - "token": "BEARER_TOKEN", # bearer token + 'token': 'BEARER_TOKEN', # bearer token # api_key: 'API_KEY', # API_KEY # path: 'PATH', # path to credentials file # credentials_string: credentials_string, # credentials as string @@ -27,10 +27,10 @@ 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 + '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( @@ -43,18 +43,18 @@ # Initialize Client try: - insert_data = [{"": ""}, {"": ""}] + insert_data = [{'': ''}, {'': ''}] - token_data = [{"": ""}, {"": ""}] + token_data = [{'': ''}, {'': ''}] insert_request = InsertRequest( - table_name="", + table_name='', values=insert_data, token_strict=TokenStrict.ENABLE, # token strict is enabled, tokens=token_data, ) - response = skyflow_client.vault("VAULT_ID").insert(insert_request) - print("Response:", response) + response = skyflow_client.vault('VAULT_ID').insert(insert_request) + print('Response:', response) except SkyflowError as e: - print("Error Occurred:", e) + print('Error Occurred:', e) diff --git a/samples/vault_api/insert_records.py b/samples/vault_api/insert_records.py index 44a24003..5e87f1d6 100644 --- a/samples/vault_api/insert_records.py +++ b/samples/vault_api/insert_records.py @@ -5,18 +5,18 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - "clientID": "", - "clientName": "", - "tokenURI": "", - "keyID": "", - "privateKey": "", + 'clientID': '', + 'clientName': '', + 'tokenURI': '', + 'keyID': '', + 'privateKey': '', } credentials_string = json.dumps(skyflow_credentials) # 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 + 'token': 'BEARER_TOKEN', # bearer token + # api_key: 'API_KEY', # API_KEY + # path: 'PATH', # path to credentials file # credentials_string: credentials_string, # credentials as string } @@ -24,10 +24,10 @@ 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 + '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( @@ -39,16 +39,16 @@ # sample data insert_data = [ - {"": "", "": ""}, + {'': '', '': ''}, ] insert_request = InsertRequest( - table_name="TABLE_NAME", + table_name='TABLE_NAME', values=insert_data, continue_on_error=False, # if continue on error is set true we will return request_index for errors return_tokens=True, ) -response = skyflow_client.vault("VAULT_ID").insert(insert_request) +response = skyflow_client.vault('VAULT_ID').insert(insert_request) print(response) diff --git a/samples/vault_api/invoke_connection.py b/samples/vault_api/invoke_connection.py index d49666a3..a2243fa2 100644 --- a/samples/vault_api/invoke_connection.py +++ b/samples/vault_api/invoke_connection.py @@ -6,17 +6,17 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - "clientID": "", - "clientName": "", - "tokenURI": "", - "keyID": "", - "privateKey": "", + 'clientID': '', + 'clientName': '', + 'tokenURI': '', + 'keyID': '', + 'privateKey': '', } credentials_string = json.dumps(skyflow_credentials) # please pass one of api_key, token, credentials_string & path as credentials credentials = { - "token": "BEARER_TOKEN", # bearer token + 'token': 'BEARER_TOKEN', # bearer token # api_key: 'API_KEY', # API_KEY # path: 'PATH', # path to credentials file # credentials_string: credentials_string, # credentials as string @@ -26,17 +26,17 @@ 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 + '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_connection_config( { - "connection_id": "CONNECTION_ID", - "connection_url": "CONNECTION_URL", - "credentials": credentials, + 'connection_id': 'CONNECTION_ID', + 'connection_url': 'CONNECTION_URL', + 'credentials': credentials, } ) .add_skyflow_credentials( @@ -47,10 +47,10 @@ ) -body = {"KEY1": "VALUE1", "KEY2": "VALUE2"} -headers = {"KEY1": "VALUE1"} -path_params = {"KEY1": "VALUE1"} -query_params = {"KEY1": "VALUE1"} +body = {'KEY1': 'VALUE1', 'KEY2': 'VALUE2'} +headers = {'KEY1': 'VALUE1'} +path_params = {'KEY1': 'VALUE1'} +query_params = {'KEY1': 'VALUE1'} invoke_connection_request = InvokeConnectionRequest( method=Method.POST, diff --git a/samples/vault_api/query_records.py b/samples/vault_api/query_records.py index 52d5dc45..fa6ff6b7 100644 --- a/samples/vault_api/query_records.py +++ b/samples/vault_api/query_records.py @@ -5,17 +5,17 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - "clientID": "", - "clientName": "", - "tokenURI": "", - "keyID": "", - "privateKey": "", + 'clientID': '', + 'clientName': '', + 'tokenURI': '', + 'keyID': '', + 'privateKey': '', } credentials_string = json.dumps(skyflow_credentials) # please pass one of api_key, token, credentials_string & path as credentials credentials = { - "token": "BEARER_TOKEN", # bearer token + 'token': 'BEARER_TOKEN', # bearer token # api_key: 'API_KEY', # API_KEY # path: 'PATH', # path to credentials file # credentials_string: credentials_string, # credentials as string @@ -25,17 +25,17 @@ 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 + '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_connection_config( { - "connection_id": "CONNECTION_ID", - "connection_url": "CONNECTION_URL", - "credentials": credentials, + 'connection_id': 'CONNECTION_ID', + 'connection_url': 'CONNECTION_URL', + 'credentials': credentials, } ) .add_skyflow_credentials( @@ -46,11 +46,11 @@ ) # sample query -query = "" +query = '' query_request = QueryRequest(query=query) -response = skyflow_client.vault("VAULT_ID").query(query_request) +response = skyflow_client.vault('VAULT_ID').query(query_request) print(response) diff --git a/samples/vault_api/update_record.py b/samples/vault_api/update_record.py index 6c591916..367e4ac7 100644 --- a/samples/vault_api/update_record.py +++ b/samples/vault_api/update_record.py @@ -5,17 +5,17 @@ # To generate Bearer Token from credentials string. skyflow_credentials = { - "clientID": "", - "clientName": "", - "tokenURI": "", - "keyID": "", - "privateKey": "", + 'clientID': '', + 'clientName': '', + 'tokenURI': '', + 'keyID': '', + 'privateKey': '', } credentials_string = json.dumps(skyflow_credentials) # please pass one of api_key, token, credentials_string & path as credentials credentials = { - "token": "BEARER_TOKEN", # bearer token + 'token': 'BEARER_TOKEN', # bearer token # api_key: 'API_KEY', # API_KEY # path: 'PATH', # path to credentials file # credentials_string: credentials_string, # credentials as string @@ -25,17 +25,17 @@ 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 + '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_connection_config( { - "connection_id": "CONNECTION_ID", - "connection_url": "CONNECTION_URL", - "credentials": credentials, + 'connection_id': 'CONNECTION_ID', + 'connection_url': 'CONNECTION_URL', + 'credentials': credentials, } ) .add_skyflow_credentials( @@ -46,10 +46,10 @@ ) # sample data -update_data = {"id": "", "": ""} +update_data = {'id': '', '': ''} -update_request = UpdateRequest(table="TABLE_NAME", data=update_data) +update_request = UpdateRequest(table='TABLE_NAME', data=update_data) -response = skyflow_client.vault("VAULT_ID").update(update_request) +response = skyflow_client.vault('VAULT_ID').update(update_request) print(response) From 687ebd107927e0168dcbd775738f6271018b8f38 Mon Sep 17 00:00:00 2001 From: saileshwar-skyflow Date: Wed, 20 Nov 2024 12:38:01 +0530 Subject: [PATCH 7/7] SK-1731: Fix batch records creation --- skyflow/vault/controller/_vault.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skyflow/vault/controller/_vault.py b/skyflow/vault/controller/_vault.py index a7c8eade..2361f063 100644 --- a/skyflow/vault/controller/_vault.py +++ b/skyflow/vault/controller/_vault.py @@ -30,7 +30,7 @@ def __build_bulk_field_records(self, values, tokens=None): def __build_batch_field_records(self, values, tokens, table_name, return_tokens, upsert): batch_record_list = [] for i, value in enumerate(values): - token = tokens[i] if tokens is not None else None + token = tokens[i] if tokens is not None and i < len(tokens) else None batch_record = V1BatchRecord( fields=value, table_name=table_name, @@ -83,6 +83,7 @@ def insert(self, request: InsertRequest): if request.continue_on_error: api_response = records_api.record_service_batch_operation(self.__vault_client.get_vault_id(), insert_body) + print("respomse: ", api_response) else: api_response = records_api.record_service_insert_record(self.__vault_client.get_vault_id(),