class KubernetesDiscoveryClient implements DiscoveryClient {

	private final RestTemplate rest;

	private final boolean emptyNamespaces;

	private final Set<String> namespaces;

	private final String discoveryServerUrl;

	@Deprecated(forRemoval = true)
	public KubernetesDiscoveryClient(RestTemplate rest, KubernetesDiscoveryClientProperties properties) {
		if (!StringUtils.hasText(properties.getDiscoveryServerUrl())) {
			throw new DiscoveryServerUrlInvalidException();
		}
		this.rest = rest;
		this.emptyNamespaces = properties.getNamespaces().isEmpty();
		this.namespaces = properties.getNamespaces();
		this.discoveryServerUrl = properties.getDiscoveryServerUrl();
	}

	KubernetesDiscoveryClient(RestTemplate rest, KubernetesDiscoveryProperties kubernetesDiscoveryProperties) {
		if (!StringUtils.hasText(kubernetesDiscoveryProperties.discoveryServerUrl())) {
			throw new DiscoveryServerUrlInvalidException();
		}
		this.rest = rest;
		this.emptyNamespaces = kubernetesDiscoveryProperties.namespaces().isEmpty();
		this.namespaces = kubernetesDiscoveryProperties.namespaces();
		this.discoveryServerUrl = kubernetesDiscoveryProperties.discoveryServerUrl();
	}

	@Override
	public String description() {
		return "Kubernetes Discovery Client";
	}

	@Override
	public List<ServiceInstance> getInstances(String serviceId) {
		DefaultKubernetesServiceInstance[] responseBody = rest
				.getForEntity(discoveryServerUrl + "/apps/" + serviceId, DefaultKubernetesServiceInstance[].class)
				.getBody();
		if (responseBody != null && responseBody.length > 0) {
			return Arrays.stream(responseBody).filter(this::matchNamespaces).collect(Collectors.toList());
		}
		return List.of();
	}

	@Override
	public List<String> getServices() {<FILL_FUNCTION_BODY>}

	private boolean matchNamespaces(DefaultKubernetesServiceInstance kubernetesServiceInstance) {
		return emptyNamespaces || namespaces.contains(kubernetesServiceInstance.getNamespace());
	}

	private boolean matchNamespaces(Service service) {
		return service.serviceInstances().isEmpty()
				|| service.serviceInstances().stream().anyMatch(this::matchNamespaces);
	}

}

		Service[] services = rest.getForEntity(discoveryServerUrl + "/apps", Service[].class).getBody();
		if (services != null && services.length > 0) {
			return Arrays.stream(services).filter(this::matchNamespaces).map(Service::name).toList();
		}
		return List.of();
	
<no_super_class>