Skip to content

Configuration

Configuration management for the Bloomy SDK.

Configuration

Configuration(api_key: str | None = None)

The Configuration class is responsible for managing authentication.

Initialize a new Configuration instance.

Parameters:

  • api_key (str | None, default: None ) –

    Optional API key. If not provided, will attempt to load from environment variable or configuration file.

Example
config = Bloomy.Configuration(api_key)

Methods:

  • configure_api_key

    Configure the API key using the provided username and password.

Source code in src/bloomy/configuration.py
def __init__(self, api_key: str | None = None) -> None:
    """Initialize a new Configuration instance.

    Args:
        api_key: Optional API key. If not provided, will attempt to load from
                 environment variable or configuration file.

    Example:
        ```python
        config = Bloomy.Configuration(api_key)
        ```

    """
    self.api_key = api_key or os.environ.get("BG_API_KEY") or self._load_api_key()

Functions

configure_api_key

configure_api_key(username: str, password: str, store_key: bool = False) -> None

Configure the API key using the provided username and password.

Parameters:

  • username (str) –

    The username for authentication

  • password (str) –

    The password for authentication

  • store_key (bool, default: False ) –

    Whether to store the API key (default: False)

Note

This method only fetches and stores the API key if it is currently None. It saves the key under '~/.bloomy/config.yaml' if 'store_key: True' is passed.

Example
config.configure_api_key("user", "pass", store_key=True)
config.api_key
# Returns: 'xxxx...'
Source code in src/bloomy/configuration.py
def configure_api_key(
    self, username: str, password: str, store_key: bool = False
) -> None:
    """Configure the API key using the provided username and password.

    Args:
        username: The username for authentication
        password: The password for authentication
        store_key: Whether to store the API key (default: False)

    Note:
        This method only fetches and stores the API key if it is currently None.
        It saves the key under '~/.bloomy/config.yaml' if 'store_key: True' is
        passed.

    Example:
        ```python
        config.configure_api_key("user", "pass", store_key=True)
        config.api_key
        # Returns: 'xxxx...'
        ```

    """
    self.api_key = self._fetch_api_key(username, password)
    if store_key:
        self._store_api_key()