Sessions
Importing and defining a custom Session
objects for use within clients
This custom Session
object can be passed when creating new clients
of any kind
.
The main purpose of this is to allow for the use of custom Session
objects when working across multiple tenants simultaneously.
[ ]:
import os
from peak import Session
custom_session_1 = Session(auth_token=os.environ.get("API_KEY_1"), stage="test")
custom_session_2 = Session(auth_token=os.environ.get("API_KEY_2"), stage="prod")
Multi-Environment usage example with a Workflow
client
[ ]:
from peak.resources import workflows
wf_client_custom_session_1: workflows.Workflow = workflows.get_client(session=custom_session_1)
wf_client_custom_session_2: workflows.Workflow = workflows.get_client(session=custom_session_2)
The default behavior is to pick up arguments from the user’s environment.
[ ]:
wf_client: workflows.Workflow = workflows.get_client()