Search in sources :

Example 1 with DeleteAliasRequest

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());
}
Also used : HashMap(java.util.HashMap) DeleteAliasRequest(org.opensearch.client.indices.DeleteAliasRequest) UpdateSettingsRequest(org.opensearch.action.admin.indices.settings.put.UpdateSettingsRequest) RefreshRequest(org.opensearch.action.admin.indices.refresh.RefreshRequest) OpenIndexRequest(org.opensearch.action.admin.indices.open.OpenIndexRequest) ForceMergeRequest(org.opensearch.action.admin.indices.forcemerge.ForceMergeRequest) GetDataStreamRequest(org.opensearch.client.indices.GetDataStreamRequest) AnalyzeRequest(org.opensearch.client.indices.AnalyzeRequest) DeleteIndexTemplateRequest(org.opensearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest) AcknowledgedRequest(org.opensearch.action.support.master.AcknowledgedRequest) PutMappingRequest(org.opensearch.client.indices.PutMappingRequest) PutIndexTemplateRequest(org.opensearch.client.indices.PutIndexTemplateRequest) DeleteDataStreamRequest(org.opensearch.client.indices.DeleteDataStreamRequest) ClearIndicesCacheRequest(org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest) RolloverRequest(org.opensearch.client.indices.rollover.RolloverRequest) CreateIndexRequest(org.opensearch.client.indices.CreateIndexRequest) FlushRequest(org.opensearch.action.admin.indices.flush.FlushRequest) GetIndexRequest(org.opensearch.client.indices.GetIndexRequest) DeleteAliasRequest(org.opensearch.client.indices.DeleteAliasRequest) GetFieldMappingsRequest(org.opensearch.client.indices.GetFieldMappingsRequest) GetSettingsRequest(org.opensearch.action.admin.indices.settings.get.GetSettingsRequest) DeleteIndexRequest(org.opensearch.action.admin.indices.delete.DeleteIndexRequest) ResizeRequest(org.opensearch.client.indices.ResizeRequest) CloseIndexRequest(org.opensearch.client.indices.CloseIndexRequest) GetIndexTemplatesRequest(org.opensearch.client.indices.GetIndexTemplatesRequest) GetMappingsRequest(org.opensearch.client.indices.GetMappingsRequest) GetAliasesRequest(org.opensearch.action.admin.indices.alias.get.GetAliasesRequest) CreateDataStreamRequest(org.opensearch.client.indices.CreateDataStreamRequest) IndicesAliasesRequest(org.opensearch.action.admin.indices.alias.IndicesAliasesRequest) ValidateQueryRequest(org.opensearch.action.admin.indices.validate.query.ValidateQueryRequest) IndexTemplatesExistRequest(org.opensearch.client.indices.IndexTemplatesExistRequest)

Example 2 with DeleteAliasRequest

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;
}
Also used : UpdateSettingsRequest(org.opensearch.action.admin.indices.settings.put.UpdateSettingsRequest) CreateIndexRequest(org.opensearch.client.indices.CreateIndexRequest) SimulateIndexTemplateRequest(org.opensearch.client.indices.SimulateIndexTemplateRequest) FlushRequest(org.opensearch.action.admin.indices.flush.FlushRequest) RefreshRequest(org.opensearch.action.admin.indices.refresh.RefreshRequest) GetIndexRequest(org.opensearch.client.indices.GetIndexRequest) DeleteAliasRequest(org.opensearch.client.indices.DeleteAliasRequest) OpenIndexRequest(org.opensearch.action.admin.indices.open.OpenIndexRequest) GetFieldMappingsRequest(org.opensearch.client.indices.GetFieldMappingsRequest) ForceMergeRequest(org.opensearch.action.admin.indices.forcemerge.ForceMergeRequest) GetSettingsRequest(org.opensearch.action.admin.indices.settings.get.GetSettingsRequest) GetDataStreamRequest(org.opensearch.client.indices.GetDataStreamRequest) DeleteIndexRequest(org.opensearch.action.admin.indices.delete.DeleteIndexRequest) ComposableIndexTemplateExistRequest(org.opensearch.client.indices.ComposableIndexTemplateExistRequest) AnalyzeRequest(org.opensearch.client.indices.AnalyzeRequest) ResizeRequest(org.opensearch.client.indices.ResizeRequest) GetComposableIndexTemplateRequest(org.opensearch.client.indices.GetComposableIndexTemplateRequest) DataStreamsStatsRequest(org.opensearch.client.indices.DataStreamsStatsRequest) DeleteIndexTemplateRequest(org.opensearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest) CloseIndexRequest(org.opensearch.client.indices.CloseIndexRequest) GetIndexTemplatesRequest(org.opensearch.client.indices.GetIndexTemplatesRequest) GetMappingsRequest(org.opensearch.client.indices.GetMappingsRequest) GetAliasesRequest(org.opensearch.action.admin.indices.alias.get.GetAliasesRequest) PutComposableIndexTemplateRequest(org.opensearch.client.indices.PutComposableIndexTemplateRequest) CreateDataStreamRequest(org.opensearch.client.indices.CreateDataStreamRequest) IndicesAliasesRequest(org.opensearch.action.admin.indices.alias.IndicesAliasesRequest) PutMappingRequest(org.opensearch.client.indices.PutMappingRequest) DeleteComposableIndexTemplateRequest(org.opensearch.client.indices.DeleteComposableIndexTemplateRequest) PutIndexTemplateRequest(org.opensearch.client.indices.PutIndexTemplateRequest) ValidateQueryRequest(org.opensearch.action.admin.indices.validate.query.ValidateQueryRequest) DeleteDataStreamRequest(org.opensearch.client.indices.DeleteDataStreamRequest) ClearIndicesCacheRequest(org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest) IndexTemplatesExistRequest(org.opensearch.client.indices.IndexTemplatesExistRequest) RolloverRequest(org.opensearch.client.indices.rollover.RolloverRequest)

Example 3 with DeleteAliasRequest

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));
}
Also used : AcknowledgedResponse(org.opensearch.action.support.master.AcknowledgedResponse) DeleteAliasRequest(org.opensearch.client.indices.DeleteAliasRequest) IndicesAliasesRequest(org.opensearch.action.admin.indices.alias.IndicesAliasesRequest) Matchers.containsString(org.hamcrest.Matchers.containsString) AliasActions(org.opensearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions)

Aggregations

IndicesAliasesRequest (org.opensearch.action.admin.indices.alias.IndicesAliasesRequest)3 DeleteAliasRequest (org.opensearch.client.indices.DeleteAliasRequest)3 GetAliasesRequest (org.opensearch.action.admin.indices.alias.get.GetAliasesRequest)2 ClearIndicesCacheRequest (org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest)2 DeleteIndexRequest (org.opensearch.action.admin.indices.delete.DeleteIndexRequest)2 FlushRequest (org.opensearch.action.admin.indices.flush.FlushRequest)2 ForceMergeRequest (org.opensearch.action.admin.indices.forcemerge.ForceMergeRequest)2 OpenIndexRequest (org.opensearch.action.admin.indices.open.OpenIndexRequest)2 RefreshRequest (org.opensearch.action.admin.indices.refresh.RefreshRequest)2 GetSettingsRequest (org.opensearch.action.admin.indices.settings.get.GetSettingsRequest)2 UpdateSettingsRequest (org.opensearch.action.admin.indices.settings.put.UpdateSettingsRequest)2 DeleteIndexTemplateRequest (org.opensearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest)2 ValidateQueryRequest (org.opensearch.action.admin.indices.validate.query.ValidateQueryRequest)2 AnalyzeRequest (org.opensearch.client.indices.AnalyzeRequest)2 CloseIndexRequest (org.opensearch.client.indices.CloseIndexRequest)2 CreateDataStreamRequest (org.opensearch.client.indices.CreateDataStreamRequest)2 CreateIndexRequest (org.opensearch.client.indices.CreateIndexRequest)2 DeleteDataStreamRequest (org.opensearch.client.indices.DeleteDataStreamRequest)2 GetDataStreamRequest (org.opensearch.client.indices.GetDataStreamRequest)2 GetFieldMappingsRequest (org.opensearch.client.indices.GetFieldMappingsRequest)2