-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathget_service_url.py
More file actions
24 lines (18 loc) · 967 Bytes
/
get_service_url.py
File metadata and controls
24 lines (18 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from common.constants import DEFAULT_BASE_PATH, PR_ENV_PREFIX
def get_service_url(service_env: str | None, service_base_path: str | None) -> str:
"""Sets the service URL based on service parameters derived from env vars. PR environments use internal-dev while
we also default to this environment. The only other exceptions are preprod which maps to the Apigee int environment
and prod which does not have a subdomain."""
if not service_base_path:
service_base_path = DEFAULT_BASE_PATH
if service_env is None or is_pr_env(service_env):
subdomain = "internal-dev."
elif service_env == "preprod":
subdomain = "int."
elif service_env == "prod":
subdomain = ""
else:
subdomain = f"{service_env}."
return f"https://{subdomain}api.service.nhs.uk/{service_base_path}"
def is_pr_env(service_env: str | None) -> bool:
return service_env is not None and service_env.startswith(PR_ENV_PREFIX)