-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathget_with_options.py
More file actions
36 lines (31 loc) · 1.05 KB
/
get_with_options.py
File metadata and controls
36 lines (31 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'''
Copyright (c) 2022 Skyflow, Inc.
'''
from skyflow.errors import SkyflowError
from skyflow.service_account import generate_bearer_token, is_expired
from skyflow.vault import Client, Configuration, RedactionType, GetOptions
# cache token for reuse
bearerToken = ''
def token_provider():
global bearerToken
if is_expired(bearerToken):
bearerToken, _ = generate_bearer_token('<YOUR_CREDENTIALS_FILE_PATH>')
return bearerToken
try:
config = Configuration(
'<YOUR_VAULT_ID>', '<YOUR_VAULT_URL>', token_provider)
client = Client(config)
options = GetOptions(False)
data = {"records": [
{
"ids": ["<SKYFLOW_ID1>", "<SKYFLOW_ID2>", "<SKYFLOW_ID3>"],
"table": "<TABLE_NAME>",
"redaction": RedactionType.PLAIN_TEXT
}
]}
response = client.get(data,options=options)
print('Response:', response)
except SkyflowError as skyflow_error:
print('Skyflow Error Occurred:', skyflow_error)
except Exception as general_error:
print('Unexpected Error Occurred:', general_error)