use of org.opensearch.action.admin.cluster.node.reload.NodesReloadSecureSettingsRequest in project OpenSearch by opensearch-project.
the class RestReloadSecureSettingsAction method prepareRequest.
@Override
public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
final String[] nodesIds = Strings.splitStringByCommaToArray(request.param("nodeId"));
final NodesReloadSecureSettingsRequestBuilder nodesRequestBuilder = client.admin().cluster().prepareReloadSecureSettings().setTimeout(request.param("timeout")).setNodesIds(nodesIds);
request.withContentOrSourceParamParserOrNull(parser -> {
if (parser != null) {
final NodesReloadSecureSettingsRequest nodesRequest = PARSER.parse(parser, null);
nodesRequestBuilder.setSecureStorePassword(nodesRequest.getSecureSettingsPassword());
}
});
return channel -> nodesRequestBuilder.execute(new RestBuilderListener<NodesReloadSecureSettingsResponse>(channel) {
@Override
public RestResponse buildResponse(NodesReloadSecureSettingsResponse response, XContentBuilder builder) throws Exception {
builder.startObject();
RestActions.buildNodesHeader(builder, channel.request(), response);
builder.field("cluster_name", response.getClusterName().value());
response.toXContent(builder, channel.request());
builder.endObject();
nodesRequestBuilder.request().closePassword();
return new BytesRestResponse(RestStatus.OK, builder);
}
});
}
use of org.opensearch.action.admin.cluster.node.reload.NodesReloadSecureSettingsRequest in project OpenSearch by opensearch-project.
the class RestReloadSecureSettingsActionTests method testParserWithoutPassword.
public void testParserWithoutPassword() throws Exception {
final String request = "{" + "}";
try (XContentParser parser = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, request)) {
NodesReloadSecureSettingsRequest reloadSecureSettingsRequest = RestReloadSecureSettingsAction.PARSER.parse(parser, null);
assertThat(reloadSecureSettingsRequest.getSecureSettingsPassword(), nullValue());
}
}
use of org.opensearch.action.admin.cluster.node.reload.NodesReloadSecureSettingsRequest in project OpenSearch by opensearch-project.
the class RestReloadSecureSettingsActionTests method testParserWithPassword.
public void testParserWithPassword() throws Exception {
final String request = "{" + "\"secure_settings_password\": \"secure_settings_password_string\"" + "}";
try (XContentParser parser = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, request)) {
NodesReloadSecureSettingsRequest reloadSecureSettingsRequest = RestReloadSecureSettingsAction.PARSER.parse(parser, null);
assertEquals("secure_settings_password_string", reloadSecureSettingsRequest.getSecureSettingsPassword().toString());
}
}
Aggregations