Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds exists/aliasExists() methods to SDKIndicesClient #802

Merged
merged 2 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/main/java/org/opensearch/sdk/SDKClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
import org.opensearch.client.indices.CreateIndexResponse;
import org.opensearch.client.indices.GetFieldMappingsRequest;
import org.opensearch.client.indices.GetFieldMappingsResponse;
import org.opensearch.client.indices.GetIndexRequest;
import org.opensearch.client.indices.GetMappingsRequest;
import org.opensearch.client.indices.GetMappingsResponse;
import org.opensearch.client.indices.PutMappingRequest;
Expand Down Expand Up @@ -738,5 +739,27 @@ public Cancellable rolloverIndex(RolloverRequest rolloverRequest, ActionListener
public Cancellable getAliases(GetAliasesRequest getAliasesRequest, ActionListener<GetAliasesResponse> listener) {
return this.indicesClient.getAliasAsync(getAliasesRequest, options, listener);
}

/**
* Asynchronously checks if one or more aliases exist using the Aliases Exist API.
*
* @param getAliasesRequest the request
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public Cancellable existsAlias(GetAliasesRequest getAliasesRequest, ActionListener<Boolean> listener) {
return this.indicesClient.existsAliasAsync(getAliasesRequest, options, listener);
}

/**
* Asynchronously checks if the index (indices) exists or not.
*
* @param getIndexRequest the request
* @param listener the listener to be notified upon request completion
* @return cancellable that may be used to cancel the request
*/
public Cancellable exists(GetIndexRequest getIndexRequest, ActionListener<Boolean> listener) {
return this.indicesClient.existsAsync(getIndexRequest, options, listener);
}
}
}
3 changes: 3 additions & 0 deletions src/test/java/org/opensearch/sdk/TestSDKClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.opensearch.client.ResponseListener;
import org.opensearch.client.indices.CreateIndexRequest;
import org.opensearch.client.indices.GetFieldMappingsRequest;
import org.opensearch.client.indices.GetIndexRequest;
import org.opensearch.client.indices.GetMappingsRequest;
import org.opensearch.client.indices.PutMappingRequest;
import org.opensearch.client.indices.rollover.RolloverRequest;
Expand Down Expand Up @@ -153,6 +154,8 @@ public void testSDKIndicesClient() throws Exception {
indicesClient.rolloverIndex(new RolloverRequest("", ""), ActionListener.wrap(r -> {}, e -> {}))
);
assertInstanceOf(Cancellable.class, indicesClient.getAliases(new GetAliasesRequest(), ActionListener.wrap(r -> {}, e -> {})));
assertInstanceOf(Cancellable.class, indicesClient.existsAlias(new GetAliasesRequest(), ActionListener.wrap(r -> {}, e -> {})));
assertInstanceOf(Cancellable.class, indicesClient.exists(new GetIndexRequest(), ActionListener.wrap(r -> {}, e -> {})));

sdkClient.doCloseHighLevelClient();
}
Expand Down