|
| 1 | +/* |
| 2 | + * Copyright 2025 Google LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +// Auto-generated code. Do not edit. |
| 18 | + |
| 19 | +package com.google.genai; |
| 20 | + |
| 21 | +import com.fasterxml.jackson.databind.JsonNode; |
| 22 | +import com.fasterxml.jackson.databind.ObjectMapper; |
| 23 | +import com.fasterxml.jackson.databind.node.ArrayNode; |
| 24 | +import com.fasterxml.jackson.databind.node.ObjectNode; |
| 25 | + |
| 26 | +final class OperationsConverters { |
| 27 | + private final ApiClient apiClient; |
| 28 | + |
| 29 | + public OperationsConverters(ApiClient apiClient) { |
| 30 | + this.apiClient = apiClient; |
| 31 | + } |
| 32 | + |
| 33 | + @ExcludeFromGeneratedCoverageReport |
| 34 | + ObjectNode fetchPredictOperationParametersToMldev(JsonNode fromObject, ObjectNode parentObject) { |
| 35 | + ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode(); |
| 36 | + if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"operationName"}))) { |
| 37 | + throw new IllegalArgumentException("operationName parameter is not supported in Gemini API."); |
| 38 | + } |
| 39 | + |
| 40 | + if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"resourceName"}))) { |
| 41 | + throw new IllegalArgumentException("resourceName parameter is not supported in Gemini API."); |
| 42 | + } |
| 43 | + |
| 44 | + if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"config"}))) { |
| 45 | + throw new IllegalArgumentException("config parameter is not supported in Gemini API."); |
| 46 | + } |
| 47 | + |
| 48 | + return toObject; |
| 49 | + } |
| 50 | + |
| 51 | + @ExcludeFromGeneratedCoverageReport |
| 52 | + ObjectNode getOperationParametersToMldev(JsonNode fromObject, ObjectNode parentObject) { |
| 53 | + ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode(); |
| 54 | + if (Common.getValueByPath(fromObject, new String[] {"operationName"}) != null) { |
| 55 | + Common.setValueByPath( |
| 56 | + toObject, |
| 57 | + new String[] {"_url", "operationName"}, |
| 58 | + Common.getValueByPath(fromObject, new String[] {"operationName"})); |
| 59 | + } |
| 60 | + |
| 61 | + if (Common.getValueByPath(fromObject, new String[] {"config"}) != null) { |
| 62 | + Common.setValueByPath( |
| 63 | + toObject, |
| 64 | + new String[] {"config"}, |
| 65 | + Common.getValueByPath(fromObject, new String[] {"config"})); |
| 66 | + } |
| 67 | + |
| 68 | + return toObject; |
| 69 | + } |
| 70 | + |
| 71 | + @ExcludeFromGeneratedCoverageReport |
| 72 | + ObjectNode fetchPredictOperationParametersToVertex(JsonNode fromObject, ObjectNode parentObject) { |
| 73 | + ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode(); |
| 74 | + if (Common.getValueByPath(fromObject, new String[] {"operationName"}) != null) { |
| 75 | + Common.setValueByPath( |
| 76 | + toObject, |
| 77 | + new String[] {"operationName"}, |
| 78 | + Common.getValueByPath(fromObject, new String[] {"operationName"})); |
| 79 | + } |
| 80 | + |
| 81 | + if (Common.getValueByPath(fromObject, new String[] {"resourceName"}) != null) { |
| 82 | + Common.setValueByPath( |
| 83 | + toObject, |
| 84 | + new String[] {"_url", "resourceName"}, |
| 85 | + Common.getValueByPath(fromObject, new String[] {"resourceName"})); |
| 86 | + } |
| 87 | + |
| 88 | + if (Common.getValueByPath(fromObject, new String[] {"config"}) != null) { |
| 89 | + Common.setValueByPath( |
| 90 | + toObject, |
| 91 | + new String[] {"config"}, |
| 92 | + Common.getValueByPath(fromObject, new String[] {"config"})); |
| 93 | + } |
| 94 | + |
| 95 | + return toObject; |
| 96 | + } |
| 97 | + |
| 98 | + @ExcludeFromGeneratedCoverageReport |
| 99 | + ObjectNode getOperationParametersToVertex(JsonNode fromObject, ObjectNode parentObject) { |
| 100 | + ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode(); |
| 101 | + if (Common.getValueByPath(fromObject, new String[] {"operationName"}) != null) { |
| 102 | + Common.setValueByPath( |
| 103 | + toObject, |
| 104 | + new String[] {"_url", "operationName"}, |
| 105 | + Common.getValueByPath(fromObject, new String[] {"operationName"})); |
| 106 | + } |
| 107 | + |
| 108 | + if (Common.getValueByPath(fromObject, new String[] {"config"}) != null) { |
| 109 | + Common.setValueByPath( |
| 110 | + toObject, |
| 111 | + new String[] {"config"}, |
| 112 | + Common.getValueByPath(fromObject, new String[] {"config"})); |
| 113 | + } |
| 114 | + |
| 115 | + return toObject; |
| 116 | + } |
| 117 | + |
| 118 | + @ExcludeFromGeneratedCoverageReport |
| 119 | + ObjectNode videoFromMldev(JsonNode fromObject, ObjectNode parentObject) { |
| 120 | + ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode(); |
| 121 | + if (Common.getValueByPath(fromObject, new String[] {"video", "uri"}) != null) { |
| 122 | + Common.setValueByPath( |
| 123 | + toObject, |
| 124 | + new String[] {"uri"}, |
| 125 | + Common.getValueByPath(fromObject, new String[] {"video", "uri"})); |
| 126 | + } |
| 127 | + |
| 128 | + if (Common.getValueByPath(fromObject, new String[] {"video", "encodedVideo"}) != null) { |
| 129 | + Common.setValueByPath( |
| 130 | + toObject, |
| 131 | + new String[] {"videoBytes"}, |
| 132 | + Transformers.tBytes( |
| 133 | + Common.getValueByPath(fromObject, new String[] {"video", "encodedVideo"}))); |
| 134 | + } |
| 135 | + |
| 136 | + if (Common.getValueByPath(fromObject, new String[] {"encoding"}) != null) { |
| 137 | + Common.setValueByPath( |
| 138 | + toObject, |
| 139 | + new String[] {"mimeType"}, |
| 140 | + Common.getValueByPath(fromObject, new String[] {"encoding"})); |
| 141 | + } |
| 142 | + |
| 143 | + return toObject; |
| 144 | + } |
| 145 | + |
| 146 | + @ExcludeFromGeneratedCoverageReport |
| 147 | + ObjectNode generatedVideoFromMldev(JsonNode fromObject, ObjectNode parentObject) { |
| 148 | + ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode(); |
| 149 | + if (Common.getValueByPath(fromObject, new String[] {"_self"}) != null) { |
| 150 | + Common.setValueByPath( |
| 151 | + toObject, |
| 152 | + new String[] {"video"}, |
| 153 | + videoFromMldev( |
| 154 | + JsonSerializable.toJsonNode( |
| 155 | + Common.getValueByPath(fromObject, new String[] {"_self"})), |
| 156 | + toObject)); |
| 157 | + } |
| 158 | + |
| 159 | + return toObject; |
| 160 | + } |
| 161 | + |
| 162 | + @ExcludeFromGeneratedCoverageReport |
| 163 | + ObjectNode generateVideosResponseFromMldev(JsonNode fromObject, ObjectNode parentObject) { |
| 164 | + ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode(); |
| 165 | + if (Common.getValueByPath(fromObject, new String[] {"generatedSamples"}) != null) { |
| 166 | + ArrayNode keyArray = |
| 167 | + (ArrayNode) Common.getValueByPath(fromObject, new String[] {"generatedSamples"}); |
| 168 | + ObjectMapper objectMapper = new ObjectMapper(); |
| 169 | + ArrayNode result = objectMapper.createArrayNode(); |
| 170 | + |
| 171 | + for (JsonNode item : keyArray) { |
| 172 | + result.add(generatedVideoFromMldev(JsonSerializable.toJsonNode(item), toObject)); |
| 173 | + } |
| 174 | + Common.setValueByPath(toObject, new String[] {"generatedVideos"}, result); |
| 175 | + } |
| 176 | + |
| 177 | + if (Common.getValueByPath(fromObject, new String[] {"raiMediaFilteredCount"}) != null) { |
| 178 | + Common.setValueByPath( |
| 179 | + toObject, |
| 180 | + new String[] {"raiMediaFilteredCount"}, |
| 181 | + Common.getValueByPath(fromObject, new String[] {"raiMediaFilteredCount"})); |
| 182 | + } |
| 183 | + |
| 184 | + if (Common.getValueByPath(fromObject, new String[] {"raiMediaFilteredReasons"}) != null) { |
| 185 | + Common.setValueByPath( |
| 186 | + toObject, |
| 187 | + new String[] {"raiMediaFilteredReasons"}, |
| 188 | + Common.getValueByPath(fromObject, new String[] {"raiMediaFilteredReasons"})); |
| 189 | + } |
| 190 | + |
| 191 | + return toObject; |
| 192 | + } |
| 193 | + |
| 194 | + @ExcludeFromGeneratedCoverageReport |
| 195 | + ObjectNode generateVideosOperationFromMldev(JsonNode fromObject, ObjectNode parentObject) { |
| 196 | + ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode(); |
| 197 | + if (Common.getValueByPath(fromObject, new String[] {"name"}) != null) { |
| 198 | + Common.setValueByPath( |
| 199 | + toObject, |
| 200 | + new String[] {"name"}, |
| 201 | + Common.getValueByPath(fromObject, new String[] {"name"})); |
| 202 | + } |
| 203 | + |
| 204 | + if (Common.getValueByPath(fromObject, new String[] {"metadata"}) != null) { |
| 205 | + Common.setValueByPath( |
| 206 | + toObject, |
| 207 | + new String[] {"metadata"}, |
| 208 | + Common.getValueByPath(fromObject, new String[] {"metadata"})); |
| 209 | + } |
| 210 | + |
| 211 | + if (Common.getValueByPath(fromObject, new String[] {"done"}) != null) { |
| 212 | + Common.setValueByPath( |
| 213 | + toObject, |
| 214 | + new String[] {"done"}, |
| 215 | + Common.getValueByPath(fromObject, new String[] {"done"})); |
| 216 | + } |
| 217 | + |
| 218 | + if (Common.getValueByPath(fromObject, new String[] {"error"}) != null) { |
| 219 | + Common.setValueByPath( |
| 220 | + toObject, |
| 221 | + new String[] {"error"}, |
| 222 | + Common.getValueByPath(fromObject, new String[] {"error"})); |
| 223 | + } |
| 224 | + |
| 225 | + if (Common.getValueByPath(fromObject, new String[] {"response", "generateVideoResponse"}) |
| 226 | + != null) { |
| 227 | + Common.setValueByPath( |
| 228 | + toObject, |
| 229 | + new String[] {"response"}, |
| 230 | + generateVideosResponseFromMldev( |
| 231 | + JsonSerializable.toJsonNode( |
| 232 | + Common.getValueByPath( |
| 233 | + fromObject, new String[] {"response", "generateVideoResponse"})), |
| 234 | + toObject)); |
| 235 | + } |
| 236 | + |
| 237 | + return toObject; |
| 238 | + } |
| 239 | + |
| 240 | + @ExcludeFromGeneratedCoverageReport |
| 241 | + ObjectNode videoFromVertex(JsonNode fromObject, ObjectNode parentObject) { |
| 242 | + ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode(); |
| 243 | + if (Common.getValueByPath(fromObject, new String[] {"gcsUri"}) != null) { |
| 244 | + Common.setValueByPath( |
| 245 | + toObject, |
| 246 | + new String[] {"uri"}, |
| 247 | + Common.getValueByPath(fromObject, new String[] {"gcsUri"})); |
| 248 | + } |
| 249 | + |
| 250 | + if (Common.getValueByPath(fromObject, new String[] {"bytesBase64Encoded"}) != null) { |
| 251 | + Common.setValueByPath( |
| 252 | + toObject, |
| 253 | + new String[] {"videoBytes"}, |
| 254 | + Transformers.tBytes( |
| 255 | + Common.getValueByPath(fromObject, new String[] {"bytesBase64Encoded"}))); |
| 256 | + } |
| 257 | + |
| 258 | + if (Common.getValueByPath(fromObject, new String[] {"mimeType"}) != null) { |
| 259 | + Common.setValueByPath( |
| 260 | + toObject, |
| 261 | + new String[] {"mimeType"}, |
| 262 | + Common.getValueByPath(fromObject, new String[] {"mimeType"})); |
| 263 | + } |
| 264 | + |
| 265 | + return toObject; |
| 266 | + } |
| 267 | + |
| 268 | + @ExcludeFromGeneratedCoverageReport |
| 269 | + ObjectNode generatedVideoFromVertex(JsonNode fromObject, ObjectNode parentObject) { |
| 270 | + ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode(); |
| 271 | + if (Common.getValueByPath(fromObject, new String[] {"_self"}) != null) { |
| 272 | + Common.setValueByPath( |
| 273 | + toObject, |
| 274 | + new String[] {"video"}, |
| 275 | + videoFromVertex( |
| 276 | + JsonSerializable.toJsonNode( |
| 277 | + Common.getValueByPath(fromObject, new String[] {"_self"})), |
| 278 | + toObject)); |
| 279 | + } |
| 280 | + |
| 281 | + return toObject; |
| 282 | + } |
| 283 | + |
| 284 | + @ExcludeFromGeneratedCoverageReport |
| 285 | + ObjectNode generateVideosResponseFromVertex(JsonNode fromObject, ObjectNode parentObject) { |
| 286 | + ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode(); |
| 287 | + if (Common.getValueByPath(fromObject, new String[] {"videos"}) != null) { |
| 288 | + ArrayNode keyArray = (ArrayNode) Common.getValueByPath(fromObject, new String[] {"videos"}); |
| 289 | + ObjectMapper objectMapper = new ObjectMapper(); |
| 290 | + ArrayNode result = objectMapper.createArrayNode(); |
| 291 | + |
| 292 | + for (JsonNode item : keyArray) { |
| 293 | + result.add(generatedVideoFromVertex(JsonSerializable.toJsonNode(item), toObject)); |
| 294 | + } |
| 295 | + Common.setValueByPath(toObject, new String[] {"generatedVideos"}, result); |
| 296 | + } |
| 297 | + |
| 298 | + if (Common.getValueByPath(fromObject, new String[] {"raiMediaFilteredCount"}) != null) { |
| 299 | + Common.setValueByPath( |
| 300 | + toObject, |
| 301 | + new String[] {"raiMediaFilteredCount"}, |
| 302 | + Common.getValueByPath(fromObject, new String[] {"raiMediaFilteredCount"})); |
| 303 | + } |
| 304 | + |
| 305 | + if (Common.getValueByPath(fromObject, new String[] {"raiMediaFilteredReasons"}) != null) { |
| 306 | + Common.setValueByPath( |
| 307 | + toObject, |
| 308 | + new String[] {"raiMediaFilteredReasons"}, |
| 309 | + Common.getValueByPath(fromObject, new String[] {"raiMediaFilteredReasons"})); |
| 310 | + } |
| 311 | + |
| 312 | + return toObject; |
| 313 | + } |
| 314 | + |
| 315 | + @ExcludeFromGeneratedCoverageReport |
| 316 | + ObjectNode generateVideosOperationFromVertex(JsonNode fromObject, ObjectNode parentObject) { |
| 317 | + ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode(); |
| 318 | + if (Common.getValueByPath(fromObject, new String[] {"name"}) != null) { |
| 319 | + Common.setValueByPath( |
| 320 | + toObject, |
| 321 | + new String[] {"name"}, |
| 322 | + Common.getValueByPath(fromObject, new String[] {"name"})); |
| 323 | + } |
| 324 | + |
| 325 | + if (Common.getValueByPath(fromObject, new String[] {"metadata"}) != null) { |
| 326 | + Common.setValueByPath( |
| 327 | + toObject, |
| 328 | + new String[] {"metadata"}, |
| 329 | + Common.getValueByPath(fromObject, new String[] {"metadata"})); |
| 330 | + } |
| 331 | + |
| 332 | + if (Common.getValueByPath(fromObject, new String[] {"done"}) != null) { |
| 333 | + Common.setValueByPath( |
| 334 | + toObject, |
| 335 | + new String[] {"done"}, |
| 336 | + Common.getValueByPath(fromObject, new String[] {"done"})); |
| 337 | + } |
| 338 | + |
| 339 | + if (Common.getValueByPath(fromObject, new String[] {"error"}) != null) { |
| 340 | + Common.setValueByPath( |
| 341 | + toObject, |
| 342 | + new String[] {"error"}, |
| 343 | + Common.getValueByPath(fromObject, new String[] {"error"})); |
| 344 | + } |
| 345 | + |
| 346 | + if (Common.getValueByPath(fromObject, new String[] {"response"}) != null) { |
| 347 | + Common.setValueByPath( |
| 348 | + toObject, |
| 349 | + new String[] {"response"}, |
| 350 | + generateVideosResponseFromVertex( |
| 351 | + JsonSerializable.toJsonNode( |
| 352 | + Common.getValueByPath(fromObject, new String[] {"response"})), |
| 353 | + toObject)); |
| 354 | + } |
| 355 | + |
| 356 | + return toObject; |
| 357 | + } |
| 358 | +} |
0 commit comments