models.workflow.Workflow, Transition and Status

class Workflow(json, **kwargs)[source]

Workflow object.

Initialize a Workflow Object.

edit(name: str = <pykechain.utils.Empty object>, description: str = <pykechain.utils.Empty object>, *args, **kwargs) None[source]

Change the workflow object.

Change the name and description of a workflow. It is also possible to update the workflow options and also the ‘active’ flag. To change the active flag of the workflow we kindly refer to the activate() and deactivate() methods on the workflow.

classmethod list(client: Client, **kwargs) List[Workflow][source]

Retrieve a list of Workflow objects through the client.

classmethod get(client: Client, **kwargs) Workflow[source]

Retrieve a single Workflow object using the client.

delete()[source]

Delete Workflow.

classmethod create(client: Client, name: str, scope: Union[Scope, str, UUID], category: WorkflowCategory = 'DEFINED', description: str = None, options: dict = None, active: bool = False, **kwargs) Workflow[source]

Create a new Workflow object using the client.

Parameters
  • client – Client object.

  • name – Name of the workflow

  • scope – Scope of the workflow

  • category – (optional) category of the workflow, defaults to WorkflowCategory.DEFINED

  • description – (optional) description of the workflow

  • options – (optional) JSON/dictionary with workflow options

  • active – (optional) boolean flag to set the workflow to active. Defaults to False

  • kwargs – (optional) additional kwargs.

Returns

a Workflow object

Raises

APIError – When the Workflow could not be created.

property status_order: List[Status]

Statuses in the right order.

transition(value: Optional[str] = None, attr: Optional[str] = None) Transition[source]

Retrieve the Transition belonging to this workflow based on its name, ref or uuid.

Parameters
  • value – transition name, ref or UUID to search for

  • attr – the attribute to match on. E.g. to_status=<Status Obj>

Returns

a single Transition

Raises

NotFoundError – if the Transition is not part of the Workflow

:raises MultipleFoundError

Example

>>> workflow = project.workflow('Simple Flow')
>>> transition = workflow.transition('in progress')
>>> todo_status = client.status(name="To Do")
>>> transition = workflow.transition(todo_status, attr="to_status")
property transitions

Retrieve the Transitions belonging to this workflow.

Returns

multiple Transition

status(value: Optional[str] = None, attr: Optional[str] = None) Status[source]

Retrieve the Status belonging to this workflow based on its name, ref or uuid.

Parameters
  • value – status name, ref or UUID to search for

  • attr – the attribute to match on.

Returns

a single Status

Raises

NotFoundError – if the Status is not part of the Workflow

:raises MultipleFoundError

Example

>>> workflow = project.workflow('Simple Flow')
>>> status = workflow.status('To Do')
property statuses

Retrieve the Statuses belonging to this workflow.

Returns

multiple Status

activate()[source]

Set the active status to True.

deactivate()[source]

Set the active status to False.

clone(target_scope: Scope = <pykechain.utils.Empty object>, name: ~typing.Optional[str] = <pykechain.utils.Empty object>, description: ~typing.Optional[str] = <pykechain.utils.Empty object>) Workflow[source]

Clone the current workflow into a new workflow.

Also used to ‘import’ a catalog workflow into a scope.

Parameters
  • target_scope – (optional) target scope where to clone the Workflow to. Defaults current scope.

  • name – (optional) name of the new workflow

  • description – (optional) description of the new workflow

update_transition(transition: ~typing.Union[~pykechain.models.workflow.Transition, str, ~uuid.UUID], name: ~typing.Optional[str] = <pykechain.utils.Empty object>, description: ~typing.Optional[str] = <pykechain.utils.Empty object>, from_status: ~typing.Optional[~typing.List[str]] = <pykechain.utils.Empty object>) Transition[source]

Update a specific Transition in the current workflow.

Update the transition inside the worfklow based on a transition_id.

Parameters
  • transition – Transition object or transition id to alter

  • name – (optional) name to change

  • description – (optional) description to change

  • from_status – (optional) a list of from statuses to update

delete_transition(transition: Union[Transition, str, UUID]) None[source]

Remove Transition from the current Workflow and delete it.

If the Transition is still connected to other Workflows, it will not be removed, and will result in a 400 reporting all attached Workflows.

Parameters

transition – object or uuid of a transition to delete.

create_transition(name: str, to_status: ~typing.Union[~pykechain.models.workflow.Status, str, ~uuid.UUID], transition_type: ~pykechain.enums.TransitionType = 'GLOBAL', from_status: ~typing.Optional[~typing.List[~typing.Union[str, ~uuid.UUID, ~pykechain.models.workflow.Status]]] = <pykechain.utils.Empty object>, description: ~typing.Optional[str] = <pykechain.utils.Empty object>)[source]

Create a new Transition and associate it to the current Workflow.

Parameters
  • name – name of the transition.

  • to_status – status where to transition to (a single status or status id)

  • transition_type – transition type to transition to. (defaults to Global)

  • from_status – (optional) status to transition from. Not used for Global transitions.

  • description – (optional) description.

create_status(name: str, category: ~pykechain.enums.StatusCategory = 'UNDEFINED', description: ~typing.Optional[str] = <pykechain.utils.Empty object>) Status[source]

Create a new Status.

Will create a new status, a new global transition to that status and will link the new Global transition to that status to the current workflow.

Parameters
  • name – name of the status

  • category – status category (defaults to UNDEFINED)

  • description – (optional) description of the status

Link a list of Transitions to a Workflow.

Parameters

transitions – a list of Transition Objects or transition_ids to link to the workflow.

Unlink a list of Transitions to a Workflow.

Parameters

transitions – a list of Transition Objects or transition_ids to link to the workflow.

class Transition(json, **kwargs)[source]

Transition Object.

Initialise a Transition object.

classmethod list(client: Client, **kwargs) List[Transition][source]

Retrieve a list of Transition objects through the client.

classmethod get(client: Client, **kwargs) Transition[source]

Retrieve a Transition object through the client.

class Status(json, **kwargs)[source]

Status object.

Initialize a Status object.

classmethod list(client: Client, **kwargs) List[Status][source]

Retrieve a list of Status objects through the client.

classmethod get(client: Client, **kwargs) Status[source]

Retrieve a Status object through the client.