Skip to content
This repository was archived by the owner on Jan 31, 2022. It is now read-only.

Commit 59f9c5d

Browse files
authored
feat(Index): Expose sync methods (#544)
1 parent 1f13332 commit 59f9c5d

File tree

1 file changed

+22
-22
lines changed
  • algoliasearch/src/main/java/com/algolia/search/saas

1 file changed

+22
-22
lines changed

algoliasearch/src/main/java/com/algolia/search/saas/Index.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ protected JSONObject addObject(JSONObject obj, @Nullable RequestOptions requestO
10251025
* @param requestOptions Request-specific options.
10261026
* @throws AlgoliaException
10271027
*/
1028-
protected JSONObject addObject(JSONObject obj, String objectID, @Nullable RequestOptions requestOptions) throws AlgoliaException {
1028+
public JSONObject addObject(JSONObject obj, String objectID, @Nullable RequestOptions requestOptions) throws AlgoliaException {
10291029
try {
10301030
return client.putRequest("/1/indexes/" + encodedIndexName + "/" + URLEncoder.encode(objectID, "UTF-8"), /* urlParameters: */ null, obj.toString(), requestOptions);
10311031
} catch (UnsupportedEncodingException e) {
@@ -1057,7 +1057,7 @@ protected JSONObject batch(JSONArray actions, @Nullable RequestOptions requestOp
10571057
* @param requestOptions Request-specific options.
10581058
* @throws AlgoliaException
10591059
*/
1060-
protected JSONObject addObjects(JSONArray inputArray, @Nullable RequestOptions requestOptions) throws AlgoliaException {
1060+
public JSONObject addObjects(JSONArray inputArray, @Nullable RequestOptions requestOptions) throws AlgoliaException {
10611061
try {
10621062
JSONArray array = new JSONArray();
10631063
for (int n = 0; n < inputArray.length(); n++) {
@@ -1079,7 +1079,7 @@ protected JSONObject addObjects(JSONArray inputArray, @Nullable RequestOptions r
10791079
* @param requestOptions Request-specific options.
10801080
* @throws AlgoliaException
10811081
*/
1082-
protected JSONObject getObject(String objectID, @Nullable RequestOptions requestOptions) throws AlgoliaException {
1082+
public JSONObject getObject(String objectID, @Nullable RequestOptions requestOptions) throws AlgoliaException {
10831083
try {
10841084
return client.getRequest("/1/indexes/" + encodedIndexName + "/" + URLEncoder.encode(objectID, "UTF-8"), /* urlParameters: */ null, false, requestOptions);
10851085
} catch (UnsupportedEncodingException e) {
@@ -1095,7 +1095,7 @@ protected JSONObject getObject(String objectID, @Nullable RequestOptions request
10951095
* @param requestOptions Request-specific options.
10961096
* @throws AlgoliaException
10971097
*/
1098-
protected JSONObject getObject(String objectID, Collection<String> attributesToRetrieve, @Nullable RequestOptions requestOptions) throws AlgoliaException {
1098+
public JSONObject getObject(String objectID, Collection<String> attributesToRetrieve, @Nullable RequestOptions requestOptions) throws AlgoliaException {
10991099
try {
11001100
String path = "/1/indexes/" + encodedIndexName + "/" + URLEncoder.encode(objectID, "UTF-8");
11011101
Map<String, String> urlParameters = new HashMap<>();
@@ -1114,7 +1114,7 @@ protected JSONObject getObject(String objectID, Collection<String> attributesToR
11141114
* @param objectIDs the array of unique identifier of objects to retrieve
11151115
* @throws AlgoliaException
11161116
*/
1117-
protected JSONObject getObjects(Collection<String> objectIDs) throws AlgoliaException {
1117+
public JSONObject getObjects(Collection<String> objectIDs) throws AlgoliaException {
11181118
return getObjects(objectIDs, /* attributesToRetrieve: */ null, /* requestOptions: */ null);
11191119
}
11201120

@@ -1126,7 +1126,7 @@ protected JSONObject getObjects(Collection<String> objectIDs) throws AlgoliaExce
11261126
* @param requestOptions Request-specific options.
11271127
* @throws AlgoliaException
11281128
*/
1129-
protected JSONObject getObjects(@NonNull Collection<String> objectIDs, @Nullable Collection<String> attributesToRetrieve, @Nullable RequestOptions requestOptions) throws AlgoliaException {
1129+
public JSONObject getObjects(@NonNull Collection<String> objectIDs, @Nullable Collection<String> attributesToRetrieve, @Nullable RequestOptions requestOptions) throws AlgoliaException {
11301130
try {
11311131
JSONArray requests = new JSONArray();
11321132
for (String id : objectIDs) {
@@ -1153,7 +1153,7 @@ protected JSONObject getObjects(@NonNull Collection<String> objectIDs, @Nullable
11531153
* @param requestOptions Request-specific options.
11541154
* @throws AlgoliaException
11551155
*/
1156-
protected JSONObject partialUpdateObject(JSONObject partialObject, String objectID, Boolean createIfNotExists, @Nullable RequestOptions requestOptions) throws AlgoliaException {
1156+
public JSONObject partialUpdateObject(JSONObject partialObject, String objectID, Boolean createIfNotExists, @Nullable RequestOptions requestOptions) throws AlgoliaException {
11571157
try {
11581158
String path = "/1/indexes/" + encodedIndexName + "/" + URLEncoder.encode(objectID, "UTF-8") + "/partial";
11591159
Map<String, String> urlParameters = new HashMap<>();
@@ -1173,7 +1173,7 @@ protected JSONObject partialUpdateObject(JSONObject partialObject, String object
11731173
* @param requestOptions Request-specific options.
11741174
* @throws AlgoliaException
11751175
*/
1176-
protected JSONObject partialUpdateObjects(JSONArray inputArray, boolean createIfNotExists, @Nullable RequestOptions requestOptions) throws AlgoliaException {
1176+
public JSONObject partialUpdateObjects(JSONArray inputArray, boolean createIfNotExists, @Nullable RequestOptions requestOptions) throws AlgoliaException {
11771177
try {
11781178
final String action = createIfNotExists ? "partialUpdateObject" : "partialUpdateObjectNoCreate";
11791179
JSONArray array = new JSONArray();
@@ -1198,7 +1198,7 @@ protected JSONObject partialUpdateObjects(JSONArray inputArray, boolean createIf
11981198
* @param requestOptions Request-specific options.
11991199
* @throws AlgoliaException
12001200
*/
1201-
protected JSONObject saveObject(JSONObject object, String objectID, @Nullable RequestOptions requestOptions) throws AlgoliaException {
1201+
public JSONObject saveObject(JSONObject object, String objectID, @Nullable RequestOptions requestOptions) throws AlgoliaException {
12021202
try {
12031203
return client.putRequest("/1/indexes/" + encodedIndexName + "/" + URLEncoder.encode(objectID, "UTF-8"), /* urlParameters: */ null, object.toString(), requestOptions);
12041204
} catch (UnsupportedEncodingException e) {
@@ -1213,7 +1213,7 @@ protected JSONObject saveObject(JSONObject object, String objectID, @Nullable Re
12131213
* @param requestOptions Request-specific options.
12141214
* @throws AlgoliaException
12151215
*/
1216-
protected JSONObject saveObjects(JSONArray inputArray, @Nullable RequestOptions requestOptions) throws AlgoliaException {
1216+
public JSONObject saveObjects(JSONArray inputArray, @Nullable RequestOptions requestOptions) throws AlgoliaException {
12171217
try {
12181218
JSONArray array = new JSONArray();
12191219
for (int n = 0; n < inputArray.length(); n++) {
@@ -1237,7 +1237,7 @@ protected JSONObject saveObjects(JSONArray inputArray, @Nullable RequestOptions
12371237
* @param requestOptions Request-specific options.
12381238
* @throws AlgoliaException
12391239
*/
1240-
protected JSONObject deleteObject(String objectID, @Nullable RequestOptions requestOptions) throws AlgoliaException {
1240+
public JSONObject deleteObject(String objectID, @Nullable RequestOptions requestOptions) throws AlgoliaException {
12411241
if (objectID.length() == 0) {
12421242
throw new AlgoliaException("Invalid objectID");
12431243
}
@@ -1255,7 +1255,7 @@ protected JSONObject deleteObject(String objectID, @Nullable RequestOptions requ
12551255
* @param requestOptions Request-specific options.
12561256
* @throws AlgoliaException
12571257
*/
1258-
protected JSONObject deleteObjects(Collection<String> objects, @Nullable RequestOptions requestOptions) throws AlgoliaException {
1258+
public JSONObject deleteObjects(Collection<String> objects, @Nullable RequestOptions requestOptions) throws AlgoliaException {
12591259
try {
12601260
JSONArray array = new JSONArray();
12611261
for (String id : objects) {
@@ -1281,7 +1281,7 @@ protected JSONObject deleteObjects(Collection<String> objects, @Nullable Request
12811281
* @deprecated use {@link Index#deleteBy(Query)} instead.
12821282
*/
12831283
@Deprecated
1284-
protected void deleteByQuery(@NonNull Query query, @Nullable RequestOptions requestOptions) throws AlgoliaException {
1284+
public void deleteByQuery(@NonNull Query query, @Nullable RequestOptions requestOptions) throws AlgoliaException {
12851285
try {
12861286
boolean hasMore;
12871287
do {
@@ -1312,7 +1312,7 @@ protected void deleteByQuery(@NonNull Query query, @Nullable RequestOptions requ
13121312
* @param query the query string
13131313
* @throws AlgoliaException
13141314
*/
1315-
protected JSONObject deleteBy(@NonNull Query query) throws AlgoliaException {
1315+
public JSONObject deleteBy(@NonNull Query query) throws AlgoliaException {
13161316
return deleteBy(query, null);
13171317
}
13181318

@@ -1323,7 +1323,7 @@ protected JSONObject deleteBy(@NonNull Query query) throws AlgoliaException {
13231323
* @throws AlgoliaException
13241324
*
13251325
*/
1326-
protected JSONObject deleteBy(@NonNull Query query, RequestOptions requestOptions) throws AlgoliaException {
1326+
public JSONObject deleteBy(@NonNull Query query, RequestOptions requestOptions) throws AlgoliaException {
13271327
try {
13281328
return client.postRequest("/1/indexes/" + encodedIndexName + "/deleteByQuery", query.getParameters(), new JSONObject().put("params", query.build()).toString(), false, requestOptions);
13291329
} catch (JSONException e) {
@@ -1339,7 +1339,7 @@ protected JSONObject deleteBy(@NonNull Query query, RequestOptions requestOption
13391339
* @return a JSONObject containing search results
13401340
* @throws AlgoliaException
13411341
*/
1342-
protected JSONObject search(@Nullable Query query, @Nullable RequestOptions requestOptions) throws AlgoliaException {
1342+
public JSONObject search(@Nullable Query query, @Nullable RequestOptions requestOptions) throws AlgoliaException {
13431343
if (query == null) {
13441344
query = new Query();
13451345
}
@@ -1397,7 +1397,7 @@ protected byte[] searchRaw(@Nullable Query query, @Nullable RequestOptions reque
13971397
* @param timeToWait time to sleep seed
13981398
* @throws AlgoliaException
13991399
*/
1400-
protected JSONObject waitTask(String taskID, long timeToWait) throws AlgoliaException {
1400+
public JSONObject waitTask(String taskID, long timeToWait) throws AlgoliaException {
14011401
try {
14021402
while (true) {
14031403
JSONObject obj = client.getRequest("/1/indexes/" + encodedIndexName + "/task/" + URLEncoder.encode(taskID, "UTF-8"), /* urlParameters: */ null, false, /* requestOptions: */ null);
@@ -1427,7 +1427,7 @@ protected JSONObject waitTask(String taskID, long timeToWait) throws AlgoliaExce
14271427
* @param taskID the id of the task returned by server
14281428
* @throws AlgoliaException
14291429
*/
1430-
protected JSONObject waitTask(String taskID) throws AlgoliaException {
1430+
public JSONObject waitTask(String taskID) throws AlgoliaException {
14311431
return waitTask(taskID, MAX_TIME_MS_TO_WAIT);
14321432
}
14331433

@@ -1438,7 +1438,7 @@ protected JSONObject waitTask(String taskID) throws AlgoliaException {
14381438
*
14391439
* @param requestOptions Request-specific options.
14401440
*/
1441-
protected JSONObject getSettings(@Nullable RequestOptions requestOptions) throws AlgoliaException {
1441+
public JSONObject getSettings(@Nullable RequestOptions requestOptions) throws AlgoliaException {
14421442
Map<String, String> urlParameters = new HashMap<>();
14431443
urlParameters.put("getVersion", Integer.toString(DEFAULT_SETTINGS_VERSION));
14441444
return client.getRequest("/1/indexes/" + encodedIndexName + "/settings", urlParameters, false, requestOptions);
@@ -1452,7 +1452,7 @@ protected JSONObject getSettings(@Nullable RequestOptions requestOptions) throws
14521452
* @param requestOptions Request-specific options.
14531453
* @throws AlgoliaException
14541454
*/
1455-
protected JSONObject getSettings(int formatVersion, @Nullable RequestOptions requestOptions) throws AlgoliaException {
1455+
public JSONObject getSettings(int formatVersion, @Nullable RequestOptions requestOptions) throws AlgoliaException {
14561456
Map<String, String> urlParameters = new HashMap<>();
14571457
urlParameters.put("getVersion", Integer.toString(formatVersion));
14581458
return client.getRequest("/1/indexes/" + encodedIndexName + "/settings", urlParameters, false, requestOptions);
@@ -1466,7 +1466,7 @@ protected JSONObject getSettings(int formatVersion, @Nullable RequestOptions req
14661466
* @param requestOptions Request-specific options.
14671467
* @throws AlgoliaException
14681468
*/
1469-
protected JSONObject setSettings(JSONObject settings, boolean forwardToReplicas, @Nullable RequestOptions requestOptions) throws AlgoliaException {
1469+
public JSONObject setSettings(JSONObject settings, boolean forwardToReplicas, @Nullable RequestOptions requestOptions) throws AlgoliaException {
14701470
Map<String, String> urlParameters = new HashMap<>();
14711471
urlParameters.put("forwardToReplicas", Boolean.toString(forwardToReplicas));
14721472
return client.putRequest("/1/indexes/" + encodedIndexName + "/settings", urlParameters, settings.toString(), requestOptions);
@@ -1478,7 +1478,7 @@ protected JSONObject setSettings(JSONObject settings, boolean forwardToReplicas,
14781478
* @param requestOptions Request-specific options.
14791479
* @throws AlgoliaException
14801480
*/
1481-
protected JSONObject clearIndex(@Nullable RequestOptions requestOptions) throws AlgoliaException {
1481+
public JSONObject clearIndex(@Nullable RequestOptions requestOptions) throws AlgoliaException {
14821482
return client.postRequest("/1/indexes/" + encodedIndexName + "/clear", /* urlParameters: */ null, "", false, requestOptions);
14831483
}
14841484

0 commit comments

Comments
 (0)