Skip to content

Commit

Permalink
docs(java): document browse and waitForApiKey (#956)
Browse files Browse the repository at this point in the history
  • Loading branch information
millotp authored Aug 25, 2022
1 parent f16f719 commit fbe774d
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
40 changes: 40 additions & 0 deletions website/docs/clients/guides/wait-for-api-key-to-be-valid.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,45 @@ $client->waitForApiKey('delete', $key);

```

</TabItem>
<TabItem value="java">

```java
import com.algolia.api.SearchClient;
import com.algolia.model.search.*;
import com.algolia.utils.*;

SearchClient client = new SearchClient("<YOUR_APP_ID>", "<YOUR_API_KEY>");

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);
```

</TabItem>
</TabsLanguage>
32 changes: 31 additions & 1 deletion website/docs/clients/migration-guides/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,37 @@ var_dump($rules);
<TabItem value="java">

```java
// WIP
// browse records
Iterable<MyObject> objects = client.browseObjects(
"<YOUR_INDEX_NAME>",
// all base `browse` options are forwarded to the `browse` method
new BrowseParamsObject()
);
for (MyObject object : objects) {
System.out.println(object.myProperty);
}

// browse rules
Iterable<Rule> rules = client.browseRules(
"<YOUR_INDEX_NAME>",
// all base `searchRules` options are forwarded to the `searchRules` method (optional)
new SearchRulesParams()
);
for (Rule rule : rules) {
System.out.println(rule);
}

// browse synonyms
Iterable<SynonymHit> synonyms = client.browseRules(
"<YOUR_INDEX_NAME>",
// 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);
}

```

Expand Down

0 comments on commit fbe774d

Please sign in to comment.