Skip to content

Commit

Permalink
fix(client): Add deleteIndex method (without RequestOptions version) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aseure authored and ElPicador committed Feb 13, 2018
1 parent f730810 commit 92b34af
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,37 @@ public Task copyIndex(
return copyIndex(srcIndexName, dstIndexName, scopes, RequestOptions.empty);
}

/**
* Delete an existing index
*
* @param indexName The index name that will be deleted
* @return The associated task
*/
public Task deleteIndex(@Nonnull String indexName) throws AlgoliaException {
return deleteIndex(indexName, RequestOptions.empty);
}

/**
* Delete an existing index
*
* @param indexName The index name that will be deleted
* @param requestOptions Options to pass to this request
* @return The associated task
*/
public Task deleteIndex(@Nonnull String indexName, @Nonnull RequestOptions requestOptions) throws AlgoliaException {
Task result =
httpClient.requestWithRetry(
new AlgoliaRequest<>(
HttpMethod.DELETE,
false,
Arrays.asList("1", "indexes", indexName),
requestOptions,
Task.class));

return result.setAPIClient(this).setIndex(indexName);
}


/**
* Return 10 last log entries.
*
Expand Down Expand Up @@ -695,19 +726,6 @@ public MultiQueriesResult multipleQueries(
.setParameters(ImmutableMap.of("strategy", strategy.getName())));
}

Task deleteIndex(String indexName, RequestOptions requestOptions) throws AlgoliaException {
Task result =
httpClient.requestWithRetry(
new AlgoliaRequest<>(
HttpMethod.DELETE,
false,
Arrays.asList("1", "indexes", indexName),
requestOptions,
Task.class));

return result.setAPIClient(this).setIndex(indexName);
}

<T> TaskIndexing addObject(String indexName, T object, RequestOptions requestOptions)
throws AlgoliaException {
TaskIndexing result =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,24 @@ public CompletableFuture<MultiQueriesResult> multipleQueries(
.setParameters(ImmutableMap.of("strategy", strategy.getName())));
}

/** Package protected method for the Index class */
CompletableFuture<AsyncTask> deleteIndex(String indexName, RequestOptions requestOptions) {
/**
* Delete an existing index
*
* @param indexName The index name that will be deleted
* @return The associated task
*/
public CompletableFuture<AsyncTask> deleteIndex(@Nonnull String indexName) {
return deleteIndex(indexName, RequestOptions.empty);
}

/**
* Delete an existing index
*
* @param indexName The index name that will be deleted
* @param requestOptions Options to pass to this request
* @return The associated task
*/
public CompletableFuture<AsyncTask> deleteIndex(@Nonnull String indexName, @Nonnull RequestOptions requestOptions) {
return httpClient
.requestWithRetry(
new AlgoliaRequest<>(
Expand All @@ -669,6 +685,7 @@ CompletableFuture<AsyncTask> deleteIndex(String indexName, RequestOptions reques
.thenApply(s -> s.setIndex(indexName));
}

/** Package protected method for the Index class */
<T> CompletableFuture<AsyncTaskIndexing> addObject(
String indexName, T object, RequestOptions requestOptions) {
return httpClient
Expand Down

0 comments on commit 92b34af

Please sign in to comment.