Locations
albert.collections.locations.LocationCollection
Bases: BaseCollection
LocationCollection is a collection class for managing Location entities in the Albert platform.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AlbertSession
|
The Albert session instance. |
required |
Methods:
Name | Description |
---|---|
get_all |
Get all Location entities matching the provided criteria. |
get_by_id |
Retrieves a location by its ID. |
update |
Update a Location entity. |
exists |
Determines if a location, with the same name, exists in the collection. |
create |
Creates a new Location entity. |
get_or_create |
Retrieves a Location by its name or creates it if it does not exist. |
delete |
Deletes a Location entity. |
Attributes:
Name | Type | Description |
---|---|---|
base_path |
|
Source code in src/albert/collections/locations.py
get_all
get_all(
*,
ids: list[str] | None = None,
name: str | list[str] | None = None,
country: str | None = None,
exact_match: bool = False,
start_key: str | None = None,
max_items: int | None = None,
) -> Iterator[Location]
Get all Location entities matching the provided criteria.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ids
|
list[str]
|
The list of IDs to filter the locations. Max length is 100. |
None
|
name
|
str or list[str]
|
The name or names of locations to search for. |
None
|
country
|
str
|
Country code to filter by. |
None
|
exact_match
|
bool
|
Whether to return only exact matches. Default is False. |
False
|
start_key
|
str
|
The pagination key to start from. |
None
|
max_items
|
int
|
Maximum number of items to return in total. If None, fetches all available items. |
None
|
Returns:
Type | Description |
---|---|
Iterator[Location]
|
An iterator of Location entities matching the filters. |
Source code in src/albert/collections/locations.py
get_by_id
update
Update a Location entity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
location
|
Location
|
The Location entity to update. The ID of the Location entity must be provided. |
required |
Returns:
Type | Description |
---|---|
Location
|
The updated Location entity as returned by the server. |
Source code in src/albert/collections/locations.py
exists
Determines if a location, with the same name, exists in the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
location
|
Location
|
The Location entity to check |
required |
Returns:
Type | Description |
---|---|
Location | None
|
The existing registered Location entity if found, otherwise None. |
Source code in src/albert/collections/locations.py
create
Creates a new Location entity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
location
|
Location
|
The Location entity to create. |
required |
Returns:
Type | Description |
---|---|
Location
|
The created Location entity. |
Source code in src/albert/collections/locations.py
get_or_create
Retrieves a Location by its name or creates it if it does not exist.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
location
|
Location
|
The Location entity to retrieve or create. |
required |
Returns:
Type | Description |
---|---|
Location
|
The found or created Location entity. |
Source code in src/albert/collections/locations.py
delete
delete(*, id: str) -> None
Deletes a Location entity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
Str
|
The id of the Location entity to delete. |
required |
Returns:
Type | Description |
---|---|
None
|
|