Skip to content

Commit 0fc3eb3

Browse files
DATA-868 - removeing schema_name from auth call
1 parent ef2b651 commit 0fc3eb3

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ For API Key authentication:
6262
key = api_key_from_platform
6363
secret = api_secret_from_platform
6464
65-
# default value for db_schema is production pipeline schema
66-
cli.login('apikey', secret_id=secret, key_id=key, db_schema=schema_name)
65+
cli.login('apikey', secret_id=secret, key_id=key)
6766
```
6867

6968
### Proxy Servers and CA Certs
@@ -82,6 +81,15 @@ Similarly, if you need to use your own CA Certificates, set the CURL_CA_BUNDLE e
8281
CURL_CA_BUNDLE="/path/to/my/certificates"
8382
```
8483

84+
### Selecting database schema
85+
By default, the production pipeline schema will be considered to retrive data from the tenant.
86+
To select a perticular development pipeline schema you can use following function call:
87+
88+
```
89+
db_schema = pipeline_id
90+
cli.select_db_schema(schema_name=db_schema)
91+
```
92+
8593
### Retrieving Data
8694

8795
The typical workflow for getting data from Sight Machine is:

smsdk/Auth/auth.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def _auth_basic(self, email=None, password=None):
8989

9090
return success
9191

92-
def _auth_apikey(self, secret_id, key_id, db_schema=""):
92+
def _auth_apikey(self, secret_id, key_id):
9393
"""
9494
Authenticate by sending an API key.
9595
@@ -104,8 +104,6 @@ def _auth_apikey(self, secret_id, key_id, db_schema=""):
104104
self.session.headers.update({SM_AUTH_HEADER_SECRET_ID: secret_id})
105105
self.session.headers.update({SM_AUTH_HEADER_SECRET_ID_OLD: secret_id}) #add v0/v1 compat
106106
self.session.headers.update({SM_AUTH_HEADER_KEY_ID: key_id})
107-
if db_schema:
108-
self.session.headers.update({X_SM_DB_SCHEMA: db_schema})
109107

110108
if not self.check_auth():
111109
raise RuntimeError(

smsdk/client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from pandas.io.json import json_normalize
1313

1414
from smsdk.utils import get_url
15-
from smsdk.Auth.auth import Authenticator
15+
from smsdk.Auth.auth import Authenticator, X_SM_DB_SCHEMA
1616
from smsdk.tool_register import smsdkentities
1717
from smsdk.client_v0 import ClientV0
1818

@@ -115,6 +115,9 @@ def __init__(self, tenant, site_domain="sightmachine.io", protocol = "https"):
115115
# Setup Authenticator
116116
self.auth = Authenticator(self)
117117
self.session = self.auth.session
118+
119+
def select_db_schema(self, schema_name):
120+
self.session.headers.update({X_SM_DB_SCHEMA:schema_name})
118121

119122
def get_data_v1(self, ename, util_name, normalize=True, *args, **kwargs):
120123
"""

0 commit comments

Comments
 (0)