class Config: (source)
Constructor: Config(client_id, config_file, profile, profile_env, ...)
Reader for Nebius CLI-style configuration files.
The Config class locates and parses a YAML-based configuration
file (by default under ~/.nebius/config.yaml) and exposes convenience
methods to obtain the default parent id, endpoint, and credentials
configured for the active profile.
Example
Initialize the SDK with CLI config:
from nebius.sdk import SDK
from nebius.aio.cli_config import Config
# Initialize SDK with CLI config reader
sdk = SDK(config_reader=Config())
# The config reader will automatically handle authentication
# based on the active CLI profile
# You can also access config properties directly
config = Config()
print(f"Default parent ID: {config.parent_id}")
print(f"Endpoint: {config.endpoint()}")
| Parameters | |
| client | Optional client id used for federation flows. |
| config | Path to the configuration YAML file. |
| profile | Optional profile name to select; when omitted the default profile from the config or the environment variable indicated by profile_env is used. |
| profile | Environment variable name used to select a profile. |
| token | Environment variable name that may contain an IAM token and will take priority over file-based credentials. |
| no | If True skip environment token lookup, profile selection, and endpoint override. If you want to disable only one of these features, you can set the env variable name to some invalid value. |
| no | If True disable automatic parent id resolution. |
| max | Maximum number of auth retries when interacting with external services (passed to underlying bearers). |
| endpoint | Optional endpoint URL to override profile setting. |
| endpoint | Environment variable name used to override the endpoint URL from the profile. |
| metrics | Optional callback object or mapping that receives config
metrics from this reader and auth metrics from credentials it creates.
The last config_load event is replayed when metrics are attached
later via set_metrics. |
| auth | Optional callback object or mapping for auth-only
metrics emitted by credentials returned from get_credentials.
Ignored when metrics is provided because full metrics are reused for
auth callbacks. |
| impersonate | Optional service account id to impersonate. Overrides impersonate-service-account-id from the selected profile. |
| Method | __init__ |
Initialize the config reader, and read the config file, selecting the active profile. |
| Method | endpoint |
Return the configured endpoint for the active profile. |
| Method | get |
Resolve and return credentials for the active profile. |
| Method | profile |
Return the selected profile name. |
| Method | set |
Attach auth-only metrics used by credentials returned later. |
| Method | set |
Attach full config/auth metrics and replay the last config load. |
| Property | parent |
Return the parent id from the active profile. |
| Method | _add |
Wrap token credentials with service-account impersonation if configured. |
| Method | _get |
Get the profile from the config file. |
| Method | _record |
Undocumented |
| Instance Variable | _auth |
Undocumented |
| Instance Variable | _client |
Undocumented |
| Instance Variable | _config |
Undocumented |
| Instance Variable | _endpoint |
Undocumented |
| Instance Variable | _impersonate |
Undocumented |
| Instance Variable | _last |
Undocumented |
| Instance Variable | _max |
Undocumented |
| Instance Variable | _metrics |
Undocumented |
| Instance Variable | _no |
Undocumented |
| Instance Variable | _priority |
Undocumented |
| Instance Variable | _profile |
Undocumented |
| Instance Variable | _profile |
Undocumented |
str | None = None, config_file: str | Path = Path(str | None = None, profile_env: str = PROFILE_ENV, token_env: str = TOKEN_ENV, no_env: bool = False, no_parent_id: bool = False, max_retries: int = 2, endpoint: str | None = None, endpoint_env: str = ENDPOINT_ENV, metrics: MetricsLike = None, auth_metrics: AuthMetricsLike = None, impersonate_service_account_id: str | None = None):
(source)
¶
Initialize the config reader, and read the config file, selecting the active profile.
metrics receives both configuration metrics and auth metrics for credentials created by this reader. auth_metrics receives only auth metrics and is used only when metrics is not provided.
Return the configured endpoint for the active profile.
If the profile does not define an endpoint this method returns an empty string.
| Returns | |
str | endpoint string or empty string when not configured |
ClientChannelInterface, writer: TextIO | None = None, no_browser_open: bool = False, ssl_ctx: SSLContext | None = None) -> Credentials:
(source)
¶
Resolve and return credentials for the active profile.
This method consults, in order of priority:
- An environment-provided token bearer (if present and enabled).
- A token file specified by token-file in the profile.
- The profile's auth-type which may be federation or service account and will create the corresponding bearer implementation.
The returned object is suitable to be consumed by
nebius.aio.channel.Channel and may be one of
nebius.aio.authorization.authorization.Provider, a
nebius.aio.token.token.Bearer, a TokenRequester
reader, a low-level nebius.aio.token.token.Token, or a raw
string token depending on the profile and environment.
| Parameters | |
channel:ClientChannelInterface | channel instance used for network-bound credential flows |
writer:optional TextIO | optional text stream used by interactive flows (federation) |
nobool | when True, federation flows will not open browsers |
sslSSLContext | optional SSLContext forwarded to federation flows |
| Returns | |
Provider, nebius.aio.token.token.Bearer,
TokenRequester, Token or str | a credentials object appropriate for the active profile |
| Raises | |
ConfigError | for malformed or missing profile entries |
Attach auth-only metrics used by credentials returned later.
This does not emit or replay config-reader metrics. Use
set_metrics when the same sink should receive both config and
auth events.
Attach full config/auth metrics and replay the last config load.
The same callback object is propagated to credentials returned later so token acquisition, refresh, and cache events share the same sink.
Return the parent id from the active profile.
The value is read from the active profile's parent-id field and validated to be a non-empty string.
| Returns | |
| the parent id configured for the active profile | |
| Raises | |
NoParentIdError | if parent id usage is disabled or the value is missing or empty in the profile |
ConfigError | if the profile contains a non-string parent-id |
Credentials, channel: ClientChannelInterface) -> Credentials:
(source)
¶
Wrap token credentials with service-account impersonation if configured.