AsanaCreateTaskOperator¶
Use the AsanaCreateTaskOperator
to
create an Asana task.
Using the Operator¶
The AsanaCreateTaskOperator minimally requires the new task’s name and
the Asana connection to use to connect to your account (conn_id
). There are many other
task attributes you can specify
through the task_parameters
. You must specify at least one of workspace
,
parent
, or projects
in the task_parameters
or in the connection.
AsanaDeleteTaskOperator¶
Use the AsanaDeleteTaskOperator
to
delete an existing Asana task.
Using the Operator¶
The AsanaDeleteTaskOperator requires the task id to delete. Use the conn_id
parameter to specify the Asana connection to use to connect to your account.
AsanaFindTaskOperator¶
Use the AsanaFindTaskOperator
to
search for Asana tasks that fit some criteria.
Using the Operator¶
The AsanaFindTaskOperator requires a dict of search parameters following the description
here.
Use the conn_id
parameter to specify the Asana connection to use to connect
to your account. Any parameters provided through the connection will be used in the
search if not overridden in the search_parameters
.
AsanaUpdateTaskOperator¶
Use the AsanaUpdateTaskOperator
to
update an existing Asana task.
Using the Operator¶
The AsanaUpdateTaskOperator minimally requires the task id to update and
the Asana connection to use to connect to your account (conn_id
). There are many other
task attributes you can overwrite
through the task_parameters
.
# Create a task. `task_parameters` is used to specify attributes the new task should have.
# You must specify at least one of 'workspace', 'projects', or 'parent' in `task_parameters`
# unless these are specified in the connection. Any attributes you specify in
# `task_parameters` will override values from the connection.
create = AsanaCreateTaskOperator(
task_id="run_asana_create_task",
task_parameters={"notes": "Some notes about the task."},
name="New Task Name",
)
# Find tasks matching search criteria. `search_parameters` is used to specify these criteria.
# You must specify `project`, `section`, `tag`, `user_task_list`, or both
# `assignee` and `workspace` in `search_parameters` or in the connection.
# This example shows how you can override a project specified in the connection by
# passing a different value for project into `search_parameters`
one_week_ago = (datetime.now() - timedelta(days=7)).strftime("%Y-%m-%d")
find = AsanaFindTaskOperator(
task_id="run_asana_find_task",
search_parameters={"project": ASANA_PROJECT_ID_OVERRIDE, "modified_since": one_week_ago},
)
# Update a task. `task_parameters` is used to specify the new values of
# task attributes you want to update.
update = AsanaUpdateTaskOperator(
task_id="run_asana_update_task",
asana_task_gid=ASANA_TASK_TO_UPDATE,
task_parameters={"notes": "This task was updated!", "completed": True},
)
# Delete a task. This task will complete successfully even if `asana_task_gid` does not exist.
delete = AsanaDeleteTaskOperator(
task_id="run_asana_delete_task",
asana_task_gid=ASANA_TASK_TO_DELETE,
)
create >> find >> update >> delete