|
| 1 | +/* |
| 2 | + * SPDX-License-Identifier: Apache-2.0 |
| 3 | + * |
| 4 | + * The OpenSearch Contributors require contributions made to |
| 5 | + * this file be licensed under the Apache-2.0 license or a |
| 6 | + * compatible open source license. |
| 7 | + */ |
| 8 | + |
| 9 | +/* |
| 10 | + * Licensed to Elasticsearch B.V. under one or more contributor |
| 11 | + * license agreements. See the NOTICE file distributed with |
| 12 | + * this work for additional information regarding copyright |
| 13 | + * ownership. Elasticsearch B.V. licenses this file to you under |
| 14 | + * the Apache License, Version 2.0 (the "License"); you may |
| 15 | + * not use this file except in compliance with the License. |
| 16 | + * You may obtain a copy of the License at |
| 17 | + * |
| 18 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 19 | + * |
| 20 | + * Unless required by applicable law or agreed to in writing, |
| 21 | + * software distributed under the License is distributed on an |
| 22 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 23 | + * KIND, either express or implied. See the License for the |
| 24 | + * specific language governing permissions and limitations |
| 25 | + * under the License. |
| 26 | + */ |
| 27 | + |
| 28 | +/* |
| 29 | + * Modifications Copyright OpenSearch Contributors. See |
| 30 | + * GitHub history for details. |
| 31 | + */ |
| 32 | + |
| 33 | +//---------------------------------------------------- |
| 34 | +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. |
| 35 | +//---------------------------------------------------- |
| 36 | + |
| 37 | +package org.opensearch.client.opensearch._types.query_dsl; |
| 38 | + |
| 39 | +import jakarta.json.stream.JsonGenerator; |
| 40 | +import java.util.List; |
| 41 | +import java.util.Objects; |
| 42 | +import java.util.function.Function; |
| 43 | +import javax.annotation.Generated; |
| 44 | +import javax.annotation.Nonnull; |
| 45 | +import javax.annotation.Nullable; |
| 46 | +import org.opensearch.client.json.JsonpDeserializable; |
| 47 | +import org.opensearch.client.json.JsonpDeserializer; |
| 48 | +import org.opensearch.client.json.JsonpMapper; |
| 49 | +import org.opensearch.client.json.ObjectBuilderDeserializer; |
| 50 | +import org.opensearch.client.json.ObjectDeserializer; |
| 51 | +import org.opensearch.client.util.ApiTypeHelper; |
| 52 | +import org.opensearch.client.util.CopyableBuilder; |
| 53 | +import org.opensearch.client.util.ObjectBuilder; |
| 54 | +import org.opensearch.client.util.ToCopyableBuilder; |
| 55 | + |
| 56 | +// typedef: _types.query_dsl.AgenticQuery |
| 57 | + |
| 58 | +@JsonpDeserializable |
| 59 | +@Generated("org.opensearch.client.codegen.CodeGenerator") |
| 60 | +public class AgenticQuery extends QueryBase implements QueryVariant, ToCopyableBuilder<AgenticQuery.Builder, AgenticQuery> { |
| 61 | + |
| 62 | + @Nullable |
| 63 | + private final String memoryId; |
| 64 | + |
| 65 | + @Nonnull |
| 66 | + private final List<String> queryFields; |
| 67 | + |
| 68 | + @Nonnull |
| 69 | + private final String queryText; |
| 70 | + |
| 71 | + // --------------------------------------------------------------------------------------------- |
| 72 | + |
| 73 | + private AgenticQuery(Builder builder) { |
| 74 | + super(builder); |
| 75 | + this.memoryId = builder.memoryId; |
| 76 | + this.queryFields = ApiTypeHelper.unmodifiable(builder.queryFields); |
| 77 | + this.queryText = ApiTypeHelper.requireNonNull(builder.queryText, this, "queryText"); |
| 78 | + } |
| 79 | + |
| 80 | + public static AgenticQuery of(Function<AgenticQuery.Builder, ObjectBuilder<AgenticQuery>> fn) { |
| 81 | + return fn.apply(new Builder()).build(); |
| 82 | + } |
| 83 | + |
| 84 | + /** |
| 85 | + * {@link Query} variant kind. |
| 86 | + */ |
| 87 | + @Override |
| 88 | + public Query.Kind _queryKind() { |
| 89 | + return Query.Kind.Agentic; |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * The memory ID from a previous response, used to continue a conversation with prior context. Applicable for conversational agents |
| 94 | + * only. |
| 95 | + * <p> |
| 96 | + * API name: {@code memory_id} |
| 97 | + * </p> |
| 98 | + */ |
| 99 | + @Nullable |
| 100 | + public final String memoryId() { |
| 101 | + return this.memoryId; |
| 102 | + } |
| 103 | + |
| 104 | + /** |
| 105 | + * A list of index fields that the agent should consider when generating the search query. |
| 106 | + * <p> |
| 107 | + * API name: {@code query_fields} |
| 108 | + * </p> |
| 109 | + */ |
| 110 | + @Nonnull |
| 111 | + public final List<String> queryFields() { |
| 112 | + return this.queryFields; |
| 113 | + } |
| 114 | + |
| 115 | + /** |
| 116 | + * Required - The natural language question to be answered by the agent. |
| 117 | + * <p> |
| 118 | + * API name: {@code query_text} |
| 119 | + * </p> |
| 120 | + */ |
| 121 | + @Nonnull |
| 122 | + public final String queryText() { |
| 123 | + return this.queryText; |
| 124 | + } |
| 125 | + |
| 126 | + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { |
| 127 | + super.serializeInternal(generator, mapper); |
| 128 | + if (this.memoryId != null) { |
| 129 | + generator.writeKey("memory_id"); |
| 130 | + generator.write(this.memoryId); |
| 131 | + } |
| 132 | + |
| 133 | + if (ApiTypeHelper.isDefined(this.queryFields)) { |
| 134 | + generator.writeKey("query_fields"); |
| 135 | + generator.writeStartArray(); |
| 136 | + for (String item0 : this.queryFields) { |
| 137 | + generator.write(item0); |
| 138 | + } |
| 139 | + generator.writeEnd(); |
| 140 | + } |
| 141 | + |
| 142 | + generator.writeKey("query_text"); |
| 143 | + generator.write(this.queryText); |
| 144 | + } |
| 145 | + |
| 146 | + // --------------------------------------------------------------------------------------------- |
| 147 | + |
| 148 | + @Override |
| 149 | + @Nonnull |
| 150 | + public Builder toBuilder() { |
| 151 | + return new Builder(this); |
| 152 | + } |
| 153 | + |
| 154 | + @Nonnull |
| 155 | + public static Builder builder() { |
| 156 | + return new Builder(); |
| 157 | + } |
| 158 | + |
| 159 | + /** |
| 160 | + * Builder for {@link AgenticQuery}. |
| 161 | + */ |
| 162 | + public static class Builder extends QueryBase.AbstractBuilder<Builder> implements CopyableBuilder<Builder, AgenticQuery> { |
| 163 | + @Nullable |
| 164 | + private String memoryId; |
| 165 | + @Nullable |
| 166 | + private List<String> queryFields; |
| 167 | + private String queryText; |
| 168 | + |
| 169 | + public Builder() {} |
| 170 | + |
| 171 | + private Builder(AgenticQuery o) { |
| 172 | + super(o); |
| 173 | + this.memoryId = o.memoryId; |
| 174 | + this.queryFields = _listCopy(o.queryFields); |
| 175 | + this.queryText = o.queryText; |
| 176 | + } |
| 177 | + |
| 178 | + private Builder(Builder o) { |
| 179 | + super(o); |
| 180 | + this.memoryId = o.memoryId; |
| 181 | + this.queryFields = _listCopy(o.queryFields); |
| 182 | + this.queryText = o.queryText; |
| 183 | + } |
| 184 | + |
| 185 | + @Override |
| 186 | + @Nonnull |
| 187 | + public Builder copy() { |
| 188 | + return new Builder(this); |
| 189 | + } |
| 190 | + |
| 191 | + @Override |
| 192 | + @Nonnull |
| 193 | + protected Builder self() { |
| 194 | + return this; |
| 195 | + } |
| 196 | + |
| 197 | + /** |
| 198 | + * The memory ID from a previous response, used to continue a conversation with prior context. Applicable for conversational agents |
| 199 | + * only. |
| 200 | + * <p> |
| 201 | + * API name: {@code memory_id} |
| 202 | + * </p> |
| 203 | + */ |
| 204 | + @Nonnull |
| 205 | + public final Builder memoryId(@Nullable String value) { |
| 206 | + this.memoryId = value; |
| 207 | + return this; |
| 208 | + } |
| 209 | + |
| 210 | + /** |
| 211 | + * A list of index fields that the agent should consider when generating the search query. |
| 212 | + * <p> |
| 213 | + * API name: {@code query_fields} |
| 214 | + * </p> |
| 215 | + * |
| 216 | + * <p> |
| 217 | + * Adds all elements of <code>list</code> to <code>queryFields</code>. |
| 218 | + * </p> |
| 219 | + */ |
| 220 | + @Nonnull |
| 221 | + public final Builder queryFields(List<String> list) { |
| 222 | + this.queryFields = _listAddAll(this.queryFields, list); |
| 223 | + return this; |
| 224 | + } |
| 225 | + |
| 226 | + /** |
| 227 | + * A list of index fields that the agent should consider when generating the search query. |
| 228 | + * <p> |
| 229 | + * API name: {@code query_fields} |
| 230 | + * </p> |
| 231 | + * |
| 232 | + * <p> |
| 233 | + * Adds one or more values to <code>queryFields</code>. |
| 234 | + * </p> |
| 235 | + */ |
| 236 | + @Nonnull |
| 237 | + public final Builder queryFields(String value, String... values) { |
| 238 | + this.queryFields = _listAdd(this.queryFields, value, values); |
| 239 | + return this; |
| 240 | + } |
| 241 | + |
| 242 | + /** |
| 243 | + * Required - The natural language question to be answered by the agent. |
| 244 | + * <p> |
| 245 | + * API name: {@code query_text} |
| 246 | + * </p> |
| 247 | + */ |
| 248 | + @Nonnull |
| 249 | + public final Builder queryText(String value) { |
| 250 | + this.queryText = value; |
| 251 | + return this; |
| 252 | + } |
| 253 | + |
| 254 | + /** |
| 255 | + * Builds a {@link AgenticQuery}. |
| 256 | + * |
| 257 | + * @throws NullPointerException if some of the required fields are null. |
| 258 | + */ |
| 259 | + @Override |
| 260 | + @Nonnull |
| 261 | + public AgenticQuery build() { |
| 262 | + _checkSingleUse(); |
| 263 | + |
| 264 | + return new AgenticQuery(this); |
| 265 | + } |
| 266 | + } |
| 267 | + |
| 268 | + // --------------------------------------------------------------------------------------------- |
| 269 | + |
| 270 | + /** |
| 271 | + * Json deserializer for {@link AgenticQuery} |
| 272 | + */ |
| 273 | + public static final JsonpDeserializer<AgenticQuery> _DESERIALIZER = ObjectBuilderDeserializer.lazy( |
| 274 | + Builder::new, |
| 275 | + AgenticQuery::setupAgenticQueryDeserializer |
| 276 | + ); |
| 277 | + |
| 278 | + protected static void setupAgenticQueryDeserializer(ObjectDeserializer<AgenticQuery.Builder> op) { |
| 279 | + setupQueryBaseDeserializer(op); |
| 280 | + op.add(Builder::memoryId, JsonpDeserializer.stringDeserializer(), "memory_id"); |
| 281 | + op.add(Builder::queryFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "query_fields"); |
| 282 | + op.add(Builder::queryText, JsonpDeserializer.stringDeserializer(), "query_text"); |
| 283 | + } |
| 284 | + |
| 285 | + @Override |
| 286 | + public int hashCode() { |
| 287 | + int result = super.hashCode(); |
| 288 | + result = 31 * result + Objects.hashCode(this.memoryId); |
| 289 | + result = 31 * result + Objects.hashCode(this.queryFields); |
| 290 | + result = 31 * result + this.queryText.hashCode(); |
| 291 | + return result; |
| 292 | + } |
| 293 | + |
| 294 | + @Override |
| 295 | + public boolean equals(Object o) { |
| 296 | + if (!super.equals(o)) { |
| 297 | + return false; |
| 298 | + } |
| 299 | + if (this == o) return true; |
| 300 | + if (o == null || this.getClass() != o.getClass()) return false; |
| 301 | + AgenticQuery other = (AgenticQuery) o; |
| 302 | + return Objects.equals(this.memoryId, other.memoryId) |
| 303 | + && Objects.equals(this.queryFields, other.queryFields) |
| 304 | + && this.queryText.equals(other.queryText); |
| 305 | + } |
| 306 | +} |
0 commit comments