Tasks
albert.collections.tasks
DataTemplateId
module-attribute
AlbertHTTPError
Bases: AlbertException
Base class for all erors due to HTTP responses.
Source code in src/albert/exceptions.py
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
BaseTask
Bases: BaseTaggedResource
Base class for all task types. Use PropertyTask, BatchTask, or GeneralTask for specific task types.
assigned_to
class-attribute
instance-attribute
assigned_to: SerializeAsEntityLink[User] | None = Field(
default=None, alias="AssignedTo"
)
claimed_date
class-attribute
instance-attribute
claimed_date: str | None = Field(
alias="claimedDate", default=None
)
closed_date
class-attribute
instance-attribute
closed_date: str | None = Field(
alias="closedDate", default=None
)
completed_date
class-attribute
instance-attribute
completed_date: str | None = Field(
alias="completedDate", default=None
)
due_date
class-attribute
instance-attribute
due_date: str | None = Field(alias='dueDate', default=None)
inventory_information
class-attribute
instance-attribute
inventory_information: list[InventoryInformation] = Field(
alias="Inventories", default=None
)
location
class-attribute
instance-attribute
location: SerializeAsEntityLink[Location] | None = Field(
default=None, alias="Location"
)
metadata
class-attribute
instance-attribute
page_state
class-attribute
instance-attribute
parent_id
class-attribute
instance-attribute
parent_id: str | None = Field(
alias="parentId", default=None
)
pass_fail
class-attribute
instance-attribute
pass_fail: bool | None = Field(
alias="passOrFail", default=None
)
project
class-attribute
instance-attribute
project: (
SerializeAsEntityLink[Project]
| list[SerializeAsEntityLink[Project]]
| None
) = Field(default=None, alias="Project")
security_class
class-attribute
instance-attribute
sources
class-attribute
instance-attribute
start_date
class-attribute
instance-attribute
start_date: str | None = Field(
alias="startDate", default=None
)
OrderBy
PropertyTask
Bases: BaseTask
Represents a batch task.
This class is used to create and manage batch tasks. It includes the base task attributes and additional attributes specific to batch tasks.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the batch task. |
inventory_information |
list[InventoryInformation]
|
Information about the inventory associated with the batch task. |
location |
SerializeAsEntityLink[Location]
|
The location where the batch task is performed. |
parent_id |
str
|
The ID of the parent project. |
blocks |
list[Block]
|
A list of blocks associated with the batch task. |
id |
(str, optional)
|
The ID of the batch task, by default None. |
metadata |
(dict[str, MetadataItem], optional)
|
Metadata associated with the batch task, by default an empty dictionary. |
due_date |
(str, optional)
|
The due date of the batch task. YYY-MM-DD format, by default None. |
notes |
(str, optional)
|
Notes associated with the batch task, by default None. |
priority |
(TaskPriority, optional)
|
The priority of the batch task, by default None. |
assigned_to |
(SerializeAsEntityLink[User], optional)
|
The user assigned to the batch task, by default None. |
state |
(TaskState, optional)
|
The state of the batch task, by default None. |
sources |
(list[TaskSource], optional)
|
A list of sources associated with the batch task, by default an empty list. |
security_class |
(SecurityClass, optional)
|
The security class of the batch task, by default None. |
start_date |
str, read only
|
The start date of the batch task, by default None. |
claimed_date |
str, read only
|
The claimed date of the batch task, by default None. |
completed_date |
str, read only
|
The completed date of the batch task, by default None. |
closed_date |
str, read only
|
The closed date of the batch task, by default None. |
batch_task_id
class-attribute
instance-attribute
batch_task_id: str | None = Field(
alias="batchTaskId", default=None
)
blocks
class-attribute
instance-attribute
blocks: list[Block] | None = Field(
alias="Blocks", default=None
)
qc_task
class-attribute
instance-attribute
qc_task: bool | None = Field(alias='qcTask', default=None)
TaskCategory
TaskCollection
TaskCollection(*, session: AlbertSession)
Bases: BaseCollection
TaskCollection is a collection class for managing Task entities in the Albert platform.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AlbertSession
|
The Albert Session information |
required |
Methods:
Name | Description |
---|---|
add_block |
Add a block to a Property task. |
create |
Create a new task. Tasks can be of different types, such as PropertyTask, and are created using the provided task object. |
delete |
Delete a task. |
get_by_id |
Retrieve a task by its ID. |
get_history |
|
list |
Search for tasks matching the given criteria. |
remove_block |
Remove a block from a Property task. |
update |
Update a task. |
update_block_workflow |
Update the workflow of a specific block within a task. |
Source code in src/albert/collections/tasks.py
add_block
add_block(
*,
task_id: TaskId,
data_template_id: DataTemplateId,
workflow_id: WorkflowId,
) -> None
Add a block to a Property task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_id
|
TaskId
|
The ID of the task to add the block to. |
required |
data_template_id
|
DataTemplateId
|
The ID of the data template to use for the block. |
required |
workflow_id
|
WorkflowId
|
The ID of the workflow to assign to the block. |
required |
Returns:
Type | Description |
---|---|
None
|
This method does not return any value. |
Source code in src/albert/collections/tasks.py
create
Create a new task. Tasks can be of different types, such as PropertyTask, and are created using the provided task object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task
|
BaseTask
|
The task object to create. |
required |
Returns:
Type | Description |
---|---|
BaseTask
|
The registered task object. |
Source code in src/albert/collections/tasks.py
delete
delete(*, id: TaskId) -> None
Delete a task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
TaskId
|
The ID of the task to delete. |
required |
get_by_id
Retrieve a task by its ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
TaskId
|
The ID of the task to retrieve. |
required |
Returns:
Type | Description |
---|---|
BaseTask
|
The task object with the provided ID. |
Source code in src/albert/collections/tasks.py
get_history
get_history(
*,
id: TaskId,
order: OrderBy = DESCENDING,
limit: int = 1000,
entity: HistoryEntity | None = None,
blockId: str | None = None,
startKey: str | None = None,
) -> TaskHistory
Source code in src/albert/collections/tasks.py
list
list(
*,
order: OrderBy = DESCENDING,
text: str | None = None,
sort_by: str | None = None,
tags: list[str] | None = None,
task_id: list[str] | None = None,
linked_task: list[str] | None = None,
category: TaskCategory | None = None,
albert_id: list[str] | None = None,
data_template: list[str] | None = None,
assigned_to: list[str] | None = None,
location: list[str] | None = None,
priority: list[str] | None = None,
status: list[str] | None = None,
parameter_group: list[str] | None = None,
created_by: list[str] | None = None,
project_id: str | None = None,
limit: int = 100,
offset: int = 0,
) -> Iterator[BaseTask]
Search for tasks matching the given criteria.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
order
|
OrderBy
|
The order in which to return results, by default OrderBy.DESCENDING |
DESCENDING
|
text
|
str | None
|
The text to search for, by default None |
None
|
sort_by
|
str | None
|
The attribute to sort by, by default None |
None
|
tags
|
list[str] | None
|
The tags to search for, by default None |
None
|
task_id
|
list[str] | None
|
The related task IDs to search for, by default None |
None
|
linked_task
|
list[str] | None
|
The Linked Task IDs to search for, by default None |
None
|
category
|
TaskCategory | None
|
The category of the task to search for, by default None |
None
|
albert_id
|
list[str] | None
|
The Albert IDs to search for, by default None |
None
|
data_template
|
list[str] | None
|
The data template IDs to search for, by default None |
None
|
assigned_to
|
list[str] | None
|
The User IDs to search for, by default None |
None
|
location
|
list[str] | None
|
The Locations names to search for, by default None |
None
|
priority
|
list[str] | None
|
The Priority levels to search for, by default None |
None
|
status
|
list[str] | None
|
The Task Statuses to search for, by default None |
None
|
parameter_group
|
list[str] | None
|
The related Parameter Group IDs to search for, by default None |
None
|
created_by
|
list[str] | None
|
The User IDs of the task creators to search for, by default None |
None
|
project_id
|
str | None
|
The Project ID to search for, by default None |
None
|
Yields:
Type | Description |
---|---|
Iterator[BaseTask]
|
An iterator of matching Task objects. |
Source code in src/albert/collections/tasks.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
|
remove_block
Remove a block from a Property task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_id
|
str
|
ID of the Task to remove the block from (e.g., TASFOR1234) |
required |
block_id
|
str
|
ID of the Block to remove (e.g., BLK1) |
required |
Returns:
Type | Description |
---|---|
None
|
|
Source code in src/albert/collections/tasks.py
update
Update a task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task
|
BaseTask
|
The updated Task object. |
required |
Returns:
Type | Description |
---|---|
BaseTask
|
The updated Task object as it exists in the Albert platform. |
Source code in src/albert/collections/tasks.py
update_block_workflow
update_block_workflow(
*,
task_id: TaskId,
block_id: BlockId,
workflow_id: WorkflowId,
) -> None
Update the workflow of a specific block within a task.
This method updates the workflow of a specified block within a task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_id
|
str
|
The ID of the task. |
required |
block_id
|
str
|
The ID of the block within the task. |
required |
workflow_id
|
str
|
The ID of the new workflow to be assigned to the block. |
required |
Returns:
Type | Description |
---|---|
None
|
This method does not return any value. |
Notes
- The method asserts that the retrieved task is an instance of
PropertyTask
. - If the block's current workflow matches the new workflow ID, no update is performed.
- The method handles the case where the block has a default workflow named "No Parameter Group".
Source code in src/albert/collections/tasks.py
TaskHistory
Bases: BaseAlbertModel