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;
}
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;
}
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()));
}
Aggregations