Search in sources :

Example 1 with IndexTemplatesExistRequest

use of org.opensearch.client.indices.IndexTemplatesExistRequest in project OpenSearch by opensearch-project.

the class IndicesRequestConverters method templatesExist.

static Request templatesExist(ComposableIndexTemplateExistRequest indexTemplatesExistRequest) {
    final String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_index_template").addPathPart(indexTemplatesExistRequest.name()).build();
    final Request request = new Request(HttpHead.METHOD_NAME, endpoint);
    final RequestConverters.Params params = new RequestConverters.Params();
    params.withLocal(indexTemplatesExistRequest.isLocal());
    params.withMasterTimeout(indexTemplatesExistRequest.getMasterNodeTimeout());
    request.addParameters(params.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 2 with IndexTemplatesExistRequest

use of org.opensearch.client.indices.IndexTemplatesExistRequest in project OpenSearch by opensearch-project.

the class IndicesRequestConverters method templatesExist.

static Request templatesExist(IndexTemplatesExistRequest indexTemplatesExistRequest) {
    final String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_template").addCommaSeparatedPathParts(indexTemplatesExistRequest.names()).build();
    final Request request = new Request(HttpHead.METHOD_NAME, endpoint);
    final RequestConverters.Params params = new RequestConverters.Params();
    params.withLocal(indexTemplatesExistRequest.isLocal());
    params.withMasterTimeout(indexTemplatesExistRequest.getMasterNodeTimeout());
    request.addParameters(params.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 IndexTemplatesExistRequest

use of org.opensearch.client.indices.IndexTemplatesExistRequest in project OpenSearch by opensearch-project.

the class IndicesRequestConvertersTests method testTemplatesExistRequest.

public void testTemplatesExistRequest() {
    final int numberOfNames = OpenSearchTestCase.usually() ? 1 : OpenSearchTestCase.randomIntBetween(2, 20);
    final List<String> names = Arrays.asList(OpenSearchTestCase.randomArray(numberOfNames, numberOfNames, String[]::new, () -> OpenSearchTestCase.randomAlphaOfLengthBetween(1, 100)));
    final Map<String, String> expectedParams = new HashMap<>();
    final IndexTemplatesExistRequest indexTemplatesExistRequest = new IndexTemplatesExistRequest(names);
    RequestConvertersTests.setRandomMasterTimeout(indexTemplatesExistRequest::setMasterNodeTimeout, expectedParams);
    RequestConvertersTests.setRandomLocal(indexTemplatesExistRequest::setLocal, expectedParams);
    assertThat(indexTemplatesExistRequest.names(), equalTo(names));
    final Request request = IndicesRequestConverters.templatesExist(indexTemplatesExistRequest);
    assertThat(request.getMethod(), equalTo(HttpHead.METHOD_NAME));
    assertThat(request.getEndpoint(), equalTo("/_template/" + String.join(",", names)));
    assertThat(request.getParameters(), equalTo(expectedParams));
    assertThat(request.getEntity(), nullValue());
    expectThrows(NullPointerException.class, () -> new IndexTemplatesExistRequest((String[]) null));
    expectThrows(NullPointerException.class, () -> new IndexTemplatesExistRequest((List<String>) null));
    expectThrows(IllegalArgumentException.class, () -> new IndexTemplatesExistRequest(new String[] { (randomBoolean() ? "" : null) }));
    expectThrows(IllegalArgumentException.class, () -> new IndexTemplatesExistRequest(singletonList(randomBoolean() ? "" : null)));
    expectThrows(IllegalArgumentException.class, () -> new IndexTemplatesExistRequest(new String[] {}));
    expectThrows(IllegalArgumentException.class, () -> new IndexTemplatesExistRequest(emptyList()));
}
Also used : HashMap(java.util.HashMap) IndexTemplatesExistRequest(org.opensearch.client.indices.IndexTemplatesExistRequest) 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) Collections.singletonList(java.util.Collections.singletonList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List)

Aggregations

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