Skip to content

Commit 6eddb15

Browse files
committed
Merge branch 'master' into feature-jindex-master
2 parents da3a6fd + 4a3d66c commit 6eddb15

File tree

296 files changed

+10224
-2797
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

296 files changed

+10224
-2797
lines changed

buildSrc/version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ slf4j = 1.6.2
1515
# when updating the JNA version, also update the version in buildSrc/build.gradle
1616
jna = 4.5.1
1717

18-
netty = 4.1.30.Final
18+
netty = 4.1.31.Final
1919
joda = 2.10.1
2020

2121
# test dependencies

client/rest-high-level/src/main/java/org/elasticsearch/client/CcrClient.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.elasticsearch.action.ActionListener;
2323
import org.elasticsearch.client.ccr.PauseFollowRequest;
24+
import org.elasticsearch.client.ccr.PutAutoFollowPatternRequest;
2425
import org.elasticsearch.client.ccr.PutFollowRequest;
2526
import org.elasticsearch.client.ccr.PutFollowResponse;
2627
import org.elasticsearch.client.ccr.ResumeFollowRequest;
@@ -219,4 +220,46 @@ public void unfollowAsync(UnfollowRequest request,
219220
);
220221
}
221222

223+
/**
224+
* Stores an auto follow pattern.
225+
*
226+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html">
227+
* the docs</a> for more.
228+
*
229+
* @param request the request
230+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
231+
* @return the response
232+
* @throws IOException in case there is a problem sending the request or parsing back the response
233+
*/
234+
public AcknowledgedResponse putAutoFollowPattern(PutAutoFollowPatternRequest request, RequestOptions options) throws IOException {
235+
return restHighLevelClient.performRequestAndParseEntity(
236+
request,
237+
CcrRequestConverters::putAutoFollowPattern,
238+
options,
239+
AcknowledgedResponse::fromXContent,
240+
Collections.emptySet()
241+
);
242+
}
243+
244+
/**
245+
* Asynchronously stores an auto follow pattern.
246+
*
247+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html">
248+
* the docs</a> for more.
249+
*
250+
* @param request the request
251+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
252+
*/
253+
public void putAutoFollowPatternAsync(PutAutoFollowPatternRequest request,
254+
RequestOptions options,
255+
ActionListener<AcknowledgedResponse> listener) {
256+
restHighLevelClient.performRequestAsyncAndParseEntity(
257+
request,
258+
CcrRequestConverters::putAutoFollowPattern,
259+
options,
260+
AcknowledgedResponse::fromXContent,
261+
listener,
262+
Collections.emptySet());
263+
}
264+
222265
}

client/rest-high-level/src/main/java/org/elasticsearch/client/CcrRequestConverters.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.http.client.methods.HttpPost;
2323
import org.apache.http.client.methods.HttpPut;
2424
import org.elasticsearch.client.ccr.PauseFollowRequest;
25+
import org.elasticsearch.client.ccr.PutAutoFollowPatternRequest;
2526
import org.elasticsearch.client.ccr.PutFollowRequest;
2627
import org.elasticsearch.client.ccr.ResumeFollowRequest;
2728
import org.elasticsearch.client.ccr.UnfollowRequest;
@@ -69,4 +70,14 @@ static Request unfollow(UnfollowRequest unfollowRequest) {
6970
return new Request(HttpPost.METHOD_NAME, endpoint);
7071
}
7172

73+
static Request putAutoFollowPattern(PutAutoFollowPatternRequest putAutoFollowPatternRequest) throws IOException {
74+
String endpoint = new RequestConverters.EndpointBuilder()
75+
.addPathPartAsIs("_ccr", "auto_follow")
76+
.addPathPart(putAutoFollowPatternRequest.getName())
77+
.build();
78+
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
79+
request.setEntity(createEntity(putAutoFollowPatternRequest, REQUEST_BODY_CONTENT_TYPE));
80+
return request;
81+
}
82+
7283
}

client/rest-high-level/src/main/java/org/elasticsearch/client/MLRequestConverters.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.elasticsearch.client.ml.DeleteCalendarJobRequest;
3333
import org.elasticsearch.client.ml.DeleteCalendarRequest;
3434
import org.elasticsearch.client.ml.DeleteDatafeedRequest;
35+
import org.elasticsearch.client.ml.DeleteExpiredDataRequest;
3536
import org.elasticsearch.client.ml.DeleteFilterRequest;
3637
import org.elasticsearch.client.ml.DeleteForecastRequest;
3738
import org.elasticsearch.client.ml.DeleteJobRequest;
@@ -155,6 +156,17 @@ static Request closeJob(CloseJobRequest closeJobRequest) throws IOException {
155156
return request;
156157
}
157158

159+
static Request deleteExpiredData(DeleteExpiredDataRequest deleteExpiredDataRequest) {
160+
String endpoint = new EndpointBuilder()
161+
.addPathPartAsIs("_xpack")
162+
.addPathPartAsIs("ml")
163+
.addPathPartAsIs("_delete_expired_data")
164+
.build();
165+
Request request = new Request(HttpDelete.METHOD_NAME, endpoint);
166+
167+
return request;
168+
}
169+
158170
static Request deleteJob(DeleteJobRequest deleteJobRequest) {
159171
String endpoint = new EndpointBuilder()
160172
.addPathPartAsIs("_xpack")

client/rest-high-level/src/main/java/org/elasticsearch/client/MachineLearningClient.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import org.elasticsearch.client.ml.DeleteCalendarJobRequest;
2727
import org.elasticsearch.client.ml.DeleteCalendarRequest;
2828
import org.elasticsearch.client.ml.DeleteDatafeedRequest;
29+
import org.elasticsearch.client.ml.DeleteExpiredDataRequest;
30+
import org.elasticsearch.client.ml.DeleteExpiredDataResponse;
2931
import org.elasticsearch.client.ml.DeleteFilterRequest;
3032
import org.elasticsearch.client.ml.DeleteForecastRequest;
3133
import org.elasticsearch.client.ml.DeleteJobRequest;
@@ -227,6 +229,48 @@ public void getJobStatsAsync(GetJobStatsRequest request, RequestOptions options,
227229
Collections.emptySet());
228230
}
229231

232+
/**
233+
* Deletes expired data from Machine Learning Jobs
234+
* <p>
235+
* For additional info
236+
* see <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-expired-data.html">ML Delete Expired Data
237+
* documentation</a>
238+
*
239+
* @param request The request to delete expired ML data
240+
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
241+
* @return The action response which contains the acknowledgement or the task id depending on whether the action was set to wait for
242+
* completion
243+
* @throws IOException when there is a serialization issue sending the request or receiving the response
244+
*/
245+
public DeleteExpiredDataResponse deleteExpiredData(DeleteExpiredDataRequest request, RequestOptions options) throws IOException {
246+
return restHighLevelClient.performRequestAndParseEntity(request,
247+
MLRequestConverters::deleteExpiredData,
248+
options,
249+
DeleteExpiredDataResponse::fromXContent,
250+
Collections.emptySet());
251+
}
252+
253+
/**
254+
* Deletes expired data from Machine Learning Jobs asynchronously and notifies the listener on completion
255+
* <p>
256+
* For additional info
257+
* see <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-expired-data.html">ML Delete Expired Data
258+
* documentation</a>
259+
*
260+
* @param request The request to delete expired ML data
261+
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
262+
* @param listener Listener to be notified upon request completion
263+
*/
264+
public void deleteExpiredDataAsync(DeleteExpiredDataRequest request, RequestOptions options,
265+
ActionListener<DeleteExpiredDataResponse> listener) {
266+
restHighLevelClient.performRequestAsyncAndParseEntity(request,
267+
MLRequestConverters::deleteExpiredData,
268+
options,
269+
DeleteExpiredDataResponse::fromXContent,
270+
listener,
271+
Collections.emptySet());
272+
}
273+
230274
/**
231275
* Deletes the given Machine Learning Job
232276
* <p>

client/rest-high-level/src/main/java/org/elasticsearch/client/SecurityClient.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
import org.elasticsearch.client.security.GetPrivilegesResponse;
4343
import org.elasticsearch.client.security.GetRoleMappingsRequest;
4444
import org.elasticsearch.client.security.GetRoleMappingsResponse;
45+
import org.elasticsearch.client.security.GetRolesRequest;
46+
import org.elasticsearch.client.security.GetRolesResponse;
4547
import org.elasticsearch.client.security.GetSslCertificatesRequest;
4648
import org.elasticsearch.client.security.GetSslCertificatesResponse;
4749
import org.elasticsearch.client.security.HasPrivilegesRequest;
@@ -407,6 +409,35 @@ public DeleteRoleMappingResponse deleteRoleMapping(DeleteRoleMappingRequest requ
407409
DeleteRoleMappingResponse::fromXContent, emptySet());
408410
}
409411

412+
/**
413+
* Asynchronously retrieves roles from the native roles store.
414+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html">
415+
* the docs</a> for more.
416+
*
417+
* @param request the request with the roles to get
418+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
419+
* @param listener the listener to be notified upon request completion
420+
*/
421+
public void getRolesAsync(GetRolesRequest request, RequestOptions options, ActionListener<GetRolesResponse> listener) {
422+
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::getRoles, options,
423+
GetRolesResponse::fromXContent, listener, emptySet());
424+
}
425+
426+
/**
427+
* Retrieves roles from the native roles store.
428+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html">
429+
* the docs</a> for more.
430+
*
431+
* @param request the request with the roles to get
432+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
433+
* @return the response from the delete role call
434+
* @throws IOException in case there is a problem sending the request or parsing back the response
435+
*/
436+
public GetRolesResponse getRoles(final GetRolesRequest request, final RequestOptions options) throws IOException {
437+
return restHighLevelClient.performRequestAndParseEntity(request, SecurityRequestConverters::getRoles, options,
438+
GetRolesResponse::fromXContent, emptySet());
439+
}
440+
410441
/**
411442
* Asynchronously delete a role mapping.
412443
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role-mapping.html">

client/rest-high-level/src/main/java/org/elasticsearch/client/SecurityRequestConverters.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.elasticsearch.client.security.DeleteRoleMappingRequest;
3333
import org.elasticsearch.client.security.DeleteRoleRequest;
3434
import org.elasticsearch.client.security.InvalidateTokenRequest;
35+
import org.elasticsearch.client.security.GetRolesRequest;
3536
import org.elasticsearch.client.security.PutRoleMappingRequest;
3637
import org.elasticsearch.client.security.HasPrivilegesRequest;
3738
import org.elasticsearch.client.security.DisableUserRequest;
@@ -170,6 +171,15 @@ static Request deleteRole(DeleteRoleRequest deleteRoleRequest) {
170171
return request;
171172
}
172173

174+
static Request getRoles(GetRolesRequest getRolesRequest) {
175+
RequestConverters.EndpointBuilder builder = new RequestConverters.EndpointBuilder();
176+
builder.addPathPartAsIs("_xpack/security/role");
177+
if (getRolesRequest.getRoleNames().size() > 0) {
178+
builder.addPathPart(Strings.collectionToCommaDelimitedString(getRolesRequest.getRoleNames()));
179+
}
180+
return new Request(HttpGet.METHOD_NAME, builder.build());
181+
}
182+
173183
static Request createToken(CreateTokenRequest createTokenRequest) throws IOException {
174184
Request request = new Request(HttpPost.METHOD_NAME, "/_xpack/security/oauth2/token");
175185
request.setEntity(createEntity(createTokenRequest, REQUEST_BODY_CONTENT_TYPE));
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.client.ccr;
21+
22+
import org.elasticsearch.client.Validatable;
23+
import org.elasticsearch.common.ParseField;
24+
import org.elasticsearch.common.xcontent.ToXContentObject;
25+
import org.elasticsearch.common.xcontent.XContentBuilder;
26+
27+
import java.io.IOException;
28+
import java.util.List;
29+
import java.util.Objects;
30+
31+
public final class PutAutoFollowPatternRequest extends FollowConfig implements Validatable, ToXContentObject {
32+
33+
static final ParseField LEADER_PATTERNS_FIELD = new ParseField("leader_index_patterns");
34+
static final ParseField FOLLOW_PATTERN_FIELD = new ParseField("follow_index_pattern");
35+
36+
private final String name;
37+
private final String remoteCluster;
38+
private final List<String> leaderIndexPatterns;
39+
private String followIndexNamePattern;
40+
41+
public PutAutoFollowPatternRequest(String name, String remoteCluster, List<String> leaderIndexPatterns) {
42+
this.name = Objects.requireNonNull(name);
43+
this.remoteCluster = Objects.requireNonNull(remoteCluster);
44+
this.leaderIndexPatterns = Objects.requireNonNull(leaderIndexPatterns);
45+
}
46+
47+
public String getName() {
48+
return name;
49+
}
50+
51+
public String getRemoteCluster() {
52+
return remoteCluster;
53+
}
54+
55+
public List<String> getLeaderIndexPatterns() {
56+
return leaderIndexPatterns;
57+
}
58+
59+
public String getFollowIndexNamePattern() {
60+
return followIndexNamePattern;
61+
}
62+
63+
public void setFollowIndexNamePattern(String followIndexNamePattern) {
64+
this.followIndexNamePattern = followIndexNamePattern;
65+
}
66+
67+
@Override
68+
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
69+
builder.startObject();
70+
builder.field(PutFollowRequest.REMOTE_CLUSTER_FIELD.getPreferredName(), remoteCluster);
71+
builder.field(LEADER_PATTERNS_FIELD.getPreferredName(), leaderIndexPatterns);
72+
if (followIndexNamePattern != null) {
73+
builder.field(FOLLOW_PATTERN_FIELD.getPreferredName(), followIndexNamePattern);
74+
}
75+
toXContentFragment(builder, params);
76+
builder.endObject();
77+
return builder;
78+
}
79+
80+
@Override
81+
public boolean equals(Object o) {
82+
if (this == o) return true;
83+
if (o == null || getClass() != o.getClass()) return false;
84+
if (!super.equals(o)) return false;
85+
PutAutoFollowPatternRequest that = (PutAutoFollowPatternRequest) o;
86+
return Objects.equals(name, that.name) &&
87+
Objects.equals(remoteCluster, that.remoteCluster) &&
88+
Objects.equals(leaderIndexPatterns, that.leaderIndexPatterns) &&
89+
Objects.equals(followIndexNamePattern, that.followIndexNamePattern);
90+
}
91+
92+
@Override
93+
public int hashCode() {
94+
return Objects.hash(
95+
super.hashCode(),
96+
name,
97+
remoteCluster,
98+
leaderIndexPatterns,
99+
followIndexNamePattern
100+
);
101+
}
102+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.elasticsearch.client.ml;
20+
21+
import org.elasticsearch.action.ActionRequest;
22+
import org.elasticsearch.action.ActionRequestValidationException;
23+
24+
/**
25+
* Request to delete expired model snapshots and forecasts
26+
*/
27+
public class DeleteExpiredDataRequest extends ActionRequest {
28+
29+
/**
30+
* Create a new request to delete expired data
31+
*/
32+
public DeleteExpiredDataRequest() {
33+
}
34+
35+
@Override
36+
public ActionRequestValidationException validate() {
37+
return null;
38+
}
39+
}

0 commit comments

Comments
 (0)