Companies
albert.collections.companies.CompanyCollection
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 |
---|---|
get_all |
Get all company entities with optional filters. |
exists |
Checks if a company exists by its name. |
get_by_id |
Get a company by its ID. |
get_by_name |
Retrieves a company by its name. |
create |
Creates a new company entity. |
get_or_create |
Retrieves a company by its name or creates it if it does not exist. |
delete |
Deletes a company entity. |
rename |
Renames an existing company entity. |
update |
Update a Company entity. The id of the company must be provided. |
Attributes:
Name | Type | Description |
---|---|---|
base_path |
|
Source code in src/albert/collections/companies.py
get_all
get_all(
*,
name: str | list[str] = None,
exact_match: bool = True,
start_key: str | None = None,
max_items: int | None = None,
) -> Iterator[Company]
Get all company entities with optional filters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str | list[str]
|
The name(s) of the company to filter by. |
None
|
exact_match
|
bool
|
Whether to match the name(s) exactly. Default is True. |
True
|
start_key
|
str
|
Key to start paginated results from. |
None
|
max_items
|
int
|
Maximum number of items to return in total. If None, fetches all available items. |
None
|
Returns:
Type | Description |
---|---|
Iterator[Company]
|
An iterator of Company entities. |
Source code in src/albert/collections/companies.py
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_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
create
Creates a new company entity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
company
|
Union[str, Company]
|
The company name or Company object to create. |
required |
Returns:
Type | Description |
---|---|
Company
|
The created Company object. |
Source code in src/albert/collections/companies.py
get_or_create
Retrieves a company by its name or creates it if it does not exist.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
company
|
Union[str, Company]
|
The company name or Company object to retrieve or create. |
required |
Returns:
Type | Description |
---|---|
Company
|
The Company object if found or created. |
Source code in src/albert/collections/companies.py
delete
delete(*, id: CompanyId) -> None
Deletes a company entity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
The ID of the company to delete. |
required |
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. |