Notebooks
albert.collections.notebooks
NotebookBlock
module-attribute
NotebookBlock = Annotated[
_NotebookBlockUnion, Field(discriminator="type")
]
AlbertException
AlbertException(message: str)
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
NotFoundError
Notebook
Bases: BaseResource
id
class-attribute
instance-attribute
parent_id
class-attribute
instance-attribute
NotebookCollection
NotebookCollection(*, session: AlbertSession)
Bases: BaseCollection
NotebookCollection is a collection class for managing Notebook entities in the Albert platform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The Albert session instance. |
required |
Methods:
| Name | Description |
|---|---|
copy |
Create a copy of a Notebook into a specified parent |
create |
Create or return notebook for the provided notebook. |
delete |
Deletes a notebook by its ID. |
get_block_by_id |
Retrieve a Notebook Block by its ID. |
get_by_id |
Retrieve a Notebook by its ID. |
list_by_parent_id |
Retrieve a Notebook by parent ID. |
update |
Update a notebook. |
update_block_content |
Updates the block content of a Notebook. This does not update the notebook name (use .update for that). |
Source code in src/albert/collections/notebooks.py
copy
copy(
*,
notebook_copy_info: NotebookCopyInfo,
type: NotebookCopyType,
) -> Notebook
Create a copy of a Notebook into a specified parent
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notebook_copy_info
|
NotebookCopyInfo
|
The copy information for the Notebook copy |
required |
type
|
NotebookCopyType
|
Differentiate whether copy is for templates, task, project or restoreTemplate |
required |
Returns:
| Type | Description |
|---|---|
Notebook
|
The result of the copied Notebook. |
Source code in src/albert/collections/notebooks.py
create
Create or return notebook for the provided notebook. This endpoint automatically tries to find an existing notebook with the same parameter setpoints, and will either return the existing notebook or create a new one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notebook
|
Notebook
|
A list of Notebook objects to find or create. |
required |
Returns:
| Type | Description |
|---|---|
Notebook
|
A list of created or found Notebook objects. |
Source code in src/albert/collections/notebooks.py
delete
delete(*, id: str) -> None
Deletes a notebook by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The ID of the notebook to delete. |
required |
get_block_by_id
get_block_by_id(
*, notebook_id: str, block_id: str
) -> NotebookBlock
Retrieve a Notebook Block by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notebook_id
|
str
|
The ID of the Notebook to which the Block belongs. |
required |
block_id
|
str
|
The ID of the Notebook Block to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
NotebookBlock
|
The NotebookBlock object. |
Source code in src/albert/collections/notebooks.py
get_by_id
list_by_parent_id
Retrieve a Notebook by parent ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_id
|
str
|
The ID of the parent ID, e.g. task. |
required |
Returns:
| Type | Description |
|---|---|
list[Notebook]
|
list of notebook references. |
Source code in src/albert/collections/notebooks.py
update
Update a notebook.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notebook
|
Notebook
|
The updated notebook object. |
required |
Returns:
| Type | Description |
|---|---|
Notebook
|
The updated notebook object as returned by the server. |
Source code in src/albert/collections/notebooks.py
update_block_content
Updates the block content of a Notebook. This does not update the notebook name (use .update for that). If a block in the Notebook does not already exist on Albert, it will be created. Note: The order of the Blocks in your Notebook matter and will be used in the updated Notebook!
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notebook
|
Notebook
|
The updated notebook object. |
required |
Returns:
| Type | Description |
|---|---|
Notebook
|
The updated notebook object as returned by the server. |
Source code in src/albert/collections/notebooks.py
NotebookCopyInfo
pydantic-model
Bases: BaseAlbertModel
Show JSON schema:
{
"$defs": {
"ACL": {
"description": "The Access Control List (ACL) for a user",
"properties": {
"id": {
"description": "The id of the user for which this ACL applies",
"title": "Id",
"type": "string"
},
"fgc": {
"anyOf": [
{
"$ref": "#/$defs/AccessControlLevel"
},
{
"type": "null"
}
],
"default": null,
"description": "The Fine-Grain Control Level"
}
},
"required": [
"id"
],
"title": "ACL",
"type": "object"
},
"AccessControlLevel": {
"description": "The fine grain control",
"enum": [
"ProjectOwner",
"ProjectEditor",
"ProjectViewer",
"ProjectAllTask",
"ProjectPropertyTask",
"InventoryOwner",
"InventoryViewer",
"CustomTemplateOwner",
"CustomTemplateViewer"
],
"title": "AccessControlLevel",
"type": "string"
},
"AuditFields": {
"description": "The audit fields for a resource",
"properties": {
"by": {
"default": null,
"title": "By",
"type": "string"
},
"byName": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Byname"
},
"at": {
"anyOf": [
{
"format": "date-time",
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "At"
}
},
"title": "AuditFields",
"type": "object"
},
"NotebookCopyACL": {
"properties": {
"status": {
"anyOf": [
{
"$ref": "#/$defs/Status"
},
{
"type": "null"
}
],
"default": null
},
"Created": {
"anyOf": [
{
"$ref": "#/$defs/AuditFields"
},
{
"type": "null"
}
],
"default": null
},
"Updated": {
"anyOf": [
{
"$ref": "#/$defs/AuditFields"
},
{
"type": "null"
}
],
"default": null
},
"fgclist": {
"default": null,
"items": {
"$ref": "#/$defs/ACL"
},
"title": "Fgclist",
"type": "array"
},
"class": {
"title": "Class",
"type": "string"
}
},
"required": [
"class"
],
"title": "NotebookCopyACL",
"type": "object"
},
"Status": {
"description": "The status of a resource",
"enum": [
"active",
"inactive"
],
"title": "Status",
"type": "string"
}
},
"properties": {
"id": {
"title": "Id",
"type": "string"
},
"parentId": {
"title": "Parentid",
"type": "string"
},
"notebookName": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Notebookname"
},
"name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Name"
},
"acl": {
"anyOf": [
{
"$ref": "#/$defs/NotebookCopyACL"
},
{
"type": "null"
}
],
"default": null
}
},
"required": [
"id",
"parentId"
],
"title": "NotebookCopyInfo",
"type": "object"
}
Fields:
NotebookCopyType
PutBlockDatum
pydantic-model
Bases: BaseAlbertModel
Show JSON schema:
{
"$defs": {
"AttachesContent": {
"properties": {
"title": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title"
},
"namespace": {
"default": "result",
"title": "Namespace",
"type": "string"
},
"fileKey": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Filekey"
},
"mimeType": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Mimetype"
},
"signedURL": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Signedurl"
}
},
"title": "AttachesContent",
"type": "object"
},
"BlockType": {
"enum": [
"paragraph",
"list",
"header",
"checklist",
"image",
"attaches",
"ketcher",
"table"
],
"title": "BlockType",
"type": "string"
},
"BulletedListContent": {
"properties": {
"items": {
"items": {
"$ref": "#/$defs/NotebookListItem"
},
"title": "Items",
"type": "array"
},
"style": {
"const": "unordered",
"default": "unordered",
"title": "Style",
"type": "string"
}
},
"required": [
"items"
],
"title": "BulletedListContent",
"type": "object"
},
"ChecklistContent": {
"properties": {
"items": {
"items": {
"$ref": "#/$defs/ChecklistItem"
},
"title": "Items",
"type": "array"
}
},
"required": [
"items"
],
"title": "ChecklistContent",
"type": "object"
},
"ChecklistItem": {
"properties": {
"checked": {
"title": "Checked",
"type": "boolean"
},
"text": {
"title": "Text",
"type": "string"
}
},
"required": [
"checked",
"text"
],
"title": "ChecklistItem",
"type": "object"
},
"HeaderContent": {
"properties": {
"level": {
"enum": [
1,
2,
3
],
"title": "Level",
"type": "integer"
},
"text": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Text"
}
},
"required": [
"level",
"text"
],
"title": "HeaderContent",
"type": "object"
},
"ImageContent": {
"properties": {
"title": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title"
},
"namespace": {
"default": "result",
"title": "Namespace",
"type": "string"
},
"stretched": {
"default": false,
"title": "Stretched",
"type": "boolean"
},
"withBackground": {
"default": false,
"title": "Withbackground",
"type": "boolean"
},
"withBorder": {
"default": false,
"title": "Withborder",
"type": "boolean"
},
"fileKey": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Filekey"
},
"signedURL": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Signedurl"
}
},
"title": "ImageContent",
"type": "object"
},
"KetcherContent": {
"properties": {
"synthesisId": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Synthesisid"
},
"name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Name"
},
"id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Id"
},
"blockId": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Blockid"
},
"data": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Data"
},
"fileKey": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Filekey"
},
"s3Key": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "S3Key"
},
"png": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Png"
},
"ketcherUrl": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Ketcherurl"
}
},
"title": "KetcherContent",
"type": "object"
},
"NotebookListItem": {
"properties": {
"content": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Content"
},
"items": {
"items": {
"$ref": "#/$defs/NotebookListItem"
},
"title": "Items",
"type": "array"
}
},
"required": [
"content"
],
"title": "NotebookListItem",
"type": "object"
},
"NumberedListContent": {
"properties": {
"items": {
"items": {
"$ref": "#/$defs/NotebookListItem"
},
"title": "Items",
"type": "array"
},
"style": {
"const": "ordered",
"default": "ordered",
"title": "Style",
"type": "string"
}
},
"required": [
"items"
],
"title": "NumberedListContent",
"type": "object"
},
"ParagraphContent": {
"properties": {
"text": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Text"
}
},
"required": [
"text"
],
"title": "ParagraphContent",
"type": "object"
},
"PutOperation": {
"enum": [
"update",
"delete"
],
"title": "PutOperation",
"type": "string"
},
"TableContent": {
"properties": {
"content": {
"items": {
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"type": "array"
},
"title": "Content",
"type": "array"
},
"withHeadings": {
"default": false,
"title": "Withheadings",
"type": "boolean"
}
},
"required": [
"content"
],
"title": "TableContent",
"type": "object"
}
},
"properties": {
"id": {
"title": "Id",
"type": "string"
},
"operation": {
"$ref": "#/$defs/PutOperation"
},
"blockType": {
"anyOf": [
{
"$ref": "#/$defs/BlockType"
},
{
"type": "null"
}
],
"default": null
},
"content": {
"anyOf": [
{
"$ref": "#/$defs/HeaderContent"
},
{
"$ref": "#/$defs/ParagraphContent"
},
{
"$ref": "#/$defs/ChecklistContent"
},
{
"$ref": "#/$defs/AttachesContent"
},
{
"$ref": "#/$defs/ImageContent"
},
{
"$ref": "#/$defs/KetcherContent"
},
{
"$ref": "#/$defs/TableContent"
},
{
"$ref": "#/$defs/BulletedListContent"
},
{
"$ref": "#/$defs/NumberedListContent"
},
{
"type": "null"
}
],
"default": null,
"title": "Content"
},
"previousBlockId": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Previousblockid"
}
},
"required": [
"id",
"operation"
],
"title": "PutBlockDatum",
"type": "object"
}
Fields:
-
id(str) -
operation(PutOperation) -
type(BlockType | None) -
content(NotebookContent | None) -
previous_block_id(str | None)
Validators:
content_matches_type
pydantic-validator
content_matches_type() -> PutBlockDatum
Source code in src/albert/resources/notebooks.py
model_dump
Shallow model_dump to exclude None values (None only removed from top level). This ensures required attrs are not removed.
Source code in src/albert/resources/notebooks.py
PutBlockPayload
pydantic-model
Bases: BaseAlbertModel
Show JSON schema:
{
"$defs": {
"AttachesContent": {
"properties": {
"title": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title"
},
"namespace": {
"default": "result",
"title": "Namespace",
"type": "string"
},
"fileKey": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Filekey"
},
"mimeType": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Mimetype"
},
"signedURL": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Signedurl"
}
},
"title": "AttachesContent",
"type": "object"
},
"BlockType": {
"enum": [
"paragraph",
"list",
"header",
"checklist",
"image",
"attaches",
"ketcher",
"table"
],
"title": "BlockType",
"type": "string"
},
"BulletedListContent": {
"properties": {
"items": {
"items": {
"$ref": "#/$defs/NotebookListItem"
},
"title": "Items",
"type": "array"
},
"style": {
"const": "unordered",
"default": "unordered",
"title": "Style",
"type": "string"
}
},
"required": [
"items"
],
"title": "BulletedListContent",
"type": "object"
},
"ChecklistContent": {
"properties": {
"items": {
"items": {
"$ref": "#/$defs/ChecklistItem"
},
"title": "Items",
"type": "array"
}
},
"required": [
"items"
],
"title": "ChecklistContent",
"type": "object"
},
"ChecklistItem": {
"properties": {
"checked": {
"title": "Checked",
"type": "boolean"
},
"text": {
"title": "Text",
"type": "string"
}
},
"required": [
"checked",
"text"
],
"title": "ChecklistItem",
"type": "object"
},
"HeaderContent": {
"properties": {
"level": {
"enum": [
1,
2,
3
],
"title": "Level",
"type": "integer"
},
"text": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Text"
}
},
"required": [
"level",
"text"
],
"title": "HeaderContent",
"type": "object"
},
"ImageContent": {
"properties": {
"title": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Title"
},
"namespace": {
"default": "result",
"title": "Namespace",
"type": "string"
},
"stretched": {
"default": false,
"title": "Stretched",
"type": "boolean"
},
"withBackground": {
"default": false,
"title": "Withbackground",
"type": "boolean"
},
"withBorder": {
"default": false,
"title": "Withborder",
"type": "boolean"
},
"fileKey": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Filekey"
},
"signedURL": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Signedurl"
}
},
"title": "ImageContent",
"type": "object"
},
"KetcherContent": {
"properties": {
"synthesisId": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Synthesisid"
},
"name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Name"
},
"id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Id"
},
"blockId": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Blockid"
},
"data": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Data"
},
"fileKey": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Filekey"
},
"s3Key": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "S3Key"
},
"png": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Png"
},
"ketcherUrl": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Ketcherurl"
}
},
"title": "KetcherContent",
"type": "object"
},
"NotebookListItem": {
"properties": {
"content": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Content"
},
"items": {
"items": {
"$ref": "#/$defs/NotebookListItem"
},
"title": "Items",
"type": "array"
}
},
"required": [
"content"
],
"title": "NotebookListItem",
"type": "object"
},
"NumberedListContent": {
"properties": {
"items": {
"items": {
"$ref": "#/$defs/NotebookListItem"
},
"title": "Items",
"type": "array"
},
"style": {
"const": "ordered",
"default": "ordered",
"title": "Style",
"type": "string"
}
},
"required": [
"items"
],
"title": "NumberedListContent",
"type": "object"
},
"ParagraphContent": {
"properties": {
"text": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Text"
}
},
"required": [
"text"
],
"title": "ParagraphContent",
"type": "object"
},
"PutBlockDatum": {
"properties": {
"id": {
"title": "Id",
"type": "string"
},
"operation": {
"$ref": "#/$defs/PutOperation"
},
"blockType": {
"anyOf": [
{
"$ref": "#/$defs/BlockType"
},
{
"type": "null"
}
],
"default": null
},
"content": {
"anyOf": [
{
"$ref": "#/$defs/HeaderContent"
},
{
"$ref": "#/$defs/ParagraphContent"
},
{
"$ref": "#/$defs/ChecklistContent"
},
{
"$ref": "#/$defs/AttachesContent"
},
{
"$ref": "#/$defs/ImageContent"
},
{
"$ref": "#/$defs/KetcherContent"
},
{
"$ref": "#/$defs/TableContent"
},
{
"$ref": "#/$defs/BulletedListContent"
},
{
"$ref": "#/$defs/NumberedListContent"
},
{
"type": "null"
}
],
"default": null,
"title": "Content"
},
"previousBlockId": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Previousblockid"
}
},
"required": [
"id",
"operation"
],
"title": "PutBlockDatum",
"type": "object"
},
"PutOperation": {
"enum": [
"update",
"delete"
],
"title": "PutOperation",
"type": "string"
},
"TableContent": {
"properties": {
"content": {
"items": {
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"type": "array"
},
"title": "Content",
"type": "array"
},
"withHeadings": {
"default": false,
"title": "Withheadings",
"type": "boolean"
}
},
"required": [
"content"
],
"title": "TableContent",
"type": "object"
}
},
"properties": {
"data": {
"items": {
"$ref": "#/$defs/PutBlockDatum"
},
"title": "Data",
"type": "array"
}
},
"required": [
"data"
],
"title": "PutBlockPayload",
"type": "object"
}
Fields:
model_dump
model_dump to ensure only top-level None attrs are removed on PutBlockDatum.