Config module¶
Reference to the config.py module.
config
¶
Configuration constants and helpers shared across the Nextmv SDK.
This module is intentionally free of CLI dependencies so that it can be
imported by both nextmv.cloud and nextmv.cli without coupling.
Constants
CONFIG_DIR
~/.nextmv/ — the root directory for all Nextmv local configuration.
CONFIG_FILE
~/.nextmv/config.yaml — the main configuration file.
SESSIONS_FILE
~/.nextmv/sessions.yaml — per-endpoint OIDC configuration. Each top-
level key is an endpoint hostname (e.g. api.cloud.nextmv.io) and the
value is a mapping with oidc_discovery_url and client_id. The
production endpoint api.cloud.nextmv.io is always available as a
built-in fallback, sourced from :data:nextmv.auth.OIDC_DISCOVERY_URL and
:data:nextmv.auth.CLIENT_ID.
API_KEY_KEY
The YAML key used to store the API key in a profile ("apikey").
ENDPOINT_KEY
The YAML key used to store the endpoint in a profile ("endpoint").
AUTH_TYPE_KEY
The YAML key used to store the authentication type in a profile
("auth_type").
AUTH_SESSION_KEY
The YAML key used to store the auth session name in a profile
("auth_session"). When present on a pkce profile, tokens are
shared with all other profiles that reference the same session name,
allowing a single browser login to cover multiple profiles. When absent,
the "default" session is used.
TEAM_ID_KEY
The YAML key used to store the team (organization) UUID in a pkce
profile ("team_id"). The value is sent as the nextmv-account
request header so the API can scope requests to the correct team.
OIDC_DISCOVERY_URL_KEY
The YAML key used in sessions.yaml to store the OIDC discovery URL for
an endpoint ("oidc_discovery_url").
CLIENT_ID_KEY
The YAML key used in sessions.yaml to store the OAuth2 client ID for
an endpoint ("client_id").
AuthType
Enumeration of supported authentication types (API_KEY, PKCE).
DEFAULT_AUTH_SESSION
The reserved session name used when auth_session is not specified
("default"). This name cannot be used as a profile name.
DEFAULT_ENDPOINT
The default API endpoint ("api.cloud.nextmv.io").
AuthType
¶
load_config
¶
Load the current configuration from the config file. Returns an empty dictionary if no configuration file exists.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
The current configuration as a dictionary. |
Source code in nextmv-py/nextmv/nextmv/config.py
save_config
¶
Save the given configuration to the config file.
| PARAMETER | DESCRIPTION |
|---|---|
|
The configuration to save. |
Source code in nextmv-py/nextmv/nextmv/config.py
load_sessions
¶
Load the sessions configuration from ~/.nextmv/sessions.yaml.
Returns an empty dictionary if the file does not exist. The returned dict
is keyed by endpoint hostname; each value is a mapping with at least
oidc_discovery_url and client_id.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
The sessions configuration, or |
Source code in nextmv-py/nextmv/nextmv/config.py
save_sessions
¶
Persist the sessions configuration to ~/.nextmv/sessions.yaml.
| PARAMETER | DESCRIPTION |
|---|---|
|
The full sessions mapping to write, keyed by endpoint hostname. |
Source code in nextmv-py/nextmv/nextmv/config.py
get_endpoint_oidc_config
¶
get_endpoint_oidc_config(
endpoint: str, sessions: dict[str, Any] | None = None
) -> dict[str, str] | None
Return the OIDC configuration (oidc_discovery_url and client_id)
for endpoint.
Lookup order:
- sessions (the caller-supplied dict, typically loaded from
sessions.yaml). - The built-in fallback table :data:
_BUILTIN_OIDC— coversapi.cloud.nextmv.ioso that existing users don't need to re-runnextmv configuration create.
| PARAMETER | DESCRIPTION |
|---|---|
|
The endpoint hostname, e.g.
TYPE:
|
|
The sessions mapping loaded from |
| RETURNS | DESCRIPTION |
|---|---|
dict[str, str] | None
|
A dict with |
Source code in nextmv-py/nextmv/nextmv/config.py
non_profile_keys
¶
Returns the set of top-level config keys that are not profile names.
| RETURNS | DESCRIPTION |
|---|---|
set[str]
|
The set of non-profile keys. |
Source code in nextmv-py/nextmv/nextmv/config.py
get_auth_type
¶
Returns the auth type for the given profile. Defaults to
AuthType.API_KEY if the key is absent (backwards compatible).
| PARAMETER | DESCRIPTION |
|---|---|
|
The full configuration dictionary loaded from config.yaml.
TYPE:
|
|
The profile name. If None, the default (top-level) profile is used.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
AuthType
|
Either |
Source code in nextmv-py/nextmv/nextmv/config.py
get_auth_session
¶
Returns the auth session name to use for token storage for profile.
When auth_session is explicitly set on the profile, that value is
returned. Otherwise the reserved DEFAULT_AUTH_SESSION ("default")
is returned, meaning that all profiles without an explicit session share a
single set of tokens. This is the expected UX for users who have only one
Nextmv identity.
| PARAMETER | DESCRIPTION |
|---|---|
|
The full configuration dictionary loaded from config.yaml.
TYPE:
|
|
The profile name. If
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The session name (never empty; falls back to |
Source code in nextmv-py/nextmv/nextmv/config.py
get_team_id
¶
Returns the team (organization) UUID stored in profile, or None if
not set.
| PARAMETER | DESCRIPTION |
|---|---|
|
The full configuration dictionary loaded from config.yaml.
TYPE:
|
|
The profile name. If
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str | None
|
The team UUID, or |
Source code in nextmv-py/nextmv/nextmv/config.py
get_system_certs
¶
Returns True if profile is configured to use the system certificate
store for TLS connections (via the truststore package).
| PARAMETER | DESCRIPTION |
|---|---|
|
The full configuration dictionary loaded from config.yaml.
TYPE:
|
|
The profile name. If
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
|
Source code in nextmv-py/nextmv/nextmv/config.py
get_sso_domain
¶
Return the SSO domain stored in profile, or None if not set.
Source code in nextmv-py/nextmv/nextmv/config.py
get_profile_endpoint
¶
Returns the endpoint hostname for profile.
| PARAMETER | DESCRIPTION |
|---|---|
|
The full configuration dictionary loaded from config.yaml.
TYPE:
|
|
The profile name. If
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The endpoint hostname, falling back to |
Source code in nextmv-py/nextmv/nextmv/config.py
list_pkce_profiles
¶
Returns a list of profile names (or None for the default profile)
whose profile type is pkce.
| PARAMETER | DESCRIPTION |
|---|---|
|
The full configuration dictionary loaded from config.yaml.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[str | None]
|
A list where each entry is either a named profile string or |