forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Types removal - deprecate include_type_name with index templates (ela…
…stic#37484) Added deprecation warnings for use of include_type_name in put/get index templates. HLRC changes: GetIndexTemplateRequest has a new client-side class which is a copy of server's GetIndexTemplateResponse but modified to be typeless. PutIndexTemplateRequest has a new client-side counterpart which doesn't use types in the mappings Relates to elastic#35190
- Loading branch information
1 parent
1ff3a96
commit a549026
Showing
17 changed files
with
1,617 additions
and
105 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
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
90 changes: 90 additions & 0 deletions
90
...-high-level/src/main/java/org/elasticsearch/client/indices/GetIndexTemplatesResponse.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,90 @@ | ||
/* | ||
* 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.indices; | ||
|
||
import org.elasticsearch.common.xcontent.XContentParser; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
|
||
public class GetIndexTemplatesResponse { | ||
|
||
@Override | ||
public String toString() { | ||
List<IndexTemplateMetaData> thisList = new ArrayList<>(this.indexTemplates); | ||
thisList.sort(Comparator.comparing(IndexTemplateMetaData::name)); | ||
return "GetIndexTemplatesResponse [indexTemplates=" + thisList + "]"; | ||
} | ||
|
||
private final List<IndexTemplateMetaData> indexTemplates; | ||
|
||
GetIndexTemplatesResponse() { | ||
indexTemplates = new ArrayList<>(); | ||
} | ||
|
||
GetIndexTemplatesResponse(List<IndexTemplateMetaData> indexTemplates) { | ||
this.indexTemplates = indexTemplates; | ||
} | ||
|
||
public List<IndexTemplateMetaData> getIndexTemplates() { | ||
return indexTemplates; | ||
} | ||
|
||
|
||
public static GetIndexTemplatesResponse fromXContent(XContentParser parser) throws IOException { | ||
final List<IndexTemplateMetaData> templates = new ArrayList<>(); | ||
for (XContentParser.Token token = parser.nextToken(); token != XContentParser.Token.END_OBJECT; token = parser.nextToken()) { | ||
if (token == XContentParser.Token.FIELD_NAME) { | ||
final IndexTemplateMetaData templateMetaData = IndexTemplateMetaData.Builder.fromXContent(parser, parser.currentName()); | ||
templates.add(templateMetaData); | ||
} | ||
} | ||
return new GetIndexTemplatesResponse(templates); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
List<IndexTemplateMetaData> sortedList = new ArrayList<>(this.indexTemplates); | ||
sortedList.sort(Comparator.comparing(IndexTemplateMetaData::name)); | ||
return Objects.hash(sortedList); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
// To compare results we need to make sure the templates are listed in the same order | ||
GetIndexTemplatesResponse other = (GetIndexTemplatesResponse) obj; | ||
List<IndexTemplateMetaData> thisList = new ArrayList<>(this.indexTemplates); | ||
List<IndexTemplateMetaData> otherList = new ArrayList<>(other.indexTemplates); | ||
thisList.sort(Comparator.comparing(IndexTemplateMetaData::name)); | ||
otherList.sort(Comparator.comparing(IndexTemplateMetaData::name)); | ||
return Objects.equals(thisList, otherList); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.