-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Add start rollup job support to HL REST Client #34623
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
Changes from 7 commits
453be79
11b6a03
0d32c63
48ca811
de4b2a9
b9f8817
a716b4e
c6b4930
2a94112
d727958
4b2712a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,9 +28,11 @@ | |
|
||
public abstract class AcknowledgedResponse implements ToXContentObject { | ||
private final boolean acknowledged; | ||
private final String field; | ||
|
||
public AcknowledgedResponse(final boolean acknowledged) { | ||
public AcknowledgedResponse(final boolean acknowledged, final String field) { | ||
this.acknowledged = acknowledged; | ||
this.field = field; | ||
} | ||
|
||
public boolean isAcknowledged() { | ||
|
@@ -58,7 +60,7 @@ public int hashCode() { | |
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException { | ||
builder.startObject(); | ||
{ | ||
builder.field("acknowledged", isAcknowledged()); | ||
builder.field(field, isAcknowledged()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Im not sure i like changing this, because it would be nice if we had a more generic AcknowledgedResponse. I understand that yall need to override the "acknowledged" field, but maybe its best to have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. np, will update |
||
} | ||
builder.endObject(); | ||
return builder; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* 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.rollup; | ||
|
||
import org.elasticsearch.client.Validatable; | ||
|
||
import java.util.Objects; | ||
|
||
public class StartRollupJobRequest implements Validatable { | ||
|
||
private final String jobId; | ||
|
||
public StartRollupJobRequest(final String jobId) { | ||
this.jobId = Objects.requireNonNull(jobId, "id parameter must not be null"); | ||
} | ||
|
||
public String getJobId() { | ||
return jobId; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
final StartRollupJobRequest that = (StartRollupJobRequest) o; | ||
return Objects.equals(jobId, that.jobId); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(jobId); | ||
} | ||
} |
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.rollup; | ||
|
||
import org.elasticsearch.common.ParseField; | ||
import org.elasticsearch.common.xcontent.ConstructingObjectParser; | ||
import org.elasticsearch.common.xcontent.XContentParser; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg; | ||
|
||
public class StartRollupJobResponse extends AcknowledgedResponse { | ||
|
||
private static final String PARSE_FIELD_NAME = "started"; | ||
|
||
public StartRollupJobResponse(boolean acknowledged) { | ||
super(acknowledged, PARSE_FIELD_NAME); | ||
} | ||
|
||
public static StartRollupJobResponse fromXContent(final XContentParser parser) throws IOException { | ||
return PARSER.parse(parser, null); | ||
} | ||
|
||
private static final ConstructingObjectParser<StartRollupJobResponse, Void> PARSER | ||
= new ConstructingObjectParser<>("start_rollup_job_response", true, | ||
args -> new StartRollupJobResponse((boolean) args[0])); | ||
static { | ||
PARSER.declareBoolean(constructorArg(), new ParseField(PARSE_FIELD_NAME)); | ||
} | ||
} |
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.
this is now a variadic, so u can
.addPathPartAsIs("_xpack", "rollup", "job")
....