Skip to content

Commit 4d709be

Browse files
authored
CreateHttpManagementPayload (#162)
* implemented httpManagementPayload * removed whitespace * improved docstring: return type * improved docstring: return type of get_client_response_links * improved typehints
1 parent 8da0ac3 commit 4d709be

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

azure/durable_functions/models/DurableOrchestrationClient.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json
22
from datetime import datetime
3-
from typing import List, Any, Awaitable
3+
from typing import List, Any, Awaitable, Optional, Dict
44
from time import time
55
from asyncio import sleep
66
from urllib.parse import urlparse, quote
@@ -113,25 +113,43 @@ def create_check_status_response(self, request, instance_id):
113113
}
114114
return func.HttpResponse(**response_args)
115115

116-
def get_client_response_links(self, request, instance_id):
116+
def create_http_management_payload(self, instance_id: str) -> Dict[str, str]:
117117
"""Create a dictionary of orchestrator management urls.
118118
119119
Parameters
120120
----------
121-
request : HttpRequest
121+
instance_id : str
122+
The ID of the orchestration instance to check.
123+
124+
Returns
125+
-------
126+
Dict[str, str]
127+
a dictionary object of orchestrator instance management urls
128+
"""
129+
return self.get_client_response_links(None, instance_id)
130+
131+
def get_client_response_links(
132+
self,
133+
request: Optional[func.HttpRequest], instance_id: str) -> Dict[str, str]:
134+
"""Create a dictionary of orchestrator management urls.
135+
136+
Parameters
137+
----------
138+
request : Optional[HttpRequest]
122139
The HTTP request that triggered the current orchestration instance.
123140
instance_id : str
124141
The ID of the orchestration instance to check.
125142
126143
Returns
127144
-------
128-
dict
145+
Dict[str, str]
129146
a dictionary object of orchestrator instance management urls
130147
"""
131148
payload = self._orchestration_bindings.management_urls.copy()
132149

133150
for key, _ in payload.items():
134-
if request.url:
151+
request_is_not_none = not (request is None)
152+
if request_is_not_none and request.url:
135153
payload[key] = self._replace_url_origin(request.url, payload[key])
136154
payload[key] = payload[key].replace(
137155
self._orchestration_bindings.management_urls["id"], instance_id)

0 commit comments

Comments
 (0)