Companies
albert.collections.companies
AlbertException
AlbertException(message: str)
AlbertPaginator
AlbertPaginator(
*,
path: str,
mode: PaginationMode,
session: AlbertSession,
deserialize: Callable[
[Iterable[dict]], Iterable[ItemType]
],
params: dict[str, str] | None = None,
)
Bases: Iterator[ItemType]
Helper class for pagination through Albert endpoints.
Two pagination modes are possible:
- Offset-based via by the offset query parameter
- Key-based via by the startKey query parameter and 'lastKey' response field
A custom deserialize function is provided when additional logic is required to load
the raw items returned by the search listing, e.g., making additional Albert API calls.
Source code in src/albert/core/pagination.py
AlbertSession
AlbertSession(
*,
base_url: str,
token: str | None = None,
auth_manager: AlbertClientCredentials
| AlbertSSOClient
| None = None,
retries: int | None = None,
)
Bases: Session
A session that has a base URL, which is prefixed to all request URLs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
The base URL to prefix to all relative request paths (e.g., "https://app.albertinvent.com"). |
required |
token
|
str | None
|
A static JWT token for authentication. Ignored if |
None
|
auth_manager
|
AlbertClientCredentials | AlbertSSOClient
|
An authentication manager used to dynamically fetch and refresh tokens.
If provided, it overrides |
None
|
retries
|
int
|
The number of automatic retries on failed requests (default is 3). |
None
|
Methods:
| Name | Description |
|---|---|
request |
|
Source code in src/albert/core/session.py
request
Source code in src/albert/core/session.py
BaseCollection
BaseCollection(*, session: AlbertSession)
BaseCollection is the base class for all collection classes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The Albert API Session instance. |
required |
Source code in src/albert/collections/base.py
Company
Bases: BaseResource
Company is a Pydantic model representing a company entity.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The name of the company. |
id |
str | None
|
The Albert ID of the company. Set when the company is retrieved from Albert. |
distance |
float | None
|
The scores of a company in a search result, optional. Read-only. |
CompanyCollection
CompanyCollection(*, session: AlbertSession)
Bases: BaseCollection
CompanyCollection is a collection class for managing Company entities in the Albert platform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The Albert session instance. |
required |
Methods:
| Name | Description |
|---|---|
create |
Creates a new company entity. |
delete |
Deletes a company entity. |
exists |
Checks if a company exists by its name. |
get_all |
Get all company entities with optional filters. |
get_by_id |
Get a company by its ID. |
get_by_name |
Retrieves a company by its name. |
rename |
Renames an existing company entity. |
update |
Update a Company entity. The id of the company must be provided. |
Source code in src/albert/collections/companies.py
create
Creates a new company entity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
company
|
Union[str, Company]
|
The company name or Company object to create. |
required |
check_if_exists
|
bool
|
Whether to check if the company already exists, by default True. |
True
|
Returns:
| Type | Description |
|---|---|
Company
|
The created Company object. |
Source code in src/albert/collections/companies.py
delete
delete(*, id: str) -> None
Deletes a company entity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The ID of the company to delete. |
required |
exists
Checks if a company exists by its name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the company to check. |
required |
exact_match
|
bool
|
Whether to match the name exactly, by default True. |
True
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the company exists, False otherwise. |
Source code in src/albert/collections/companies.py
get_all
get_all(
*,
limit: int = 50,
name: str | list[str] = None,
exact_match: bool = True,
start_key: str | None = None,
) -> Iterator[Company]
Get all company entities with optional filters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit
|
int
|
The maximum number of companies to return, by default 50. |
50
|
name
|
Union[str, None]
|
The name of the company to filter by, by default None. |
None
|
exact_match
|
bool
|
Whether to match the name exactly, by default True. |
True
|
Returns:
| Type | Description |
|---|---|
Iterator
|
An iterator of Company objects. |
Source code in src/albert/collections/companies.py
get_by_id
Get a company by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The ID of the company to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
Company
|
The Company object. |
Source code in src/albert/collections/companies.py
get_by_name
Retrieves a company by its name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the company to retrieve. |
required |
exact_match
|
bool
|
Whether to match the name exactly, by default True. |
True
|
Returns:
| Type | Description |
|---|---|
Company
|
The Company object if found, None otherwise. |
Source code in src/albert/collections/companies.py
rename
Renames an existing company entity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
old_name
|
str
|
The current name of the company. |
required |
new_name
|
str
|
The new name of the company. |
required |
Returns:
| Type | Description |
|---|---|
Company
|
The renamed Company object |
Source code in src/albert/collections/companies.py
update
Update a Company entity. The id of the company must be provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
company
|
Company
|
The updated Company object. |
required |
Returns:
| Type | Description |
|---|---|
Company
|
The updated Company object as registered in Albert. |