class documentation

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_idOptional client id used for federation flows.
config_filePath to the configuration YAML file.
profileOptional profile name to select; when omitted the default profile from the config or the environment variable indicated by profile_env is used.
profile_envEnvironment variable name used to select a profile.
token_envEnvironment variable name that may contain an IAM token and will take priority over file-based credentials.
no_envIf 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_parent_idIf True disable automatic parent id resolution.
max_retriesMaximum number of auth retries when interacting with external services (passed to underlying bearers).
endpointOptional endpoint URL to override profile setting.
endpoint_envEnvironment 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_credentials Resolve and return credentials for the active profile.
Property parent_id Return the parent id from the active profile.
Method _get_profile Get the profile from the config file.
Instance Variable _client_id Undocumented
Instance Variable _config_file Undocumented
Instance Variable _endpoint Undocumented
Instance Variable _max_retries Undocumented
Instance Variable _no_parent_id Undocumented
Instance Variable _priority_bearer Undocumented
Instance Variable _profile Undocumented
Instance Variable _profile_name Undocumented
def __init__(self, client_id: str | None = None, config_file: str | Path = Path(DEFAULT_CONFIG_DIR) / DEFAULT_CONFIG_FILE, profile: 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.

def endpoint(self) -> str: (source)

Return the configured endpoint for the active profile.

If the profile does not define an endpoint this method returns an empty string.

Returns
strendpoint string or empty string when not configured
def get_credentials(self, channel: 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:

  1. An environment-provided token bearer (if present and enabled).
  2. A token file specified by token-file in the profile.
  3. 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:ClientChannelInterfacechannel instance used for network-bound credential flows
writer:optional TextIOoptional text stream used by interactive flows (federation)
no_browser_open:boolwhen True, federation flows will not open browsers
ssl_ctx:optional SSLContextoptional SSLContext forwarded to federation flows
Returns
Provider, nebius.aio.token.token.Bearer, TokenRequester, Token or stra credentials object appropriate for the active profile
Raises
ConfigErrorfor 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
NoParentIdErrorif parent id usage is disabled or the value is missing or empty in the profile
ConfigErrorif the profile contains a non-string parent-id
def _get_profile(self): (source)

Get the profile from the config file.

_client_id = (source)

Undocumented

_config_file = (source)

Undocumented

_endpoint: str | None = (source)

Undocumented

_max_retries = (source)

Undocumented

_no_parent_id = (source)

Undocumented

_priority_bearer: EnvBearer | None = (source)

Undocumented

_profile: dict[str, Any] = (source)

Undocumented

_profile_name = (source)

Undocumented