diff --git a/docs-snippets-npm/package.json b/docs-snippets-npm/package.json index 777fc056..ec796042 100644 --- a/docs-snippets-npm/package.json +++ b/docs-snippets-npm/package.json @@ -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 } diff --git a/foundry_sdk/_core/client_init_helpers.py b/foundry_sdk/_core/client_init_helpers.py index 3b1cea39..7a7c2a19 100644 --- a/foundry_sdk/_core/client_init_helpers.py +++ b/foundry_sdk/_core/client_init_helpers.py @@ -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 @@ -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 diff --git a/foundry_sdk/_core/hostname_supplier.py b/foundry_sdk/_core/hostname_supplier.py index cd68c70e..f3116a9c 100644 --- a/foundry_sdk/_core/hostname_supplier.py +++ b/foundry_sdk/_core/hostname_supplier.py @@ -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]}'.") diff --git a/foundry_sdk/_version.py b/foundry_sdk/_version.py index b732105e..37f8dcbf 100644 --- a/foundry_sdk/_version.py +++ b/foundry_sdk/_version.py @@ -17,4 +17,4 @@ # using the autorelease bot __version__ = "0.0.0" -__openapi_document_version__ = "1.1542.0" +__openapi_document_version__ = "1.1545.0"