Skip to content

Function object

The Function object comes with CRUD methods, a run method, task methods, trigger methods, and kind specific methods.

CRUD methods

Crud methods are used to interact with the entity object in the backend or locally.

  • save(): Save or update the entity into the backend.
  • export(): Export the entity locally as yaml file.
  • refresh(): Refresh (read) the entity from the backend.

save

Save or update the entity into the backend.

Parameters:

Name Type Description Default
update bool

Flag to indicate update.

False

Returns:

Type Description
ContextEntity

Entity saved.

export

Export object as a YAML file in the context folder.

Returns:

Type Description
str

Exported filepath.

refresh

Refresh object from backend.

Returns:

Type Description
ContextEntity

Entity refreshed.

Run method

The run() method is used to execute the function.

run

Run function. This method creates a new run and executes it.

Parameters:

Name Type Description Default
action str

Action to execute.

required
wait bool

Flag to wait for execution.

False
log_info bool

Flag to log information while waiting.

True
extensions list[dict] | None

List of extensions to apply.

None
**kwargs dict

Keyword arguments passed to Run builder.

{}

Returns:

Type Description
Run

Run instance.

Task methods

The function object exposes the following methods to manage tasks.

  • new_task(): Create a task for an action.
  • get_task(): Get the task for an action.
  • list_task(): List the tasks related to the function.
  • update_task(): Update the task for an action.

new_task

Create new task. If the task already exists, update it.

Parameters:

Name Type Description Default
action str

Action name.

required
**kwargs dict

Task spec keyword arguments.

{}

Returns:

Type Description
Task

New task.

get_task

Get task.

Parameters:

Name Type Description Default
action str

Action name.

required

Returns:

Type Description
Task

Task.

list_task

List tasks of the executable entity from backend.

Parameters:

Name Type Description Default
q str

Query string to filter objects.

None
name str

Object name.

None
kind str

Kind of the object.

None
user str

User that created the object.

None
state str

Object state.

None
created str

Creation date filter.

None
updated str

Update date filter.

None

Returns:

Type Description
list[Task]

List of object instances.

update_task

Update task.

Parameters:

Name Type Description Default
action str

Action name.

required
**kwargs dict

Task spec keyword arguments.

{}

Returns:

Type Description
Task

Task.

Trigger methods

The function object exposes the following methods to manage triggers.

  • trigger(): Create a trigger for the function.
  • get_trigger(): Get a trigger by identifier.
  • list_triggers(): List the triggers related to the function.

trigger

Trigger function.

Parameters:

Name Type Description Default
action str

Action to execute.

required
kind str

Trigger kind.

required
name str

Trigger name.

required
template dict

Template for the trigger.

None
**kwargs dict

Keyword arguments passed to trigger builder.

{}

Returns:

Type Description
Trigger

Object instance.

get_trigger

Get object from backend.

Parameters:

Name Type Description Default
identifier str

Entity key (store://...) or entity ID.

required

Returns:

Type Description
Trigger

Object instance.

list_triggers

List triggers of the executable entity from backend.

Parameters:

Name Type Description Default
q str

Query string to filter objects.

None
name str

Object name.

None
kind str

Kind of the object.

None
user str

User that created the object.

None
created str

Creation date filter.

None
updated str

Update date filter.

None
versions str

Object version, default is latest.

None
task str

Task string filter.

None

Returns:

Type Description
list[Trigger]

List of object instances.

Kind specific methods

Kind specific methods are used to express potential behaviors of different object kinds. See the kinds section for more information.