Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
358 changes: 358 additions & 0 deletions src/main/java/com/google/genai/OperationsConverters.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,358 @@
/*
* Copyright 2025 Google LLC
*
* Licensed 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
*
* https://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.
*/

// Auto-generated code. Do not edit.

package com.google.genai;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;

final class OperationsConverters {
private final ApiClient apiClient;

public OperationsConverters(ApiClient apiClient) {
this.apiClient = apiClient;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode fetchPredictOperationParametersToMldev(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"operationName"}))) {
throw new IllegalArgumentException("operationName parameter is not supported in Gemini API.");
}

if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"resourceName"}))) {
throw new IllegalArgumentException("resourceName parameter is not supported in Gemini API.");
}

if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"config"}))) {
throw new IllegalArgumentException("config parameter is not supported in Gemini API.");
}

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode getOperationParametersToMldev(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"operationName"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"_url", "operationName"},
Common.getValueByPath(fromObject, new String[] {"operationName"}));
}

if (Common.getValueByPath(fromObject, new String[] {"config"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"config"},
Common.getValueByPath(fromObject, new String[] {"config"}));
}

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode fetchPredictOperationParametersToVertex(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"operationName"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"operationName"},
Common.getValueByPath(fromObject, new String[] {"operationName"}));
}

if (Common.getValueByPath(fromObject, new String[] {"resourceName"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"_url", "resourceName"},
Common.getValueByPath(fromObject, new String[] {"resourceName"}));
}

if (Common.getValueByPath(fromObject, new String[] {"config"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"config"},
Common.getValueByPath(fromObject, new String[] {"config"}));
}

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode getOperationParametersToVertex(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"operationName"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"_url", "operationName"},
Common.getValueByPath(fromObject, new String[] {"operationName"}));
}

if (Common.getValueByPath(fromObject, new String[] {"config"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"config"},
Common.getValueByPath(fromObject, new String[] {"config"}));
}

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode videoFromMldev(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"video", "uri"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"uri"},
Common.getValueByPath(fromObject, new String[] {"video", "uri"}));
}

if (Common.getValueByPath(fromObject, new String[] {"video", "encodedVideo"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"videoBytes"},
Transformers.tBytes(
Common.getValueByPath(fromObject, new String[] {"video", "encodedVideo"})));
}

if (Common.getValueByPath(fromObject, new String[] {"encoding"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"mimeType"},
Common.getValueByPath(fromObject, new String[] {"encoding"}));
}

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode generatedVideoFromMldev(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"_self"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"video"},
videoFromMldev(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"_self"})),
toObject));
}

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode generateVideosResponseFromMldev(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"generatedSamples"}) != null) {
ArrayNode keyArray =
(ArrayNode) Common.getValueByPath(fromObject, new String[] {"generatedSamples"});
ObjectMapper objectMapper = new ObjectMapper();
ArrayNode result = objectMapper.createArrayNode();

for (JsonNode item : keyArray) {
result.add(generatedVideoFromMldev(JsonSerializable.toJsonNode(item), toObject));
}
Common.setValueByPath(toObject, new String[] {"generatedVideos"}, result);
}

if (Common.getValueByPath(fromObject, new String[] {"raiMediaFilteredCount"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"raiMediaFilteredCount"},
Common.getValueByPath(fromObject, new String[] {"raiMediaFilteredCount"}));
}

if (Common.getValueByPath(fromObject, new String[] {"raiMediaFilteredReasons"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"raiMediaFilteredReasons"},
Common.getValueByPath(fromObject, new String[] {"raiMediaFilteredReasons"}));
}

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode generateVideosOperationFromMldev(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"name"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"name"},
Common.getValueByPath(fromObject, new String[] {"name"}));
}

if (Common.getValueByPath(fromObject, new String[] {"metadata"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"metadata"},
Common.getValueByPath(fromObject, new String[] {"metadata"}));
}

if (Common.getValueByPath(fromObject, new String[] {"done"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"done"},
Common.getValueByPath(fromObject, new String[] {"done"}));
}

if (Common.getValueByPath(fromObject, new String[] {"error"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"error"},
Common.getValueByPath(fromObject, new String[] {"error"}));
}

if (Common.getValueByPath(fromObject, new String[] {"response", "generateVideoResponse"})
!= null) {
Common.setValueByPath(
toObject,
new String[] {"response"},
generateVideosResponseFromMldev(
JsonSerializable.toJsonNode(
Common.getValueByPath(
fromObject, new String[] {"response", "generateVideoResponse"})),
toObject));
}

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode videoFromVertex(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"gcsUri"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"uri"},
Common.getValueByPath(fromObject, new String[] {"gcsUri"}));
}

if (Common.getValueByPath(fromObject, new String[] {"bytesBase64Encoded"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"videoBytes"},
Transformers.tBytes(
Common.getValueByPath(fromObject, new String[] {"bytesBase64Encoded"})));
}

if (Common.getValueByPath(fromObject, new String[] {"mimeType"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"mimeType"},
Common.getValueByPath(fromObject, new String[] {"mimeType"}));
}

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode generatedVideoFromVertex(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"_self"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"video"},
videoFromVertex(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"_self"})),
toObject));
}

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode generateVideosResponseFromVertex(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"videos"}) != null) {
ArrayNode keyArray = (ArrayNode) Common.getValueByPath(fromObject, new String[] {"videos"});
ObjectMapper objectMapper = new ObjectMapper();
ArrayNode result = objectMapper.createArrayNode();

for (JsonNode item : keyArray) {
result.add(generatedVideoFromVertex(JsonSerializable.toJsonNode(item), toObject));
}
Common.setValueByPath(toObject, new String[] {"generatedVideos"}, result);
}

if (Common.getValueByPath(fromObject, new String[] {"raiMediaFilteredCount"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"raiMediaFilteredCount"},
Common.getValueByPath(fromObject, new String[] {"raiMediaFilteredCount"}));
}

if (Common.getValueByPath(fromObject, new String[] {"raiMediaFilteredReasons"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"raiMediaFilteredReasons"},
Common.getValueByPath(fromObject, new String[] {"raiMediaFilteredReasons"}));
}

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode generateVideosOperationFromVertex(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"name"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"name"},
Common.getValueByPath(fromObject, new String[] {"name"}));
}

if (Common.getValueByPath(fromObject, new String[] {"metadata"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"metadata"},
Common.getValueByPath(fromObject, new String[] {"metadata"}));
}

if (Common.getValueByPath(fromObject, new String[] {"done"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"done"},
Common.getValueByPath(fromObject, new String[] {"done"}));
}

if (Common.getValueByPath(fromObject, new String[] {"error"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"error"},
Common.getValueByPath(fromObject, new String[] {"error"}));
}

if (Common.getValueByPath(fromObject, new String[] {"response"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"response"},
generateVideosResponseFromVertex(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"response"})),
toObject));
}

return toObject;
}
}