Albert Client
albert.albert.Albert
Albert(
*,
base_url: str | None = None,
token: str | None = None,
client_credentials: ClientCredentials | None = None,
retries: int | None = None,
session: AlbertSession | None = None,
)
Albert is the main client class for interacting with the Albert API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_url
|
str
|
The base URL of the Albert API (default is "https://app.albertinvent.com"). |
None
|
token
|
str
|
The token for authentication (default is read from environment variable "ALBERT_TOKEN"). |
None
|
client_credentials
|
ClientCredentials | None
|
The client credentials for programmatic authentication.
Client credentials can be read from the environment by |
None
|
retries
|
int
|
The maximum number of retries for failed requests (default is None). |
None
|
session
|
AlbertSession
|
An optional preconfigured session to use for API requests. If not provided,
a default session is created using the other parameters or environment variables.
When supplied, |
None
|
Attributes:
Name | Type | Description |
---|---|---|
session |
AlbertSession
|
The session for API requests, with a base URL set. |
projects |
ProjectCollection
|
The project collection instance. |
tags |
TagCollection
|
The tag collection instance. |
inventory |
InventoryCollection
|
The inventory collection instance. |
companies |
CompanyCollection
|
The company collection instance. |
Source code in src/albert/albert.py
albert.utils.credentials.ClientCredentials
Bases: BaseAlbertModel
Client authentication credentials for the Albert API.
Show JSON schema:
{
"description": "Client authentication credentials for the Albert API.",
"properties": {
"id": {
"title": "Id",
"type": "string"
},
"secret": {
"format": "password",
"title": "Secret",
"type": "string",
"writeOnly": true
}
},
"required": [
"id",
"secret"
],
"title": "ClientCredentials",
"type": "object"
}
Fields:
from_env
from_env(
*,
client_id_env: str = "ALBERT_CLIENT_ID",
client_secret_env: str = "ALBERT_CLIENT_SECRET",
) -> Union[ClientCredentials, None]
Read ClientCredentials
from the environment.
Returns None if the client_id_env
and client_secret_env
environment variables
are not defined.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client_id_env
|
str
|
Name of the environment variable containing the client ID (defaults to "ALBERT_CLIENT_ID") |
'ALBERT_CLIENT_ID'
|
client_secret_env
|
str
|
Name of the environment variable containing the client secret (defaults to "ALBERT_CLIENT_SECRET") |
'ALBERT_CLIENT_SECRET'
|
Returns:
Type | Description |
---|---|
ClientCredentials | None
|
The client credentials obtained from the environment, if present. |