Skip to content

Commit

Permalink
SK-1731-Updated samples and internal release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
saileshwar-skyflow committed Nov 19, 2024
1 parent 1a235bb commit 4d5b551
Show file tree
Hide file tree
Showing 18 changed files with 91 additions and 102 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/internal-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- "*.yml"
- "*.md"
- "skyflow/utils/_version.py"
- "samples/*"
- "samples/**"
branches:
- release/*

Expand All @@ -20,4 +20,4 @@ jobs:
ref: ${{ github.ref_name }}
is-internal: true
secrets: inherit


6 changes: 2 additions & 4 deletions samples/service_account/scoped_token_generation_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@

# Generate bearer token from credentials file path
options = {
"ctx": "<CONTEXT_ID>"
"role_ids": ["ROLE_ID1", "ROLE_ID2"]
}

if is_expired(bearer_token):
bearer_token, token_type = generate_bearer_token(
"<YOUR_CREDENTIALS_FILE_PATH>", options
Expand All @@ -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)
3 changes: 1 addition & 2 deletions samples/service_account/token_generation_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

# Generate bearer token from credentials file path
options = {
"role_ids": ["ROLE_ID1", "ROLE_ID2"]
"ctx": "<CONTEXT_ID>"
}

if is_expired(bearer_token):
bearer_token, token_type = generate_bearer_token(
"<YOUR_CREDENTIALS_FILE_PATH>", options
Expand All @@ -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)
4 changes: 1 addition & 3 deletions samples/vault_api/client_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
6 changes: 3 additions & 3 deletions samples/vault_api/credentials_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down
16 changes: 6 additions & 10 deletions samples/vault_api/delete_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand All @@ -35,14 +35,10 @@
]

delete_request = DeleteRequest(
table='TABLE_NAME',
table='<TABLE_NAME>',
ids = primary_delete_ids
)

# will return first Vault ID
response = client.vault().delete(delete_request)

print(response)


response = client.vault('<VAULT_ID>').delete(delete_request)

print(response)
6 changes: 3 additions & 3 deletions samples/vault_api/detokenize_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down
7 changes: 3 additions & 4 deletions samples/vault_api/get_column_values.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
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":"<YOUR_CLIENT_ID>","clientName":"<YOUR_CLIENT_NAME>","tokenURI":"<YOUR_TOKEN_URI>","keyID":"<YOUR_KEY_ID>","privateKey":"<YOUR_PRIVATE_KEY>"}'

# 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 = (
Expand Down
7 changes: 3 additions & 4 deletions samples/vault_api/get_records.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
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":"<YOUR_CLIENT_ID>","clientName":"<YOUR_CLIENT_NAME>","tokenURI":"<YOUR_TOKEN_URI>","keyID":"<YOUR_KEY_ID>","privateKey":"<YOUR_PRIVATE_KEY>"}'

# 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 = (
Expand Down
50 changes: 27 additions & 23 deletions samples/vault_api/insert_byot.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
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":"<YOUR_CLIENT_ID>","clientName":"<YOUR_CLIENT_NAME>","tokenURI":"<YOUR_TOKEN_URI>","keyID":"<YOUR_KEY_ID>","privateKey":"<YOUR_PRIVATE_KEY>"}'

# 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 = (
Expand All @@ -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 = [
{"<FIELD_NAME1>": '<VALUE1>'},
{"<FIELD_NAME2>": '<VALUE2>'}
]

token_data = [
{"<FIELD_NAME1>": '<TOKEN1>'},
{"<FIELD_NAME2>": '<TOKEN2>'}
]

response = skyflow_client.vault('VAULT_ID').insert(insert_request)
insert_request = InsertRequest(
table_name='<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)
14 changes: 6 additions & 8 deletions samples/vault_api/insert_records.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
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":"<YOUR_CLIENT_ID>","clientName":"<YOUR_CLIENT_NAME>","tokenURI":"<YOUR_TOKEN_URI>","keyID":"<YOUR_KEY_ID>","privateKey":"<YOUR_PRIVATE_KEY>"}'

# 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 = (
Expand All @@ -29,8 +28,7 @@

# sample data
insert_data = [
{ "card_number": 'CARD_NUMBER1', "card_cvv": 'CVV1' },
{ "card_number": 'CARD_NUMBER2', "card_cvv": 'CVV2' },
{ "<FIELD>": '<VALUE>', "<FIELD>": '<VALUE>' },
]

insert_request = InsertRequest(
Expand All @@ -42,4 +40,4 @@

response = skyflow_client.vault('VAULT_ID').insert(insert_request)

print(response)
print(response)
24 changes: 15 additions & 9 deletions samples/vault_api/invoke_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
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":"<YOUR_CLIENT_ID>","clientName":"<YOUR_CLIENT_NAME>","tokenURI":"<YOUR_TOKEN_URI>","keyID":"<YOUR_KEY_ID>","privateKey":"<YOUR_PRIVATE_KEY>"}'

# 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 = (
Expand All @@ -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)
13 changes: 5 additions & 8 deletions samples/vault_api/query_records.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
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":"<YOUR_CLIENT_ID>","clientName":"<YOUR_CLIENT_NAME>","tokenURI":"<YOUR_TOKEN_URI>","keyID":"<YOUR_KEY_ID>","privateKey":"<YOUR_PRIVATE_KEY>"}'

# 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 = (
Expand Down Expand Up @@ -44,4 +41,4 @@

response = skyflow_client.vault("VAULT_ID").query(query_request)

print(response)
print(response)
11 changes: 4 additions & 7 deletions samples/vault_api/tokenize_records.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
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":"<YOUR_CLIENT_ID>","clientName":"<YOUR_CLIENT_NAME>","tokenURI":"<YOUR_TOKEN_URI>","keyID":"<YOUR_KEY_ID>","privateKey":"<YOUR_PRIVATE_KEY>"}'

# 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 = (
Expand Down
Loading

0 comments on commit 4d5b551

Please sign in to comment.