def correlate(data: CorrelationMessageDto = CorrelationMessageDto()) -> Optional[ MessageCorrelationResultWithVariableDto]: api = use_api() result = api.post("/message", data=data.dict(exclude_unset=True, by_alias=True)) if result: return MessageCorrelationResultWithVariableDto.parse_obj(result)
def complete( id: str, data: CompleteTaskDto = CompleteTaskDto() ) -> Optional[Mapping[str, VariableValueDto]]: api = use_api() result = api.post(f"/task/{id}/complete", data=data.dict(exclude_unset=True, by_alias=True)) if result: return {k: VariableValueDto.parse_obj(v) for k, v in result.items()}
def get_xml(id: str = None, key: str = None, tenant_id: str = None) -> ProcessDefinitionDiagramDto: if not id or key: raise ValueError("You need to provide either id or key") api = use_api() if id: path = f"/process-definition/{id}/xml" elif key and tenant_id: path = f"/process-definition/key/{key}/tenant-id/{tenant_id}/xml" else: path = f"/process-definition/key/{key}/xml" result = api.get(path) return ProcessDefinitionDiagramDto.parse_obj(result)
def get_variables(id: str) -> Mapping[str, VariableValueDto]: api = use_api() result = api.get(f"/process-instance/{id}/variables") return {key: VariableValueDto.parse_obj(value) for key, value in result.items()}
def update_variables(id: str, data: PatchVariablesDto): api = use_api() api.post(f"/process-instance/{id}/variables", data=data.dict(exclude_unset=True, by_alias=True))
def get_list(data: ProcessInstanceQueryDto = ProcessInstanceQueryDto()) -> Sequence[ProcessInstanceDto]: api = use_api() result = api.post("/process-instance", data=data.dict(exclude_unset=True, by_alias=True)) return [ProcessInstanceDto.parse_obj(item) for item in result]
def get(id: str): api = use_api() result = api.get(f"/process-instance/{id}") return ProcessInstanceDto.parse_obj(result)
def version() -> str: api = use_api() result = api.get("/version") return result['version']
def get_identity_links(id: str): api = use_api() result = api.get(f"/task/{id}/identity-links") return [IdentityLinkDto.parse_obj(item) for item in result]
def set_assignee(id: str, user_id: str): api = use_api() api.post(f"/task/{id}/assignee", data={"userId": user_id})
def unclaim(id: str): api = use_api() api.post(f"/task/{id}/unclaim")
def claim(id: str, user_id: str): api = use_api() api.post(f"/task/{id}/claim", data={"userId": user_id})
def get_variables(id: str): api = use_api() result = api.get(f"/task/{id}/variables") return {k: VariableValueDto.parse_obj(v) for k, v in result.items()}
def get(id: str) -> TaskDto: api = use_api() result = api.get(f"/task/{id}") return TaskDto.parse_obj(result)
def get_list(query: TaskQueryDto = TaskQueryDto()) -> List[TaskDto]: api = use_api() data = query.dict(exclude_unset=True, by_alias=True) result = api.post("/task", data=data) return [TaskDto.parse_obj(task) for task in result]
def get(id: str) -> ProcessDefinitionDto: api = use_api() result = api.get(f"/process-definition/{id}") return ProcessDefinitionDto.parse_obj(result)