Skip to content

Commit fbe774d

Browse files
authored
docs(java): document browse and waitForApiKey (#956)
1 parent f16f719 commit fbe774d

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

website/docs/clients/guides/wait-for-api-key-to-be-valid.mdx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,45 @@ $client->waitForApiKey('delete', $key);
9595

9696
```
9797

98+
</TabItem>
99+
<TabItem value="java">
100+
101+
```java
102+
import com.algolia.api.SearchClient;
103+
import com.algolia.model.search.*;
104+
import com.algolia.utils.*;
105+
106+
SearchClient client = new SearchClient("<YOUR_APP_ID>", "<YOUR_API_KEY>");
107+
108+
AddApiKeyResponse keyResponse = client.addApiKey(new ApiKey().addAcl(Acl.ANALYTICS).addAcl(Acl.BROWSE).addAcl(Acl.EDIT_SETTINGS));
109+
String key = keyResponse.getKey();
110+
111+
// Poll the task status with defaults values
112+
client.waitForApiKey(ApiKeyOperation.ADD, key);
113+
114+
// The fields to update on your API key
115+
ApiKey updatesToPerform = new ApiKey()
116+
.addAcl(Acl.ANALYTICS)
117+
.addAcl(Acl.SEARCH)
118+
.addIndexes("products");
119+
120+
// Call for update
121+
client.updateApiKey(key, updatesToPerform);
122+
123+
// Wait for update to be done
124+
client.waitForApiKey(
125+
ApiKeyOperation.UPDATE,
126+
key,
127+
// We provide the updated fields to check if the changes have been applied
128+
updatesToPerform
129+
);
130+
131+
// Call for delete
132+
client.deleteApiKey(key);
133+
134+
// Wait for delete to be done
135+
client.waitForApiKey(ApiKeyOperation.DELETE, key);
136+
```
137+
98138
</TabItem>
99139
</TabsLanguage>

website/docs/clients/migration-guides/index.mdx

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,37 @@ var_dump($rules);
513513
<TabItem value="java">
514514

515515
```java
516-
// WIP
516+
// browse records
517+
Iterable<MyObject> objects = client.browseObjects(
518+
"<YOUR_INDEX_NAME>",
519+
// all base `browse` options are forwarded to the `browse` method
520+
new BrowseParamsObject()
521+
);
522+
for (MyObject object : objects) {
523+
System.out.println(object.myProperty);
524+
}
525+
526+
// browse rules
527+
Iterable<Rule> rules = client.browseRules(
528+
"<YOUR_INDEX_NAME>",
529+
// all base `searchRules` options are forwarded to the `searchRules` method (optional)
530+
new SearchRulesParams()
531+
);
532+
for (Rule rule : rules) {
533+
System.out.println(rule);
534+
}
535+
536+
// browse synonyms
537+
Iterable<SynonymHit> synonyms = client.browseRules(
538+
"<YOUR_INDEX_NAME>",
539+
// only search for specific types of synonyms. (optional)
540+
null,
541+
// all base `searchSynonyms` options are forwarded to the `searchSynonyms` method (optional)
542+
new SearchSynonymsParams()
543+
);
544+
for (SynonymHit synonym : synonyms) {
545+
System.out.println(synonym);
546+
}
517547

518548
```
519549

0 commit comments

Comments
 (0)