11from datetime import datetime
22from dateutil .parser import parse as dt_parse
33from typing import Any , List , Dict , Optional , Union
4-
4+ from . OrchestrationRuntimeStatus import OrchestrationRuntimeStatus
55from .utils .json_utils import add_attrib , add_datetime_attrib
66
77
@@ -15,7 +15,8 @@ class DurableOrchestrationStatus:
1515 def __init__ (self , name : Optional [str ] = None , instanceId : Optional [str ] = None ,
1616 createdTime : Optional [str ] = None , lastUpdatedTime : Optional [str ] = None ,
1717 input : Optional [Any ] = None , output : Optional [Any ] = None ,
18- runtimeStatus : Optional [str ] = None , customStatus : Optional [Any ] = None ,
18+ runtimeStatus : Optional [OrchestrationRuntimeStatus ] = None ,
19+ customStatus : Optional [Any ] = None ,
1920 history : Optional [List [Any ]] = None ,
2021 ** kwargs ):
2122 self ._name : Optional [str ] = name
@@ -26,7 +27,9 @@ def __init__(self, name: Optional[str] = None, instanceId: Optional[str] = None,
2627 if lastUpdatedTime is not None else None
2728 self ._input : Any = input
2829 self ._output : Any = output
29- self ._runtime_status : Optional [str ] = runtimeStatus # TODO: GH issue 178
30+ self ._runtime_status : Optional [OrchestrationRuntimeStatus ] = runtimeStatus
31+ if runtimeStatus is not None :
32+ self ._runtime_status = OrchestrationRuntimeStatus (runtimeStatus )
3033 self ._custom_status : Any = customStatus
3134 self ._history : Optional [List [Any ]] = history
3235 if kwargs is not None :
@@ -82,7 +85,8 @@ def to_json(self) -> Dict[str, Union[int, str]]:
8285 add_datetime_attrib (json , self , 'last_updated_time' , 'lastUpdatedTime' )
8386 add_attrib (json , self , 'output' )
8487 add_attrib (json , self , 'input_' , 'input' )
85- add_attrib (json , self , 'runtime_status' , 'runtimeStatus' )
88+ if self .runtime_status is not None :
89+ json ["runtimeStatus" ] = self .runtime_status .name
8690 add_attrib (json , self , 'custom_status' , 'customStatus' )
8791 add_attrib (json , self , 'history' )
8892 return json
@@ -129,7 +133,7 @@ def output(self) -> Any:
129133 return self ._output
130134
131135 @property
132- def runtime_status (self ) -> Optional [str ]:
136+ def runtime_status (self ) -> Optional [OrchestrationRuntimeStatus ]:
133137 """Get the runtime status of the orchestration instance."""
134138 return self ._runtime_status
135139
0 commit comments