sift_client.credentials
¶
Credential resolution shared by SiftClient and the pytest plugin.
This module reads the same sift.toml profiles that sift-cli --profile
uses. An environment that you configure once for the CLI is then available to
the Python client, and you do not restate its endpoints. See
:func:resolve_credentials for the precedence order. The Credentials and
profiles guide describes the config file.
This module is the public surface. The implementation is in
sift_client._internal.credentials.
| CLASS | DESCRIPTION |
|---|---|
ResolvedCredentials |
Credentials resolved from arguments, environment, and config file. |
| FUNCTION | DESCRIPTION |
|---|---|
resolve_credentials |
Resolve Sift credentials across arguments, environment, and |
ResolvedCredentials
dataclass
¶
ResolvedCredentials(
api_key: str,
grpc_url: str,
rest_url: str,
app_url: str | None,
use_ssl: bool,
profile: str | None,
sources: Mapping[str, str],
)
Credentials resolved from arguments, environment, and config file.
sources maps each field name to the layer that supplied it: "arg",
"profile:<name>", "env", "default", or "unset". Use it to
find which environment the client connects to. You then do not have to
work through the precedence order by hand.
| ATTRIBUTE | DESCRIPTION |
|---|---|
api_key |
TYPE:
|
grpc_url |
TYPE:
|
rest_url |
TYPE:
|
app_url |
TYPE:
|
use_ssl |
TYPE:
|
profile |
TYPE:
|
sources |
TYPE:
|
resolve_credentials
¶
resolve_credentials(
api_key: str | None = None,
grpc_url: str | None = None,
rest_url: str | None = None,
app_url: str | None = None,
profile: str | None = None,
config_path: str | None = None,
env: Mapping[str, str] | None = None,
require: bool = True,
) -> ResolvedCredentials
Resolve Sift credentials across arguments, environment, and sift.toml.
| PARAMETER | DESCRIPTION |
|---|---|
api_key
|
Explicit API key, overriding every other layer.
TYPE:
|
grpc_url
|
Explicit gRPC endpoint, overriding every other layer.
TYPE:
|
rest_url
|
Explicit REST endpoint, overriding every other layer.
TYPE:
|
app_url
|
Explicit Sift web-app origin, overriding every other layer.
TYPE:
|
profile
|
Name of a profile in the config file. It outranks the per-field environment variables. See the module docstring.
TYPE:
|
config_path
|
Path to a specific config file, bypassing discovery.
TYPE:
|
env
|
Environment mapping to read, defaulting to
TYPE:
|
require
|
If
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ResolvedCredentials
|
The resolved credentials, including which layer supplied each field. |
| RAISES | DESCRIPTION |
|---|---|
SiftCredentialsError
|
This function cannot read or parse the config
file, the named profile does not exist, or |