Cas
albert.collections.cas
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
Cas
pydantic-model
Bases: BaseModel
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 |
---|---|
cas_exists |
Checks if a CAS exists by its number. |
create |
Creates a new CAS entity. |
delete |
Deletes a CAS by its ID. |
get_by_id |
Retrieves a CAS by its ID. |
get_by_number |
Retrieves a CAS by its number. |
list |
Lists CAS entities with optional filters. |
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
cas_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
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
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
list
list(
*,
limit: int = 50,
start_key: str | None = None,
number: str | None = None,
id: str | None = None,
order_by: OrderBy = DESCENDING,
) -> Iterator[Cas]
Lists 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
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 |