Cas
albert.collections.cas.CasCollection
Bases: BaseCollection
CasCollection is a collection class for managing Cas entities on the Albert Platform.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AlbertSession
|
The Albert session instance. |
required |
Methods:
Name | Description |
---|---|
get_all |
Get all CAS entities with optional filters. |
exists |
Checks if a CAS exists by its number. |
create |
Creates a new CAS entity. |
get_or_create |
Retrieves a CAS by its number or creates it if it does not exist. |
get_by_id |
Retrieves a CAS by its ID. |
get_by_number |
Retrieves a CAS by its number. |
delete |
Deletes a CAS by its ID. |
update |
Updates a CAS entity. The updated object must have the same ID as the object you want to update. |
Attributes:
Name | Type | Description |
---|---|---|
base_path |
|
Source code in src/albert/collections/cas.py
get_all
get_all(
*,
number: str | None = None,
cas: list[str] | None = None,
id: CasId | None = None,
order_by: OrderBy = DESCENDING,
start_key: str | None = None,
max_items: int | None = None,
) -> Iterator[Cas]
Get all CAS entities with optional filters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
number
|
str
|
Filter CAS entities by CAS number. |
None
|
cas
|
list[str] | None
|
Filter CAS entities by a list of CAS numbers. |
None
|
id
|
str
|
Filter CAS entities by Albert CAS ID. |
None
|
order_by
|
OrderBy
|
Sort direction (ascending or descending). Default is DESCENDING. |
DESCENDING
|
start_key
|
str
|
The pagination key to start fetching from. |
None
|
max_items
|
int
|
Maximum number of items to return in total. If None, fetches all available items. |
None
|
Returns:
Type | Description |
---|---|
Iterator[Cas]
|
An iterator over Cas entities. |
Source code in src/albert/collections/cas.py
exists
Checks if a CAS exists by its number.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
number
|
str
|
The number of the CAS to check. |
required |
exact_match
|
bool
|
Whether to match the number exactly, by default True. |
True
|
Returns:
Type | Description |
---|---|
bool
|
True if the CAS exists, False otherwise. |
Source code in src/albert/collections/cas.py
create
Creates a new CAS entity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cas
|
Union[str, Cas]
|
The CAS number or Cas object to create. |
required |
Returns:
Type | Description |
---|---|
Cas
|
The created Cas object. |
Source code in src/albert/collections/cas.py
get_or_create
Retrieves a CAS by its number or creates it if it does not exist.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cas
|
Union[str, Cas]
|
The CAS number or Cas object to retrieve or create. |
required |
Returns:
Type | Description |
---|---|
Cas
|
The Cas object if found or created. |
Source code in src/albert/collections/cas.py
get_by_id
Retrieves a CAS by its ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
The ID of the CAS to retrieve. |
required |
Returns:
Type | Description |
---|---|
Cas
|
The Cas object if found, None otherwise. |
Source code in src/albert/collections/cas.py
get_by_number
Retrieves a CAS by its number.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
number
|
str
|
The number of the CAS to retrieve. |
required |
exact_match
|
bool
|
Whether to match the number exactly, by default True. |
True
|
Returns:
Type | Description |
---|---|
Optional[Cas]
|
The Cas object if found, None otherwise. |
Source code in src/albert/collections/cas.py
delete
delete(*, id: CasId) -> None
Deletes a CAS by its ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
The ID of the CAS to delete. |
required |
Returns:
Type | Description |
---|---|
None
|
|
Source code in src/albert/collections/cas.py
update
Updates a CAS entity. The updated object must have the same ID as the object you want to update.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
updated_object
|
Cas
|
The Updated Cas object. |
required |
Returns:
Type | Description |
---|---|
Cas
|
The updated Cas object as it appears in Albert |