Skip to content

Commit

Permalink
CreateHttpManagementPayload (#162)
Browse files Browse the repository at this point in the history
* implemented httpManagementPayload

* removed whitespace

* improved docstring: return type

* improved docstring: return type of get_client_response_links

* improved typehints
  • Loading branch information
davidmrdavid authored Jul 24, 2020
1 parent 8da0ac3 commit 4d709be
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions azure/durable_functions/models/DurableOrchestrationClient.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from datetime import datetime
from typing import List, Any, Awaitable
from typing import List, Any, Awaitable, Optional, Dict
from time import time
from asyncio import sleep
from urllib.parse import urlparse, quote
Expand Down Expand Up @@ -113,25 +113,43 @@ def create_check_status_response(self, request, instance_id):
}
return func.HttpResponse(**response_args)

def get_client_response_links(self, request, instance_id):
def create_http_management_payload(self, instance_id: str) -> Dict[str, str]:
"""Create a dictionary of orchestrator management urls.
Parameters
----------
request : HttpRequest
instance_id : str
The ID of the orchestration instance to check.
Returns
-------
Dict[str, str]
a dictionary object of orchestrator instance management urls
"""
return self.get_client_response_links(None, instance_id)

def get_client_response_links(
self,
request: Optional[func.HttpRequest], instance_id: str) -> Dict[str, str]:
"""Create a dictionary of orchestrator management urls.
Parameters
----------
request : Optional[HttpRequest]
The HTTP request that triggered the current orchestration instance.
instance_id : str
The ID of the orchestration instance to check.
Returns
-------
dict
Dict[str, str]
a dictionary object of orchestrator instance management urls
"""
payload = self._orchestration_bindings.management_urls.copy()

for key, _ in payload.items():
if request.url:
request_is_not_none = not (request is None)
if request_is_not_none and request.url:
payload[key] = self._replace_url_origin(request.url, payload[key])
payload[key] = payload[key].replace(
self._orchestration_bindings.management_urls["id"], instance_id)
Expand Down

0 comments on commit 4d709be

Please sign in to comment.