-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into field_caps_with_objects
- Loading branch information
Showing
139 changed files
with
4,327 additions
and
838 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
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
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
104 changes: 104 additions & 0 deletions
104
client/rest-high-level/src/main/java/org/elasticsearch/client/ml/GetCalendarsRequest.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,104 @@ | ||
/* | ||
* 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.ml; | ||
|
||
import org.elasticsearch.action.ActionRequest; | ||
import org.elasticsearch.action.ActionRequestValidationException; | ||
import org.elasticsearch.client.ml.calendars.Calendar; | ||
import org.elasticsearch.common.xcontent.ObjectParser; | ||
import org.elasticsearch.common.xcontent.ToXContentObject; | ||
import org.elasticsearch.common.xcontent.XContentBuilder; | ||
|
||
import org.elasticsearch.client.ml.job.util.PageParams; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
public class GetCalendarsRequest extends ActionRequest implements ToXContentObject { | ||
|
||
public static final ObjectParser<GetCalendarsRequest, Void> PARSER = | ||
new ObjectParser<>("get_calendars_request", GetCalendarsRequest::new); | ||
|
||
static { | ||
PARSER.declareString(GetCalendarsRequest::setCalendarId, Calendar.ID); | ||
PARSER.declareObject(GetCalendarsRequest::setPageParams, PageParams.PARSER, PageParams.PAGE); | ||
} | ||
|
||
private String calendarId; | ||
private PageParams pageParams; | ||
|
||
public GetCalendarsRequest() { | ||
} | ||
|
||
public GetCalendarsRequest(String calendarId) { | ||
this.calendarId = calendarId; | ||
} | ||
|
||
public String getCalendarId() { | ||
return calendarId; | ||
} | ||
|
||
public void setCalendarId(String calendarId) { | ||
this.calendarId = calendarId; | ||
} | ||
|
||
public PageParams getPageParams() { | ||
return pageParams; | ||
} | ||
|
||
public void setPageParams(PageParams pageParams) { | ||
this.pageParams = pageParams; | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
if (calendarId != null) { | ||
builder.field(Calendar.ID.getPreferredName(), calendarId); | ||
} | ||
if (pageParams != null) { | ||
builder.field(PageParams.PAGE.getPreferredName(), pageParams); | ||
} | ||
builder.endObject(); | ||
return builder; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(calendarId, pageParams); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == null) { | ||
return false; | ||
} | ||
if (getClass() != obj.getClass()) { | ||
return false; | ||
} | ||
GetCalendarsRequest other = (GetCalendarsRequest) obj; | ||
return Objects.equals(calendarId, other.calendarId) && Objects.equals(pageParams, other.pageParams); | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
client/rest-high-level/src/main/java/org/elasticsearch/client/ml/GetCalendarsResponse.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,86 @@ | ||
/* | ||
* 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.ml; | ||
|
||
import org.elasticsearch.client.ml.calendars.Calendar; | ||
import org.elasticsearch.common.ParseField; | ||
import org.elasticsearch.common.Strings; | ||
import org.elasticsearch.common.xcontent.ConstructingObjectParser; | ||
import org.elasticsearch.common.xcontent.XContentParser; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg; | ||
|
||
public class GetCalendarsResponse extends AbstractResultResponse<Calendar> { | ||
|
||
public static final ParseField RESULTS_FIELD = new ParseField("calendars"); | ||
|
||
@SuppressWarnings("unchecked") | ||
public static final ConstructingObjectParser<GetCalendarsResponse, Void> PARSER = | ||
new ConstructingObjectParser<>("calendars_response", true, | ||
a -> new GetCalendarsResponse((List<Calendar>) a[0], (long) a[1])); | ||
|
||
static { | ||
PARSER.declareObjectArray(constructorArg(), Calendar.PARSER, RESULTS_FIELD); | ||
PARSER.declareLong(constructorArg(), AbstractResultResponse.COUNT); | ||
} | ||
|
||
public static GetCalendarsResponse fromXContent(XContentParser parser) throws IOException { | ||
return PARSER.parse(parser, null); | ||
} | ||
|
||
GetCalendarsResponse(List<Calendar> calendars, long count) { | ||
super(RESULTS_FIELD, calendars, count); | ||
} | ||
|
||
/** | ||
* The collection of {@link Calendar} objects found in the query | ||
*/ | ||
public List<Calendar> calendars() { | ||
return results; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(results, count); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
|
||
if (obj == null || getClass() != obj.getClass()) { | ||
return false; | ||
} | ||
|
||
GetCalendarsResponse other = (GetCalendarsResponse) obj; | ||
return Objects.equals(results, other.results) && count == other.count; | ||
} | ||
|
||
@Override | ||
public final String toString() { | ||
return Strings.toString(this); | ||
} | ||
} |
Oops, something went wrong.