Albert Client
albert.Albert
Albert(
*,
base_url: str | None = None,
token: str | None = None,
auth_manager: AlbertClientCredentials
| AlbertSSOClient
| None = None,
retries: int | None = None,
timeout: float
| tuple[float, float]
| None = DEFAULT_TIMEOUT,
headers: Mapping[str, str] | 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
|
timeout
|
float | tuple[float, float]
|
Default timeout in seconds applied to every call. Accepts a single
float (applied to both connect and read) or a |
DEFAULT_TIMEOUT
|
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 os.getenv("ALBERT_TOKEN"),
auth_manager=auth_manager,
retries=retries,
timeout=timeout,
headers=headers,
)
design_candidate_sets
design_candidate_sets: DesignCandidateSetCollection
Design candidate sets on the v4 design service.
design_candidates
design_candidates: DesignCandidateCollection
Design candidates on the v4 design service.
design_model_configs
design_model_configs: DesignModelConfigCollection
Design model configs on the v4 design service.
from_token
from_token(
*,
base_url: str | None,
token: str,
timeout: float
| tuple[float, float]
| None = DEFAULT_TIMEOUT,
headers: Mapping[str, str] | None = None,
) -> Albert
Create an Albert client using a static token for authentication.
Source code in src/albert/client.py
from_sso
from_sso(
*,
base_url: str | None,
email: str,
port: int = 5000,
tenant_id: str | None = None,
retries: int | None = None,
timeout: float
| tuple[float, float]
| None = DEFAULT_TIMEOUT,
headers: Mapping[str, str] | None = None,
login_timeout: int = DEFAULT_LOGIN_TIMEOUT,
) -> Albert
Create an Albert client using interactive OAuth2 SSO login.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str | None
|
The base URL of the Albert API. Defaults to the |
required |
email
|
str
|
The email address used to initiate the SSO login. |
required |
port
|
int
|
The starting port for the local redirect server (default is 5000). |
5000
|
tenant_id
|
str | None
|
Tenant ID to scope the SSO login. |
None
|
retries
|
int | None
|
Maximum number of retries for failed HTTP requests. |
None
|
timeout
|
float | tuple[float, float] | None
|
Default timeout in seconds applied to every API request made by the client.
Does not affect the SSO login; use |
DEFAULT_TIMEOUT
|
headers
|
Mapping[str, str] | None
|
Extra headers sent with every request. |
None
|
login_timeout
|
int
|
Seconds to wait for the user to complete the browser login (default is 120). |
DEFAULT_LOGIN_TIMEOUT
|
Returns:
| Type | Description |
|---|---|
Albert
|
An authenticated Albert client. |
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,
timeout: float
| tuple[float, float]
| None = DEFAULT_TIMEOUT,
headers: Mapping[str, str] | None = None,
) -> Albert
Create an Albert client using client credentials authentication.