-
Notifications
You must be signed in to change notification settings - Fork 24.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HLRC: split migration request converters (#33436)
In an effort to encapsulate the different clients, the request converters are being shuffled around. This splits the MigrationClient request converters.
- Loading branch information
Showing
5 changed files
with
88 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...nt/rest-high-level/src/main/java/org/elasticsearch/client/MigrationRequestConverters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.client; | ||
|
||
import org.apache.http.client.methods.HttpGet; | ||
import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoRequest; | ||
|
||
public class MigrationRequestConverters { | ||
|
||
static Request getMigrationAssistance(IndexUpgradeInfoRequest indexUpgradeInfoRequest) { | ||
RequestConverters.EndpointBuilder endpointBuilder = new RequestConverters.EndpointBuilder() | ||
.addPathPartAsIs("_xpack/migration/assistance") | ||
.addCommaSeparatedPathParts(indexUpgradeInfoRequest.indices()); | ||
String endpoint = endpointBuilder.build(); | ||
Request request = new Request(HttpGet.METHOD_NAME, endpoint); | ||
RequestConverters.Params parameters = new RequestConverters.Params(request); | ||
parameters.withIndicesOptions(indexUpgradeInfoRequest.indicesOptions()); | ||
return request; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...st-high-level/src/test/java/org/elasticsearch/client/MigrationRequestConvertersTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.client; | ||
|
||
import org.apache.http.client.methods.HttpGet; | ||
import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoRequest; | ||
import org.elasticsearch.test.ESTestCase; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class MigrationRequestConvertersTests extends ESTestCase { | ||
|
||
public static void testGetMigrationAssistance() { | ||
IndexUpgradeInfoRequest upgradeInfoRequest = new IndexUpgradeInfoRequest(); | ||
String expectedEndpoint = "/_xpack/migration/assistance"; | ||
if (randomBoolean()) { | ||
String[] indices = RequestConvertersTests.randomIndicesNames(1, 5); | ||
upgradeInfoRequest.indices(indices); | ||
expectedEndpoint += "/" + String.join(",", indices); | ||
} | ||
Map<String, String> expectedParams = new HashMap<>(); | ||
RequestConvertersTests.setRandomIndicesOptions(upgradeInfoRequest::indicesOptions, upgradeInfoRequest::indicesOptions, | ||
expectedParams); | ||
Request request = MigrationRequestConverters.getMigrationAssistance(upgradeInfoRequest); | ||
assertEquals(HttpGet.METHOD_NAME, request.getMethod()); | ||
assertEquals(expectedEndpoint, request.getEndpoint()); | ||
assertNull(request.getEntity()); | ||
assertEquals(expectedParams, request.getParameters()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters