-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for the get rollup job to the High Level REST Client. I had to do three interesting and unexpected things: 1. I ported the rollup state wiping code into the high level client tests. I'll move this into the test framework in a followup and remove the x-pack version. 2. The `timeout` in the rollup config was serialized using the `toString` representation of `TimeValue` which produces fractional time values which are more human readable but aren't supported by parsing. So I switched it to `getStringRep`. 3. Refactor the xcontent round trip testing utilities so we can test parsing of classes that don't implements `ToXContent`.
- Loading branch information
Showing
15 changed files
with
1,093 additions
and
51 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
77 changes: 77 additions & 0 deletions
77
...nt/rest-high-level/src/main/java/org/elasticsearch/client/rollup/GetRollupJobRequest.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,77 @@ | ||
/* | ||
* 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 org.elasticsearch.client.ValidationException; | ||
|
||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
/** | ||
* Request to fetch rollup jobs. | ||
*/ | ||
public class GetRollupJobRequest implements Validatable { | ||
private final String jobId; | ||
|
||
/** | ||
* Create a requets . | ||
* @param jobId id of the job to return or {@code _all} to return all jobs | ||
*/ | ||
public GetRollupJobRequest(final String jobId) { | ||
Objects.requireNonNull(jobId, "jobId is required"); | ||
if ("_all".equals(jobId)) { | ||
throw new IllegalArgumentException("use the default ctor to ask for all jobs"); | ||
} | ||
this.jobId = jobId; | ||
} | ||
|
||
/** | ||
* Create a request to load all rollup jobs. | ||
*/ | ||
public GetRollupJobRequest() { | ||
this.jobId = "_all"; | ||
} | ||
|
||
/** | ||
* ID of the job to return. | ||
*/ | ||
public String getJobId() { | ||
return jobId; | ||
} | ||
|
||
@Override | ||
public Optional<ValidationException> validate() { | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
final GetRollupJobRequest that = (GetRollupJobRequest) o; | ||
return jobId.equals(that.jobId); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(jobId); | ||
} | ||
} |
Oops, something went wrong.