Locations
albert.collections.locations
AlbertSession
AlbertSession(
*,
base_url: str,
token: str | None = None,
client_credentials: ClientCredentials | 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 requests. (e.g., "https://sandbox.albertinvent.com") |
required |
retries
|
int
|
The number of retries for failed requests. Defaults to 3. |
None
|
client_credentials
|
ClientCredentials | None
|
The client credentials for programmatic authentication. Optional if token is provided. |
None
|
token
|
str | None
|
The JWT token for authentication. Optional if client credentials are provided. |
None
|
Methods:
Name | Description |
---|---|
request |
|
Source code in src/albert/session.py
request
Source code in src/albert/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
Location
Bases: BaseResource
A location in Albert.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the location. |
id |
str | None
|
The Albert ID of the location. Set when the location is retrieved from Albert. |
latitude |
float
|
The latitude of the location. |
longitude |
float
|
The longitude of the location. |
address |
str
|
The address of the location. |
country |
str | None
|
The country code of the location. Must be two characters long. |
country
class-attribute
instance-attribute
country: str | None = Field(
None, max_length=2, min_length=2
)
LocationCollection
LocationCollection(*, session: AlbertSession)
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 |
---|---|
create |
Creates a new Location entity. |
delete |
Deletes a Location entity. |
get_by_id |
Retrieves a location by its ID. |
list |
Searches for locations matching the provided criteria. |
location_exists |
Determines if a location, with the same name, exists in the collection. |
update |
Update a Location entity. |
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
|
|
Source code in src/albert/collections/locations.py
get_by_id
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
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
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. |