|
| 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 | +//---------------------------------------------------- |
| 21 | +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. |
| 22 | +//---------------------------------------------------- |
| 23 | + |
| 24 | +package co.elastic.clients.elasticsearch.ml; |
| 25 | + |
| 26 | +import co.elastic.clients.elasticsearch._types.ErrorResponse; |
| 27 | +import co.elastic.clients.elasticsearch._types.RequestBase; |
| 28 | +import co.elastic.clients.json.JsonpDeserializable; |
| 29 | +import co.elastic.clients.json.JsonpDeserializer; |
| 30 | +import co.elastic.clients.json.ObjectBuilderDeserializer; |
| 31 | +import co.elastic.clients.json.ObjectDeserializer; |
| 32 | +import co.elastic.clients.transport.Endpoint; |
| 33 | +import co.elastic.clients.transport.endpoints.SimpleEndpoint; |
| 34 | +import co.elastic.clients.util.ApiTypeHelper; |
| 35 | +import co.elastic.clients.util.ObjectBuilder; |
| 36 | +import co.elastic.clients.util.ObjectBuilderBase; |
| 37 | +import jakarta.json.stream.JsonGenerator; |
| 38 | +import java.lang.Boolean; |
| 39 | +import java.lang.String; |
| 40 | +import java.util.HashMap; |
| 41 | +import java.util.Map; |
| 42 | +import java.util.Objects; |
| 43 | +import java.util.function.Function; |
| 44 | +import javax.annotation.Nullable; |
| 45 | + |
| 46 | +// typedef: ml.get_model_snapshot_upgrade_stats.Request |
| 47 | + |
| 48 | +/** |
| 49 | + * Retrieves usage information for anomaly detection job model snapshot |
| 50 | + * upgrades. |
| 51 | + * |
| 52 | + * @see <a href= |
| 53 | + * "../doc-files/api-spec.html#ml.get_model_snapshot_upgrade_stats.Request">API |
| 54 | + * specification</a> |
| 55 | + */ |
| 56 | + |
| 57 | +public class GetModelSnapshotUpgradeStatsRequest extends RequestBase { |
| 58 | + @Nullable |
| 59 | + private final Boolean allowNoMatch; |
| 60 | + |
| 61 | + private final String jobId; |
| 62 | + |
| 63 | + @Nullable |
| 64 | + private final String snapshotId; |
| 65 | + |
| 66 | + // --------------------------------------------------------------------------------------------- |
| 67 | + |
| 68 | + private GetModelSnapshotUpgradeStatsRequest(Builder builder) { |
| 69 | + |
| 70 | + this.allowNoMatch = builder.allowNoMatch; |
| 71 | + this.jobId = ApiTypeHelper.requireNonNull(builder.jobId, this, "jobId"); |
| 72 | + this.snapshotId = builder.snapshotId; |
| 73 | + |
| 74 | + } |
| 75 | + |
| 76 | + public static GetModelSnapshotUpgradeStatsRequest of( |
| 77 | + Function<Builder, ObjectBuilder<GetModelSnapshotUpgradeStatsRequest>> fn) { |
| 78 | + return fn.apply(new Builder()).build(); |
| 79 | + } |
| 80 | + |
| 81 | + /** |
| 82 | + * Specifies what to do when the request: |
| 83 | + * <ul> |
| 84 | + * <li>Contains wildcard expressions and there are no jobs that match.</li> |
| 85 | + * <li>Contains the _all string or no identifiers and there are no matches.</li> |
| 86 | + * <li>Contains wildcard expressions and there are only partial matches.</li> |
| 87 | + * </ul> |
| 88 | + * <p> |
| 89 | + * The default value is true, which returns an empty jobs array when there are |
| 90 | + * no matches and the subset of results when there are partial matches. If this |
| 91 | + * parameter is false, the request returns a 404 status code when there are no |
| 92 | + * matches or only partial matches. |
| 93 | + * <p> |
| 94 | + * API name: {@code allow_no_match} |
| 95 | + */ |
| 96 | + @Nullable |
| 97 | + public final Boolean allowNoMatch() { |
| 98 | + return this.allowNoMatch; |
| 99 | + } |
| 100 | + |
| 101 | + /** |
| 102 | + * Required - Identifier for the anomaly detection job. |
| 103 | + * <p> |
| 104 | + * API name: {@code job_id} |
| 105 | + */ |
| 106 | + public final String jobId() { |
| 107 | + return this.jobId; |
| 108 | + } |
| 109 | + |
| 110 | + /** |
| 111 | + * A numerical character string that uniquely identifies the model snapshot. You |
| 112 | + * can get information for multiple snapshots by using a comma-separated list or |
| 113 | + * a wildcard expression. You can get all snapshots by using <code>_all</code>, |
| 114 | + * by specifying <code>*</code> as the snapshot ID, or by omitting the snapshot |
| 115 | + * ID. |
| 116 | + * <p> |
| 117 | + * API name: {@code snapshot_id} |
| 118 | + */ |
| 119 | + @Nullable |
| 120 | + public final String snapshotId() { |
| 121 | + return this.snapshotId; |
| 122 | + } |
| 123 | + |
| 124 | + // --------------------------------------------------------------------------------------------- |
| 125 | + |
| 126 | + /** |
| 127 | + * Builder for {@link GetModelSnapshotUpgradeStatsRequest}. |
| 128 | + */ |
| 129 | + |
| 130 | + public static class Builder extends ObjectBuilderBase |
| 131 | + implements |
| 132 | + ObjectBuilder<GetModelSnapshotUpgradeStatsRequest> { |
| 133 | + @Nullable |
| 134 | + private Boolean allowNoMatch; |
| 135 | + |
| 136 | + private String jobId; |
| 137 | + |
| 138 | + @Nullable |
| 139 | + private String snapshotId; |
| 140 | + |
| 141 | + /** |
| 142 | + * Specifies what to do when the request: |
| 143 | + * <ul> |
| 144 | + * <li>Contains wildcard expressions and there are no jobs that match.</li> |
| 145 | + * <li>Contains the _all string or no identifiers and there are no matches.</li> |
| 146 | + * <li>Contains wildcard expressions and there are only partial matches.</li> |
| 147 | + * </ul> |
| 148 | + * <p> |
| 149 | + * The default value is true, which returns an empty jobs array when there are |
| 150 | + * no matches and the subset of results when there are partial matches. If this |
| 151 | + * parameter is false, the request returns a 404 status code when there are no |
| 152 | + * matches or only partial matches. |
| 153 | + * <p> |
| 154 | + * API name: {@code allow_no_match} |
| 155 | + */ |
| 156 | + public final Builder allowNoMatch(@Nullable Boolean value) { |
| 157 | + this.allowNoMatch = value; |
| 158 | + return this; |
| 159 | + } |
| 160 | + |
| 161 | + /** |
| 162 | + * Required - Identifier for the anomaly detection job. |
| 163 | + * <p> |
| 164 | + * API name: {@code job_id} |
| 165 | + */ |
| 166 | + public final Builder jobId(String value) { |
| 167 | + this.jobId = value; |
| 168 | + return this; |
| 169 | + } |
| 170 | + |
| 171 | + /** |
| 172 | + * A numerical character string that uniquely identifies the model snapshot. You |
| 173 | + * can get information for multiple snapshots by using a comma-separated list or |
| 174 | + * a wildcard expression. You can get all snapshots by using <code>_all</code>, |
| 175 | + * by specifying <code>*</code> as the snapshot ID, or by omitting the snapshot |
| 176 | + * ID. |
| 177 | + * <p> |
| 178 | + * API name: {@code snapshot_id} |
| 179 | + */ |
| 180 | + public final Builder snapshotId(@Nullable String value) { |
| 181 | + this.snapshotId = value; |
| 182 | + return this; |
| 183 | + } |
| 184 | + |
| 185 | + /** |
| 186 | + * Builds a {@link GetModelSnapshotUpgradeStatsRequest}. |
| 187 | + * |
| 188 | + * @throws NullPointerException |
| 189 | + * if some of the required fields are null. |
| 190 | + */ |
| 191 | + public GetModelSnapshotUpgradeStatsRequest build() { |
| 192 | + _checkSingleUse(); |
| 193 | + |
| 194 | + return new GetModelSnapshotUpgradeStatsRequest(this); |
| 195 | + } |
| 196 | + } |
| 197 | + |
| 198 | + // --------------------------------------------------------------------------------------------- |
| 199 | + |
| 200 | + /** |
| 201 | + * Endpoint "{@code ml.get_model_snapshot_upgrade_stats}". |
| 202 | + */ |
| 203 | + public static final Endpoint<GetModelSnapshotUpgradeStatsRequest, GetModelSnapshotUpgradeStatsResponse, ErrorResponse> _ENDPOINT = new SimpleEndpoint<>( |
| 204 | + "es/ml.get_model_snapshot_upgrade_stats", |
| 205 | + |
| 206 | + // Request method |
| 207 | + request -> { |
| 208 | + return "GET"; |
| 209 | + |
| 210 | + }, |
| 211 | + |
| 212 | + // Request path |
| 213 | + request -> { |
| 214 | + final int _snapshotId = 1 << 0; |
| 215 | + final int _jobId = 1 << 1; |
| 216 | + |
| 217 | + int propsSet = 0; |
| 218 | + |
| 219 | + if (request.snapshotId() != null) |
| 220 | + propsSet |= _snapshotId; |
| 221 | + propsSet |= _jobId; |
| 222 | + |
| 223 | + if (propsSet == (_jobId | _snapshotId)) { |
| 224 | + StringBuilder buf = new StringBuilder(); |
| 225 | + buf.append("/_ml"); |
| 226 | + buf.append("/anomaly_detectors"); |
| 227 | + buf.append("/"); |
| 228 | + SimpleEndpoint.pathEncode(request.jobId, buf); |
| 229 | + buf.append("/model_snapshots"); |
| 230 | + buf.append("/"); |
| 231 | + SimpleEndpoint.pathEncode(request.snapshotId, buf); |
| 232 | + buf.append("/_upgrade"); |
| 233 | + buf.append("/_stats"); |
| 234 | + return buf.toString(); |
| 235 | + } |
| 236 | + throw SimpleEndpoint.noPathTemplateFound("path"); |
| 237 | + |
| 238 | + }, |
| 239 | + |
| 240 | + // Request parameters |
| 241 | + request -> { |
| 242 | + Map<String, String> params = new HashMap<>(); |
| 243 | + if (request.allowNoMatch != null) { |
| 244 | + params.put("allow_no_match", String.valueOf(request.allowNoMatch)); |
| 245 | + } |
| 246 | + return params; |
| 247 | + |
| 248 | + }, SimpleEndpoint.emptyMap(), false, GetModelSnapshotUpgradeStatsResponse._DESERIALIZER); |
| 249 | +} |
0 commit comments