From 629edeaf485df9db0ac3330edc103fe6b27861f9 Mon Sep 17 00:00:00 2001 From: algolia-bot Date: Fri, 30 Aug 2024 13:16:05 +0000 Subject: [PATCH] fix(clients): correly parse usage hosts (generated) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/algolia/api-clients-automation/pull/3622 Co-authored-by: algolia-bot Co-authored-by: Clément Vannicatte --- .../java/com/algolia/api/UsageClient.java | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/algoliasearch/src/main/java/com/algolia/api/UsageClient.java b/algoliasearch/src/main/java/com/algolia/api/UsageClient.java index 3ef2b67cd..e13c5cf63 100644 --- a/algoliasearch/src/main/java/com/algolia/api/UsageClient.java +++ b/algoliasearch/src/main/java/com/algolia/api/UsageClient.java @@ -11,14 +11,10 @@ import com.algolia.utils.*; import com.fasterxml.jackson.core.type.TypeReference; import java.util.ArrayList; -import java.util.Collections; import java.util.EnumSet; import java.util.List; import java.util.Map; -import java.util.Random; import java.util.concurrent.CompletableFuture; -import java.util.stream.Collectors; -import java.util.stream.Stream; import javax.annotation.Nonnull; public class UsageClient extends ApiClient { @@ -28,22 +24,14 @@ public UsageClient(String appId, String apiKey) { } public UsageClient(String appId, String apiKey, ClientOptions options) { - super(appId, apiKey, "Usage", options, getDefaultHosts(appId)); + super(appId, apiKey, "Usage", options, getDefaultHosts()); } - private static List getDefaultHosts(String appId) { + private static List getDefaultHosts() { List hosts = new ArrayList<>(); - hosts.add(new Host(appId + "-dsn.algolia.net", EnumSet.of(CallType.READ))); - hosts.add(new Host(appId + ".algolia.net", EnumSet.of(CallType.WRITE))); - - List commonHosts = new ArrayList<>(); - hosts.add(new Host(appId + "-1.algolianet.net", EnumSet.of(CallType.READ, CallType.WRITE))); - hosts.add(new Host(appId + "-2.algolianet.net", EnumSet.of(CallType.READ, CallType.WRITE))); - hosts.add(new Host(appId + "-3.algolianet.net", EnumSet.of(CallType.READ, CallType.WRITE))); - - Collections.shuffle(commonHosts, new Random()); - - return Stream.concat(hosts.stream(), commonHosts.stream()).collect(Collectors.toList()); + hosts.add(new Host("usage.algolia.com", EnumSet.of(CallType.READ, CallType.WRITE))); + hosts.add(new Host("usage-dev.algolia.com", EnumSet.of(CallType.READ, CallType.WRITE))); + return hosts; } /**