public ZoneEndpoint zoneEndpoint(InstanceName instance, ZoneId zone, ClusterSpec.Id cluster, boolean useNonPublicEndpointForTest) {
        if (zone.environment().isTest() &&
            (useNonPublicEndpointForTest ||
             instances().stream()
                        .anyMatch(spec -> spec.zoneEndpoints()
                                              .getOrDefault(cluster, Map.of())
                                              .values()
                                              .stream()
                                              .anyMatch(endpoint -> ! endpoint.isPublicEndpoint()))) &&
            // Remove once Azure supports private endpoints
            !zone.region().value().startsWith(CloudName.AZURE.value() + "-")) {

            return ZoneEndpoint.privateEndpoint;
        }

        if (zone.environment().isManuallyDeployed())
            return devSpec.zoneEndpoints.getOrDefault(cluster, ZoneEndpoint.defaultEndpoint);

        return instance(instance).flatMap(spec -> spec.zoneEndpoint(zone, cluster))
                                 .orElse(ZoneEndpoint.defaultEndpoint);
    }
Returns the most specific zone endpoint, where specificity is given, in decreasing order:
1. The given instance has declared a zone endpoint for the cluster, for the given region.
2. The given instance has declared a universal zone endpoint for the cluster.
3. The application has declared a zone endpoint for the cluster, for the given region.
4. The application has declared a universal zone endpoint for the cluster.
5. None of the above apply, and the default of a publicly visible endpoint is used.
config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java