Configuration¶
The Delair-Stack Python SDK has a unique entry point through the
delairstack.sdk.DelairStackSDK
class. When instantiating
that class, one must provide credentials through:
The keyword arguments
delairstack.sdk.DelairStackSDK.__init__()
function.A configuration file.
Keyword Arguments¶
Here are the configurable properties:
user
- The user identifier. Required if not provided through a configuration file, nor usingclient_id
password
- The account password. Required if not provided through a configuration file anduser
is used.client_id
- An API client identifier. Required if not provided through a configuration file, nor usinguser
.secret
- The API client secret. Required if not provided through a configuration file andclient_id
is used.access_token
- An optional API access token to use to authenticate requests as an alternative to usinguser
orclient_id
.url
- The public endpoint of Delair-Stack. Default to https://www.delair.ai.connection
- A dictionnary providing the connection configuration.proxy_url
- An optional proxy URL (⚠️ will be overrided by the value ofhttps_proxy
orhttp_proxy
environment variable if set).
The connection configuration can specify the default number of retries
through the key max_retries
(the default is to retry each request
10 times with a backoff factor) and whether to disable check of SSL
certificates through the key disable_ssl_certificate
(the default
is to disable such checks).
Configuration File¶
Configuration can be read from a file. Configuration files must be written using JSON format as a single JSON object. The supported properties are the same as the one described in the Keyword Arguments section.
The path of the default configuration file depends on the operating
system and is documented with the
delairstack.core.config.ConnectionConfig
class.
Example Configuration File¶
Here is a simple configuration file:
{"user": "firstname.lastname@example.com",
"password": "20h!nph-14-l2394"}
And a more complete one, specifying both a custom URL and connection configurations:
{
"user": "firstname.lastname@example.com",
"password": "20h!nph-14-12394",
"url": "https://www.delair.ai",
"connection": {
"max_retries": 3,
"disable_ssl_certificate": true
},
"proxy_url": "https://my-proxy.com:8888"
}
Custom Configuration File¶
In case one has multiple accounts, it’s possible to specify a custom
configuration file. For example, to instantiate a
delairstack.sdk.DelairStackSDK
using the configuration found
in the ~/.local/share/python-delairstack/devconf.json
file:
from delairstack import DelairStackSDK
sdk = DelairStackSDK(config_path='~/.local/share/python-delairstack/devconf.json')