1
1
from datetime import datetime
2
2
from dateutil .parser import parse as dt_parse
3
3
from typing import Any , List , Dict , Optional , Union
4
-
4
+ from . OrchestrationRuntimeStatus import OrchestrationRuntimeStatus
5
5
from .utils .json_utils import add_attrib , add_datetime_attrib
6
6
7
7
@@ -15,7 +15,8 @@ class DurableOrchestrationStatus:
15
15
def __init__ (self , name : Optional [str ] = None , instanceId : Optional [str ] = None ,
16
16
createdTime : Optional [str ] = None , lastUpdatedTime : Optional [str ] = None ,
17
17
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 ,
19
20
history : Optional [List [Any ]] = None ,
20
21
** kwargs ):
21
22
self ._name : Optional [str ] = name
@@ -26,7 +27,9 @@ def __init__(self, name: Optional[str] = None, instanceId: Optional[str] = None,
26
27
if lastUpdatedTime is not None else None
27
28
self ._input : Any = input
28
29
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 )
30
33
self ._custom_status : Any = customStatus
31
34
self ._history : Optional [List [Any ]] = history
32
35
if kwargs is not None :
@@ -82,7 +85,8 @@ def to_json(self) -> Dict[str, Union[int, str]]:
82
85
add_datetime_attrib (json , self , 'last_updated_time' , 'lastUpdatedTime' )
83
86
add_attrib (json , self , 'output' )
84
87
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
86
90
add_attrib (json , self , 'custom_status' , 'customStatus' )
87
91
add_attrib (json , self , 'history' )
88
92
return json
@@ -129,7 +133,7 @@ def output(self) -> Any:
129
133
return self ._output
130
134
131
135
@property
132
- def runtime_status (self ) -> Optional [str ]:
136
+ def runtime_status (self ) -> Optional [OrchestrationRuntimeStatus ]:
133
137
"""Get the runtime status of the orchestration instance."""
134
138
return self ._runtime_status
135
139
0 commit comments