Skip to content
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

Deprecate allow_no_jobs and allow_no_datafeeds in favor of allow_no_match #60601

Merged
merged 4 commits into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ static Request getJob(GetJobRequest getJobRequest) {
Request request = new Request(HttpGet.METHOD_NAME, endpoint);

RequestConverters.Params params = new RequestConverters.Params();
if (getJobRequest.getAllowNoJobs() != null) {
params.putParam("allow_no_jobs", Boolean.toString(getJobRequest.getAllowNoJobs()));
if (getJobRequest.getAllowNoMatch() != null) {
params.putParam("allow_no_match", Boolean.toString(getJobRequest.getAllowNoMatch()));
}
request.addParameters(params.asMap());
return request;
Expand All @@ -137,8 +137,8 @@ static Request getJobStats(GetJobStatsRequest getJobStatsRequest) {
Request request = new Request(HttpGet.METHOD_NAME, endpoint);

RequestConverters.Params params = new RequestConverters.Params();
if (getJobStatsRequest.getAllowNoJobs() != null) {
params.putParam("allow_no_jobs", Boolean.toString(getJobStatsRequest.getAllowNoJobs()));
if (getJobStatsRequest.getAllowNoMatch() != null) {
params.putParam("allow_no_match", Boolean.toString(getJobStatsRequest.getAllowNoMatch()));
}
request.addParameters(params.asMap());
return request;
Expand Down Expand Up @@ -266,9 +266,9 @@ static Request getDatafeed(GetDatafeedRequest getDatafeedRequest) {
Request request = new Request(HttpGet.METHOD_NAME, endpoint);

RequestConverters.Params params = new RequestConverters.Params();
if (getDatafeedRequest.getAllowNoDatafeeds() != null) {
params.putParam(GetDatafeedRequest.ALLOW_NO_DATAFEEDS.getPreferredName(),
Boolean.toString(getDatafeedRequest.getAllowNoDatafeeds()));
if (getDatafeedRequest.getAllowNoMatch() != null) {
params.putParam(GetDatafeedRequest.ALLOW_NO_MATCH.getPreferredName(),
Boolean.toString(getDatafeedRequest.getAllowNoMatch()));
}
request.addParameters(params.asMap());
return request;
Expand Down Expand Up @@ -323,8 +323,8 @@ static Request getDatafeedStats(GetDatafeedStatsRequest getDatafeedStatsRequest)
Request request = new Request(HttpGet.METHOD_NAME, endpoint);

RequestConverters.Params params = new RequestConverters.Params();
if (getDatafeedStatsRequest.getAllowNoDatafeeds() != null) {
params.putParam("allow_no_datafeeds", Boolean.toString(getDatafeedStatsRequest.getAllowNoDatafeeds()));
if (getDatafeedStatsRequest.getAllowNoMatch() != null) {
params.putParam("allow_no_match", Boolean.toString(getDatafeedStatsRequest.getAllowNoMatch()));
}
request.addParameters(params.asMap());
return request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class CloseJobRequest implements ToXContentObject, Validatable {
public static final ParseField JOB_ID = new ParseField("job_id");
public static final ParseField TIMEOUT = new ParseField("timeout");
public static final ParseField FORCE = new ParseField("force");
public static final ParseField ALLOW_NO_JOBS = new ParseField("allow_no_jobs");
public static final ParseField ALLOW_NO_MATCH = new ParseField("allow_no_match");

@SuppressWarnings("unchecked")
public static final ConstructingObjectParser<CloseJobRequest, Void> PARSER = new ConstructingObjectParser<>(
Expand All @@ -55,15 +55,15 @@ public class CloseJobRequest implements ToXContentObject, Validatable {
JOB_ID, ObjectParser.ValueType.STRING_ARRAY);
PARSER.declareString((obj, val) -> obj.setTimeout(TimeValue.parseTimeValue(val, TIMEOUT.getPreferredName())), TIMEOUT);
PARSER.declareBoolean(CloseJobRequest::setForce, FORCE);
PARSER.declareBoolean(CloseJobRequest::setAllowNoJobs, ALLOW_NO_JOBS);
PARSER.declareBoolean(CloseJobRequest::setAllowNoMatch, ALLOW_NO_MATCH);
}

private static final String ALL_JOBS = "_all";

private final List<String> jobIds;
private TimeValue timeout;
private Boolean force;
private Boolean allowNoJobs;
private Boolean allowNoMatch;

/**
* Explicitly close all jobs
Expand Down Expand Up @@ -128,24 +128,24 @@ public void setForce(boolean force) {
this.force = force;
}

public Boolean getAllowNoJobs() {
return this.allowNoJobs;
public Boolean getAllowNoMatch() {
return this.allowNoMatch;
}

/**
* Whether to ignore if a wildcard expression matches no jobs.
*
* This includes {@code _all} string or when no jobs have been specified
*
* @param allowNoJobs When {@code true} ignore if wildcard or {@code _all} matches no jobs. Defaults to {@code true}
* @param allowNoMatch When {@code true} ignore if wildcard or {@code _all} matches no jobs. Defaults to {@code true}
*/
public void setAllowNoJobs(boolean allowNoJobs) {
this.allowNoJobs = allowNoJobs;
public void setAllowNoMatch(boolean allowNoMatch) {
this.allowNoMatch = allowNoMatch;
}

@Override
public int hashCode() {
return Objects.hash(jobIds, timeout, force, allowNoJobs);
return Objects.hash(jobIds, timeout, force, allowNoMatch);
}

@Override
Expand All @@ -162,7 +162,7 @@ public boolean equals(Object other) {
return Objects.equals(jobIds, that.jobIds) &&
Objects.equals(timeout, that.timeout) &&
Objects.equals(force, that.force) &&
Objects.equals(allowNoJobs, that.allowNoJobs);
Objects.equals(allowNoMatch, that.allowNoMatch);
}

@Override
Expand All @@ -175,8 +175,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
if (force != null) {
builder.field(FORCE.getPreferredName(), force);
}
if (allowNoJobs != null) {
builder.field(ALLOW_NO_JOBS.getPreferredName(), allowNoJobs);
if (allowNoMatch != null) {
builder.field(ALLOW_NO_MATCH.getPreferredName(), allowNoMatch);
}
builder.endObject();
return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
public class GetDatafeedRequest implements Validatable, ToXContentObject {

public static final ParseField DATAFEED_IDS = new ParseField("datafeed_ids");
public static final ParseField ALLOW_NO_DATAFEEDS = new ParseField("allow_no_datafeeds");
public static final ParseField ALLOW_NO_MATCH = new ParseField("allow_no_match");

private static final String ALL_DATAFEEDS = "_all";
private final List<String> datafeedIds;
private Boolean allowNoDatafeeds;
private Boolean allowNoMatch;

@SuppressWarnings("unchecked")
public static final ConstructingObjectParser<GetDatafeedRequest, Void> PARSER = new ConstructingObjectParser<>(
Expand All @@ -53,7 +53,7 @@ public class GetDatafeedRequest implements Validatable, ToXContentObject {

static {
PARSER.declareStringArray(ConstructingObjectParser.optionalConstructorArg(), DATAFEED_IDS);
PARSER.declareBoolean(GetDatafeedRequest::setAllowNoDatafeeds, ALLOW_NO_DATAFEEDS);
PARSER.declareBoolean(GetDatafeedRequest::setAllowNoMatch, ALLOW_NO_MATCH);
}

/**
Expand Down Expand Up @@ -89,20 +89,20 @@ public List<String> getDatafeedIds() {
/**
* Whether to ignore if a wildcard expression matches no datafeeds.
*
* @param allowNoDatafeeds If this is {@code false}, then an error is returned when a wildcard (or {@code _all})
* @param allowNoMatch If this is {@code false}, then an error is returned when a wildcard (or {@code _all})
* does not match any datafeeds
*/
public void setAllowNoDatafeeds(boolean allowNoDatafeeds) {
this.allowNoDatafeeds = allowNoDatafeeds;
public void setAllowNoMatch(boolean allowNoMatch) {
this.allowNoMatch = allowNoMatch;
}

public Boolean getAllowNoDatafeeds() {
return allowNoDatafeeds;
public Boolean getAllowNoMatch() {
return allowNoMatch;
}

@Override
public int hashCode() {
return Objects.hash(datafeedIds, allowNoDatafeeds);
return Objects.hash(datafeedIds, allowNoMatch);
}

@Override
Expand All @@ -117,7 +117,7 @@ public boolean equals(Object other) {

GetDatafeedRequest that = (GetDatafeedRequest) other;
return Objects.equals(datafeedIds, that.datafeedIds) &&
Objects.equals(allowNoDatafeeds, that.allowNoDatafeeds);
Objects.equals(allowNoMatch, that.allowNoMatch);
}

@Override
Expand All @@ -128,8 +128,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
builder.field(DATAFEED_IDS.getPreferredName(), datafeedIds);
}

if (allowNoDatafeeds != null) {
builder.field(ALLOW_NO_DATAFEEDS.getPreferredName(), allowNoDatafeeds);
if (allowNoMatch != null) {
builder.field(ALLOW_NO_MATCH.getPreferredName(), allowNoMatch);
}

builder.endObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
*/
public class GetDatafeedStatsRequest implements Validatable, ToXContentObject {

public static final ParseField ALLOW_NO_DATAFEEDS = new ParseField("allow_no_datafeeds");
public static final ParseField ALLOW_NO_MATCH = new ParseField("allow_no_match");

@SuppressWarnings("unchecked")
public static final ConstructingObjectParser<GetDatafeedStatsRequest, Void> PARSER = new ConstructingObjectParser<>(
Expand All @@ -52,13 +52,13 @@ public class GetDatafeedStatsRequest implements Validatable, ToXContentObject {
PARSER.declareField(ConstructingObjectParser.constructorArg(),
p -> Arrays.asList(Strings.commaDelimitedListToStringArray(p.text())),
DatafeedConfig.ID, ObjectParser.ValueType.STRING_ARRAY);
PARSER.declareBoolean(GetDatafeedStatsRequest::setAllowNoDatafeeds, ALLOW_NO_DATAFEEDS);
PARSER.declareBoolean(GetDatafeedStatsRequest::setAllowNoMatch, ALLOW_NO_MATCH);
}

private static final String ALL_DATAFEEDS = "_all";

private final List<String> datafeedIds;
private Boolean allowNoDatafeeds;
private Boolean allowNoMatch;

/**
* Explicitly gets all datafeeds statistics
Expand Down Expand Up @@ -92,24 +92,24 @@ public List<String> getDatafeedIds() {
return datafeedIds;
}

public Boolean getAllowNoDatafeeds() {
return this.allowNoDatafeeds;
public Boolean getAllowNoMatch() {
return this.allowNoMatch;
}

/**
* Whether to ignore if a wildcard expression matches no datafeeds.
*
* This includes {@code _all} string or when no datafeeds have been specified
*
* @param allowNoDatafeeds When {@code true} ignore if wildcard or {@code _all} matches no datafeeds. Defaults to {@code true}
* @param allowNoMatch When {@code true} ignore if wildcard or {@code _all} matches no datafeeds. Defaults to {@code true}
*/
public void setAllowNoDatafeeds(boolean allowNoDatafeeds) {
this.allowNoDatafeeds = allowNoDatafeeds;
public void setAllowNoMatch(boolean allowNoMatch) {
this.allowNoMatch = allowNoMatch;
}

@Override
public int hashCode() {
return Objects.hash(datafeedIds, allowNoDatafeeds);
return Objects.hash(datafeedIds, allowNoMatch);
}

@Override
Expand All @@ -124,15 +124,15 @@ public boolean equals(Object other) {

GetDatafeedStatsRequest that = (GetDatafeedStatsRequest) other;
return Objects.equals(datafeedIds, that.datafeedIds) &&
Objects.equals(allowNoDatafeeds, that.allowNoDatafeeds);
Objects.equals(allowNoMatch, that.allowNoMatch);
}

@Override
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
builder.startObject();
builder.field(DatafeedConfig.ID.getPreferredName(), Strings.collectionToCommaDelimitedString(datafeedIds));
if (allowNoDatafeeds != null) {
builder.field(ALLOW_NO_DATAFEEDS.getPreferredName(), allowNoDatafeeds);
if (allowNoMatch != null) {
builder.field(ALLOW_NO_MATCH.getPreferredName(), allowNoMatch);
}
builder.endObject();
return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
public class GetJobRequest implements Validatable, ToXContentObject {

public static final ParseField JOB_IDS = new ParseField("job_ids");
public static final ParseField ALLOW_NO_JOBS = new ParseField("allow_no_jobs");
public static final ParseField ALLOW_NO_MATCH = new ParseField("allow_no_match");

private static final String ALL_JOBS = "_all";
private final List<String> jobIds;
private Boolean allowNoJobs;
private Boolean allowNoMatch;

@SuppressWarnings("unchecked")
public static final ConstructingObjectParser<GetJobRequest, Void> PARSER = new ConstructingObjectParser<>(
Expand All @@ -54,7 +54,7 @@ public class GetJobRequest implements Validatable, ToXContentObject {

static {
PARSER.declareStringArray(ConstructingObjectParser.optionalConstructorArg(), JOB_IDS);
PARSER.declareBoolean(GetJobRequest::setAllowNoJobs, ALLOW_NO_JOBS);
PARSER.declareBoolean(GetJobRequest::setAllowNoMatch, ALLOW_NO_MATCH);
}

/**
Expand Down Expand Up @@ -90,19 +90,19 @@ public List<String> getJobIds() {
/**
* Whether to ignore if a wildcard expression matches no jobs.
*
* @param allowNoJobs If this is {@code false}, then an error is returned when a wildcard (or {@code _all}) does not match any jobs
* @param allowNoMatch If this is {@code false}, then an error is returned when a wildcard (or {@code _all}) does not match any jobs
*/
public void setAllowNoJobs(boolean allowNoJobs) {
this.allowNoJobs = allowNoJobs;
public void setAllowNoMatch(boolean allowNoMatch) {
this.allowNoMatch = allowNoMatch;
}

public Boolean getAllowNoJobs() {
return allowNoJobs;
public Boolean getAllowNoMatch() {
return allowNoMatch;
}

@Override
public int hashCode() {
return Objects.hash(jobIds, allowNoJobs);
return Objects.hash(jobIds, allowNoMatch);
}

@Override
Expand All @@ -117,7 +117,7 @@ public boolean equals(Object other) {

GetJobRequest that = (GetJobRequest) other;
return Objects.equals(jobIds, that.jobIds) &&
Objects.equals(allowNoJobs, that.allowNoJobs);
Objects.equals(allowNoMatch, that.allowNoMatch);
}

@Override
Expand All @@ -128,8 +128,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
builder.field(JOB_IDS.getPreferredName(), jobIds);
}

if (allowNoJobs != null) {
builder.field(ALLOW_NO_JOBS.getPreferredName(), allowNoJobs);
if (allowNoMatch != null) {
builder.field(ALLOW_NO_MATCH.getPreferredName(), allowNoMatch);
}

builder.endObject();
Expand Down
Loading