use of org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest in project OpenSearch by opensearch-project.
the class SnapshotRequestConverters method verifyRepository.
static Request verifyRepository(VerifyRepositoryRequest verifyRepositoryRequest) {
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_snapshot").addPathPart(verifyRepositoryRequest.name()).addPathPartAsIs("_verify").build();
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withMasterTimeout(verifyRepositoryRequest.masterNodeTimeout());
parameters.withTimeout(verifyRepositoryRequest.timeout());
request.addParameters(parameters.asMap());
return request;
}
use of org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest in project OpenSearch by opensearch-project.
the class SnapshotRequestConvertersTests method testVerifyRepository.
public void testVerifyRepository() {
Map<String, String> expectedParams = new HashMap<>();
String repository = RequestConvertersTests.randomIndicesNames(1, 1)[0];
String endpoint = "/_snapshot/" + repository + "/_verify";
VerifyRepositoryRequest verifyRepositoryRequest = new VerifyRepositoryRequest(repository);
RequestConvertersTests.setRandomMasterTimeout(verifyRepositoryRequest, expectedParams);
RequestConvertersTests.setRandomTimeout(verifyRepositoryRequest::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams);
Request request = SnapshotRequestConverters.verifyRepository(verifyRepositoryRequest);
assertThat(request.getEndpoint(), equalTo(endpoint));
assertThat(request.getMethod(), equalTo(HttpPost.METHOD_NAME));
assertThat(request.getParameters(), equalTo(expectedParams));
}
use of org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest in project OpenSearch by opensearch-project.
the class SnapshotIT method testVerifyRepository.
public void testVerifyRepository() throws IOException {
AcknowledgedResponse putRepositoryResponse = createTestRepository("test", FsRepository.TYPE, "{\"location\": \".\"}");
assertTrue(putRepositoryResponse.isAcknowledged());
VerifyRepositoryRequest request = new VerifyRepositoryRequest("test");
VerifyRepositoryResponse response = execute(request, highLevelClient().snapshot()::verifyRepository, highLevelClient().snapshot()::verifyRepositoryAsync);
assertThat(response.getNodes().size(), equalTo(1));
}
use of org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest in project OpenSearch by opensearch-project.
the class SnapshotClientDocumentationIT method testSnapshotVerifyRepository.
public void testSnapshotVerifyRepository() throws IOException {
RestHighLevelClient client = highLevelClient();
createTestRepositories();
// tag::verify-repository-request
VerifyRepositoryRequest request = new VerifyRepositoryRequest(repositoryName);
// end::verify-repository-request
// tag::verify-repository-request-masterTimeout
// <1>
request.masterNodeTimeout(TimeValue.timeValueMinutes(1));
// <2>
request.masterNodeTimeout("1m");
// end::verify-repository-request-masterTimeout
// tag::verify-repository-request-timeout
// <1>
request.timeout(TimeValue.timeValueMinutes(1));
// <2>
request.timeout("1m");
// end::verify-repository-request-timeout
// tag::verify-repository-execute
VerifyRepositoryResponse response = client.snapshot().verifyRepository(request, RequestOptions.DEFAULT);
// end::verify-repository-execute
// tag::verify-repository-response
List<VerifyRepositoryResponse.NodeView> repositoryMetadataResponse = response.getNodes();
// end::verify-repository-response
assertThat(1, equalTo(repositoryMetadataResponse.size()));
final boolean async = Booleans.parseBoolean(System.getProperty("tests.rest.async", "false"));
if (async) {
assertThat("asyncIntegTest-0", equalTo(repositoryMetadataResponse.get(0).getName()));
} else {
assertThat("integTest-0", equalTo(repositoryMetadataResponse.get(0).getName()));
}
}
use of org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest in project OpenSearch by opensearch-project.
the class RestVerifyRepositoryAction method prepareRequest.
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
VerifyRepositoryRequest verifyRepositoryRequest = verifyRepositoryRequest(request.param("repository"));
verifyRepositoryRequest.masterNodeTimeout(request.paramAsTime("master_timeout", verifyRepositoryRequest.masterNodeTimeout()));
verifyRepositoryRequest.timeout(request.paramAsTime("timeout", verifyRepositoryRequest.timeout()));
return channel -> client.admin().cluster().verifyRepository(verifyRepositoryRequest, new RestToXContentListener<>(channel));
}
Aggregations