azure-functions-durable 1.2.9__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.
Files changed (101) hide show
  1. azure/durable_functions/__init__.py +81 -81
  2. azure/durable_functions/constants.py +9 -9
  3. azure/durable_functions/decorators/__init__.py +3 -3
  4. azure/durable_functions/decorators/durable_app.py +249 -249
  5. azure/durable_functions/decorators/metadata.py +109 -109
  6. azure/durable_functions/entity.py +125 -125
  7. azure/durable_functions/models/DurableEntityContext.py +201 -201
  8. azure/durable_functions/models/DurableHttpRequest.py +58 -58
  9. azure/durable_functions/models/DurableOrchestrationBindings.py +66 -66
  10. azure/durable_functions/models/DurableOrchestrationClient.py +781 -781
  11. azure/durable_functions/models/DurableOrchestrationContext.py +722 -707
  12. azure/durable_functions/models/DurableOrchestrationStatus.py +156 -156
  13. azure/durable_functions/models/EntityStateResponse.py +23 -23
  14. azure/durable_functions/models/FunctionContext.py +7 -7
  15. azure/durable_functions/models/OrchestrationRuntimeStatus.py +32 -32
  16. azure/durable_functions/models/OrchestratorState.py +117 -116
  17. azure/durable_functions/models/PurgeHistoryResult.py +33 -33
  18. azure/durable_functions/models/ReplaySchema.py +8 -8
  19. azure/durable_functions/models/RetryOptions.py +69 -69
  20. azure/durable_functions/models/RpcManagementOptions.py +86 -86
  21. azure/durable_functions/models/Task.py +426 -426
  22. azure/durable_functions/models/TaskOrchestrationExecutor.py +346 -336
  23. azure/durable_functions/models/TokenSource.py +56 -56
  24. azure/durable_functions/models/__init__.py +24 -24
  25. azure/durable_functions/models/actions/Action.py +23 -23
  26. azure/durable_functions/models/actions/ActionType.py +18 -18
  27. azure/durable_functions/models/actions/CallActivityAction.py +41 -41
  28. azure/durable_functions/models/actions/CallActivityWithRetryAction.py +45 -45
  29. azure/durable_functions/models/actions/CallEntityAction.py +46 -46
  30. azure/durable_functions/models/actions/CallHttpAction.py +35 -35
  31. azure/durable_functions/models/actions/CallSubOrchestratorAction.py +40 -40
  32. azure/durable_functions/models/actions/CallSubOrchestratorWithRetryAction.py +44 -44
  33. azure/durable_functions/models/actions/CompoundAction.py +35 -35
  34. azure/durable_functions/models/actions/ContinueAsNewAction.py +36 -36
  35. azure/durable_functions/models/actions/CreateTimerAction.py +48 -48
  36. azure/durable_functions/models/actions/NoOpAction.py +35 -35
  37. azure/durable_functions/models/actions/SignalEntityAction.py +47 -47
  38. azure/durable_functions/models/actions/WaitForExternalEventAction.py +63 -63
  39. azure/durable_functions/models/actions/WhenAllAction.py +14 -14
  40. azure/durable_functions/models/actions/WhenAnyAction.py +14 -14
  41. azure/durable_functions/models/actions/__init__.py +24 -24
  42. azure/durable_functions/models/entities/EntityState.py +74 -74
  43. azure/durable_functions/models/entities/OperationResult.py +76 -76
  44. azure/durable_functions/models/entities/RequestMessage.py +53 -53
  45. azure/durable_functions/models/entities/ResponseMessage.py +48 -48
  46. azure/durable_functions/models/entities/Signal.py +62 -62
  47. azure/durable_functions/models/entities/__init__.py +17 -17
  48. azure/durable_functions/models/history/HistoryEvent.py +92 -92
  49. azure/durable_functions/models/history/HistoryEventType.py +27 -27
  50. azure/durable_functions/models/history/__init__.py +8 -8
  51. azure/durable_functions/models/utils/__init__.py +7 -7
  52. azure/durable_functions/models/utils/entity_utils.py +103 -91
  53. azure/durable_functions/models/utils/http_utils.py +69 -69
  54. azure/durable_functions/models/utils/json_utils.py +56 -56
  55. azure/durable_functions/orchestrator.py +71 -71
  56. {azure_functions_durable-1.2.9.dist-info → azure_functions_durable-1.2.10.dist-info}/LICENSE +21 -21
  57. {azure_functions_durable-1.2.9.dist-info → azure_functions_durable-1.2.10.dist-info}/METADATA +58 -58
  58. azure_functions_durable-1.2.10.dist-info/RECORD +100 -0
  59. tests/models/test_DecoratorMetadata.py +135 -135
  60. tests/models/test_Decorators.py +107 -107
  61. tests/models/test_DurableOrchestrationBindings.py +68 -68
  62. tests/models/test_DurableOrchestrationClient.py +730 -730
  63. tests/models/test_DurableOrchestrationContext.py +102 -102
  64. tests/models/test_DurableOrchestrationStatus.py +59 -59
  65. tests/models/test_OrchestrationState.py +28 -28
  66. tests/models/test_RpcManagementOptions.py +79 -79
  67. tests/models/test_TokenSource.py +10 -10
  68. tests/orchestrator/models/OrchestrationInstance.py +18 -18
  69. tests/orchestrator/orchestrator_test_utils.py +130 -130
  70. tests/orchestrator/schemas/OrchetrationStateSchema.py +66 -66
  71. tests/orchestrator/test_call_http.py +235 -176
  72. tests/orchestrator/test_continue_as_new.py +67 -67
  73. tests/orchestrator/test_create_timer.py +126 -126
  74. tests/orchestrator/test_entity.py +395 -395
  75. tests/orchestrator/test_external_event.py +53 -53
  76. tests/orchestrator/test_fan_out_fan_in.py +175 -175
  77. tests/orchestrator/test_is_replaying_flag.py +101 -101
  78. tests/orchestrator/test_retries.py +308 -308
  79. tests/orchestrator/test_sequential_orchestrator.py +841 -841
  80. tests/orchestrator/test_sequential_orchestrator_custom_status.py +119 -119
  81. tests/orchestrator/test_sequential_orchestrator_with_retry.py +465 -465
  82. tests/orchestrator/test_serialization.py +30 -30
  83. tests/orchestrator/test_sub_orchestrator.py +95 -95
  84. tests/orchestrator/test_sub_orchestrator_with_retry.py +129 -129
  85. tests/orchestrator/test_task_any.py +60 -60
  86. tests/tasks/tasks_test_utils.py +17 -17
  87. tests/tasks/test_new_uuid.py +34 -34
  88. tests/test_utils/ContextBuilder.py +174 -174
  89. tests/test_utils/EntityContextBuilder.py +56 -56
  90. tests/test_utils/constants.py +1 -1
  91. tests/test_utils/json_utils.py +30 -30
  92. tests/test_utils/testClasses.py +56 -56
  93. tests/utils/__init__.py +1 -0
  94. tests/utils/test_entity_utils.py +24 -0
  95. azure_functions_durable-1.2.9.data/data/_manifest/bsi.json +0 -1
  96. azure_functions_durable-1.2.9.data/data/_manifest/manifest.cat +0 -0
  97. azure_functions_durable-1.2.9.data/data/_manifest/manifest.spdx.json +0 -11985
  98. azure_functions_durable-1.2.9.data/data/_manifest/manifest.spdx.json.sha256 +0 -1
  99. azure_functions_durable-1.2.9.dist-info/RECORD +0 -102
  100. {azure_functions_durable-1.2.9.dist-info → azure_functions_durable-1.2.10.dist-info}/WHEEL +0 -0
  101. {azure_functions_durable-1.2.9.dist-info → azure_functions_durable-1.2.10.dist-info}/top_level.txt +0 -0
@@ -1,56 +1,56 @@
1
- from abc import ABC
2
- from typing import Dict, Union
3
-
4
- from azure.durable_functions.models.utils.json_utils import add_attrib
5
-
6
-
7
- class TokenSource(ABC):
8
- """Token Source implementation for [Azure Managed Identities].
9
-
10
- https://docs.microsoft.com/azure/active-directory/managed-identities-azure-resources/overview.
11
-
12
- @example Get a list of Azure Subscriptions by calling the Azure Resource Manager HTTP API.
13
- ```python
14
- import azure.durable_functions as df
15
-
16
- def generator_function(context):
17
- return yield context.callHttp(
18
- "GET",
19
- "https://management.azure.com/subscriptions?api-version=2019-06-01",
20
- None,
21
- None,
22
- df.ManagedIdentityTokenSource("https://management.core.windows.net"))
23
- """
24
-
25
- def __init__(self):
26
- super().__init__()
27
-
28
-
29
- class ManagedIdentityTokenSource(TokenSource):
30
- """Returns a `ManagedIdentityTokenSource` object."""
31
-
32
- def __init__(self, resource: str):
33
- super().__init__()
34
- self._resource: str = resource
35
- self._kind: str = "AzureManagedIdentity"
36
-
37
- @property
38
- def resource(self) -> str:
39
- """Get the Azure Active Directory resource identifier of the web API being invoked.
40
-
41
- For example, `https://management.core.windows.net/` or `https://graph.microsoft.com/`.
42
- """
43
- return self._resource
44
-
45
- def to_json(self) -> Dict[str, Union[str, int]]:
46
- """Convert object into a json dictionary.
47
-
48
- Returns
49
- -------
50
- Dict[str, Any]
51
- The instance of the class converted into a json dictionary
52
- """
53
- json_dict: Dict[str, Union[str, int]] = {}
54
- add_attrib(json_dict, self, 'resource')
55
- json_dict["kind"] = self._kind
56
- return json_dict
1
+ from abc import ABC
2
+ from typing import Dict, Union
3
+
4
+ from azure.durable_functions.models.utils.json_utils import add_attrib
5
+
6
+
7
+ class TokenSource(ABC):
8
+ """Token Source implementation for [Azure Managed Identities].
9
+
10
+ https://docs.microsoft.com/azure/active-directory/managed-identities-azure-resources/overview.
11
+
12
+ @example Get a list of Azure Subscriptions by calling the Azure Resource Manager HTTP API.
13
+ ```python
14
+ import azure.durable_functions as df
15
+
16
+ def generator_function(context):
17
+ return yield context.callHttp(
18
+ "GET",
19
+ "https://management.azure.com/subscriptions?api-version=2019-06-01",
20
+ None,
21
+ None,
22
+ df.ManagedIdentityTokenSource("https://management.core.windows.net"))
23
+ """
24
+
25
+ def __init__(self):
26
+ super().__init__()
27
+
28
+
29
+ class ManagedIdentityTokenSource(TokenSource):
30
+ """Returns a `ManagedIdentityTokenSource` object."""
31
+
32
+ def __init__(self, resource: str):
33
+ super().__init__()
34
+ self._resource: str = resource
35
+ self._kind: str = "AzureManagedIdentity"
36
+
37
+ @property
38
+ def resource(self) -> str:
39
+ """Get the Azure Active Directory resource identifier of the web API being invoked.
40
+
41
+ For example, `https://management.core.windows.net/` or `https://graph.microsoft.com/`.
42
+ """
43
+ return self._resource
44
+
45
+ def to_json(self) -> Dict[str, Union[str, int]]:
46
+ """Convert object into a json dictionary.
47
+
48
+ Returns
49
+ -------
50
+ Dict[str, Any]
51
+ The instance of the class converted into a json dictionary
52
+ """
53
+ json_dict: Dict[str, Union[str, int]] = {}
54
+ add_attrib(json_dict, self, 'resource')
55
+ json_dict["kind"] = self._kind
56
+ return json_dict
@@ -1,24 +1,24 @@
1
- """Model definitions for Durable Functions."""
2
- from .DurableOrchestrationBindings import DurableOrchestrationBindings
3
- from .DurableOrchestrationClient import DurableOrchestrationClient
4
- from .DurableOrchestrationContext import DurableOrchestrationContext
5
- from .OrchestratorState import OrchestratorState
6
- from .OrchestrationRuntimeStatus import OrchestrationRuntimeStatus
7
- from .PurgeHistoryResult import PurgeHistoryResult
8
- from .RetryOptions import RetryOptions
9
- from .DurableHttpRequest import DurableHttpRequest
10
- from .TokenSource import ManagedIdentityTokenSource
11
- from .DurableEntityContext import DurableEntityContext
12
-
13
- __all__ = [
14
- 'DurableOrchestrationBindings',
15
- 'DurableOrchestrationClient',
16
- 'DurableEntityContext',
17
- 'DurableOrchestrationContext',
18
- 'DurableHttpRequest',
19
- 'ManagedIdentityTokenSource',
20
- 'OrchestratorState',
21
- 'OrchestrationRuntimeStatus',
22
- 'PurgeHistoryResult',
23
- 'RetryOptions'
24
- ]
1
+ """Model definitions for Durable Functions."""
2
+ from .DurableOrchestrationBindings import DurableOrchestrationBindings
3
+ from .DurableOrchestrationClient import DurableOrchestrationClient
4
+ from .DurableOrchestrationContext import DurableOrchestrationContext
5
+ from .OrchestratorState import OrchestratorState
6
+ from .OrchestrationRuntimeStatus import OrchestrationRuntimeStatus
7
+ from .PurgeHistoryResult import PurgeHistoryResult
8
+ from .RetryOptions import RetryOptions
9
+ from .DurableHttpRequest import DurableHttpRequest
10
+ from .TokenSource import ManagedIdentityTokenSource
11
+ from .DurableEntityContext import DurableEntityContext
12
+
13
+ __all__ = [
14
+ 'DurableOrchestrationBindings',
15
+ 'DurableOrchestrationClient',
16
+ 'DurableEntityContext',
17
+ 'DurableOrchestrationContext',
18
+ 'DurableHttpRequest',
19
+ 'ManagedIdentityTokenSource',
20
+ 'OrchestratorState',
21
+ 'OrchestrationRuntimeStatus',
22
+ 'PurgeHistoryResult',
23
+ 'RetryOptions'
24
+ ]
@@ -1,23 +1,23 @@
1
- from typing import Dict, Any
2
- from abc import ABC, abstractmethod
3
-
4
-
5
- class Action(ABC):
6
- """Defines the base abstract class for Actions that need to be implemented."""
7
-
8
- @property
9
- @abstractmethod
10
- def action_type(self) -> int:
11
- """Get the type of action this class represents."""
12
- pass
13
-
14
- @abstractmethod
15
- def to_json(self) -> Dict[str, Any]:
16
- """Convert object into a json dictionary.
17
-
18
- Returns
19
- -------
20
- Dict[str, Any]
21
- The instance of the class converted into a json dictionary
22
- """
23
- pass
1
+ from typing import Dict, Any
2
+ from abc import ABC, abstractmethod
3
+
4
+
5
+ class Action(ABC):
6
+ """Defines the base abstract class for Actions that need to be implemented."""
7
+
8
+ @property
9
+ @abstractmethod
10
+ def action_type(self) -> int:
11
+ """Get the type of action this class represents."""
12
+ pass
13
+
14
+ @abstractmethod
15
+ def to_json(self) -> Dict[str, Any]:
16
+ """Convert object into a json dictionary.
17
+
18
+ Returns
19
+ -------
20
+ Dict[str, Any]
21
+ The instance of the class converted into a json dictionary
22
+ """
23
+ pass
@@ -1,18 +1,18 @@
1
- from enum import IntEnum
2
-
3
-
4
- class ActionType(IntEnum):
5
- """Defines the values associated to the types of activities that can be scheduled."""
6
-
7
- CALL_ACTIVITY: int = 0
8
- CALL_ACTIVITY_WITH_RETRY: int = 1
9
- CALL_SUB_ORCHESTRATOR: int = 2
10
- CALL_SUB_ORCHESTRATOR_WITH_RETRY: int = 3
11
- CONTINUE_AS_NEW: int = 4
12
- CREATE_TIMER: int = 5
13
- WAIT_FOR_EXTERNAL_EVENT: int = 6
14
- CALL_ENTITY = 7
15
- CALL_HTTP: int = 8
16
- SIGNAL_ENTITY: int = 9
17
- WHEN_ANY = 11
18
- WHEN_ALL = 12
1
+ from enum import IntEnum
2
+
3
+
4
+ class ActionType(IntEnum):
5
+ """Defines the values associated to the types of activities that can be scheduled."""
6
+
7
+ CALL_ACTIVITY: int = 0
8
+ CALL_ACTIVITY_WITH_RETRY: int = 1
9
+ CALL_SUB_ORCHESTRATOR: int = 2
10
+ CALL_SUB_ORCHESTRATOR_WITH_RETRY: int = 3
11
+ CONTINUE_AS_NEW: int = 4
12
+ CREATE_TIMER: int = 5
13
+ WAIT_FOR_EXTERNAL_EVENT: int = 6
14
+ CALL_ENTITY = 7
15
+ CALL_HTTP: int = 8
16
+ SIGNAL_ENTITY: int = 9
17
+ WHEN_ANY = 11
18
+ WHEN_ALL = 12
@@ -1,41 +1,41 @@
1
- from typing import Dict, Union
2
-
3
- from .Action import Action
4
- from .ActionType import ActionType
5
- from ..utils.json_utils import add_attrib
6
- from json import dumps
7
- from azure.functions._durable_functions import _serialize_custom_object
8
-
9
-
10
- class CallActivityAction(Action):
11
- """Defines the structure of the Call Activity object.
12
-
13
- Provides the information needed by the durable extension to be able to schedule the activity.
14
- """
15
-
16
- def __init__(self, function_name: str, input_=None):
17
- self.function_name: str = function_name
18
- # It appears that `.input_` needs to be JSON-serializable at this point
19
- self.input_ = dumps(input_, default=_serialize_custom_object)
20
-
21
- if not self.function_name:
22
- raise ValueError("function_name cannot be empty")
23
-
24
- @property
25
- def action_type(self) -> int:
26
- """Get the type of action this class represents."""
27
- return ActionType.CALL_ACTIVITY
28
-
29
- def to_json(self) -> Dict[str, Union[str, int]]:
30
- """Convert object into a json dictionary.
31
-
32
- Returns
33
- -------
34
- Dict[str, Union[str, int]]
35
- The instance of the class converted into a json dictionary
36
- """
37
- json_dict: Dict[str, Union[str, int]] = {}
38
- add_attrib(json_dict, self, 'action_type', 'actionType')
39
- add_attrib(json_dict, self, 'function_name', 'functionName')
40
- add_attrib(json_dict, self, 'input_', 'input')
41
- return json_dict
1
+ from typing import Dict, Union
2
+
3
+ from .Action import Action
4
+ from .ActionType import ActionType
5
+ from ..utils.json_utils import add_attrib
6
+ from json import dumps
7
+ from azure.functions._durable_functions import _serialize_custom_object
8
+
9
+
10
+ class CallActivityAction(Action):
11
+ """Defines the structure of the Call Activity object.
12
+
13
+ Provides the information needed by the durable extension to be able to schedule the activity.
14
+ """
15
+
16
+ def __init__(self, function_name: str, input_=None):
17
+ self.function_name: str = function_name
18
+ # It appears that `.input_` needs to be JSON-serializable at this point
19
+ self.input_ = dumps(input_, default=_serialize_custom_object)
20
+
21
+ if not self.function_name:
22
+ raise ValueError("function_name cannot be empty")
23
+
24
+ @property
25
+ def action_type(self) -> int:
26
+ """Get the type of action this class represents."""
27
+ return ActionType.CALL_ACTIVITY
28
+
29
+ def to_json(self) -> Dict[str, Union[str, int]]:
30
+ """Convert object into a json dictionary.
31
+
32
+ Returns
33
+ -------
34
+ Dict[str, Union[str, int]]
35
+ The instance of the class converted into a json dictionary
36
+ """
37
+ json_dict: Dict[str, Union[str, int]] = {}
38
+ add_attrib(json_dict, self, 'action_type', 'actionType')
39
+ add_attrib(json_dict, self, 'function_name', 'functionName')
40
+ add_attrib(json_dict, self, 'input_', 'input')
41
+ return json_dict
@@ -1,45 +1,45 @@
1
- from json import dumps
2
- from typing import Dict, Union
3
-
4
- from .Action import Action
5
- from .ActionType import ActionType
6
- from ..RetryOptions import RetryOptions
7
- from ..utils.json_utils import add_attrib, add_json_attrib
8
- from azure.functions._durable_functions import _serialize_custom_object
9
-
10
-
11
- class CallActivityWithRetryAction(Action):
12
- """Defines the structure of the Call Activity With Retry object.
13
-
14
- Provides the information needed by the durable extension to be able to schedule the activity.
15
- """
16
-
17
- def __init__(self, function_name: str,
18
- retry_options: RetryOptions, input_=None):
19
- self.function_name: str = function_name
20
- self.retry_options: RetryOptions = retry_options
21
- self.input_ = dumps(input_, default=_serialize_custom_object)
22
-
23
- if not self.function_name:
24
- raise ValueError("function_name cannot be empty")
25
-
26
- @property
27
- def action_type(self) -> int:
28
- """Get the type of action this class represents."""
29
- return ActionType.CALL_ACTIVITY_WITH_RETRY
30
-
31
- def to_json(self) -> Dict[str, Union[str, int]]:
32
- """Convert object into a json dictionary.
33
-
34
- Returns
35
- -------
36
- Dict[str, Union[str, int]]
37
- The instance of the class converted into a json dictionary
38
- """
39
- json_dict: Dict[str, Union[str, int]] = {}
40
-
41
- add_attrib(json_dict, self, 'action_type', 'actionType')
42
- add_attrib(json_dict, self, 'function_name', 'functionName')
43
- add_attrib(json_dict, self, 'input_', 'input')
44
- add_json_attrib(json_dict, self, 'retry_options', 'retryOptions')
45
- return json_dict
1
+ from json import dumps
2
+ from typing import Dict, Union
3
+
4
+ from .Action import Action
5
+ from .ActionType import ActionType
6
+ from ..RetryOptions import RetryOptions
7
+ from ..utils.json_utils import add_attrib, add_json_attrib
8
+ from azure.functions._durable_functions import _serialize_custom_object
9
+
10
+
11
+ class CallActivityWithRetryAction(Action):
12
+ """Defines the structure of the Call Activity With Retry object.
13
+
14
+ Provides the information needed by the durable extension to be able to schedule the activity.
15
+ """
16
+
17
+ def __init__(self, function_name: str,
18
+ retry_options: RetryOptions, input_=None):
19
+ self.function_name: str = function_name
20
+ self.retry_options: RetryOptions = retry_options
21
+ self.input_ = dumps(input_, default=_serialize_custom_object)
22
+
23
+ if not self.function_name:
24
+ raise ValueError("function_name cannot be empty")
25
+
26
+ @property
27
+ def action_type(self) -> int:
28
+ """Get the type of action this class represents."""
29
+ return ActionType.CALL_ACTIVITY_WITH_RETRY
30
+
31
+ def to_json(self) -> Dict[str, Union[str, int]]:
32
+ """Convert object into a json dictionary.
33
+
34
+ Returns
35
+ -------
36
+ Dict[str, Union[str, int]]
37
+ The instance of the class converted into a json dictionary
38
+ """
39
+ json_dict: Dict[str, Union[str, int]] = {}
40
+
41
+ add_attrib(json_dict, self, 'action_type', 'actionType')
42
+ add_attrib(json_dict, self, 'function_name', 'functionName')
43
+ add_attrib(json_dict, self, 'input_', 'input')
44
+ add_json_attrib(json_dict, self, 'retry_options', 'retryOptions')
45
+ return json_dict
@@ -1,46 +1,46 @@
1
- from typing import Any, Dict
2
-
3
- from .Action import Action
4
- from .ActionType import ActionType
5
- from ..utils.json_utils import add_attrib
6
- from json import dumps
7
- from azure.functions._durable_functions import _serialize_custom_object
8
- from ..utils.entity_utils import EntityId
9
-
10
-
11
- class CallEntityAction(Action):
12
- """Defines the structure of the Call Entity object.
13
-
14
- Provides the information needed by the durable extension to be able to call an activity
15
- """
16
-
17
- def __init__(self, entity_id: EntityId, operation: str, input_=None):
18
- self.entity_id: EntityId = entity_id
19
-
20
- # Validating that EntityId exists before trying to parse its instanceId
21
- if not self.entity_id:
22
- raise ValueError("entity_id cannot be empty")
23
-
24
- self.instance_id: str = EntityId.get_scheduler_id(entity_id)
25
- self.operation: str = operation
26
- self.input_: str = dumps(input_, default=_serialize_custom_object)
27
-
28
- @property
29
- def action_type(self) -> int:
30
- """Get the type of action this class represents."""
31
- return ActionType.CALL_ENTITY
32
-
33
- def to_json(self) -> Dict[str, Any]:
34
- """Convert object into a json dictionary.
35
-
36
- Returns
37
- -------
38
- Dict[str, Any]
39
- The instance of the class converted into a json dictionary
40
- """
41
- json_dict: Dict[str, Any] = {}
42
- add_attrib(json_dict, self, "action_type", "actionType")
43
- add_attrib(json_dict, self, 'instance_id', 'instanceId')
44
- add_attrib(json_dict, self, 'operation', 'operation')
45
- add_attrib(json_dict, self, 'input_', 'input')
46
- return json_dict
1
+ from typing import Any, Dict
2
+
3
+ from .Action import Action
4
+ from .ActionType import ActionType
5
+ from ..utils.json_utils import add_attrib
6
+ from json import dumps
7
+ from azure.functions._durable_functions import _serialize_custom_object
8
+ from ..utils.entity_utils import EntityId
9
+
10
+
11
+ class CallEntityAction(Action):
12
+ """Defines the structure of the Call Entity object.
13
+
14
+ Provides the information needed by the durable extension to be able to call an activity
15
+ """
16
+
17
+ def __init__(self, entity_id: EntityId, operation: str, input_=None):
18
+ self.entity_id: EntityId = entity_id
19
+
20
+ # Validating that EntityId exists before trying to parse its instanceId
21
+ if not self.entity_id:
22
+ raise ValueError("entity_id cannot be empty")
23
+
24
+ self.instance_id: str = EntityId.get_scheduler_id(entity_id)
25
+ self.operation: str = operation
26
+ self.input_: str = dumps(input_, default=_serialize_custom_object)
27
+
28
+ @property
29
+ def action_type(self) -> int:
30
+ """Get the type of action this class represents."""
31
+ return ActionType.CALL_ENTITY
32
+
33
+ def to_json(self) -> Dict[str, Any]:
34
+ """Convert object into a json dictionary.
35
+
36
+ Returns
37
+ -------
38
+ Dict[str, Any]
39
+ The instance of the class converted into a json dictionary
40
+ """
41
+ json_dict: Dict[str, Any] = {}
42
+ add_attrib(json_dict, self, "action_type", "actionType")
43
+ add_attrib(json_dict, self, 'instance_id', 'instanceId')
44
+ add_attrib(json_dict, self, 'operation', 'operation')
45
+ add_attrib(json_dict, self, 'input_', 'input')
46
+ return json_dict
@@ -1,35 +1,35 @@
1
- from typing import Any, Dict
2
-
3
- from .Action import Action
4
- from .ActionType import ActionType
5
- from ..DurableHttpRequest import DurableHttpRequest
6
- from ..utils.json_utils import add_attrib, add_json_attrib
7
-
8
-
9
- class CallHttpAction(Action):
10
- """Defines the structure of the Call Http object.
11
-
12
- Provides the information needed by the durable extension to be able to schedule the activity.
13
- """
14
-
15
- def __init__(self, http_request: DurableHttpRequest):
16
- self._action_type: int = ActionType.CALL_HTTP
17
- self.http_request = http_request
18
-
19
- @property
20
- def action_type(self) -> int:
21
- """Get the type of action this class represents."""
22
- return ActionType.CALL_HTTP
23
-
24
- def to_json(self) -> Dict[str, Any]:
25
- """Convert object into a json dictionary.
26
-
27
- Returns
28
- -------
29
- Dict[str, Any]
30
- The instance of the class converted into a json dictionary
31
- """
32
- json_dict: Dict[str, Any] = {}
33
- add_attrib(json_dict, self, 'action_type', 'actionType')
34
- add_json_attrib(json_dict, self, 'http_request', 'httpRequest')
35
- return json_dict
1
+ from typing import Any, Dict
2
+
3
+ from .Action import Action
4
+ from .ActionType import ActionType
5
+ from ..DurableHttpRequest import DurableHttpRequest
6
+ from ..utils.json_utils import add_attrib, add_json_attrib
7
+
8
+
9
+ class CallHttpAction(Action):
10
+ """Defines the structure of the Call Http object.
11
+
12
+ Provides the information needed by the durable extension to be able to schedule the activity.
13
+ """
14
+
15
+ def __init__(self, http_request: DurableHttpRequest):
16
+ self._action_type: int = ActionType.CALL_HTTP
17
+ self.http_request = http_request
18
+
19
+ @property
20
+ def action_type(self) -> int:
21
+ """Get the type of action this class represents."""
22
+ return ActionType.CALL_HTTP
23
+
24
+ def to_json(self) -> Dict[str, Any]:
25
+ """Convert object into a json dictionary.
26
+
27
+ Returns
28
+ -------
29
+ Dict[str, Any]
30
+ The instance of the class converted into a json dictionary
31
+ """
32
+ json_dict: Dict[str, Any] = {}
33
+ add_attrib(json_dict, self, 'action_type', 'actionType')
34
+ add_json_attrib(json_dict, self, 'http_request', 'httpRequest')
35
+ return json_dict