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 |
---|---|
list |
Searches for locations matching the provided criteria. |
get_by_id |
Retrieves a location by its ID. |
update |
Update a Location entity. |
location_exists |
Determines if a location, with the same name, exists in the collection. |
create |
Creates a new Location entity. |
delete |
Deletes a Location entity. |
Attributes:
Name | Type | Description |
---|---|---|
base_path |
|
Source code in src/albert/collections/locations.py
list
list(
*,
ids: list[str] | None = None,
name: str | list[str] | None = None,
country: str | None = None,
exact_match: bool = False,
limit: int = 50,
start_key: str | None = None,
) -> Iterator[Location]
Searches for locations matching the provided criteria.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ids
|
list[str] | None
|
The list of IDs to filter the locations, by default None. Max length is 100. |
None
|
name
|
str | list[str] | None
|
The name or names of locations to search for, by default None |
None
|
country
|
str | None
|
The country code of the country to filter the locations , by default None |
None
|
exact_match
|
bool
|
Whether to return exact matches only, by default False |
False
|
Yields:
Type | Description |
---|---|
Iterator[Location]
|
An iterator of Location objects matching the search criteria. |
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 object to update. The ID of the Location object must be provided. |
required |
Returns:
Type | Description |
---|---|
Location
|
The updated Location object as returned by the server. |
Source code in src/albert/collections/locations.py
location_exists
Determines if a location, with the same name, exists in the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
location
|
Location
|
The Location object to check |
required |
Returns:
Type | Description |
---|---|
Location | None
|
The existing registered Location object 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 object to create. |
required |
Returns:
Type | Description |
---|---|
Location
|
The created Location object. |
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 object to delete. |
required |
Returns:
Type | Description |
---|---|
None
|
|