-
Notifications
You must be signed in to change notification settings - Fork 25.2k
HLRC: Get Deprecation Info API #36279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
43 changes: 43 additions & 0 deletions
43
...t-high-level/src/main/java/org/elasticsearch/client/migration/DeprecationInfoRequest.java
This file contains hidden or 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,43 @@ | ||
/* | ||
* 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.migration; | ||
|
||
import org.elasticsearch.client.Validatable; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public class DeprecationInfoRequest implements Validatable { | ||
|
||
private final List<String> indices; | ||
|
||
public DeprecationInfoRequest(List<String> indices) { | ||
this.indices = Collections.unmodifiableList(Objects.requireNonNull(indices, "indices cannot be null")); | ||
} | ||
|
||
public DeprecationInfoRequest() { | ||
this.indices = Collections.unmodifiableList(Collections.emptyList()); | ||
} | ||
|
||
public List<String> getIndices() { | ||
return indices; | ||
} | ||
} |
208 changes: 208 additions & 0 deletions
208
...-high-level/src/main/java/org/elasticsearch/client/migration/DeprecationInfoResponse.java
This file contains hidden or 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,208 @@ | ||
/* | ||
* 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.migration; | ||
|
||
import org.elasticsearch.common.Nullable; | ||
import org.elasticsearch.common.ParseField; | ||
import org.elasticsearch.common.xcontent.ConstructingObjectParser; | ||
import org.elasticsearch.common.xcontent.XContentParser; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Locale; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
public class DeprecationInfoResponse { | ||
|
||
private static final ParseField CLUSTER_SETTINGS = new ParseField("cluster_settings"); | ||
private static final ParseField NODE_SETTINGS = new ParseField("node_settings"); | ||
private static final ParseField INDEX_SETTINGS = new ParseField("index_settings"); | ||
|
||
private final List<DeprecationIssue> clusterSettingsIssues; | ||
private final List<DeprecationIssue> nodeSettingsIssues; | ||
private final Map<String, List<DeprecationIssue>> indexSettingsIssues; | ||
|
||
public DeprecationInfoResponse(List<DeprecationIssue> clusterSettingsIssues, List<DeprecationIssue> nodeSettingsIssues, | ||
Map<String, List<DeprecationIssue>> indexSettingsIssues) { | ||
this.clusterSettingsIssues = Objects.requireNonNull(clusterSettingsIssues, "cluster settings issues cannot be null"); | ||
this.nodeSettingsIssues = Objects.requireNonNull(nodeSettingsIssues, "node settings issues cannot be null"); | ||
this.indexSettingsIssues = Objects.requireNonNull(indexSettingsIssues, "index settings issues cannot be null"); | ||
} | ||
|
||
public List<DeprecationIssue> getClusterSettingsIssues() { | ||
return clusterSettingsIssues; | ||
} | ||
|
||
public List<DeprecationIssue> getNodeSettingsIssues() { | ||
return nodeSettingsIssues; | ||
} | ||
|
||
public Map<String, List<DeprecationIssue>> getIndexSettingsIssues() { | ||
return indexSettingsIssues; | ||
} | ||
|
||
private static List<DeprecationIssue> parseDeprecationIssues(XContentParser parser) throws IOException { | ||
List<DeprecationIssue> issues = new ArrayList<>(); | ||
XContentParser.Token token = null; | ||
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { | ||
if (token == XContentParser.Token.START_OBJECT) { | ||
issues.add(DeprecationIssue.PARSER.parse(parser, null)); | ||
} | ||
} | ||
return issues; | ||
} | ||
|
||
public static DeprecationInfoResponse fromXContent(XContentParser parser) throws IOException { | ||
Map<String, List<DeprecationIssue>> indexSettings = new HashMap<>(); | ||
List<DeprecationIssue> clusterSettings = new ArrayList<>(); | ||
List<DeprecationIssue> nodeSettings = new ArrayList<>(); | ||
String fieldName = null; | ||
XContentParser.Token token; | ||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { | ||
if (token == XContentParser.Token.FIELD_NAME) { | ||
fieldName = parser.currentName(); | ||
} else if (CLUSTER_SETTINGS.getPreferredName().equals(fieldName)) { | ||
clusterSettings.addAll(parseDeprecationIssues(parser)); | ||
} else if (NODE_SETTINGS.getPreferredName().equals(fieldName)) { | ||
nodeSettings.addAll(parseDeprecationIssues(parser)); | ||
} else if (INDEX_SETTINGS.getPreferredName().equals(fieldName)) { | ||
// parse out the key/value pairs | ||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { | ||
String key = parser.currentName(); | ||
List<DeprecationIssue> value = parseDeprecationIssues(parser); | ||
if (value.size() > 0) { // only add indices that contain deprecation issues | ||
indexSettings.put(key, value); | ||
} | ||
} | ||
} | ||
} | ||
return new DeprecationInfoResponse(clusterSettings, nodeSettings, indexSettings); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
DeprecationInfoResponse that = (DeprecationInfoResponse) o; | ||
return Objects.equals(clusterSettingsIssues, that.clusterSettingsIssues) && | ||
Objects.equals(nodeSettingsIssues, that.nodeSettingsIssues) && | ||
Objects.equals(indexSettingsIssues, that.indexSettingsIssues); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(clusterSettingsIssues, nodeSettingsIssues, indexSettingsIssues); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return clusterSettingsIssues.toString() + ":" + nodeSettingsIssues.toString() + ":" + indexSettingsIssues.toString(); | ||
} | ||
|
||
/** | ||
* Information about deprecated items | ||
*/ | ||
public static class DeprecationIssue { | ||
|
||
private static final ParseField LEVEL = new ParseField("level"); | ||
private static final ParseField MESSAGE = new ParseField("message"); | ||
private static final ParseField URL = new ParseField("url"); | ||
private static final ParseField DETAILS = new ParseField("details"); | ||
|
||
static final ConstructingObjectParser<DeprecationIssue, Void> PARSER = | ||
new ConstructingObjectParser<>("deprecation_issue", true, | ||
a -> new DeprecationIssue(Level.fromString((String) a[0]), (String) a[1], (String) a[2], (String) a[3])); | ||
|
||
static { | ||
PARSER.declareString(ConstructingObjectParser.constructorArg(), LEVEL); | ||
PARSER.declareString(ConstructingObjectParser.constructorArg(), MESSAGE); | ||
PARSER.declareString(ConstructingObjectParser.constructorArg(), URL); | ||
PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), DETAILS); | ||
} | ||
|
||
public enum Level { | ||
NONE, | ||
INFO, | ||
WARNING, | ||
CRITICAL | ||
; | ||
|
||
public static Level fromString(String value) { | ||
return Level.valueOf(value.toUpperCase(Locale.ROOT)); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return name().toLowerCase(Locale.ROOT); | ||
} | ||
} | ||
|
||
private Level level; | ||
private String message; | ||
private String url; | ||
private String details; | ||
|
||
public DeprecationIssue(Level level, String message, String url, @Nullable String details) { | ||
this.level = level; | ||
this.message = message; | ||
this.url = url; | ||
this.details = details; | ||
} | ||
|
||
public Level getLevel() { | ||
return level; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public String getDetails() { | ||
return details; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
DeprecationIssue that = (DeprecationIssue) o; | ||
return Objects.equals(level, that.level) && | ||
Objects.equals(message, that.message) && | ||
Objects.equals(url, that.url) && | ||
Objects.equals(details, that.details); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(level, message, url, details); | ||
} | ||
} | ||
} |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Soon (likely tomorrow) I'll have a PR removing
NONE
andINFO
from this list server-side - whichever merges last will have to remove them from this list too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ pls link the PR when u have it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aforementioned PR: #36326
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like i won ;)