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. |
| 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. |
| Property | parent |
Return the parent id from the active profile. |
| Method | _get |
Get the profile from the config file. |
| Instance Variable | _client |
Undocumented |
| Instance Variable | _config |
Undocumented |
| Instance Variable | _endpoint |
Undocumented |
| Instance Variable | _max |
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):
(source)
¶
Initialize the config reader, and read the config file, selecting the active profile.
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 |
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 |