|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch B.V. under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch B.V. licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +package co.elastic.clients.elasticsearch._types; |
| 21 | + |
| 22 | +import co.elastic.clients.json.JsonpDeserializable; |
| 23 | +import co.elastic.clients.json.JsonpDeserializer; |
| 24 | +import co.elastic.clients.json.JsonpMapper; |
| 25 | +import co.elastic.clients.json.JsonpSerializable; |
| 26 | +import co.elastic.clients.json.JsonpUtils; |
| 27 | +import co.elastic.clients.json.ObjectBuilderDeserializer; |
| 28 | +import co.elastic.clients.json.ObjectDeserializer; |
| 29 | +import co.elastic.clients.util.ApiTypeHelper; |
| 30 | +import co.elastic.clients.util.ObjectBuilder; |
| 31 | +import co.elastic.clients.util.WithJsonObjectBuilderBase; |
| 32 | +import jakarta.json.stream.JsonGenerator; |
| 33 | +import java.lang.String; |
| 34 | +import java.util.Objects; |
| 35 | +import java.util.function.Function; |
| 36 | +import javax.annotation.Nullable; |
| 37 | + |
| 38 | +//---------------------------------------------------------------- |
| 39 | +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. |
| 40 | +//---------------------------------------------------------------- |
| 41 | +// |
| 42 | +// This code is generated from the Elasticsearch API specification |
| 43 | +// at https://github.com/elastic/elasticsearch-specification |
| 44 | +// |
| 45 | +// Manual updates to this file will be lost when the code is |
| 46 | +// re-generated. |
| 47 | +// |
| 48 | +// If you find a property that is missing or wrongly typed, please |
| 49 | +// open an issue or a PR on the API specification repository. |
| 50 | +// |
| 51 | +//---------------------------------------------------------------- |
| 52 | + |
| 53 | +// typedef: _types.LookupQueryVectorBuilder |
| 54 | + |
| 55 | +/** |
| 56 | + * |
| 57 | + * @see <a href="../doc-files/api-spec.html#_types.LookupQueryVectorBuilder">API |
| 58 | + * specification</a> |
| 59 | + */ |
| 60 | +@JsonpDeserializable |
| 61 | +public class LookupQueryVectorBuilder implements QueryVectorBuilderVariant, JsonpSerializable { |
| 62 | + private final String id; |
| 63 | + |
| 64 | + private final String index; |
| 65 | + |
| 66 | + private final String path; |
| 67 | + |
| 68 | + @Nullable |
| 69 | + private final String routing; |
| 70 | + |
| 71 | + // --------------------------------------------------------------------------------------------- |
| 72 | + |
| 73 | + private LookupQueryVectorBuilder(Builder builder) { |
| 74 | + |
| 75 | + this.id = ApiTypeHelper.requireNonNull(builder.id, this, "id"); |
| 76 | + this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); |
| 77 | + this.path = ApiTypeHelper.requireNonNull(builder.path, this, "path"); |
| 78 | + this.routing = builder.routing; |
| 79 | + |
| 80 | + } |
| 81 | + |
| 82 | + public static LookupQueryVectorBuilder of(Function<Builder, ObjectBuilder<LookupQueryVectorBuilder>> fn) { |
| 83 | + return fn.apply(new Builder()).build(); |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * QueryVectorBuilder variant kind. |
| 88 | + */ |
| 89 | + @Override |
| 90 | + public QueryVectorBuilder.Kind _queryVectorBuilderKind() { |
| 91 | + return QueryVectorBuilder.Kind.Lookup; |
| 92 | + } |
| 93 | + |
| 94 | + /** |
| 95 | + * Required - The ID of the document to fetch the vector from |
| 96 | + * <p> |
| 97 | + * API name: {@code id} |
| 98 | + */ |
| 99 | + public final String id() { |
| 100 | + return this.id; |
| 101 | + } |
| 102 | + |
| 103 | + /** |
| 104 | + * Required - The name of the index to fetch the document from |
| 105 | + * <p> |
| 106 | + * API name: {@code index} |
| 107 | + */ |
| 108 | + public final String index() { |
| 109 | + return this.index; |
| 110 | + } |
| 111 | + |
| 112 | + /** |
| 113 | + * Required - The name of the field containing the vector |
| 114 | + * <p> |
| 115 | + * API name: {@code path} |
| 116 | + */ |
| 117 | + public final String path() { |
| 118 | + return this.path; |
| 119 | + } |
| 120 | + |
| 121 | + /** |
| 122 | + * The routing value to use when fetching the document |
| 123 | + * <p> |
| 124 | + * API name: {@code routing} |
| 125 | + */ |
| 126 | + @Nullable |
| 127 | + public final String routing() { |
| 128 | + return this.routing; |
| 129 | + } |
| 130 | + |
| 131 | + /** |
| 132 | + * Serialize this object to JSON. |
| 133 | + */ |
| 134 | + public void serialize(JsonGenerator generator, JsonpMapper mapper) { |
| 135 | + generator.writeStartObject(); |
| 136 | + serializeInternal(generator, mapper); |
| 137 | + generator.writeEnd(); |
| 138 | + } |
| 139 | + |
| 140 | + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { |
| 141 | + |
| 142 | + generator.writeKey("id"); |
| 143 | + generator.write(this.id); |
| 144 | + |
| 145 | + generator.writeKey("index"); |
| 146 | + generator.write(this.index); |
| 147 | + |
| 148 | + generator.writeKey("path"); |
| 149 | + generator.write(this.path); |
| 150 | + |
| 151 | + if (this.routing != null) { |
| 152 | + generator.writeKey("routing"); |
| 153 | + generator.write(this.routing); |
| 154 | + |
| 155 | + } |
| 156 | + |
| 157 | + } |
| 158 | + |
| 159 | + @Override |
| 160 | + public String toString() { |
| 161 | + return JsonpUtils.toString(this); |
| 162 | + } |
| 163 | + |
| 164 | + // --------------------------------------------------------------------------------------------- |
| 165 | + |
| 166 | + /** |
| 167 | + * Builder for {@link LookupQueryVectorBuilder}. |
| 168 | + */ |
| 169 | + |
| 170 | + public static class Builder extends WithJsonObjectBuilderBase<Builder> |
| 171 | + implements |
| 172 | + ObjectBuilder<LookupQueryVectorBuilder> { |
| 173 | + private String id; |
| 174 | + |
| 175 | + private String index; |
| 176 | + |
| 177 | + private String path; |
| 178 | + |
| 179 | + @Nullable |
| 180 | + private String routing; |
| 181 | + |
| 182 | + public Builder() { |
| 183 | + } |
| 184 | + private Builder(LookupQueryVectorBuilder instance) { |
| 185 | + this.id = instance.id; |
| 186 | + this.index = instance.index; |
| 187 | + this.path = instance.path; |
| 188 | + this.routing = instance.routing; |
| 189 | + |
| 190 | + } |
| 191 | + /** |
| 192 | + * Required - The ID of the document to fetch the vector from |
| 193 | + * <p> |
| 194 | + * API name: {@code id} |
| 195 | + */ |
| 196 | + public final Builder id(String value) { |
| 197 | + this.id = value; |
| 198 | + return this; |
| 199 | + } |
| 200 | + |
| 201 | + /** |
| 202 | + * Required - The name of the index to fetch the document from |
| 203 | + * <p> |
| 204 | + * API name: {@code index} |
| 205 | + */ |
| 206 | + public final Builder index(String value) { |
| 207 | + this.index = value; |
| 208 | + return this; |
| 209 | + } |
| 210 | + |
| 211 | + /** |
| 212 | + * Required - The name of the field containing the vector |
| 213 | + * <p> |
| 214 | + * API name: {@code path} |
| 215 | + */ |
| 216 | + public final Builder path(String value) { |
| 217 | + this.path = value; |
| 218 | + return this; |
| 219 | + } |
| 220 | + |
| 221 | + /** |
| 222 | + * The routing value to use when fetching the document |
| 223 | + * <p> |
| 224 | + * API name: {@code routing} |
| 225 | + */ |
| 226 | + public final Builder routing(@Nullable String value) { |
| 227 | + this.routing = value; |
| 228 | + return this; |
| 229 | + } |
| 230 | + |
| 231 | + @Override |
| 232 | + protected Builder self() { |
| 233 | + return this; |
| 234 | + } |
| 235 | + |
| 236 | + /** |
| 237 | + * Builds a {@link LookupQueryVectorBuilder}. |
| 238 | + * |
| 239 | + * @throws NullPointerException |
| 240 | + * if some of the required fields are null. |
| 241 | + */ |
| 242 | + public LookupQueryVectorBuilder build() { |
| 243 | + _checkSingleUse(); |
| 244 | + |
| 245 | + return new LookupQueryVectorBuilder(this); |
| 246 | + } |
| 247 | + } |
| 248 | + |
| 249 | + /** |
| 250 | + * @return New {@link Builder} initialized with field values of this instance |
| 251 | + */ |
| 252 | + public Builder rebuild() { |
| 253 | + return new Builder(this); |
| 254 | + } |
| 255 | + // --------------------------------------------------------------------------------------------- |
| 256 | + |
| 257 | + /** |
| 258 | + * Json deserializer for {@link LookupQueryVectorBuilder} |
| 259 | + */ |
| 260 | + public static final JsonpDeserializer<LookupQueryVectorBuilder> _DESERIALIZER = ObjectBuilderDeserializer |
| 261 | + .lazy(Builder::new, LookupQueryVectorBuilder::setupLookupQueryVectorBuilderDeserializer); |
| 262 | + |
| 263 | + protected static void setupLookupQueryVectorBuilderDeserializer( |
| 264 | + ObjectDeserializer<LookupQueryVectorBuilder.Builder> op) { |
| 265 | + |
| 266 | + op.add(Builder::id, JsonpDeserializer.stringDeserializer(), "id"); |
| 267 | + op.add(Builder::index, JsonpDeserializer.stringDeserializer(), "index"); |
| 268 | + op.add(Builder::path, JsonpDeserializer.stringDeserializer(), "path"); |
| 269 | + op.add(Builder::routing, JsonpDeserializer.stringDeserializer(), "routing"); |
| 270 | + |
| 271 | + } |
| 272 | + |
| 273 | +} |
0 commit comments