Cas
albert.collections.cas
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
Cas
pydantic-model
Bases: BaseAlbertModel
Represents a CAS entity.
Show JSON schema:
{
"$defs": {
"CasCategory": {
"enum": [
"User",
"Verisk",
"TSCA - Public",
"TSCA - Private",
"not TSCA",
"CAS linked to External Database",
"Unknown (Trade Secret)",
"CL_Inventory Upload"
],
"title": "CasCategory",
"type": "string"
},
"Hazard": {
"description": "Represents a chemical hazard.",
"properties": {
"subCategory": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Hazard subcategory",
"title": "Subcategory"
},
"hCode": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Hazard code",
"title": "Hcode"
},
"category": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"description": "Hazard category",
"title": "Category"
},
"class": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Hazard classification",
"title": "Class"
},
"hCodeText": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Hazard code text",
"title": "Hcodetext"
}
},
"title": "Hazard",
"type": "object"
}
},
"description": "Represents a CAS entity.",
"properties": {
"number": {
"description": "The CAS number.",
"title": "Number",
"type": "string"
},
"name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Name of the CAS.",
"title": "Name"
},
"description": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The description or name of the CAS.",
"title": "Description"
},
"notes": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Notes related to the CAS.",
"title": "Notes"
},
"category": {
"anyOf": [
{
"$ref": "#/$defs/CasCategory"
},
{
"type": "null"
}
],
"default": null,
"description": "The category of the CAS."
},
"casSmiles": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "CAS SMILES notation.",
"title": "Cassmiles"
},
"inchiKey": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "InChIKey of the CAS.",
"title": "Inchikey"
},
"iUpacName": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "IUPAC name of the CAS.",
"title": "Iupacname"
},
"albertId": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The AlbertID of the CAS.",
"title": "Albertid"
},
"hazards": {
"anyOf": [
{
"items": {
"$ref": "#/$defs/Hazard"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "Hazards associated with the CAS.",
"title": "Hazards"
},
"wgk": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "German Water Hazard Class (WGK) number.",
"title": "Wgk"
},
"ecListNo": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "European Community (EC) number.",
"title": "Eclistno"
},
"type": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Type of the CAS.",
"title": "Type"
},
"classificationType": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Classification type of the CAS.",
"title": "Classificationtype"
},
"order": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "CAS order.",
"title": "Order"
}
},
"required": [
"number"
],
"title": "Cas",
"type": "object"
}
Fields:
-
number(str) -
name(str | None) -
description(str | None) -
notes(str | None) -
category(CasCategory | None) -
smiles(str | None) -
inchi_key(str | None) -
iupac_name(str | None) -
id(str | None) -
hazards(list[Hazard] | None) -
wgk(str | None) -
ec_number(str | None) -
type(str | None) -
classification_type(str | None) -
order(str | None)
classification_type
pydantic-field
classification_type: str | None = None
Classification type of the CAS.
CasCollection
CasCollection(*, session: AlbertSession)
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 |
|---|---|
create |
Creates a new CAS entity. |
delete |
Deletes a CAS by its ID. |
exists |
Checks if a CAS exists by its number. |
get_all |
Get all CAS entities with optional filters. |
get_by_id |
Retrieves a CAS by its ID. |
get_by_number |
Retrieves a CAS by its number. |
update |
Updates a CAS entity. The updated object must have the same ID as the object you want to update. |
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
delete
delete(*, id: str) -> 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
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
get_all
get_all(
*,
limit: int = 50,
start_key: str | None = None,
number: str | None = None,
id: str | None = None,
order_by: OrderBy = DESCENDING,
) -> Iterator[Cas]
Get all CAS entities with optional filters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit
|
int | None
|
The maximum number of CAS entities to return, by default 50. |
50
|
start_key
|
str | None
|
The primary key of the first item that this operation will evaluate. |
None
|
number
|
str | None
|
Fetches list of CAS by CAS number. |
None
|
id
|
str | None
|
Fetches list of CAS using the CAS Albert ID. |
None
|
order_by
|
OrderBy
|
The order by which to sort the results, by default OrderBy.DESCENDING. |
DESCENDING
|
Returns:
| Type | Description |
|---|---|
Iterator[Cas]
|
An iterator of Cas objects. |
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
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 |