|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.algolia.search.saas.APIClient
public class APIClient
Entry point in the Java API. You should instantiate a Client object with your ApplicationID, ApiKey and Hosts to start using Algolia Search API
Nested Class Summary | |
---|---|
static class |
APIClient.IndexQuery
|
static class |
APIClient.LogType
|
Constructor Summary | |
---|---|
APIClient(String applicationID,
String apiKey)
Algolia Search initialization |
|
APIClient(String applicationID,
String apiKey,
List<String> hostsArray)
Algolia Search initialization |
Method Summary | |
---|---|
org.json.JSONObject |
addUserKey(List<String> acls)
Create a new user key |
org.json.JSONObject |
addUserKey(List<String> acls,
int validity,
int maxQueriesPerIPPerHour,
int maxHitsPerQuery)
Create a new user key |
org.json.JSONObject |
addUserKey(List<String> acls,
int validity,
int maxQueriesPerIPPerHour,
int maxHitsPerQuery,
List<String> indexes)
Create a new user key |
org.json.JSONObject |
copyIndex(String srcIndexName,
String dstIndexName)
Copy an existing index. |
org.json.JSONObject |
deleteIndex(String indexName)
Delete an index |
protected org.json.JSONObject |
deleteRequest(String url)
|
org.json.JSONObject |
deleteUserKey(String key)
Delete an existing user key |
void |
disableRateLimitForward()
Disable IP rate limit enabled with enableRateLimitForward() function |
void |
enableRateLimitForward(String adminAPIKey,
String endUserIP,
String rateLimitAPIKey)
Allow to use IP rate limit when you have a proxy between end-user and Algolia. |
String |
generateSecuredApiKey(String privateApiKey,
String tagFilters)
Generate a secured and public API Key from a list of tagFilters and an optional user token identifying the current user |
String |
generateSecuredApiKey(String privateApiKey,
String tagFilters,
String userToken)
Generate a secured and public API Key from a list of tagFilters and an optional user token identifying the current user |
org.json.JSONObject |
getLogs()
Return 10 last log entries. |
org.json.JSONObject |
getLogs(int offset,
int length)
Return last logs entries. |
org.json.JSONObject |
getLogs(int offset,
int length,
APIClient.LogType logType)
Return last logs entries. |
org.json.JSONObject |
getLogs(int offset,
int length,
boolean onlyErrors)
Return last logs entries. |
protected org.json.JSONObject |
getRequest(String url)
|
org.json.JSONObject |
getUserKeyACL(String key)
Get ACL of a user key |
Index |
initIndex(String indexName)
Get the index object initialized (no server call needed for initialization) |
org.json.JSONObject |
listIndexes()
List all existing indexes return an JSON Object in the form: { "items": [ {"name": "contacts", "createdAt": "2013-01-18T15:33:13.556Z"}, {"name": "notes", "createdAt": "2013-01-18T15:33:13.556Z"}]} |
org.json.JSONObject |
listUserKeys()
List all existing user keys with their associated ACLs |
org.json.JSONObject |
moveIndex(String srcIndexName,
String dstIndexName)
Move an existing index. |
org.json.JSONObject |
multipleQueries(List<APIClient.IndexQuery> queries)
This method allows to query multiple indexes with one API call |
protected org.json.JSONObject |
postRequest(String url,
String obj)
|
protected org.json.JSONObject |
putRequest(String url,
String obj)
|
void |
setExtraHeader(String key,
String value)
Allow to set custom headers |
void |
setTimeout(int connectTimeout,
int readTimeout)
Allow to set the timeout |
org.json.JSONObject |
updateUserKey(String key,
List<String> acls)
Update a user key |
org.json.JSONObject |
updateUserKey(String key,
List<String> acls,
int validity,
int maxQueriesPerIPPerHour,
int maxHitsPerQuery)
Update a user key |
org.json.JSONObject |
updateUserKey(String key,
List<String> acls,
int validity,
int maxQueriesPerIPPerHour,
int maxHitsPerQuery,
List<String> indexes)
Update a user key |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public APIClient(String applicationID, String apiKey)
applicationID
- the application ID you have in your admin interfaceapiKey
- a valid API key for the servicepublic APIClient(String applicationID, String apiKey, List<String> hostsArray)
applicationID
- the application ID you have in your admin interfaceapiKey
- a valid API key for the servicehostsArray
- the list of hosts that you have received for the serviceMethod Detail |
---|
public void enableRateLimitForward(String adminAPIKey, String endUserIP, String rateLimitAPIKey)
adminAPIKey
- the admin API Key you can find in your dashboardendUserIP
- the end user IP (you can use both IPV4 or IPV6 syntax)rateLimitAPIKey
- the API key on which you have a rate limitpublic void disableRateLimitForward()
public void setExtraHeader(String key, String value)
public void setTimeout(int connectTimeout, int readTimeout)
connectTimeout
- connection timeout in MSreadTimeout
- socket timeout in MSpublic org.json.JSONObject listIndexes() throws AlgoliaException
AlgoliaException
public org.json.JSONObject deleteIndex(String indexName) throws AlgoliaException
indexName
- the name of index to delete
return an object containing a "deletedAt" attribute
AlgoliaException
public org.json.JSONObject moveIndex(String srcIndexName, String dstIndexName) throws AlgoliaException
srcIndexName
- the name of index to copy.dstIndexName
- the new index name that will contains a copy of srcIndexName (destination will be overriten if it already exist).
AlgoliaException
public org.json.JSONObject copyIndex(String srcIndexName, String dstIndexName) throws AlgoliaException
srcIndexName
- the name of index to copy.dstIndexName
- the new index name that will contains a copy of srcIndexName (destination will be overriten if it already exist).
AlgoliaException
public org.json.JSONObject getLogs() throws AlgoliaException
AlgoliaException
public org.json.JSONObject getLogs(int offset, int length) throws AlgoliaException
offset
- Specify the first entry to retrieve (0-based, 0 is the most recent log entry).length
- Specify the maximum number of entries to retrieve starting at offset. Maximum allowed value: 1000.
AlgoliaException
public org.json.JSONObject getLogs(int offset, int length, boolean onlyErrors) throws AlgoliaException
offset
- Specify the first entry to retrieve (0-based, 0 is the most recent log entry).length
- Specify the maximum number of entries to retrieve starting at offset. Maximum allowed value: 1000.onlyErrors
- Retrieve only logs with an httpCode different than 200 and 201
AlgoliaException
public org.json.JSONObject getLogs(int offset, int length, APIClient.LogType logType) throws AlgoliaException
offset
- Specify the first entry to retrieve (0-based, 0 is the most recent log entry).length
- Specify the maximum number of entries to retrieve starting at offset. Maximum allowed value: 1000.logType
- Specify the type of log to retrieve
AlgoliaException
public Index initIndex(String indexName)
indexName
- the name of indexpublic org.json.JSONObject listUserKeys() throws AlgoliaException
AlgoliaException
public org.json.JSONObject getUserKeyACL(String key) throws AlgoliaException
AlgoliaException
public org.json.JSONObject deleteUserKey(String key) throws AlgoliaException
AlgoliaException
public org.json.JSONObject addUserKey(List<String> acls) throws AlgoliaException
acls
- the list of ACL for this key. Defined by an array of strings that
can contains the following values:
- search: allow to search (https and http)
- addObject: allows to add/update an object in the index (https only)
- deleteObject : allows to delete an existing object (https only)
- deleteIndex : allows to delete index content (https only)
- settings : allows to get index settings (https only)
- editSettings : allows to change index settings (https only)
AlgoliaException
public org.json.JSONObject updateUserKey(String key, List<String> acls) throws AlgoliaException
acls
- the list of ACL for this key. Defined by an array of strings that
can contains the following values:
- search: allow to search (https and http)
- addObject: allows to add/update an object in the index (https only)
- deleteObject : allows to delete an existing object (https only)
- deleteIndex : allows to delete index content (https only)
- settings : allows to get index settings (https only)
- editSettings : allows to change index settings (https only)
AlgoliaException
public org.json.JSONObject addUserKey(List<String> acls, int validity, int maxQueriesPerIPPerHour, int maxHitsPerQuery) throws AlgoliaException
acls
- the list of ACL for this key. Defined by an array of strings that
can contains the following values:
- search: allow to search (https and http)
- addObject: allows to add/update an object in the index (https only)
- deleteObject : allows to delete an existing object (https only)
- deleteIndex : allows to delete index content (https only)
- settings : allows to get index settings (https only)
- editSettings : allows to change index settings (https only)validity
- the number of seconds after which the key will be automatically removed (0 means no time limit for this key)maxQueriesPerIPPerHour
- Specify the maximum number of API calls allowed from an IP address per hour. Defaults to 0 (no rate limit).maxHitsPerQuery
- Specify the maximum number of hits this API key can retrieve in one call. Defaults to 0 (unlimited)
AlgoliaException
public org.json.JSONObject updateUserKey(String key, List<String> acls, int validity, int maxQueriesPerIPPerHour, int maxHitsPerQuery) throws AlgoliaException
acls
- the list of ACL for this key. Defined by an array of strings that
can contains the following values:
- search: allow to search (https and http)
- addObject: allows to add/update an object in the index (https only)
- deleteObject : allows to delete an existing object (https only)
- deleteIndex : allows to delete index content (https only)
- settings : allows to get index settings (https only)
- editSettings : allows to change index settings (https only)validity
- the number of seconds after which the key will be automatically removed (0 means no time limit for this key)maxQueriesPerIPPerHour
- Specify the maximum number of API calls allowed from an IP address per hour. Defaults to 0 (no rate limit).maxHitsPerQuery
- Specify the maximum number of hits this API key can retrieve in one call. Defaults to 0 (unlimited)
AlgoliaException
public org.json.JSONObject addUserKey(List<String> acls, int validity, int maxQueriesPerIPPerHour, int maxHitsPerQuery, List<String> indexes) throws AlgoliaException
acls
- the list of ACL for this key. Defined by an array of strings that
can contains the following values:
- search: allow to search (https and http)
- addObject: allows to add/update an object in the index (https only)
- deleteObject : allows to delete an existing object (https only)
- deleteIndex : allows to delete index content (https only)
- settings : allows to get index settings (https only)
- editSettings : allows to change index settings (https only)validity
- the number of seconds after which the key will be automatically removed (0 means no time limit for this key)maxQueriesPerIPPerHour
- Specify the maximum number of API calls allowed from an IP address per hour. Defaults to 0 (no rate limit).maxHitsPerQuery
- Specify the maximum number of hits this API key can retrieve in one call. Defaults to 0 (unlimited)indexes
- the list of targeted indexes
AlgoliaException
public org.json.JSONObject updateUserKey(String key, List<String> acls, int validity, int maxQueriesPerIPPerHour, int maxHitsPerQuery, List<String> indexes) throws AlgoliaException
acls
- the list of ACL for this key. Defined by an array of strings that
can contains the following values:
- search: allow to search (https and http)
- addObject: allows to add/update an object in the index (https only)
- deleteObject : allows to delete an existing object (https only)
- deleteIndex : allows to delete index content (https only)
- settings : allows to get index settings (https only)
- editSettings : allows to change index settings (https only)validity
- the number of seconds after which the key will be automatically removed (0 means no time limit for this key)maxQueriesPerIPPerHour
- Specify the maximum number of API calls allowed from an IP address per hour. Defaults to 0 (no rate limit).maxHitsPerQuery
- Specify the maximum number of hits this API key can retrieve in one call. Defaults to 0 (unlimited)indexes
- the list of targeted indexes
AlgoliaException
public String generateSecuredApiKey(String privateApiKey, String tagFilters) throws NoSuchAlgorithmException, InvalidKeyException
privateApiKey
- your private API KeytagFilters
- the list of tags applied to the query (used as security)
NoSuchAlgorithmException
InvalidKeyException
public String generateSecuredApiKey(String privateApiKey, String tagFilters, String userToken) throws NoSuchAlgorithmException, InvalidKeyException
privateApiKey
- your private API KeytagFilters
- the list of tags applied to the query (used as security)userToken
- an optional token identifying the current user
NoSuchAlgorithmException
InvalidKeyException
protected org.json.JSONObject getRequest(String url) throws AlgoliaException
AlgoliaException
protected org.json.JSONObject deleteRequest(String url) throws AlgoliaException
AlgoliaException
protected org.json.JSONObject postRequest(String url, String obj) throws AlgoliaException
AlgoliaException
protected org.json.JSONObject putRequest(String url, String obj) throws AlgoliaException
AlgoliaException
public org.json.JSONObject multipleQueries(List<APIClient.IndexQuery> queries) throws AlgoliaException
AlgoliaException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |