Skip to content

Commit 351f706

Browse files
jscudcopybara-github
authored andcommitted
chore: Update data types from discovery doc.
PiperOrigin-RevId: 832486480
1 parent 4ef22c1 commit 351f706

File tree

89 files changed

+6801
-1076
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+6801
-1076
lines changed

src/main/java/com/google/genai/Batches.java

Lines changed: 456 additions & 20 deletions
Large diffs are not rendered by default.

src/main/java/com/google/genai/Caches.java

Lines changed: 229 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,30 @@ ObjectNode contentToMldev(JsonNode fromObject, ObjectNode parentObject) {
107107
return toObject;
108108
}
109109

110+
@ExcludeFromGeneratedCoverageReport
111+
ObjectNode contentToVertex(JsonNode fromObject, ObjectNode parentObject) {
112+
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
113+
if (Common.getValueByPath(fromObject, new String[] {"parts"}) != null) {
114+
ArrayNode keyArray = (ArrayNode) Common.getValueByPath(fromObject, new String[] {"parts"});
115+
ObjectMapper objectMapper = new ObjectMapper();
116+
ArrayNode result = objectMapper.createArrayNode();
117+
118+
for (JsonNode item : keyArray) {
119+
result.add(partToVertex(JsonSerializable.toJsonNode(item), toObject));
120+
}
121+
Common.setValueByPath(toObject, new String[] {"parts"}, result);
122+
}
123+
124+
if (Common.getValueByPath(fromObject, new String[] {"role"}) != null) {
125+
Common.setValueByPath(
126+
toObject,
127+
new String[] {"role"},
128+
Common.getValueByPath(fromObject, new String[] {"role"}));
129+
}
130+
131+
return toObject;
132+
}
133+
110134
@ExcludeFromGeneratedCoverageReport
111135
ObjectNode createCachedContentConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
112136
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
@@ -207,18 +231,27 @@ ObjectNode createCachedContentConfigToVertex(JsonNode fromObject, ObjectNode par
207231
}
208232

209233
if (Common.getValueByPath(fromObject, new String[] {"contents"}) != null) {
210-
Common.setValueByPath(
211-
parentObject,
212-
new String[] {"contents"},
213-
Transformers.tContents(Common.getValueByPath(fromObject, new String[] {"contents"})));
234+
ArrayNode keyArray =
235+
(ArrayNode)
236+
Transformers.tContents(Common.getValueByPath(fromObject, new String[] {"contents"}));
237+
ObjectMapper objectMapper = new ObjectMapper();
238+
ArrayNode result = objectMapper.createArrayNode();
239+
240+
for (JsonNode item : keyArray) {
241+
result.add(contentToVertex(JsonSerializable.toJsonNode(item), toObject));
242+
}
243+
Common.setValueByPath(parentObject, new String[] {"contents"}, result);
214244
}
215245

216246
if (Common.getValueByPath(fromObject, new String[] {"systemInstruction"}) != null) {
217247
Common.setValueByPath(
218248
parentObject,
219249
new String[] {"systemInstruction"},
220-
Transformers.tContent(
221-
Common.getValueByPath(fromObject, new String[] {"systemInstruction"})));
250+
contentToVertex(
251+
JsonSerializable.toJsonNode(
252+
Transformers.tContent(
253+
Common.getValueByPath(fromObject, new String[] {"systemInstruction"}))),
254+
toObject));
222255
}
223256

224257
if (Common.getValueByPath(fromObject, new String[] {"tools"}) != null) {
@@ -428,22 +461,104 @@ ObjectNode functionDeclarationToVertex(JsonNode fromObject, ObjectNode parentObj
428461
}
429462

430463
@ExcludeFromGeneratedCoverageReport
431-
ObjectNode getCachedContentParametersToMldev(
432-
ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
464+
ObjectNode functionResponseFileDataToMldev(JsonNode fromObject, ObjectNode parentObject) {
433465
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
466+
if (Common.getValueByPath(fromObject, new String[] {"fileUri"}) != null) {
467+
Common.setValueByPath(
468+
toObject,
469+
new String[] {"fileUri"},
470+
Common.getValueByPath(fromObject, new String[] {"fileUri"}));
471+
}
472+
473+
if (Common.getValueByPath(fromObject, new String[] {"mimeType"}) != null) {
474+
Common.setValueByPath(
475+
toObject,
476+
new String[] {"mimeType"},
477+
Common.getValueByPath(fromObject, new String[] {"mimeType"}));
478+
}
479+
480+
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"displayName"}))) {
481+
throw new IllegalArgumentException("displayName parameter is not supported in Gemini API.");
482+
}
483+
484+
return toObject;
485+
}
486+
487+
@ExcludeFromGeneratedCoverageReport
488+
ObjectNode functionResponsePartToMldev(JsonNode fromObject, ObjectNode parentObject) {
489+
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
490+
if (Common.getValueByPath(fromObject, new String[] {"inlineData"}) != null) {
491+
Common.setValueByPath(
492+
toObject,
493+
new String[] {"inlineData"},
494+
Common.getValueByPath(fromObject, new String[] {"inlineData"}));
495+
}
496+
497+
if (Common.getValueByPath(fromObject, new String[] {"fileData"}) != null) {
498+
Common.setValueByPath(
499+
toObject,
500+
new String[] {"fileData"},
501+
functionResponseFileDataToMldev(
502+
JsonSerializable.toJsonNode(
503+
Common.getValueByPath(fromObject, new String[] {"fileData"})),
504+
toObject));
505+
}
506+
507+
return toObject;
508+
}
509+
510+
@ExcludeFromGeneratedCoverageReport
511+
ObjectNode functionResponseToMldev(JsonNode fromObject, ObjectNode parentObject) {
512+
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
513+
if (Common.getValueByPath(fromObject, new String[] {"willContinue"}) != null) {
514+
Common.setValueByPath(
515+
toObject,
516+
new String[] {"willContinue"},
517+
Common.getValueByPath(fromObject, new String[] {"willContinue"}));
518+
}
519+
520+
if (Common.getValueByPath(fromObject, new String[] {"scheduling"}) != null) {
521+
Common.setValueByPath(
522+
toObject,
523+
new String[] {"scheduling"},
524+
Common.getValueByPath(fromObject, new String[] {"scheduling"}));
525+
}
526+
527+
if (Common.getValueByPath(fromObject, new String[] {"parts"}) != null) {
528+
ArrayNode keyArray = (ArrayNode) Common.getValueByPath(fromObject, new String[] {"parts"});
529+
ObjectMapper objectMapper = new ObjectMapper();
530+
ArrayNode result = objectMapper.createArrayNode();
531+
532+
for (JsonNode item : keyArray) {
533+
result.add(functionResponsePartToMldev(JsonSerializable.toJsonNode(item), toObject));
534+
}
535+
Common.setValueByPath(toObject, new String[] {"parts"}, result);
536+
}
537+
538+
if (Common.getValueByPath(fromObject, new String[] {"id"}) != null) {
539+
Common.setValueByPath(
540+
toObject, new String[] {"id"}, Common.getValueByPath(fromObject, new String[] {"id"}));
541+
}
542+
434543
if (Common.getValueByPath(fromObject, new String[] {"name"}) != null) {
435544
Common.setValueByPath(
436545
toObject,
437-
new String[] {"_url", "name"},
438-
Transformers.tCachedContentName(
439-
this.apiClient, Common.getValueByPath(fromObject, new String[] {"name"})));
546+
new String[] {"name"},
547+
Common.getValueByPath(fromObject, new String[] {"name"}));
548+
}
549+
550+
if (Common.getValueByPath(fromObject, new String[] {"response"}) != null) {
551+
Common.setValueByPath(
552+
toObject,
553+
new String[] {"response"},
554+
Common.getValueByPath(fromObject, new String[] {"response"}));
440555
}
441556

442557
return toObject;
443558
}
444559

445560
@ExcludeFromGeneratedCoverageReport
446-
ObjectNode getCachedContentParametersToVertex(
561+
ObjectNode getCachedContentParametersToMldev(
447562
ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
448563
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
449564
if (Common.getValueByPath(fromObject, new String[] {"name"}) != null) {
@@ -458,17 +573,15 @@ ObjectNode getCachedContentParametersToVertex(
458573
}
459574

460575
@ExcludeFromGeneratedCoverageReport
461-
ObjectNode googleMapsToMldev(JsonNode fromObject, ObjectNode parentObject) {
576+
ObjectNode getCachedContentParametersToVertex(
577+
ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
462578
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
463-
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"authConfig"}))) {
464-
throw new IllegalArgumentException("authConfig parameter is not supported in Gemini API.");
465-
}
466-
467-
if (Common.getValueByPath(fromObject, new String[] {"enableWidget"}) != null) {
579+
if (Common.getValueByPath(fromObject, new String[] {"name"}) != null) {
468580
Common.setValueByPath(
469581
toObject,
470-
new String[] {"enableWidget"},
471-
Common.getValueByPath(fromObject, new String[] {"enableWidget"}));
582+
new String[] {"_url", "name"},
583+
Transformers.tCachedContentName(
584+
this.apiClient, Common.getValueByPath(fromObject, new String[] {"name"})));
472585
}
473586

474587
return toObject;
@@ -477,14 +590,14 @@ ObjectNode googleMapsToMldev(JsonNode fromObject, ObjectNode parentObject) {
477590
@ExcludeFromGeneratedCoverageReport
478591
ObjectNode googleSearchToMldev(JsonNode fromObject, ObjectNode parentObject) {
479592
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
480-
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"excludeDomains"}))) {
593+
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"blockingConfidence"}))) {
481594
throw new IllegalArgumentException(
482-
"excludeDomains parameter is not supported in Gemini API.");
595+
"blockingConfidence parameter is not supported in Gemini API.");
483596
}
484597

485-
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"blockingConfidence"}))) {
598+
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"excludeDomains"}))) {
486599
throw new IllegalArgumentException(
487-
"blockingConfidence parameter is not supported in Gemini API.");
600+
"excludeDomains parameter is not supported in Gemini API.");
488601
}
489602

490603
if (Common.getValueByPath(fromObject, new String[] {"timeRangeFilter"}) != null) {
@@ -659,7 +772,10 @@ ObjectNode partToMldev(JsonNode fromObject, ObjectNode parentObject) {
659772
Common.setValueByPath(
660773
toObject,
661774
new String[] {"functionResponse"},
662-
Common.getValueByPath(fromObject, new String[] {"functionResponse"}));
775+
functionResponseToMldev(
776+
JsonSerializable.toJsonNode(
777+
Common.getValueByPath(fromObject, new String[] {"functionResponse"})),
778+
toObject));
663779
}
664780

665781
if (Common.getValueByPath(fromObject, new String[] {"inlineData"}) != null) {
@@ -700,6 +816,93 @@ ObjectNode partToMldev(JsonNode fromObject, ObjectNode parentObject) {
700816
Common.getValueByPath(fromObject, new String[] {"videoMetadata"}));
701817
}
702818

819+
if (Common.getValueByPath(fromObject, new String[] {"partMetadata"}) != null) {
820+
Common.setValueByPath(
821+
toObject,
822+
new String[] {"partMetadata"},
823+
Common.getValueByPath(fromObject, new String[] {"partMetadata"}));
824+
}
825+
826+
return toObject;
827+
}
828+
829+
@ExcludeFromGeneratedCoverageReport
830+
ObjectNode partToVertex(JsonNode fromObject, ObjectNode parentObject) {
831+
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
832+
if (Common.getValueByPath(fromObject, new String[] {"functionCall"}) != null) {
833+
Common.setValueByPath(
834+
toObject,
835+
new String[] {"functionCall"},
836+
Common.getValueByPath(fromObject, new String[] {"functionCall"}));
837+
}
838+
839+
if (Common.getValueByPath(fromObject, new String[] {"codeExecutionResult"}) != null) {
840+
Common.setValueByPath(
841+
toObject,
842+
new String[] {"codeExecutionResult"},
843+
Common.getValueByPath(fromObject, new String[] {"codeExecutionResult"}));
844+
}
845+
846+
if (Common.getValueByPath(fromObject, new String[] {"executableCode"}) != null) {
847+
Common.setValueByPath(
848+
toObject,
849+
new String[] {"executableCode"},
850+
Common.getValueByPath(fromObject, new String[] {"executableCode"}));
851+
}
852+
853+
if (Common.getValueByPath(fromObject, new String[] {"fileData"}) != null) {
854+
Common.setValueByPath(
855+
toObject,
856+
new String[] {"fileData"},
857+
Common.getValueByPath(fromObject, new String[] {"fileData"}));
858+
}
859+
860+
if (Common.getValueByPath(fromObject, new String[] {"functionResponse"}) != null) {
861+
Common.setValueByPath(
862+
toObject,
863+
new String[] {"functionResponse"},
864+
Common.getValueByPath(fromObject, new String[] {"functionResponse"}));
865+
}
866+
867+
if (Common.getValueByPath(fromObject, new String[] {"inlineData"}) != null) {
868+
Common.setValueByPath(
869+
toObject,
870+
new String[] {"inlineData"},
871+
Common.getValueByPath(fromObject, new String[] {"inlineData"}));
872+
}
873+
874+
if (Common.getValueByPath(fromObject, new String[] {"text"}) != null) {
875+
Common.setValueByPath(
876+
toObject,
877+
new String[] {"text"},
878+
Common.getValueByPath(fromObject, new String[] {"text"}));
879+
}
880+
881+
if (Common.getValueByPath(fromObject, new String[] {"thought"}) != null) {
882+
Common.setValueByPath(
883+
toObject,
884+
new String[] {"thought"},
885+
Common.getValueByPath(fromObject, new String[] {"thought"}));
886+
}
887+
888+
if (Common.getValueByPath(fromObject, new String[] {"thoughtSignature"}) != null) {
889+
Common.setValueByPath(
890+
toObject,
891+
new String[] {"thoughtSignature"},
892+
Common.getValueByPath(fromObject, new String[] {"thoughtSignature"}));
893+
}
894+
895+
if (Common.getValueByPath(fromObject, new String[] {"videoMetadata"}) != null) {
896+
Common.setValueByPath(
897+
toObject,
898+
new String[] {"videoMetadata"},
899+
Common.getValueByPath(fromObject, new String[] {"videoMetadata"}));
900+
}
901+
902+
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"partMetadata"}))) {
903+
throw new IllegalArgumentException("partMetadata parameter is not supported in Vertex AI.");
904+
}
905+
703906
return toObject;
704907
}
705908

@@ -754,10 +957,7 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
754957
Common.setValueByPath(
755958
toObject,
756959
new String[] {"googleMaps"},
757-
googleMapsToMldev(
758-
JsonSerializable.toJsonNode(
759-
Common.getValueByPath(fromObject, new String[] {"googleMaps"})),
760-
toObject));
960+
Common.getValueByPath(fromObject, new String[] {"googleMaps"}));
761961
}
762962

763963
if (Common.getValueByPath(fromObject, new String[] {"googleSearch"}) != null) {

0 commit comments

Comments
 (0)