use of org.opensearch.client.indices.DeleteAliasRequest in project OpenSearch by opensearch-project.
the class IndicesRequestConvertersTests method testDeleteAlias.
public void testDeleteAlias() {
DeleteAliasRequest deleteAliasRequest = new DeleteAliasRequest(randomAlphaOfLength(4), randomAlphaOfLength(4));
Map<String, String> expectedParams = new HashMap<>();
RequestConvertersTests.setRandomMasterTimeout(deleteAliasRequest, expectedParams);
RequestConvertersTests.setRandomTimeout(deleteAliasRequest, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams);
Request request = IndicesRequestConverters.deleteAlias(deleteAliasRequest);
Assert.assertThat(request.getMethod(), equalTo(HttpDelete.METHOD_NAME));
Assert.assertThat(request.getEndpoint(), equalTo("/" + deleteAliasRequest.getIndex() + "/_alias/" + deleteAliasRequest.getAlias()));
Assert.assertThat(request.getParameters(), equalTo(expectedParams));
Assert.assertThat(request.getEntity(), nullValue());
}
use of org.opensearch.client.indices.DeleteAliasRequest in project OpenSearch by opensearch-project.
the class IndicesRequestConverters method deleteAlias.
static Request deleteAlias(DeleteAliasRequest deleteAliasRequest) {
String endpoint = new RequestConverters.EndpointBuilder().addPathPart(deleteAliasRequest.getIndex()).addPathPartAsIs("_alias").addPathPart(deleteAliasRequest.getAlias()).build();
Request request = new Request(HttpDelete.METHOD_NAME, endpoint);
RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withTimeout(deleteAliasRequest.timeout());
parameters.withMasterTimeout(deleteAliasRequest.masterNodeTimeout());
request.addParameters(parameters.asMap());
return request;
}
use of org.opensearch.client.indices.DeleteAliasRequest in project OpenSearch by opensearch-project.
the class IndicesClientIT method testDeleteAlias.
public void testDeleteAlias() throws IOException {
String index = "test";
createIndex(index, Settings.EMPTY);
String alias = "alias";
String alias2 = "alias2";
IndicesAliasesRequest aliasesAddRemoveRequest = new IndicesAliasesRequest();
aliasesAddRemoveRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).indices(index).alias(alias));
aliasesAddRemoveRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).indices(index).alias(alias + "2"));
AcknowledgedResponse aliasResponse = execute(aliasesAddRemoveRequest, highLevelClient().indices()::updateAliases, highLevelClient().indices()::updateAliasesAsync);
assertTrue(aliasResponse.isAcknowledged());
assertThat(aliasExists(alias), equalTo(true));
assertThat(aliasExists(alias2), equalTo(true));
assertThat(aliasExists(index, alias), equalTo(true));
assertThat(aliasExists(index, alias2), equalTo(true));
DeleteAliasRequest request = new DeleteAliasRequest(index, alias);
org.opensearch.client.core.AcknowledgedResponse aliasDeleteResponse = execute(request, highLevelClient().indices()::deleteAlias, highLevelClient().indices()::deleteAliasAsync);
assertThat(aliasExists(alias), equalTo(false));
assertThat(aliasExists(alias2), equalTo(true));
assertThat(aliasExists(index, alias), equalTo(false));
assertThat(aliasExists(index, alias2), equalTo(true));
}
Aggregations