Skip to content

Commit fbc49de

Browse files
committed
Use generic AcknowledgedResponse instead of extended classes (elastic#32859)
This removes custom Response classes that extend `AcknowledgedResponse` and do nothing, these classes are not needed and we can directly use the non-abstract super-class instead. While this appears to be a large PR, no code has actually changed, only class names have been changed and entire classes removed.
1 parent 3b047ae commit fbc49de

File tree

172 files changed

+855
-2091
lines changed

Some content is hidden

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

172 files changed

+855
-2091
lines changed

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

+47-51
Large diffs are not rendered by default.

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.apache.http.HttpEntity;
2323
import org.elasticsearch.action.ActionListener;
24+
import org.elasticsearch.action.support.master.AcknowledgedResponse;
2425
import org.elasticsearch.common.Strings;
2526
import org.elasticsearch.common.io.Streams;
2627
import org.elasticsearch.common.xcontent.DeprecationHandler;
@@ -30,7 +31,6 @@
3031
import org.elasticsearch.common.xcontent.XContentParser;
3132
import org.elasticsearch.common.xcontent.XContentType;
3233
import org.elasticsearch.protocol.xpack.license.DeleteLicenseRequest;
33-
import org.elasticsearch.protocol.xpack.license.DeleteLicenseResponse;
3434
import org.elasticsearch.protocol.xpack.license.GetLicenseRequest;
3535
import org.elasticsearch.protocol.xpack.license.GetLicenseResponse;
3636
import org.elasticsearch.protocol.xpack.license.PutLicenseRequest;
@@ -106,19 +106,19 @@ public void getLicenseAsync(GetLicenseRequest request, RequestOptions options, A
106106
* @return the response
107107
* @throws IOException in case there is a problem sending the request or parsing back the response
108108
*/
109-
public DeleteLicenseResponse deleteLicense(DeleteLicenseRequest request, RequestOptions options) throws IOException {
109+
public AcknowledgedResponse deleteLicense(DeleteLicenseRequest request, RequestOptions options) throws IOException {
110110
return restHighLevelClient.performRequestAndParseEntity(request, RequestConverters::deleteLicense, options,
111-
DeleteLicenseResponse::fromXContent, emptySet());
111+
AcknowledgedResponse::fromXContent, emptySet());
112112
}
113113

114114
/**
115115
* Asynchronously deletes license from the cluster.
116116
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
117117
* @param listener the listener to be notified upon request completion
118118
*/
119-
public void deleteLicenseAsync(DeleteLicenseRequest request, RequestOptions options, ActionListener<DeleteLicenseResponse> listener) {
119+
public void deleteLicenseAsync(DeleteLicenseRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
120120
restHighLevelClient.performRequestAsyncAndParseEntity(request, RequestConverters::deleteLicense, options,
121-
DeleteLicenseResponse::fromXContent, listener, emptySet());
121+
AcknowledgedResponse::fromXContent, listener, emptySet());
122122
}
123123

124124
/**

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.elasticsearch.action.ActionRequest;
2828
import org.elasticsearch.action.ActionRequestValidationException;
2929
import org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptRequest;
30-
import org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptResponse;
3130
import org.elasticsearch.action.admin.cluster.storedscripts.GetStoredScriptRequest;
3231
import org.elasticsearch.action.admin.cluster.storedscripts.GetStoredScriptResponse;
3332
import org.elasticsearch.action.bulk.BulkRequest;
@@ -53,6 +52,7 @@
5352
import org.elasticsearch.action.search.SearchRequest;
5453
import org.elasticsearch.action.search.SearchResponse;
5554
import org.elasticsearch.action.search.SearchScrollRequest;
55+
import org.elasticsearch.action.support.master.AcknowledgedResponse;
5656
import org.elasticsearch.action.update.UpdateRequest;
5757
import org.elasticsearch.action.update.UpdateResponse;
5858
import org.elasticsearch.common.CheckedConsumer;
@@ -1223,9 +1223,9 @@ public void getScriptAsync(GetStoredScriptRequest request, RequestOptions option
12231223
* @return the response
12241224
* @throws IOException in case there is a problem sending the request or parsing back the response
12251225
*/
1226-
public DeleteStoredScriptResponse deleteScript(DeleteStoredScriptRequest request, RequestOptions options) throws IOException {
1226+
public AcknowledgedResponse deleteScript(DeleteStoredScriptRequest request, RequestOptions options) throws IOException {
12271227
return performRequestAndParseEntity(request, RequestConverters::deleteScript, options,
1228-
DeleteStoredScriptResponse::fromXContent, emptySet());
1228+
AcknowledgedResponse::fromXContent, emptySet());
12291229
}
12301230

12311231
/**
@@ -1237,9 +1237,9 @@ public DeleteStoredScriptResponse deleteScript(DeleteStoredScriptRequest request
12371237
* @param listener the listener to be notified upon request completion
12381238
*/
12391239
public void deleteScriptAsync(DeleteStoredScriptRequest request, RequestOptions options,
1240-
ActionListener<DeleteStoredScriptResponse> listener) {
1240+
ActionListener<AcknowledgedResponse> listener) {
12411241
performRequestAsyncAndParseEntity(request, RequestConverters::deleteScript, options,
1242-
DeleteStoredScriptResponse::fromXContent, listener, emptySet());
1242+
AcknowledgedResponse::fromXContent, listener, emptySet());
12431243
}
12441244

12451245
/**

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

+16-18
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,21 @@
2121

2222
import org.elasticsearch.action.ActionListener;
2323
import org.elasticsearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest;
24-
import org.elasticsearch.action.admin.cluster.repositories.delete.DeleteRepositoryResponse;
2524
import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesRequest;
2625
import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesResponse;
2726
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryRequest;
28-
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse;
2927
import org.elasticsearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest;
3028
import org.elasticsearch.action.admin.cluster.repositories.verify.VerifyRepositoryResponse;
3129
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest;
3230
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
31+
import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest;
32+
import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest;
33+
import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse;
3334
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest;
3435
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
3536
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotsStatusRequest;
3637
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotsStatusResponse;
37-
import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest;
38-
import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotResponse;
39-
import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest;
40-
import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse;
38+
import org.elasticsearch.action.support.master.AcknowledgedResponse;
4139

4240
import java.io.IOException;
4341

@@ -95,9 +93,9 @@ public void getRepositoryAsync(GetRepositoriesRequest getRepositoriesRequest, Re
9593
* @return the response
9694
* @throws IOException in case there is a problem sending the request or parsing back the response
9795
*/
98-
public PutRepositoryResponse createRepository(PutRepositoryRequest putRepositoryRequest, RequestOptions options) throws IOException {
96+
public AcknowledgedResponse createRepository(PutRepositoryRequest putRepositoryRequest, RequestOptions options) throws IOException {
9997
return restHighLevelClient.performRequestAndParseEntity(putRepositoryRequest, RequestConverters::createRepository, options,
100-
PutRepositoryResponse::fromXContent, emptySet());
98+
AcknowledgedResponse::fromXContent, emptySet());
10199
}
102100

103101
/**
@@ -109,9 +107,9 @@ public PutRepositoryResponse createRepository(PutRepositoryRequest putRepository
109107
* @param listener the listener to be notified upon request completion
110108
*/
111109
public void createRepositoryAsync(PutRepositoryRequest putRepositoryRequest, RequestOptions options,
112-
ActionListener<PutRepositoryResponse> listener) {
110+
ActionListener<AcknowledgedResponse> listener) {
113111
restHighLevelClient.performRequestAsyncAndParseEntity(putRepositoryRequest, RequestConverters::createRepository, options,
114-
PutRepositoryResponse::fromXContent, listener, emptySet());
112+
AcknowledgedResponse::fromXContent, listener, emptySet());
115113
}
116114

117115
/**
@@ -123,10 +121,10 @@ public void createRepositoryAsync(PutRepositoryRequest putRepositoryRequest, Req
123121
* @return the response
124122
* @throws IOException in case there is a problem sending the request or parsing back the response
125123
*/
126-
public DeleteRepositoryResponse deleteRepository(DeleteRepositoryRequest deleteRepositoryRequest, RequestOptions options)
124+
public AcknowledgedResponse deleteRepository(DeleteRepositoryRequest deleteRepositoryRequest, RequestOptions options)
127125
throws IOException {
128126
return restHighLevelClient.performRequestAndParseEntity(deleteRepositoryRequest, RequestConverters::deleteRepository, options,
129-
DeleteRepositoryResponse::fromXContent, emptySet());
127+
AcknowledgedResponse::fromXContent, emptySet());
130128
}
131129

132130
/**
@@ -138,9 +136,9 @@ public DeleteRepositoryResponse deleteRepository(DeleteRepositoryRequest deleteR
138136
* @param listener the listener to be notified upon request completion
139137
*/
140138
public void deleteRepositoryAsync(DeleteRepositoryRequest deleteRepositoryRequest, RequestOptions options,
141-
ActionListener<DeleteRepositoryResponse> listener) {
139+
ActionListener<AcknowledgedResponse> listener) {
142140
restHighLevelClient.performRequestAsyncAndParseEntity(deleteRepositoryRequest, RequestConverters::deleteRepository, options,
143-
DeleteRepositoryResponse::fromXContent, listener, emptySet());
141+
AcknowledgedResponse::fromXContent, listener, emptySet());
144142
}
145143

146144
/**
@@ -294,9 +292,9 @@ public void restoreAsync(RestoreSnapshotRequest restoreSnapshotRequest, RequestO
294292
* @return the response
295293
* @throws IOException in case there is a problem sending the request or parsing back the response
296294
*/
297-
public DeleteSnapshotResponse delete(DeleteSnapshotRequest deleteSnapshotRequest, RequestOptions options) throws IOException {
295+
public AcknowledgedResponse delete(DeleteSnapshotRequest deleteSnapshotRequest, RequestOptions options) throws IOException {
298296
return restHighLevelClient.performRequestAndParseEntity(deleteSnapshotRequest, RequestConverters::deleteSnapshot, options,
299-
DeleteSnapshotResponse::fromXContent, emptySet());
297+
AcknowledgedResponse::fromXContent, emptySet());
300298
}
301299

302300
/**
@@ -309,8 +307,8 @@ public DeleteSnapshotResponse delete(DeleteSnapshotRequest deleteSnapshotRequest
309307
* @param listener the listener to be notified upon request completion
310308
*/
311309
public void deleteAsync(DeleteSnapshotRequest deleteSnapshotRequest, RequestOptions options,
312-
ActionListener<DeleteSnapshotResponse> listener) {
310+
ActionListener<AcknowledgedResponse> listener) {
313311
restHighLevelClient.performRequestAsyncAndParseEntity(deleteSnapshotRequest, RequestConverters::deleteSnapshot, options,
314-
DeleteSnapshotResponse::fromXContent, listener, emptySet());
312+
AcknowledgedResponse::fromXContent, listener, emptySet());
315313
}
316314
}

0 commit comments

Comments
 (0)