Attachments
albert.collections.attachments
Attachment
Bases: BaseResource
Used for attching files to Notes on Tasks, Projects, Inventory, etc. Key should match File.name
file_size
class-attribute
instance-attribute
file_size: int | None = Field(
default=None,
alias="fileSize",
exclude=True,
frozen=True,
)
metadata
class-attribute
instance-attribute
metadata: dict[str, str] | None = Field(
default=None,
alias="Metadata",
exclude=True,
frozen=True,
)
mime_type
class-attribute
instance-attribute
mime_type: str | None = Field(
default=None,
alias="mimeType",
exclude=True,
frozen=True,
)
namespace
class-attribute
instance-attribute
namespace: str = Field(default='result', alias='nameSpace')
signed_url
class-attribute
instance-attribute
signed_url: str | None = Field(
default=None,
alias="signedURL",
exclude=True,
frozen=True,
)
signed_url_v2
class-attribute
instance-attribute
signed_url_v2: str | None = Field(
default=None,
alias="signedURLV2",
exclude=True,
frozen=True,
)
AttachmentCollection
Bases: BaseCollection
AttachmentCollection is a collection class for managing Attachment entities in the Albert platform.
Methods:
Name | Description |
---|---|
attach_file_to_note |
Attaches an already uploaded file to a note. |
delete |
Deletes an attachment by ID. |
upload_and_attach_file_as_note |
Uploads a file and attaches it to a new note. A user can be tagged in the note_text string by using f-string and the User.to_note_mention() method. |
Source code in src/albert/collections/attachments.py
attach_file_to_note
attach_file_to_note(
*,
note_id: str,
file_name: str,
file_key: str,
category: FileCategory = OTHER,
) -> Attachment
Attaches an already uploaded file to a note.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
note_id
|
str
|
The ID of the note to attach the file to. |
required |
file_name
|
str
|
The name of the file to attach. |
required |
file_key
|
str
|
The unique key of the file to attach (the returned upload name). |
required |
category
|
FileCategory
|
The type of file, by default FileCategory.OTHER |
OTHER
|
Returns:
Type | Description |
---|---|
Attachment
|
The related attachment object. |
Source code in src/albert/collections/attachments.py
delete
delete(*, id: str) -> None
Deletes an attachment by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
The ID of the attachment to delete. |
required |
upload_and_attach_file_as_note
upload_and_attach_file_as_note(
parent_id: str,
file_data: IO,
note_text: str = "",
file_name: str = "",
) -> Note
Uploads a file and attaches it to a new note. A user can be tagged in the note_text string by using f-string and the User.to_note_mention() method. This allows for easy tagging and referencing of users within notes. example: f"Hello {tagged_user.to_note_mention()}!"
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent_id
|
str
|
The ID of the parent entity onto which the note will be attached. |
required |
file_data
|
IO
|
The file data to upload. |
required |
note_text
|
str
|
Any additional text to add to the note, by default "" |
''
|
file_name
|
str
|
The name of the file, by default "" |
''
|
Returns:
Type | Description |
---|---|
Note
|
The created note. |
Source code in src/albert/collections/attachments.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
FileCategory
FileCollection
FileCollection(*, session: AlbertSession)
Bases: BaseCollection
FileCollection is a collection class for managing File entities in the Albert platform.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AlbertSession
|
The Albert session instance. |
required |
Methods:
Name | Description |
---|---|
get_by_name |
Gets a file by name and namespace. |
get_signed_download_url |
Get a signed download URL for a file. |
get_signed_upload_url |
Get a signed upload URL for a file. |
sign_and_upload_file |
Sign and upload a file to Albert. |
Source code in src/albert/collections/files.py
get_by_name
get_by_name(
*,
name: str,
namespace: FileNamespace,
generic: bool = False,
) -> FileInfo
Gets a file by name and namespace.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The Name of the file |
required |
namespace
|
FileNamespace
|
The namespace of the file (e.g. AGENT, BREAKTHROUGH, PIPELINE, PUBLIC, RESULT, SDS) |
required |
generic
|
bool
|
description, by default False |
False
|
Returns:
Type | Description |
---|---|
FileInfo
|
The file information related to the matching file. |
Source code in src/albert/collections/files.py
get_signed_download_url
get_signed_download_url(
*,
name: str,
namespace: FileNamespace,
version_id: str | None = None,
generic: bool = False,
category: FileCategory | None = None,
) -> str
Get a signed download URL for a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The Name of the file |
required |
namespace
|
FileNamespace
|
The namespace of the file (e.g. AGENT, BREAKTHROUGH, PIPELINE, PUBLIC, RESULT, SDS) |
required |
version_id
|
str | None
|
The version of the file, by default None |
None
|
category
|
FileCategory | None
|
The file category (E.g., SDS, OTHER), by default None |
None
|
Returns:
Type | Description |
---|---|
str
|
description |
Source code in src/albert/collections/files.py
get_signed_upload_url
get_signed_upload_url(
*,
name: str,
namespace: FileNamespace,
content_type: str,
generic: bool = False,
category: FileCategory | None = None,
) -> str
Get a signed upload URL for a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The Name of the file |
required |
namespace
|
FileNamespace
|
The namespace of the file (e.g. AGENT, BREAKTHROUGH, PIPELINE, PUBLIC, RESULT, SDS) |
required |
content_type
|
str
|
The content type of the file |
required |
category
|
FileCategory | None
|
The File category (E.g., SDS, OTHER), by default None |
None
|
Returns:
Type | Description |
---|---|
str
|
description |
Source code in src/albert/collections/files.py
sign_and_upload_file
sign_and_upload_file(
data: IO,
name: str,
namespace: FileNamespace,
content_type: str,
generic: bool = False,
category: FileCategory | None = None,
) -> None
Sign and upload a file to Albert.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
IO
|
The file data |
required |
name
|
str
|
The name of the file |
required |
namespace
|
FileNamespace
|
The File Namespace (e.g., AGENT, BREAKTHROUGH, PIPELINE, PUBLIC, RESULT, SDS) |
required |
content_type
|
str
|
The content type of the file |
required |
category
|
FileCategory | None
|
The category of the file (E.g., SDS, OTHER), by default None |
None
|
Source code in src/albert/collections/files.py
FileNamespace
Note
Bases: BaseResource
Represents a Note on the Albert Platform. Users can be mentioned in notes by using f-string and the User.to_note_mention() method. This allows for easy tagging and referencing of users within notes. example: f"Hello {tagged_user.to_note_mention()}!"
attachments
class-attribute
instance-attribute
attachments: list[EntityLink] | None = Field(
default=None,
exclude=True,
frozen=True,
alias="Attachments",
)
NotesCollection
NotesCollection(*, session: AlbertSession)
Bases: BaseCollection
NotesCollection is a collection class for managing Note entities in the Albert platform.
Methods:
Name | Description |
---|---|
create |
Creates a new note. |
delete |
Deletes a note by its ID. |
get_by_id |
Retrieves a note by its ID. |
list |
Lists notes by their parent ID. |
update |
Updates a note. |
Source code in src/albert/collections/notes.py
create
Creates a new note.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
note
|
str
|
The note content. |
required |
Returns:
Type | Description |
---|---|
Note
|
The created note. |
Source code in src/albert/collections/notes.py
delete
delete(*, id: str) -> None
Deletes a note by its ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
The ID of the note to delete. |
required |
get_by_id
list
list(
*, parent_id: str, order_by: OrderBy = DESCENDING
) -> list[Note]
Lists notes by their parent ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent_id
|
str
|
The parent ID of the notes to list. |
required |
order_by
|
OrderBy
|
The order to list notes in, by default OrderBy.DESCENDING. |
DESCENDING
|
Returns:
Type | Description |
---|---|
List[Note]
|
The list of notes. |
Source code in src/albert/collections/notes.py
update
Updates a note.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
note
|
Note
|
The note to update. The note must have an ID. |
required |
Returns:
Type | Description |
---|---|
Note
|
The updated note as returned by the server. |