azure-functions-durable 1.2.8__py3-none-any.whl → 1.2.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- azure/durable_functions/__init__.py +81 -81
- azure/durable_functions/constants.py +9 -9
- azure/durable_functions/decorators/__init__.py +3 -3
- azure/durable_functions/decorators/durable_app.py +249 -249
- azure/durable_functions/decorators/metadata.py +109 -109
- azure/durable_functions/entity.py +125 -125
- azure/durable_functions/models/DurableEntityContext.py +201 -201
- azure/durable_functions/models/DurableHttpRequest.py +58 -58
- azure/durable_functions/models/DurableOrchestrationBindings.py +66 -66
- azure/durable_functions/models/DurableOrchestrationClient.py +781 -711
- azure/durable_functions/models/DurableOrchestrationContext.py +722 -707
- azure/durable_functions/models/DurableOrchestrationStatus.py +156 -156
- azure/durable_functions/models/EntityStateResponse.py +23 -23
- azure/durable_functions/models/FunctionContext.py +7 -7
- azure/durable_functions/models/OrchestrationRuntimeStatus.py +32 -29
- azure/durable_functions/models/OrchestratorState.py +117 -116
- azure/durable_functions/models/PurgeHistoryResult.py +33 -33
- azure/durable_functions/models/ReplaySchema.py +8 -8
- azure/durable_functions/models/RetryOptions.py +69 -69
- azure/durable_functions/models/RpcManagementOptions.py +86 -86
- azure/durable_functions/models/Task.py +426 -426
- azure/durable_functions/models/TaskOrchestrationExecutor.py +346 -333
- azure/durable_functions/models/TokenSource.py +56 -56
- azure/durable_functions/models/__init__.py +24 -24
- azure/durable_functions/models/actions/Action.py +23 -23
- azure/durable_functions/models/actions/ActionType.py +18 -18
- azure/durable_functions/models/actions/CallActivityAction.py +41 -41
- azure/durable_functions/models/actions/CallActivityWithRetryAction.py +45 -45
- azure/durable_functions/models/actions/CallEntityAction.py +46 -46
- azure/durable_functions/models/actions/CallHttpAction.py +35 -35
- azure/durable_functions/models/actions/CallSubOrchestratorAction.py +40 -40
- azure/durable_functions/models/actions/CallSubOrchestratorWithRetryAction.py +44 -44
- azure/durable_functions/models/actions/CompoundAction.py +35 -35
- azure/durable_functions/models/actions/ContinueAsNewAction.py +36 -36
- azure/durable_functions/models/actions/CreateTimerAction.py +48 -48
- azure/durable_functions/models/actions/NoOpAction.py +35 -35
- azure/durable_functions/models/actions/SignalEntityAction.py +47 -47
- azure/durable_functions/models/actions/WaitForExternalEventAction.py +63 -63
- azure/durable_functions/models/actions/WhenAllAction.py +14 -14
- azure/durable_functions/models/actions/WhenAnyAction.py +14 -14
- azure/durable_functions/models/actions/__init__.py +24 -24
- azure/durable_functions/models/entities/EntityState.py +74 -74
- azure/durable_functions/models/entities/OperationResult.py +76 -76
- azure/durable_functions/models/entities/RequestMessage.py +53 -53
- azure/durable_functions/models/entities/ResponseMessage.py +48 -48
- azure/durable_functions/models/entities/Signal.py +62 -62
- azure/durable_functions/models/entities/__init__.py +17 -17
- azure/durable_functions/models/history/HistoryEvent.py +92 -92
- azure/durable_functions/models/history/HistoryEventType.py +27 -25
- azure/durable_functions/models/history/__init__.py +8 -8
- azure/durable_functions/models/utils/__init__.py +7 -7
- azure/durable_functions/models/utils/entity_utils.py +103 -91
- azure/durable_functions/models/utils/http_utils.py +69 -69
- azure/durable_functions/models/utils/json_utils.py +56 -56
- azure/durable_functions/orchestrator.py +71 -71
- {azure_functions_durable-1.2.8.dist-info → azure_functions_durable-1.2.10.dist-info}/LICENSE +21 -21
- {azure_functions_durable-1.2.8.dist-info → azure_functions_durable-1.2.10.dist-info}/METADATA +58 -58
- azure_functions_durable-1.2.10.dist-info/RECORD +100 -0
- {azure_functions_durable-1.2.8.dist-info → azure_functions_durable-1.2.10.dist-info}/WHEEL +1 -1
- tests/models/test_DecoratorMetadata.py +135 -135
- tests/models/test_Decorators.py +107 -107
- tests/models/test_DurableOrchestrationBindings.py +68 -56
- tests/models/test_DurableOrchestrationClient.py +730 -612
- tests/models/test_DurableOrchestrationContext.py +102 -102
- tests/models/test_DurableOrchestrationStatus.py +59 -59
- tests/models/test_OrchestrationState.py +28 -28
- tests/models/test_RpcManagementOptions.py +79 -79
- tests/models/test_TokenSource.py +10 -10
- tests/orchestrator/models/OrchestrationInstance.py +18 -18
- tests/orchestrator/orchestrator_test_utils.py +130 -130
- tests/orchestrator/schemas/OrchetrationStateSchema.py +66 -66
- tests/orchestrator/test_call_http.py +235 -176
- tests/orchestrator/test_continue_as_new.py +67 -67
- tests/orchestrator/test_create_timer.py +126 -126
- tests/orchestrator/test_entity.py +395 -395
- tests/orchestrator/test_external_event.py +53 -53
- tests/orchestrator/test_fan_out_fan_in.py +175 -175
- tests/orchestrator/test_is_replaying_flag.py +101 -101
- tests/orchestrator/test_retries.py +308 -308
- tests/orchestrator/test_sequential_orchestrator.py +841 -801
- tests/orchestrator/test_sequential_orchestrator_custom_status.py +119 -119
- tests/orchestrator/test_sequential_orchestrator_with_retry.py +465 -465
- tests/orchestrator/test_serialization.py +30 -30
- tests/orchestrator/test_sub_orchestrator.py +95 -95
- tests/orchestrator/test_sub_orchestrator_with_retry.py +129 -129
- tests/orchestrator/test_task_any.py +60 -60
- tests/tasks/tasks_test_utils.py +17 -17
- tests/tasks/test_new_uuid.py +34 -34
- tests/test_utils/ContextBuilder.py +174 -174
- tests/test_utils/EntityContextBuilder.py +56 -56
- tests/test_utils/constants.py +1 -1
- tests/test_utils/json_utils.py +30 -30
- tests/test_utils/testClasses.py +56 -56
- tests/utils/__init__.py +1 -0
- tests/utils/test_entity_utils.py +24 -0
- azure_functions_durable-1.2.8.data/data/_manifest/bsi.json +0 -1
- azure_functions_durable-1.2.8.data/data/_manifest/manifest.cat +0 -0
- azure_functions_durable-1.2.8.data/data/_manifest/manifest.spdx.json +0 -12845
- azure_functions_durable-1.2.8.data/data/_manifest/manifest.spdx.json.sha256 +0 -1
- azure_functions_durable-1.2.8.dist-info/RECORD +0 -102
- {azure_functions_durable-1.2.8.dist-info → azure_functions_durable-1.2.10.dist-info}/top_level.txt +0 -0
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
from typing import Any, Dict, Union
|
|
2
|
-
|
|
3
|
-
from .Action import Action
|
|
4
|
-
from .ActionType import ActionType
|
|
5
|
-
from ..utils.json_utils import add_attrib
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class WaitForExternalEventAction(Action):
|
|
9
|
-
"""Defines the structure of Wait for External Event object.
|
|
10
|
-
|
|
11
|
-
Returns
|
|
12
|
-
-------
|
|
13
|
-
WaitForExternalEventAction
|
|
14
|
-
Returns a WaitForExternalEventAction Class.
|
|
15
|
-
|
|
16
|
-
Raises
|
|
17
|
-
------
|
|
18
|
-
ValueError
|
|
19
|
-
Raises error if external_event_name is not defined.
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
def __init__(self, external_event_name: str):
|
|
23
|
-
self.external_event_name: str = external_event_name
|
|
24
|
-
self.reason = "ExternalEvent"
|
|
25
|
-
|
|
26
|
-
if not self.external_event_name:
|
|
27
|
-
raise ValueError("external_event_name cannot be empty")
|
|
28
|
-
|
|
29
|
-
@property
|
|
30
|
-
def action_type(self) -> int:
|
|
31
|
-
"""Get the type of action this class represents."""
|
|
32
|
-
return ActionType.WAIT_FOR_EXTERNAL_EVENT
|
|
33
|
-
|
|
34
|
-
def to_json(self) -> Dict[str, Any]:
|
|
35
|
-
"""Convert object into a json dictionary.
|
|
36
|
-
|
|
37
|
-
Returns
|
|
38
|
-
-------
|
|
39
|
-
Dict[str, Union[str, int]]
|
|
40
|
-
The instance of the class converted into a json dictionary
|
|
41
|
-
"""
|
|
42
|
-
json_dict: Dict[str, Union[str, int]] = {}
|
|
43
|
-
|
|
44
|
-
add_attrib(json_dict, self, 'action_type', 'actionType')
|
|
45
|
-
add_attrib(json_dict, self, 'external_event_name', 'externalEventName')
|
|
46
|
-
add_attrib(json_dict, self, 'reason', 'reason')
|
|
47
|
-
return json_dict
|
|
48
|
-
|
|
49
|
-
def __eq__(self, other):
|
|
50
|
-
"""Override the default __eq__ method.
|
|
51
|
-
|
|
52
|
-
Returns
|
|
53
|
-
-------
|
|
54
|
-
Bool
|
|
55
|
-
Returns True if two class instances has same values at all properties,
|
|
56
|
-
and returns False otherwise.
|
|
57
|
-
"""
|
|
58
|
-
if not isinstance(other, WaitForExternalEventAction):
|
|
59
|
-
return False
|
|
60
|
-
else:
|
|
61
|
-
return self.action_type == other.action_type \
|
|
62
|
-
and self.external_event_name == other.external_event_name \
|
|
63
|
-
and self.reason == other.reason
|
|
1
|
+
from typing import Any, Dict, Union
|
|
2
|
+
|
|
3
|
+
from .Action import Action
|
|
4
|
+
from .ActionType import ActionType
|
|
5
|
+
from ..utils.json_utils import add_attrib
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class WaitForExternalEventAction(Action):
|
|
9
|
+
"""Defines the structure of Wait for External Event object.
|
|
10
|
+
|
|
11
|
+
Returns
|
|
12
|
+
-------
|
|
13
|
+
WaitForExternalEventAction
|
|
14
|
+
Returns a WaitForExternalEventAction Class.
|
|
15
|
+
|
|
16
|
+
Raises
|
|
17
|
+
------
|
|
18
|
+
ValueError
|
|
19
|
+
Raises error if external_event_name is not defined.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(self, external_event_name: str):
|
|
23
|
+
self.external_event_name: str = external_event_name
|
|
24
|
+
self.reason = "ExternalEvent"
|
|
25
|
+
|
|
26
|
+
if not self.external_event_name:
|
|
27
|
+
raise ValueError("external_event_name cannot be empty")
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def action_type(self) -> int:
|
|
31
|
+
"""Get the type of action this class represents."""
|
|
32
|
+
return ActionType.WAIT_FOR_EXTERNAL_EVENT
|
|
33
|
+
|
|
34
|
+
def to_json(self) -> Dict[str, Any]:
|
|
35
|
+
"""Convert object into a json dictionary.
|
|
36
|
+
|
|
37
|
+
Returns
|
|
38
|
+
-------
|
|
39
|
+
Dict[str, Union[str, int]]
|
|
40
|
+
The instance of the class converted into a json dictionary
|
|
41
|
+
"""
|
|
42
|
+
json_dict: Dict[str, Union[str, int]] = {}
|
|
43
|
+
|
|
44
|
+
add_attrib(json_dict, self, 'action_type', 'actionType')
|
|
45
|
+
add_attrib(json_dict, self, 'external_event_name', 'externalEventName')
|
|
46
|
+
add_attrib(json_dict, self, 'reason', 'reason')
|
|
47
|
+
return json_dict
|
|
48
|
+
|
|
49
|
+
def __eq__(self, other):
|
|
50
|
+
"""Override the default __eq__ method.
|
|
51
|
+
|
|
52
|
+
Returns
|
|
53
|
+
-------
|
|
54
|
+
Bool
|
|
55
|
+
Returns True if two class instances has same values at all properties,
|
|
56
|
+
and returns False otherwise.
|
|
57
|
+
"""
|
|
58
|
+
if not isinstance(other, WaitForExternalEventAction):
|
|
59
|
+
return False
|
|
60
|
+
else:
|
|
61
|
+
return self.action_type == other.action_type \
|
|
62
|
+
and self.external_event_name == other.external_event_name \
|
|
63
|
+
and self.reason == other.reason
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
from .ActionType import ActionType
|
|
2
|
-
from azure.durable_functions.models.actions.CompoundAction import CompoundAction
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class WhenAllAction(CompoundAction):
|
|
6
|
-
"""Defines the structure of the WhenAll Action object.
|
|
7
|
-
|
|
8
|
-
Provides the information needed by the durable extension to be able to invoke WhenAll tasks.
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
@property
|
|
12
|
-
def action_type(self) -> int:
|
|
13
|
-
"""Get the type of action this class represents."""
|
|
14
|
-
return ActionType.WHEN_ALL
|
|
1
|
+
from .ActionType import ActionType
|
|
2
|
+
from azure.durable_functions.models.actions.CompoundAction import CompoundAction
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class WhenAllAction(CompoundAction):
|
|
6
|
+
"""Defines the structure of the WhenAll Action object.
|
|
7
|
+
|
|
8
|
+
Provides the information needed by the durable extension to be able to invoke WhenAll tasks.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
@property
|
|
12
|
+
def action_type(self) -> int:
|
|
13
|
+
"""Get the type of action this class represents."""
|
|
14
|
+
return ActionType.WHEN_ALL
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
from azure.durable_functions.models.actions.CompoundAction import CompoundAction
|
|
2
|
-
from .ActionType import ActionType
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class WhenAnyAction(CompoundAction):
|
|
6
|
-
"""Defines the structure of the WhenAll Action object.
|
|
7
|
-
|
|
8
|
-
Provides the information needed by the durable extension to be able to invoke WhenAll tasks.
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
@property
|
|
12
|
-
def action_type(self) -> int:
|
|
13
|
-
"""Get the type of action this class represents."""
|
|
14
|
-
return ActionType.WHEN_ANY
|
|
1
|
+
from azure.durable_functions.models.actions.CompoundAction import CompoundAction
|
|
2
|
+
from .ActionType import ActionType
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class WhenAnyAction(CompoundAction):
|
|
6
|
+
"""Defines the structure of the WhenAll Action object.
|
|
7
|
+
|
|
8
|
+
Provides the information needed by the durable extension to be able to invoke WhenAll tasks.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
@property
|
|
12
|
+
def action_type(self) -> int:
|
|
13
|
+
"""Get the type of action this class represents."""
|
|
14
|
+
return ActionType.WHEN_ANY
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
"""Defines the models for the different forms of Activities that can be scheduled."""
|
|
2
|
-
from .Action import Action
|
|
3
|
-
from .ActionType import ActionType
|
|
4
|
-
from .CallActivityAction import CallActivityAction
|
|
5
|
-
from .CallActivityWithRetryAction import CallActivityWithRetryAction
|
|
6
|
-
from .CallSubOrchestratorAction import CallSubOrchestratorAction
|
|
7
|
-
from .WaitForExternalEventAction import WaitForExternalEventAction
|
|
8
|
-
from .CallHttpAction import CallHttpAction
|
|
9
|
-
from .CreateTimerAction import CreateTimerAction
|
|
10
|
-
from .WhenAllAction import WhenAllAction
|
|
11
|
-
from .WhenAnyAction import WhenAnyAction
|
|
12
|
-
|
|
13
|
-
__all__ = [
|
|
14
|
-
'Action',
|
|
15
|
-
'ActionType',
|
|
16
|
-
'CallActivityAction',
|
|
17
|
-
'CallActivityWithRetryAction',
|
|
18
|
-
'CallSubOrchestratorAction',
|
|
19
|
-
'CallHttpAction',
|
|
20
|
-
'WaitForExternalEventAction',
|
|
21
|
-
'CreateTimerAction',
|
|
22
|
-
'WhenAnyAction',
|
|
23
|
-
'WhenAllAction'
|
|
24
|
-
]
|
|
1
|
+
"""Defines the models for the different forms of Activities that can be scheduled."""
|
|
2
|
+
from .Action import Action
|
|
3
|
+
from .ActionType import ActionType
|
|
4
|
+
from .CallActivityAction import CallActivityAction
|
|
5
|
+
from .CallActivityWithRetryAction import CallActivityWithRetryAction
|
|
6
|
+
from .CallSubOrchestratorAction import CallSubOrchestratorAction
|
|
7
|
+
from .WaitForExternalEventAction import WaitForExternalEventAction
|
|
8
|
+
from .CallHttpAction import CallHttpAction
|
|
9
|
+
from .CreateTimerAction import CreateTimerAction
|
|
10
|
+
from .WhenAllAction import WhenAllAction
|
|
11
|
+
from .WhenAnyAction import WhenAnyAction
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
'Action',
|
|
15
|
+
'ActionType',
|
|
16
|
+
'CallActivityAction',
|
|
17
|
+
'CallActivityWithRetryAction',
|
|
18
|
+
'CallSubOrchestratorAction',
|
|
19
|
+
'CallHttpAction',
|
|
20
|
+
'WaitForExternalEventAction',
|
|
21
|
+
'CreateTimerAction',
|
|
22
|
+
'WhenAnyAction',
|
|
23
|
+
'WhenAllAction'
|
|
24
|
+
]
|
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
from typing import List, Optional, Dict, Any
|
|
2
|
-
from .Signal import Signal
|
|
3
|
-
from azure.functions._durable_functions import _serialize_custom_object
|
|
4
|
-
from .OperationResult import OperationResult
|
|
5
|
-
import json
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class EntityState:
|
|
9
|
-
"""Entity State.
|
|
10
|
-
|
|
11
|
-
Used to communicate the state of the entity back to the durable extension
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
def __init__(self,
|
|
15
|
-
results: List[OperationResult],
|
|
16
|
-
signals: List[Signal],
|
|
17
|
-
entity_exists: bool = False,
|
|
18
|
-
state: Optional[str] = None):
|
|
19
|
-
self.entity_exists = entity_exists
|
|
20
|
-
self.state = state
|
|
21
|
-
self._results = results
|
|
22
|
-
self._signals = signals
|
|
23
|
-
|
|
24
|
-
@property
|
|
25
|
-
def results(self) -> List[OperationResult]:
|
|
26
|
-
"""Get list of results of the entity.
|
|
27
|
-
|
|
28
|
-
Returns
|
|
29
|
-
-------
|
|
30
|
-
List[OperationResult]:
|
|
31
|
-
The results of the entity
|
|
32
|
-
"""
|
|
33
|
-
return self._results
|
|
34
|
-
|
|
35
|
-
@property
|
|
36
|
-
def signals(self) -> List[Signal]:
|
|
37
|
-
"""Get list of signals to the entity.
|
|
38
|
-
|
|
39
|
-
Returns
|
|
40
|
-
-------
|
|
41
|
-
List[Signal]:
|
|
42
|
-
The signals of the entity
|
|
43
|
-
"""
|
|
44
|
-
return self._signals
|
|
45
|
-
|
|
46
|
-
def to_json(self) -> Dict[str, Any]:
|
|
47
|
-
"""Convert object into a json dictionary.
|
|
48
|
-
|
|
49
|
-
Returns
|
|
50
|
-
-------
|
|
51
|
-
Dict[str, Any]
|
|
52
|
-
The instance of the class converted into a json dictionary
|
|
53
|
-
"""
|
|
54
|
-
json_dict: Dict[str, Any] = {}
|
|
55
|
-
# Serialize the OperationResult list
|
|
56
|
-
serialized_results = list(map(lambda x: x.to_json(), self.results))
|
|
57
|
-
|
|
58
|
-
json_dict["entityExists"] = self.entity_exists
|
|
59
|
-
json_dict["entityState"] = json.dumps(self.state, default=_serialize_custom_object)
|
|
60
|
-
json_dict["results"] = serialized_results
|
|
61
|
-
json_dict["signals"] = self.signals
|
|
62
|
-
return json_dict
|
|
63
|
-
|
|
64
|
-
def to_json_string(self) -> str:
|
|
65
|
-
"""Convert object into a json string.
|
|
66
|
-
|
|
67
|
-
Returns
|
|
68
|
-
-------
|
|
69
|
-
str
|
|
70
|
-
The instance of the object in json string format
|
|
71
|
-
"""
|
|
72
|
-
# TODO: Same implementation as in Orchestrator.py, we should refactor to shared a base
|
|
73
|
-
json_dict = self.to_json()
|
|
74
|
-
return json.dumps(json_dict)
|
|
1
|
+
from typing import List, Optional, Dict, Any
|
|
2
|
+
from .Signal import Signal
|
|
3
|
+
from azure.functions._durable_functions import _serialize_custom_object
|
|
4
|
+
from .OperationResult import OperationResult
|
|
5
|
+
import json
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class EntityState:
|
|
9
|
+
"""Entity State.
|
|
10
|
+
|
|
11
|
+
Used to communicate the state of the entity back to the durable extension
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def __init__(self,
|
|
15
|
+
results: List[OperationResult],
|
|
16
|
+
signals: List[Signal],
|
|
17
|
+
entity_exists: bool = False,
|
|
18
|
+
state: Optional[str] = None):
|
|
19
|
+
self.entity_exists = entity_exists
|
|
20
|
+
self.state = state
|
|
21
|
+
self._results = results
|
|
22
|
+
self._signals = signals
|
|
23
|
+
|
|
24
|
+
@property
|
|
25
|
+
def results(self) -> List[OperationResult]:
|
|
26
|
+
"""Get list of results of the entity.
|
|
27
|
+
|
|
28
|
+
Returns
|
|
29
|
+
-------
|
|
30
|
+
List[OperationResult]:
|
|
31
|
+
The results of the entity
|
|
32
|
+
"""
|
|
33
|
+
return self._results
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
def signals(self) -> List[Signal]:
|
|
37
|
+
"""Get list of signals to the entity.
|
|
38
|
+
|
|
39
|
+
Returns
|
|
40
|
+
-------
|
|
41
|
+
List[Signal]:
|
|
42
|
+
The signals of the entity
|
|
43
|
+
"""
|
|
44
|
+
return self._signals
|
|
45
|
+
|
|
46
|
+
def to_json(self) -> Dict[str, Any]:
|
|
47
|
+
"""Convert object into a json dictionary.
|
|
48
|
+
|
|
49
|
+
Returns
|
|
50
|
+
-------
|
|
51
|
+
Dict[str, Any]
|
|
52
|
+
The instance of the class converted into a json dictionary
|
|
53
|
+
"""
|
|
54
|
+
json_dict: Dict[str, Any] = {}
|
|
55
|
+
# Serialize the OperationResult list
|
|
56
|
+
serialized_results = list(map(lambda x: x.to_json(), self.results))
|
|
57
|
+
|
|
58
|
+
json_dict["entityExists"] = self.entity_exists
|
|
59
|
+
json_dict["entityState"] = json.dumps(self.state, default=_serialize_custom_object)
|
|
60
|
+
json_dict["results"] = serialized_results
|
|
61
|
+
json_dict["signals"] = self.signals
|
|
62
|
+
return json_dict
|
|
63
|
+
|
|
64
|
+
def to_json_string(self) -> str:
|
|
65
|
+
"""Convert object into a json string.
|
|
66
|
+
|
|
67
|
+
Returns
|
|
68
|
+
-------
|
|
69
|
+
str
|
|
70
|
+
The instance of the object in json string format
|
|
71
|
+
"""
|
|
72
|
+
# TODO: Same implementation as in Orchestrator.py, we should refactor to shared a base
|
|
73
|
+
json_dict = self.to_json()
|
|
74
|
+
return json.dumps(json_dict)
|
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
from typing import Optional, Dict, Any
|
|
2
|
-
from azure.functions._durable_functions import _serialize_custom_object
|
|
3
|
-
import json
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class OperationResult:
|
|
7
|
-
"""OperationResult.
|
|
8
|
-
|
|
9
|
-
The result of an Entity operation.
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
def __init__(self,
|
|
13
|
-
is_error: bool,
|
|
14
|
-
duration: int,
|
|
15
|
-
result: Optional[str] = None):
|
|
16
|
-
"""Instantiate an OperationResult.
|
|
17
|
-
|
|
18
|
-
Parameters
|
|
19
|
-
----------
|
|
20
|
-
is_error: bool
|
|
21
|
-
Whether or not the operation resulted in an exception.
|
|
22
|
-
duration: int
|
|
23
|
-
How long the operation took, in milliseconds.
|
|
24
|
-
result: Optional[str]
|
|
25
|
-
The operation result. Defaults to None.
|
|
26
|
-
"""
|
|
27
|
-
self._is_error: bool = is_error
|
|
28
|
-
self._duration: int = duration
|
|
29
|
-
self._result: Optional[str] = result
|
|
30
|
-
|
|
31
|
-
@property
|
|
32
|
-
def is_error(self) -> bool:
|
|
33
|
-
"""Determine if the operation resulted in an error.
|
|
34
|
-
|
|
35
|
-
Returns
|
|
36
|
-
-------
|
|
37
|
-
bool
|
|
38
|
-
True if the operation resulted in error. Otherwise False.
|
|
39
|
-
"""
|
|
40
|
-
return self._is_error
|
|
41
|
-
|
|
42
|
-
@property
|
|
43
|
-
def duration(self) -> int:
|
|
44
|
-
"""Get the duration of this operation.
|
|
45
|
-
|
|
46
|
-
Returns
|
|
47
|
-
-------
|
|
48
|
-
int:
|
|
49
|
-
The duration of this operation, in milliseconds
|
|
50
|
-
"""
|
|
51
|
-
return self._duration
|
|
52
|
-
|
|
53
|
-
@property
|
|
54
|
-
def result(self) -> Any:
|
|
55
|
-
"""Get the operation's result.
|
|
56
|
-
|
|
57
|
-
Returns
|
|
58
|
-
-------
|
|
59
|
-
Any
|
|
60
|
-
The operation's result
|
|
61
|
-
"""
|
|
62
|
-
return self._result
|
|
63
|
-
|
|
64
|
-
def to_json(self) -> Dict[str, Any]:
|
|
65
|
-
"""Represent OperationResult as a JSON-serializable Dict.
|
|
66
|
-
|
|
67
|
-
Returns
|
|
68
|
-
-------
|
|
69
|
-
Dict[str, Any]
|
|
70
|
-
A JSON-serializable Dict of the OperationResult
|
|
71
|
-
"""
|
|
72
|
-
to_json: Dict[str, Any] = {}
|
|
73
|
-
to_json["isError"] = self.is_error
|
|
74
|
-
to_json["duration"] = self.duration
|
|
75
|
-
to_json["result"] = json.dumps(self.result, default=_serialize_custom_object)
|
|
76
|
-
return to_json
|
|
1
|
+
from typing import Optional, Dict, Any
|
|
2
|
+
from azure.functions._durable_functions import _serialize_custom_object
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class OperationResult:
|
|
7
|
+
"""OperationResult.
|
|
8
|
+
|
|
9
|
+
The result of an Entity operation.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
def __init__(self,
|
|
13
|
+
is_error: bool,
|
|
14
|
+
duration: int,
|
|
15
|
+
result: Optional[str] = None):
|
|
16
|
+
"""Instantiate an OperationResult.
|
|
17
|
+
|
|
18
|
+
Parameters
|
|
19
|
+
----------
|
|
20
|
+
is_error: bool
|
|
21
|
+
Whether or not the operation resulted in an exception.
|
|
22
|
+
duration: int
|
|
23
|
+
How long the operation took, in milliseconds.
|
|
24
|
+
result: Optional[str]
|
|
25
|
+
The operation result. Defaults to None.
|
|
26
|
+
"""
|
|
27
|
+
self._is_error: bool = is_error
|
|
28
|
+
self._duration: int = duration
|
|
29
|
+
self._result: Optional[str] = result
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def is_error(self) -> bool:
|
|
33
|
+
"""Determine if the operation resulted in an error.
|
|
34
|
+
|
|
35
|
+
Returns
|
|
36
|
+
-------
|
|
37
|
+
bool
|
|
38
|
+
True if the operation resulted in error. Otherwise False.
|
|
39
|
+
"""
|
|
40
|
+
return self._is_error
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def duration(self) -> int:
|
|
44
|
+
"""Get the duration of this operation.
|
|
45
|
+
|
|
46
|
+
Returns
|
|
47
|
+
-------
|
|
48
|
+
int:
|
|
49
|
+
The duration of this operation, in milliseconds
|
|
50
|
+
"""
|
|
51
|
+
return self._duration
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def result(self) -> Any:
|
|
55
|
+
"""Get the operation's result.
|
|
56
|
+
|
|
57
|
+
Returns
|
|
58
|
+
-------
|
|
59
|
+
Any
|
|
60
|
+
The operation's result
|
|
61
|
+
"""
|
|
62
|
+
return self._result
|
|
63
|
+
|
|
64
|
+
def to_json(self) -> Dict[str, Any]:
|
|
65
|
+
"""Represent OperationResult as a JSON-serializable Dict.
|
|
66
|
+
|
|
67
|
+
Returns
|
|
68
|
+
-------
|
|
69
|
+
Dict[str, Any]
|
|
70
|
+
A JSON-serializable Dict of the OperationResult
|
|
71
|
+
"""
|
|
72
|
+
to_json: Dict[str, Any] = {}
|
|
73
|
+
to_json["isError"] = self.is_error
|
|
74
|
+
to_json["duration"] = self.duration
|
|
75
|
+
to_json["result"] = json.dumps(self.result, default=_serialize_custom_object)
|
|
76
|
+
return to_json
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
from typing import List, Optional, Any
|
|
2
|
-
from ..utils.entity_utils import EntityId
|
|
3
|
-
import json
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class RequestMessage:
|
|
7
|
-
"""RequestMessage.
|
|
8
|
-
|
|
9
|
-
Specifies a request to an entity.
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
def __init__(self,
|
|
13
|
-
id_: str,
|
|
14
|
-
name: Optional[str] = None,
|
|
15
|
-
signal: Optional[bool] = None,
|
|
16
|
-
input_: Optional[str] = None,
|
|
17
|
-
arg: Optional[Any] = None,
|
|
18
|
-
parent: Optional[str] = None,
|
|
19
|
-
lockset: Optional[List[EntityId]] = None,
|
|
20
|
-
pos: Optional[int] = None,
|
|
21
|
-
**kwargs):
|
|
22
|
-
# TODO: this class has too many optionals, may speak to
|
|
23
|
-
# over-caution, but it mimics the JS class. Investigate if
|
|
24
|
-
# these many Optionals are necessary.
|
|
25
|
-
self.id = id_
|
|
26
|
-
self.name = name
|
|
27
|
-
self.signal = signal
|
|
28
|
-
self.input = input_
|
|
29
|
-
self.arg = arg
|
|
30
|
-
self.parent = parent
|
|
31
|
-
self.lockset = lockset
|
|
32
|
-
self.pos = pos
|
|
33
|
-
|
|
34
|
-
@classmethod
|
|
35
|
-
def from_json(cls, json_str: str) -> 'RequestMessage':
|
|
36
|
-
"""Instantiate a RequestMessage object from the durable-extension provided JSON data.
|
|
37
|
-
|
|
38
|
-
Parameters
|
|
39
|
-
----------
|
|
40
|
-
json_str: str
|
|
41
|
-
A durable-extension provided json-formatted string representation of
|
|
42
|
-
a RequestMessage
|
|
43
|
-
|
|
44
|
-
Returns
|
|
45
|
-
-------
|
|
46
|
-
RequestMessage:
|
|
47
|
-
A RequestMessage object from the json_str parameter
|
|
48
|
-
"""
|
|
49
|
-
# We replace the `id` key for `id_` to avoid clashes with reserved
|
|
50
|
-
# identifiers in Python
|
|
51
|
-
json_dict = json.loads(json_str)
|
|
52
|
-
json_dict["id_"] = json_dict.pop("id")
|
|
53
|
-
return cls(**json_dict)
|
|
1
|
+
from typing import List, Optional, Any
|
|
2
|
+
from ..utils.entity_utils import EntityId
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class RequestMessage:
|
|
7
|
+
"""RequestMessage.
|
|
8
|
+
|
|
9
|
+
Specifies a request to an entity.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
def __init__(self,
|
|
13
|
+
id_: str,
|
|
14
|
+
name: Optional[str] = None,
|
|
15
|
+
signal: Optional[bool] = None,
|
|
16
|
+
input_: Optional[str] = None,
|
|
17
|
+
arg: Optional[Any] = None,
|
|
18
|
+
parent: Optional[str] = None,
|
|
19
|
+
lockset: Optional[List[EntityId]] = None,
|
|
20
|
+
pos: Optional[int] = None,
|
|
21
|
+
**kwargs):
|
|
22
|
+
# TODO: this class has too many optionals, may speak to
|
|
23
|
+
# over-caution, but it mimics the JS class. Investigate if
|
|
24
|
+
# these many Optionals are necessary.
|
|
25
|
+
self.id = id_
|
|
26
|
+
self.name = name
|
|
27
|
+
self.signal = signal
|
|
28
|
+
self.input = input_
|
|
29
|
+
self.arg = arg
|
|
30
|
+
self.parent = parent
|
|
31
|
+
self.lockset = lockset
|
|
32
|
+
self.pos = pos
|
|
33
|
+
|
|
34
|
+
@classmethod
|
|
35
|
+
def from_json(cls, json_str: str) -> 'RequestMessage':
|
|
36
|
+
"""Instantiate a RequestMessage object from the durable-extension provided JSON data.
|
|
37
|
+
|
|
38
|
+
Parameters
|
|
39
|
+
----------
|
|
40
|
+
json_str: str
|
|
41
|
+
A durable-extension provided json-formatted string representation of
|
|
42
|
+
a RequestMessage
|
|
43
|
+
|
|
44
|
+
Returns
|
|
45
|
+
-------
|
|
46
|
+
RequestMessage:
|
|
47
|
+
A RequestMessage object from the json_str parameter
|
|
48
|
+
"""
|
|
49
|
+
# We replace the `id` key for `id_` to avoid clashes with reserved
|
|
50
|
+
# identifiers in Python
|
|
51
|
+
json_dict = json.loads(json_str)
|
|
52
|
+
json_dict["id_"] = json_dict.pop("id")
|
|
53
|
+
return cls(**json_dict)
|