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,201 +1,201 @@
|
|
|
1
|
-
from typing import Optional, Any, Dict, Tuple, List, Callable
|
|
2
|
-
from azure.functions._durable_functions import _deserialize_custom_object
|
|
3
|
-
import json
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class DurableEntityContext:
|
|
7
|
-
"""Context of the durable entity context.
|
|
8
|
-
|
|
9
|
-
Describes the API used to specify durable entity user code.
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
def __init__(self,
|
|
13
|
-
name: str,
|
|
14
|
-
key: str,
|
|
15
|
-
exists: bool,
|
|
16
|
-
state: Any):
|
|
17
|
-
"""Context of the durable entity context.
|
|
18
|
-
|
|
19
|
-
Describes the API used to specify durable entity user code.
|
|
20
|
-
|
|
21
|
-
Parameters
|
|
22
|
-
----------
|
|
23
|
-
name: str
|
|
24
|
-
The name of the Durable Entity
|
|
25
|
-
key: str
|
|
26
|
-
The key of the Durable Entity
|
|
27
|
-
exists: bool
|
|
28
|
-
Flag to determine if the entity exists
|
|
29
|
-
state: Any
|
|
30
|
-
The internal state of the Durable Entity
|
|
31
|
-
"""
|
|
32
|
-
self._entity_name: str = name
|
|
33
|
-
self._entity_key: str = key
|
|
34
|
-
|
|
35
|
-
self._exists: bool = exists
|
|
36
|
-
self._is_newly_constructed: bool = False
|
|
37
|
-
|
|
38
|
-
self._state: Any = state
|
|
39
|
-
self._input: Any = None
|
|
40
|
-
self._operation: Optional[str] = None
|
|
41
|
-
self._result: Any = None
|
|
42
|
-
|
|
43
|
-
@property
|
|
44
|
-
def entity_name(self) -> str:
|
|
45
|
-
"""Get the name of the Entity.
|
|
46
|
-
|
|
47
|
-
Returns
|
|
48
|
-
-------
|
|
49
|
-
str
|
|
50
|
-
The name of the entity
|
|
51
|
-
"""
|
|
52
|
-
return self._entity_name
|
|
53
|
-
|
|
54
|
-
@property
|
|
55
|
-
def entity_key(self) -> str:
|
|
56
|
-
"""Get the Entity key.
|
|
57
|
-
|
|
58
|
-
Returns
|
|
59
|
-
-------
|
|
60
|
-
str
|
|
61
|
-
The entity key
|
|
62
|
-
"""
|
|
63
|
-
return self._entity_key
|
|
64
|
-
|
|
65
|
-
@property
|
|
66
|
-
def operation_name(self) -> Optional[str]:
|
|
67
|
-
"""Get the current operation name.
|
|
68
|
-
|
|
69
|
-
Returns
|
|
70
|
-
-------
|
|
71
|
-
Optional[str]
|
|
72
|
-
The current operation name
|
|
73
|
-
"""
|
|
74
|
-
if self._operation is None:
|
|
75
|
-
raise Exception("Entity operation is unassigned")
|
|
76
|
-
return self._operation
|
|
77
|
-
|
|
78
|
-
@property
|
|
79
|
-
def is_newly_constructed(self) -> bool:
|
|
80
|
-
"""Determine if the Entity was newly constructed.
|
|
81
|
-
|
|
82
|
-
Returns
|
|
83
|
-
-------
|
|
84
|
-
bool
|
|
85
|
-
True if the Entity was newly constructed. False otherwise.
|
|
86
|
-
"""
|
|
87
|
-
# This is not updated at the moment, as its semantics are unclear
|
|
88
|
-
return self._is_newly_constructed
|
|
89
|
-
|
|
90
|
-
@classmethod
|
|
91
|
-
def from_json(cls, json_str: str) -> Tuple['DurableEntityContext', List[Dict[str, Any]]]:
|
|
92
|
-
"""Instantiate a DurableEntityContext from a JSON-formatted string.
|
|
93
|
-
|
|
94
|
-
Parameters
|
|
95
|
-
----------
|
|
96
|
-
json_string: str
|
|
97
|
-
A JSON-formatted string, returned by the durable-extension,
|
|
98
|
-
which represents the entity context
|
|
99
|
-
|
|
100
|
-
Returns
|
|
101
|
-
-------
|
|
102
|
-
DurableEntityContext
|
|
103
|
-
The DurableEntityContext originated from the input string
|
|
104
|
-
"""
|
|
105
|
-
json_dict = json.loads(json_str)
|
|
106
|
-
json_dict["name"] = json_dict["self"]["name"]
|
|
107
|
-
json_dict["key"] = json_dict["self"]["key"]
|
|
108
|
-
json_dict.pop("self")
|
|
109
|
-
|
|
110
|
-
serialized_state = json_dict["state"]
|
|
111
|
-
if serialized_state is not None:
|
|
112
|
-
json_dict["state"] = from_json_util(serialized_state)
|
|
113
|
-
|
|
114
|
-
batch = json_dict.pop("batch")
|
|
115
|
-
return cls(**json_dict), batch
|
|
116
|
-
|
|
117
|
-
def set_state(self, state: Any) -> None:
|
|
118
|
-
"""Set the state of the entity.
|
|
119
|
-
|
|
120
|
-
Parameter
|
|
121
|
-
---------
|
|
122
|
-
state: Any
|
|
123
|
-
The new state of the entity
|
|
124
|
-
"""
|
|
125
|
-
self._exists = True
|
|
126
|
-
|
|
127
|
-
# should only serialize the state at the end of the batch
|
|
128
|
-
self._state = state
|
|
129
|
-
|
|
130
|
-
def get_state(self, initializer: Optional[Callable[[], Any]] = None) -> Any:
|
|
131
|
-
"""Get the current state of this entity.
|
|
132
|
-
|
|
133
|
-
Parameters
|
|
134
|
-
----------
|
|
135
|
-
initializer: Optional[Callable[[], Any]]
|
|
136
|
-
A 0-argument function to provide an initial state. Defaults to None.
|
|
137
|
-
|
|
138
|
-
Returns
|
|
139
|
-
-------
|
|
140
|
-
Any
|
|
141
|
-
The current state of the entity
|
|
142
|
-
"""
|
|
143
|
-
state = self._state
|
|
144
|
-
if state is not None:
|
|
145
|
-
return state
|
|
146
|
-
elif initializer:
|
|
147
|
-
if not callable(initializer):
|
|
148
|
-
raise Exception("initializer argument needs to be a callable function")
|
|
149
|
-
state = initializer()
|
|
150
|
-
return state
|
|
151
|
-
|
|
152
|
-
def get_input(self) -> Any:
|
|
153
|
-
"""Get the input for this operation.
|
|
154
|
-
|
|
155
|
-
Returns
|
|
156
|
-
-------
|
|
157
|
-
Any
|
|
158
|
-
The input for the current operation
|
|
159
|
-
"""
|
|
160
|
-
input_ = None
|
|
161
|
-
req_input = self._input
|
|
162
|
-
req_input = json.loads(req_input)
|
|
163
|
-
input_ = None if req_input is None else from_json_util(req_input)
|
|
164
|
-
return input_
|
|
165
|
-
|
|
166
|
-
def set_result(self, result: Any) -> None:
|
|
167
|
-
"""Set the result (return value) of the entity.
|
|
168
|
-
|
|
169
|
-
Paramaters
|
|
170
|
-
----------
|
|
171
|
-
result: Any
|
|
172
|
-
The result / return value for the entity
|
|
173
|
-
"""
|
|
174
|
-
self._exists = True
|
|
175
|
-
self._result = result
|
|
176
|
-
|
|
177
|
-
def destruct_on_exit(self) -> None:
|
|
178
|
-
"""Delete this entity after the operation completes."""
|
|
179
|
-
self._exists = False
|
|
180
|
-
self._state = None
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
def from_json_util(json_str: str) -> Any:
|
|
184
|
-
"""Load an arbitrary datatype from its JSON representation.
|
|
185
|
-
|
|
186
|
-
The Out-of-proc SDK has a special JSON encoding strategy
|
|
187
|
-
to enable arbitrary datatypes to be serialized. This utility
|
|
188
|
-
loads a JSON with the assumption that it follows that encoding
|
|
189
|
-
method.
|
|
190
|
-
|
|
191
|
-
Parameters
|
|
192
|
-
----------
|
|
193
|
-
json_str: str
|
|
194
|
-
A JSON-formatted string, from durable-extension
|
|
195
|
-
|
|
196
|
-
Returns
|
|
197
|
-
-------
|
|
198
|
-
Any:
|
|
199
|
-
The original datatype that was serialized
|
|
200
|
-
"""
|
|
201
|
-
return json.loads(json_str, object_hook=_deserialize_custom_object)
|
|
1
|
+
from typing import Optional, Any, Dict, Tuple, List, Callable
|
|
2
|
+
from azure.functions._durable_functions import _deserialize_custom_object
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class DurableEntityContext:
|
|
7
|
+
"""Context of the durable entity context.
|
|
8
|
+
|
|
9
|
+
Describes the API used to specify durable entity user code.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
def __init__(self,
|
|
13
|
+
name: str,
|
|
14
|
+
key: str,
|
|
15
|
+
exists: bool,
|
|
16
|
+
state: Any):
|
|
17
|
+
"""Context of the durable entity context.
|
|
18
|
+
|
|
19
|
+
Describes the API used to specify durable entity user code.
|
|
20
|
+
|
|
21
|
+
Parameters
|
|
22
|
+
----------
|
|
23
|
+
name: str
|
|
24
|
+
The name of the Durable Entity
|
|
25
|
+
key: str
|
|
26
|
+
The key of the Durable Entity
|
|
27
|
+
exists: bool
|
|
28
|
+
Flag to determine if the entity exists
|
|
29
|
+
state: Any
|
|
30
|
+
The internal state of the Durable Entity
|
|
31
|
+
"""
|
|
32
|
+
self._entity_name: str = name
|
|
33
|
+
self._entity_key: str = key
|
|
34
|
+
|
|
35
|
+
self._exists: bool = exists
|
|
36
|
+
self._is_newly_constructed: bool = False
|
|
37
|
+
|
|
38
|
+
self._state: Any = state
|
|
39
|
+
self._input: Any = None
|
|
40
|
+
self._operation: Optional[str] = None
|
|
41
|
+
self._result: Any = None
|
|
42
|
+
|
|
43
|
+
@property
|
|
44
|
+
def entity_name(self) -> str:
|
|
45
|
+
"""Get the name of the Entity.
|
|
46
|
+
|
|
47
|
+
Returns
|
|
48
|
+
-------
|
|
49
|
+
str
|
|
50
|
+
The name of the entity
|
|
51
|
+
"""
|
|
52
|
+
return self._entity_name
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def entity_key(self) -> str:
|
|
56
|
+
"""Get the Entity key.
|
|
57
|
+
|
|
58
|
+
Returns
|
|
59
|
+
-------
|
|
60
|
+
str
|
|
61
|
+
The entity key
|
|
62
|
+
"""
|
|
63
|
+
return self._entity_key
|
|
64
|
+
|
|
65
|
+
@property
|
|
66
|
+
def operation_name(self) -> Optional[str]:
|
|
67
|
+
"""Get the current operation name.
|
|
68
|
+
|
|
69
|
+
Returns
|
|
70
|
+
-------
|
|
71
|
+
Optional[str]
|
|
72
|
+
The current operation name
|
|
73
|
+
"""
|
|
74
|
+
if self._operation is None:
|
|
75
|
+
raise Exception("Entity operation is unassigned")
|
|
76
|
+
return self._operation
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def is_newly_constructed(self) -> bool:
|
|
80
|
+
"""Determine if the Entity was newly constructed.
|
|
81
|
+
|
|
82
|
+
Returns
|
|
83
|
+
-------
|
|
84
|
+
bool
|
|
85
|
+
True if the Entity was newly constructed. False otherwise.
|
|
86
|
+
"""
|
|
87
|
+
# This is not updated at the moment, as its semantics are unclear
|
|
88
|
+
return self._is_newly_constructed
|
|
89
|
+
|
|
90
|
+
@classmethod
|
|
91
|
+
def from_json(cls, json_str: str) -> Tuple['DurableEntityContext', List[Dict[str, Any]]]:
|
|
92
|
+
"""Instantiate a DurableEntityContext from a JSON-formatted string.
|
|
93
|
+
|
|
94
|
+
Parameters
|
|
95
|
+
----------
|
|
96
|
+
json_string: str
|
|
97
|
+
A JSON-formatted string, returned by the durable-extension,
|
|
98
|
+
which represents the entity context
|
|
99
|
+
|
|
100
|
+
Returns
|
|
101
|
+
-------
|
|
102
|
+
DurableEntityContext
|
|
103
|
+
The DurableEntityContext originated from the input string
|
|
104
|
+
"""
|
|
105
|
+
json_dict = json.loads(json_str)
|
|
106
|
+
json_dict["name"] = json_dict["self"]["name"]
|
|
107
|
+
json_dict["key"] = json_dict["self"]["key"]
|
|
108
|
+
json_dict.pop("self")
|
|
109
|
+
|
|
110
|
+
serialized_state = json_dict["state"]
|
|
111
|
+
if serialized_state is not None:
|
|
112
|
+
json_dict["state"] = from_json_util(serialized_state)
|
|
113
|
+
|
|
114
|
+
batch = json_dict.pop("batch")
|
|
115
|
+
return cls(**json_dict), batch
|
|
116
|
+
|
|
117
|
+
def set_state(self, state: Any) -> None:
|
|
118
|
+
"""Set the state of the entity.
|
|
119
|
+
|
|
120
|
+
Parameter
|
|
121
|
+
---------
|
|
122
|
+
state: Any
|
|
123
|
+
The new state of the entity
|
|
124
|
+
"""
|
|
125
|
+
self._exists = True
|
|
126
|
+
|
|
127
|
+
# should only serialize the state at the end of the batch
|
|
128
|
+
self._state = state
|
|
129
|
+
|
|
130
|
+
def get_state(self, initializer: Optional[Callable[[], Any]] = None) -> Any:
|
|
131
|
+
"""Get the current state of this entity.
|
|
132
|
+
|
|
133
|
+
Parameters
|
|
134
|
+
----------
|
|
135
|
+
initializer: Optional[Callable[[], Any]]
|
|
136
|
+
A 0-argument function to provide an initial state. Defaults to None.
|
|
137
|
+
|
|
138
|
+
Returns
|
|
139
|
+
-------
|
|
140
|
+
Any
|
|
141
|
+
The current state of the entity
|
|
142
|
+
"""
|
|
143
|
+
state = self._state
|
|
144
|
+
if state is not None:
|
|
145
|
+
return state
|
|
146
|
+
elif initializer:
|
|
147
|
+
if not callable(initializer):
|
|
148
|
+
raise Exception("initializer argument needs to be a callable function")
|
|
149
|
+
state = initializer()
|
|
150
|
+
return state
|
|
151
|
+
|
|
152
|
+
def get_input(self) -> Any:
|
|
153
|
+
"""Get the input for this operation.
|
|
154
|
+
|
|
155
|
+
Returns
|
|
156
|
+
-------
|
|
157
|
+
Any
|
|
158
|
+
The input for the current operation
|
|
159
|
+
"""
|
|
160
|
+
input_ = None
|
|
161
|
+
req_input = self._input
|
|
162
|
+
req_input = json.loads(req_input)
|
|
163
|
+
input_ = None if req_input is None else from_json_util(req_input)
|
|
164
|
+
return input_
|
|
165
|
+
|
|
166
|
+
def set_result(self, result: Any) -> None:
|
|
167
|
+
"""Set the result (return value) of the entity.
|
|
168
|
+
|
|
169
|
+
Paramaters
|
|
170
|
+
----------
|
|
171
|
+
result: Any
|
|
172
|
+
The result / return value for the entity
|
|
173
|
+
"""
|
|
174
|
+
self._exists = True
|
|
175
|
+
self._result = result
|
|
176
|
+
|
|
177
|
+
def destruct_on_exit(self) -> None:
|
|
178
|
+
"""Delete this entity after the operation completes."""
|
|
179
|
+
self._exists = False
|
|
180
|
+
self._state = None
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def from_json_util(json_str: str) -> Any:
|
|
184
|
+
"""Load an arbitrary datatype from its JSON representation.
|
|
185
|
+
|
|
186
|
+
The Out-of-proc SDK has a special JSON encoding strategy
|
|
187
|
+
to enable arbitrary datatypes to be serialized. This utility
|
|
188
|
+
loads a JSON with the assumption that it follows that encoding
|
|
189
|
+
method.
|
|
190
|
+
|
|
191
|
+
Parameters
|
|
192
|
+
----------
|
|
193
|
+
json_str: str
|
|
194
|
+
A JSON-formatted string, from durable-extension
|
|
195
|
+
|
|
196
|
+
Returns
|
|
197
|
+
-------
|
|
198
|
+
Any:
|
|
199
|
+
The original datatype that was serialized
|
|
200
|
+
"""
|
|
201
|
+
return json.loads(json_str, object_hook=_deserialize_custom_object)
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
from typing import Dict, Union, Optional
|
|
2
|
-
|
|
3
|
-
from azure.durable_functions.models.TokenSource import TokenSource
|
|
4
|
-
from azure.durable_functions.models.utils.json_utils import add_attrib, add_json_attrib
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class DurableHttpRequest:
|
|
8
|
-
"""Data structure representing a durable HTTP request."""
|
|
9
|
-
|
|
10
|
-
def __init__(self, method: str, uri: str, content: Optional[str] = None,
|
|
11
|
-
headers: Optional[Dict[str, str]] = None,
|
|
12
|
-
token_source: Optional[TokenSource] = None):
|
|
13
|
-
self._method: str = method
|
|
14
|
-
self._uri: str = uri
|
|
15
|
-
self._content: Optional[str] = content
|
|
16
|
-
self._headers: Optional[Dict[str, str]] = headers
|
|
17
|
-
self._token_source: Optional[TokenSource] = token_source
|
|
18
|
-
|
|
19
|
-
@property
|
|
20
|
-
def method(self) -> str:
|
|
21
|
-
"""Get the HTTP request method."""
|
|
22
|
-
return self._method
|
|
23
|
-
|
|
24
|
-
@property
|
|
25
|
-
def uri(self) -> str:
|
|
26
|
-
"""Get the HTTP request uri."""
|
|
27
|
-
return self._uri
|
|
28
|
-
|
|
29
|
-
@property
|
|
30
|
-
def content(self) -> Optional[str]:
|
|
31
|
-
"""Get the HTTP request content."""
|
|
32
|
-
return self._content
|
|
33
|
-
|
|
34
|
-
@property
|
|
35
|
-
def headers(self) -> Optional[Dict[str, str]]:
|
|
36
|
-
"""Get the HTTP request headers."""
|
|
37
|
-
return self._headers
|
|
38
|
-
|
|
39
|
-
@property
|
|
40
|
-
def token_source(self) -> Optional[TokenSource]:
|
|
41
|
-
"""Get the source of OAuth token to add to the request."""
|
|
42
|
-
return self._token_source
|
|
43
|
-
|
|
44
|
-
def to_json(self) -> Dict[str, Union[str, int]]:
|
|
45
|
-
"""Convert object into a json dictionary.
|
|
46
|
-
|
|
47
|
-
Returns
|
|
48
|
-
-------
|
|
49
|
-
Dict[str, Union[str, int]]
|
|
50
|
-
The instance of the class converted into a json dictionary
|
|
51
|
-
"""
|
|
52
|
-
json_dict: Dict[str, Union[str, int]] = {}
|
|
53
|
-
add_attrib(json_dict, self, 'method')
|
|
54
|
-
add_attrib(json_dict, self, 'uri')
|
|
55
|
-
add_attrib(json_dict, self, 'content')
|
|
56
|
-
add_attrib(json_dict, self, 'headers')
|
|
57
|
-
add_json_attrib(json_dict, self, 'token_source', 'tokenSource')
|
|
58
|
-
return json_dict
|
|
1
|
+
from typing import Dict, Union, Optional
|
|
2
|
+
|
|
3
|
+
from azure.durable_functions.models.TokenSource import TokenSource
|
|
4
|
+
from azure.durable_functions.models.utils.json_utils import add_attrib, add_json_attrib
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class DurableHttpRequest:
|
|
8
|
+
"""Data structure representing a durable HTTP request."""
|
|
9
|
+
|
|
10
|
+
def __init__(self, method: str, uri: str, content: Optional[str] = None,
|
|
11
|
+
headers: Optional[Dict[str, str]] = None,
|
|
12
|
+
token_source: Optional[TokenSource] = None):
|
|
13
|
+
self._method: str = method
|
|
14
|
+
self._uri: str = uri
|
|
15
|
+
self._content: Optional[str] = content
|
|
16
|
+
self._headers: Optional[Dict[str, str]] = headers
|
|
17
|
+
self._token_source: Optional[TokenSource] = token_source
|
|
18
|
+
|
|
19
|
+
@property
|
|
20
|
+
def method(self) -> str:
|
|
21
|
+
"""Get the HTTP request method."""
|
|
22
|
+
return self._method
|
|
23
|
+
|
|
24
|
+
@property
|
|
25
|
+
def uri(self) -> str:
|
|
26
|
+
"""Get the HTTP request uri."""
|
|
27
|
+
return self._uri
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def content(self) -> Optional[str]:
|
|
31
|
+
"""Get the HTTP request content."""
|
|
32
|
+
return self._content
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def headers(self) -> Optional[Dict[str, str]]:
|
|
36
|
+
"""Get the HTTP request headers."""
|
|
37
|
+
return self._headers
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def token_source(self) -> Optional[TokenSource]:
|
|
41
|
+
"""Get the source of OAuth token to add to the request."""
|
|
42
|
+
return self._token_source
|
|
43
|
+
|
|
44
|
+
def to_json(self) -> Dict[str, Union[str, int]]:
|
|
45
|
+
"""Convert object into a json dictionary.
|
|
46
|
+
|
|
47
|
+
Returns
|
|
48
|
+
-------
|
|
49
|
+
Dict[str, Union[str, int]]
|
|
50
|
+
The instance of the class converted into a json dictionary
|
|
51
|
+
"""
|
|
52
|
+
json_dict: Dict[str, Union[str, int]] = {}
|
|
53
|
+
add_attrib(json_dict, self, 'method')
|
|
54
|
+
add_attrib(json_dict, self, 'uri')
|
|
55
|
+
add_attrib(json_dict, self, 'content')
|
|
56
|
+
add_attrib(json_dict, self, 'headers')
|
|
57
|
+
add_json_attrib(json_dict, self, 'token_source', 'tokenSource')
|
|
58
|
+
return json_dict
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import json
|
|
2
|
-
from typing import Dict, Optional
|
|
3
|
-
|
|
4
|
-
from azure.durable_functions.models.FunctionContext import FunctionContext
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class DurableOrchestrationBindings:
|
|
8
|
-
"""Binding information.
|
|
9
|
-
|
|
10
|
-
Provides information relevant to the creation and management of
|
|
11
|
-
durable functions.
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
# parameter names are as defined by JSON schema and do not conform to PEP8 naming conventions
|
|
15
|
-
def __init__(self, taskHubName: str, creationUrls: Dict[str, str],
|
|
16
|
-
managementUrls: Dict[str, str], rpcBaseUrl: Optional[str] = None, **kwargs):
|
|
17
|
-
self._task_hub_name: str = taskHubName
|
|
18
|
-
self._creation_urls: Dict[str, str] = creationUrls
|
|
19
|
-
self._management_urls: Dict[str, str] = managementUrls
|
|
20
|
-
# TODO: we can remove the Optional once we drop support for 1.x,
|
|
21
|
-
# this is always provided in 2.x
|
|
22
|
-
self._rpc_base_url: Optional[str] = rpcBaseUrl
|
|
23
|
-
self._client_data = FunctionContext(**kwargs)
|
|
24
|
-
|
|
25
|
-
@property
|
|
26
|
-
def task_hub_name(self) -> str:
|
|
27
|
-
"""Get the name of the container that is used for orchestrations."""
|
|
28
|
-
return self._task_hub_name
|
|
29
|
-
|
|
30
|
-
@property
|
|
31
|
-
def creation_urls(self) -> Dict[str, str]:
|
|
32
|
-
"""Get the URLs that are used for creating new orchestrations."""
|
|
33
|
-
return self._creation_urls
|
|
34
|
-
|
|
35
|
-
@property
|
|
36
|
-
def management_urls(self) -> Dict[str, str]:
|
|
37
|
-
"""Get the URLs that are used for managing orchestrations."""
|
|
38
|
-
return self._management_urls
|
|
39
|
-
|
|
40
|
-
@property
|
|
41
|
-
def rpc_base_url(self) -> Optional[str]:
|
|
42
|
-
"""Get the base url communication between out of proc workers and the function host."""
|
|
43
|
-
return self._rpc_base_url
|
|
44
|
-
|
|
45
|
-
@property
|
|
46
|
-
def client_data(self) -> FunctionContext:
|
|
47
|
-
"""Get any additional client data provided within the context of the client."""
|
|
48
|
-
return self._client_data
|
|
49
|
-
|
|
50
|
-
@classmethod
|
|
51
|
-
def from_json(cls, json_string):
|
|
52
|
-
"""Convert the value passed into a new instance of the class.
|
|
53
|
-
|
|
54
|
-
Parameters
|
|
55
|
-
----------
|
|
56
|
-
json_string
|
|
57
|
-
Context passed a JSON serializable value to be converted into an
|
|
58
|
-
instance of the class
|
|
59
|
-
|
|
60
|
-
Returns
|
|
61
|
-
-------
|
|
62
|
-
DurableOrchestrationBindings
|
|
63
|
-
New instance of the durable orchestration binding class
|
|
64
|
-
"""
|
|
65
|
-
json_dict = json.loads(json_string)
|
|
66
|
-
return cls(**json_dict)
|
|
1
|
+
import json
|
|
2
|
+
from typing import Dict, Optional
|
|
3
|
+
|
|
4
|
+
from azure.durable_functions.models.FunctionContext import FunctionContext
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class DurableOrchestrationBindings:
|
|
8
|
+
"""Binding information.
|
|
9
|
+
|
|
10
|
+
Provides information relevant to the creation and management of
|
|
11
|
+
durable functions.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
# parameter names are as defined by JSON schema and do not conform to PEP8 naming conventions
|
|
15
|
+
def __init__(self, taskHubName: str, creationUrls: Dict[str, str],
|
|
16
|
+
managementUrls: Dict[str, str], rpcBaseUrl: Optional[str] = None, **kwargs):
|
|
17
|
+
self._task_hub_name: str = taskHubName
|
|
18
|
+
self._creation_urls: Dict[str, str] = creationUrls
|
|
19
|
+
self._management_urls: Dict[str, str] = managementUrls
|
|
20
|
+
# TODO: we can remove the Optional once we drop support for 1.x,
|
|
21
|
+
# this is always provided in 2.x
|
|
22
|
+
self._rpc_base_url: Optional[str] = rpcBaseUrl
|
|
23
|
+
self._client_data = FunctionContext(**kwargs)
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def task_hub_name(self) -> str:
|
|
27
|
+
"""Get the name of the container that is used for orchestrations."""
|
|
28
|
+
return self._task_hub_name
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def creation_urls(self) -> Dict[str, str]:
|
|
32
|
+
"""Get the URLs that are used for creating new orchestrations."""
|
|
33
|
+
return self._creation_urls
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
def management_urls(self) -> Dict[str, str]:
|
|
37
|
+
"""Get the URLs that are used for managing orchestrations."""
|
|
38
|
+
return self._management_urls
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def rpc_base_url(self) -> Optional[str]:
|
|
42
|
+
"""Get the base url communication between out of proc workers and the function host."""
|
|
43
|
+
return self._rpc_base_url
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def client_data(self) -> FunctionContext:
|
|
47
|
+
"""Get any additional client data provided within the context of the client."""
|
|
48
|
+
return self._client_data
|
|
49
|
+
|
|
50
|
+
@classmethod
|
|
51
|
+
def from_json(cls, json_string):
|
|
52
|
+
"""Convert the value passed into a new instance of the class.
|
|
53
|
+
|
|
54
|
+
Parameters
|
|
55
|
+
----------
|
|
56
|
+
json_string
|
|
57
|
+
Context passed a JSON serializable value to be converted into an
|
|
58
|
+
instance of the class
|
|
59
|
+
|
|
60
|
+
Returns
|
|
61
|
+
-------
|
|
62
|
+
DurableOrchestrationBindings
|
|
63
|
+
New instance of the durable orchestration binding class
|
|
64
|
+
"""
|
|
65
|
+
json_dict = json.loads(json_string)
|
|
66
|
+
return cls(**json_dict)
|