Storage Locations
albert.collections.storage_locations
AlbertHTTPError
Bases: AlbertException
Base class for all erors due to HTTP responses.
Source code in src/albert/exceptions.py
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
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
)
PaginationMode
StorageLocation
Bases: BaseResource
A storage location entity. For example, a specific flammables cabinet or a storage room.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The name of the storage location. |
id |
str | None
|
The Albert ID of the storage location. Set when the storage location is retrieved from Albert. |
location |
Location
|
The location entity link of the storage location. |
StorageLocationsCollection
StorageLocationsCollection(*, session: AlbertSession)
Bases: BaseCollection
StorageLocationsCollection is a collection class for managing StorageLoction entities in the Albert platform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The Albert Session information |
required |
Methods:
| Name | Description |
|---|---|
create |
Create a new storage location. |
delete |
Delete a storage location by its ID. |
get_all |
Get all storage locations with optional filtering. |
get_by_id |
Get a storage location by its ID. |
update |
Update a storage location. |
Source code in src/albert/collections/storage_locations.py
create
create(
*, storage_location: StorageLocation
) -> StorageLocation
Create a new storage location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
storage_location
|
StorageLocation
|
The storage location to create. |
required |
Returns:
| Type | Description |
|---|---|
StorageLocation
|
The created storage location. |
Source code in src/albert/collections/storage_locations.py
delete
delete(*, id: str) -> None
Delete a storage location by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The ID of the storage location to delete. |
required |
Source code in src/albert/collections/storage_locations.py
get_all
get_all(
*,
name: str | list[str] | None = None,
exact_match: bool = False,
location: str | Location | None = None,
start_key: str | None = None,
limit: int = 50,
) -> Iterator[StorageLocation]
Get all storage locations with optional filtering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | list[str] | None
|
The name or names of the storage locations to filter by, by default None |
None
|
exact_match
|
bool
|
Whether to perform an exact match on the name, by default False |
False
|
location
|
str | Location | None
|
The location ID or Location object to filter by, by default None |
None
|
Yields:
| Type | Description |
|---|---|
Iterator[StorageLocation]
|
An iterator of StorageLocation items matching the search criteria. |
Source code in src/albert/collections/storage_locations.py
get_by_id
get_by_id(*, id: str) -> StorageLocation
Get a storage location by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The ID of the storage location to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
StorageLocation
|
The retrieved storage location with the given ID. |
Source code in src/albert/collections/storage_locations.py
update
update(
*, storage_location: StorageLocation
) -> StorageLocation
Update a storage location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
storage_location
|
StorageLocation
|
The storage location to update. |
required |
Returns:
| Type | Description |
|---|---|
StorageLocation
|
The updated storage location as returned by the server. |