Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs-snippets-npm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"sls": {
"dependencies": {
"com.palantir.foundry.api:api-gateway": {
"minVersion": "1.1542.0",
"minVersion": "1.1545.0",
"maxVersion": "1.x.x",
"optional": false
}
Expand Down
9 changes: 5 additions & 4 deletions foundry_sdk/_core/client_init_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,17 @@ def _clean_hostname(hostname: str, config: Optional[Config] = None) -> str:
def maybe_create_hostname_supplier(
base_url: Optional[str] = None, config: Optional[Config] = None
) -> Optional[HostnameSupplier]:
"""Resolve hostname supplier with priority: explicit base_url > context/env vars > service discovery YAML."""
config = config or Config()

if base_url is not None:
assert_non_empty_string(base_url, "hostname")
return StaticHostnameSupplier(_clean_hostname(base_url, config))

env_hostname = maybe_get_hostname_from_context_or_environment_vars()
if env_hostname is not None:
return StaticHostnameSupplier(_clean_hostname(env_hostname, config))

service_discovery_path = os.environ.get("FOUNDRY_SERVICE_DISCOVERY_V2", None)
if service_discovery_path is not None:
import yaml
Expand All @@ -78,10 +83,6 @@ def maybe_create_hostname_supplier(
services = yaml.safe_load(f)
return ServiceDiscoveryHostnameSupplier(services)

env_hostname = maybe_get_hostname_from_context_or_environment_vars()
if env_hostname is not None:
return StaticHostnameSupplier(_clean_hostname(env_hostname, config))

return None


Expand Down
18 changes: 8 additions & 10 deletions foundry_sdk/_core/hostname_supplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,18 @@ def get_hostname( # pyright: ignore[reportIncompatibleMethodOverride]
raise ValueError("ServiceDiscoveryHostnameSupplier requires an endpoint_type.")

if endpoint_type == EndpointType.GENERIC:
return self._find_service_url("api-gateway")
return self._find_service_url("api-gateway", "api_gateway")
elif endpoint_type == EndpointType.AUTH:
return self._find_service_url("multipass")
elif endpoint_type == EndpointType.HIGH_SCALE:
return self._find_service_url("stream-proxy")
return self._find_service_url("stream-proxy", "stream_proxy")
else:
raise ValueError(f"Unsupported endpoint type: {endpoint_type}")

def _find_service_url(self, service_name: str) -> str:
if service_name not in self._services:
raise ValueError(f"Unable to discover service '{service_name}'.")
def _find_service_url(self, *service_names: str) -> str:
for name in service_names:
urls = self._services.get(name)
if urls:
return urls[0]

urls = self._services[service_name]
if not urls:
raise ValueError(f"Unable to discover URLs for service '{service_name}'.")

return urls[0]
raise ValueError(f"Unable to discover service '{service_names[0]}'.")
2 changes: 1 addition & 1 deletion foundry_sdk/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
# using the autorelease bot
__version__ = "0.0.0"

__openapi_document_version__ = "1.1542.0"
__openapi_document_version__ = "1.1545.0"