Albert Client
albert.Albert
Albert(
*,
base_url: str | None = None,
token: str | None = None,
auth_manager: AlbertClientCredentials
| AlbertSSOClient
| None = None,
retries: int | None = None,
session: AlbertSession | None = None,
)
Main client for interacting with the Albert API.
This class manages authentication and access to API resource collections. It supports token-based, SSO, and client credentials authentication via a unified interface.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_url
|
str
|
The base URL of the Albert API. If not provided, the URL from |
None
|
token
|
str
|
A static token for authentication. If provided, it overrides any |
None
|
auth_manager
|
AlbertClientCredentials | AlbertSSOClient
|
An authentication manager for OAuth2-based authentication flows.
Ignored if |
None
|
retries
|
int
|
Maximum number of retries for failed HTTP requests. |
None
|
session
|
AlbertSession
|
A fully configured session instance. If provided, |
None
|
Attributes:
Name | Type | Description |
---|---|---|
session |
AlbertSession
|
The internal session used for authenticated requests. |
projects |
ProjectCollection
|
Access to project-related API methods. |
tags |
TagCollection
|
Access to tag-related API methods. |
inventory |
InventoryCollection
|
Access to inventory-related API methods. |
companies |
CompanyCollection
|
Access to company-related API methods. |
Helpers
from_token
— Create a client using a static token.from_sso
— Create a client using interactive browser-based SSO login.from_client_credentials
— Create a client using OAuth2 client credentials.
Methods:
Name | Description |
---|---|
from_token |
Create an Albert client using a static token for authentication. |
from_sso |
Create an Albert client using interactive OAuth2 SSO login. |
from_client_credentials |
Create an Albert client using client credentials authentication. |
Source code in src/albert/client.py
session
session = session or AlbertSession(
base_url=resolved_base_url,
token=token or getenv("ALBERT_TOKEN"),
auth_manager=auth_manager,
retries=retries,
)
from_token
Create an Albert client using a static token for authentication.
from_sso
from_sso(
*,
base_url: str | None,
email: str,
port: int = 5000,
tenant_id: str | None = None,
retries: int | None = None,
) -> Albert
Create an Albert client using interactive OAuth2 SSO login.
Source code in src/albert/client.py
from_client_credentials
from_client_credentials(
*,
base_url: str | None,
client_id: str,
client_secret: str,
retries: int | None = None,
) -> Albert
Create an Albert client using client credentials authentication.