From fbe774da61367365162f7b18e0c0b9db7ba10eec Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Thu, 25 Aug 2022 17:49:14 +0200 Subject: [PATCH] docs(java): document browse and waitForApiKey (#956) --- .../utils/{retry => }/ApiKeyOperation.java | 0 .../guides/wait-for-api-key-to-be-valid.mdx | 40 +++++++++++++++++++ .../docs/clients/migration-guides/index.mdx | 32 ++++++++++++++- 3 files changed, 71 insertions(+), 1 deletion(-) rename clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/utils/{retry => }/ApiKeyOperation.java (100%) diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/utils/retry/ApiKeyOperation.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/utils/ApiKeyOperation.java similarity index 100% rename from clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/utils/retry/ApiKeyOperation.java rename to clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/utils/ApiKeyOperation.java diff --git a/website/docs/clients/guides/wait-for-api-key-to-be-valid.mdx b/website/docs/clients/guides/wait-for-api-key-to-be-valid.mdx index 720dcc1aa2..151f2d043a 100644 --- a/website/docs/clients/guides/wait-for-api-key-to-be-valid.mdx +++ b/website/docs/clients/guides/wait-for-api-key-to-be-valid.mdx @@ -95,5 +95,45 @@ $client->waitForApiKey('delete', $key); ``` + + + +```java +import com.algolia.api.SearchClient; +import com.algolia.model.search.*; +import com.algolia.utils.*; + +SearchClient client = new SearchClient("", ""); + +AddApiKeyResponse keyResponse = client.addApiKey(new ApiKey().addAcl(Acl.ANALYTICS).addAcl(Acl.BROWSE).addAcl(Acl.EDIT_SETTINGS)); +String key = keyResponse.getKey(); + +// Poll the task status with defaults values +client.waitForApiKey(ApiKeyOperation.ADD, key); + +// The fields to update on your API key +ApiKey updatesToPerform = new ApiKey() + .addAcl(Acl.ANALYTICS) + .addAcl(Acl.SEARCH) + .addIndexes("products"); + +// Call for update +client.updateApiKey(key, updatesToPerform); + +// Wait for update to be done +client.waitForApiKey( + ApiKeyOperation.UPDATE, + key, + // We provide the updated fields to check if the changes have been applied + updatesToPerform +); + +// Call for delete +client.deleteApiKey(key); + +// Wait for delete to be done +client.waitForApiKey(ApiKeyOperation.DELETE, key); +``` + diff --git a/website/docs/clients/migration-guides/index.mdx b/website/docs/clients/migration-guides/index.mdx index d90cdb1c3c..893392377f 100644 --- a/website/docs/clients/migration-guides/index.mdx +++ b/website/docs/clients/migration-guides/index.mdx @@ -513,7 +513,37 @@ var_dump($rules); ```java -// WIP +// browse records +Iterable objects = client.browseObjects( + "", + // all base `browse` options are forwarded to the `browse` method + new BrowseParamsObject() +); +for (MyObject object : objects) { + System.out.println(object.myProperty); +} + +// browse rules +Iterable rules = client.browseRules( + "", + // all base `searchRules` options are forwarded to the `searchRules` method (optional) + new SearchRulesParams() +); +for (Rule rule : rules) { + System.out.println(rule); +} + +// browse synonyms +Iterable synonyms = client.browseRules( + "", + // only search for specific types of synonyms. (optional) + null, + // all base `searchSynonyms` options are forwarded to the `searchSynonyms` method (optional) + new SearchSynonymsParams() +); +for (SynonymHit synonym : synonyms) { + System.out.println(synonym); +} ```