Skip to content

Commit 0b67828

Browse files
jscudcopybara-github
authored andcommitted
chore: update error messages to clarify which APIs support a feature.
PiperOrigin-RevId: 914394015
1 parent 642ad10 commit 0b67828

14 files changed

Lines changed: 610 additions & 282 deletions

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

Lines changed: 114 additions & 50 deletions
Large diffs are not rendered by default.

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

Lines changed: 56 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -70,30 +70,40 @@ ObjectNode authConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
7070
}
7171

7272
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"apiKeyConfig"}))) {
73-
throw new IllegalArgumentException("apiKeyConfig parameter is not supported in Gemini API.");
73+
throw new IllegalArgumentException(
74+
"apiKeyConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not"
75+
+ " in Gemini Developer API mode.");
7476
}
7577

7678
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"authType"}))) {
77-
throw new IllegalArgumentException("authType parameter is not supported in Gemini API.");
79+
throw new IllegalArgumentException(
80+
"authType parameter is only supported in Gemini Enterprise Agent Platform mode, not in"
81+
+ " Gemini Developer API mode.");
7882
}
7983

8084
if (!Common.isZero(
8185
Common.getValueByPath(fromObject, new String[] {"googleServiceAccountConfig"}))) {
8286
throw new IllegalArgumentException(
83-
"googleServiceAccountConfig parameter is not supported in Gemini API.");
87+
"googleServiceAccountConfig parameter is only supported in Gemini Enterprise Agent"
88+
+ " Platform mode, not in Gemini Developer API mode.");
8489
}
8590

8691
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"httpBasicAuthConfig"}))) {
8792
throw new IllegalArgumentException(
88-
"httpBasicAuthConfig parameter is not supported in Gemini API.");
93+
"httpBasicAuthConfig parameter is only supported in Gemini Enterprise Agent Platform"
94+
+ " mode, not in Gemini Developer API mode.");
8995
}
9096

9197
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"oauthConfig"}))) {
92-
throw new IllegalArgumentException("oauthConfig parameter is not supported in Gemini API.");
98+
throw new IllegalArgumentException(
99+
"oauthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in"
100+
+ " Gemini Developer API mode.");
93101
}
94102

95103
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"oidcConfig"}))) {
96-
throw new IllegalArgumentException("oidcConfig parameter is not supported in Gemini API.");
104+
throw new IllegalArgumentException(
105+
"oidcConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in"
106+
+ " Gemini Developer API mode.");
97107
}
98108

99109
return toObject;
@@ -110,7 +120,9 @@ ObjectNode blobToMldev(JsonNode fromObject, ObjectNode parentObject) {
110120
}
111121

112122
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"displayName"}))) {
113-
throw new IllegalArgumentException("displayName parameter is not supported in Gemini API.");
123+
throw new IllegalArgumentException(
124+
"displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in"
125+
+ " Gemini Developer API mode.");
114126
}
115127

116128
if (Common.getValueByPath(fromObject, new String[] {"mimeType"}) != null) {
@@ -242,7 +254,9 @@ ObjectNode createCachedContentConfigToMldev(JsonNode fromObject, ObjectNode pare
242254
}
243255

244256
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"kmsKeyName"}))) {
245-
throw new IllegalArgumentException("kmsKeyName parameter is not supported in Gemini API.");
257+
throw new IllegalArgumentException(
258+
"kmsKeyName parameter is only supported in Gemini Enterprise Agent Platform mode, not in"
259+
+ " Gemini Developer API mode.");
246260
}
247261

248262
return toObject;
@@ -434,7 +448,9 @@ ObjectNode deleteCachedContentResponseFromVertex(JsonNode fromObject, ObjectNode
434448
ObjectNode fileDataToMldev(JsonNode fromObject, ObjectNode parentObject) {
435449
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
436450
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"displayName"}))) {
437-
throw new IllegalArgumentException("displayName parameter is not supported in Gemini API.");
451+
throw new IllegalArgumentException(
452+
"displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in"
453+
+ " Gemini Developer API mode.");
438454
}
439455

440456
if (Common.getValueByPath(fromObject, new String[] {"fileUri"}) != null) {
@@ -477,11 +493,15 @@ ObjectNode functionCallToMldev(JsonNode fromObject, ObjectNode parentObject) {
477493
}
478494

479495
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"partialArgs"}))) {
480-
throw new IllegalArgumentException("partialArgs parameter is not supported in Gemini API.");
496+
throw new IllegalArgumentException(
497+
"partialArgs parameter is only supported in Gemini Enterprise Agent Platform mode, not in"
498+
+ " Gemini Developer API mode.");
481499
}
482500

483501
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"willContinue"}))) {
484-
throw new IllegalArgumentException("willContinue parameter is not supported in Gemini API.");
502+
throw new IllegalArgumentException(
503+
"willContinue parameter is only supported in Gemini Enterprise Agent Platform mode, not"
504+
+ " in Gemini Developer API mode.");
485505
}
486506

487507
return toObject;
@@ -507,7 +527,8 @@ ObjectNode functionCallingConfigToMldev(JsonNode fromObject, ObjectNode parentOb
507527
if (!Common.isZero(
508528
Common.getValueByPath(fromObject, new String[] {"streamFunctionCallArguments"}))) {
509529
throw new IllegalArgumentException(
510-
"streamFunctionCallArguments parameter is not supported in Gemini API.");
530+
"streamFunctionCallArguments parameter is only supported in Gemini Enterprise Agent"
531+
+ " Platform mode, not in Gemini Developer API mode.");
511532
}
512533

513534
return toObject;
@@ -578,12 +599,14 @@ ObjectNode googleSearchToMldev(JsonNode fromObject, ObjectNode parentObject) {
578599

579600
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"blockingConfidence"}))) {
580601
throw new IllegalArgumentException(
581-
"blockingConfidence parameter is not supported in Gemini API.");
602+
"blockingConfidence parameter is only supported in Gemini Enterprise Agent Platform mode,"
603+
+ " not in Gemini Developer API mode.");
582604
}
583605

584606
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"excludeDomains"}))) {
585607
throw new IllegalArgumentException(
586-
"excludeDomains parameter is not supported in Gemini API.");
608+
"excludeDomains parameter is only supported in Gemini Enterprise Agent Platform mode, not"
609+
+ " in Gemini Developer API mode.");
587610
}
588611

589612
if (Common.getValueByPath(fromObject, new String[] {"timeRangeFilter"}) != null) {
@@ -915,17 +938,20 @@ ObjectNode partToVertex(JsonNode fromObject, ObjectNode parentObject) {
915938

916939
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"toolCall"}))) {
917940
throw new IllegalArgumentException(
918-
"toolCall parameter is not supported in Gemini Enterprise Agent Platform.");
941+
"toolCall parameter is only supported in Gemini Developer API mode, not in Gemini"
942+
+ " Enterprise Agent Platform mode.");
919943
}
920944

921945
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"toolResponse"}))) {
922946
throw new IllegalArgumentException(
923-
"toolResponse parameter is not supported in Gemini Enterprise Agent Platform.");
947+
"toolResponse parameter is only supported in Gemini Developer API mode, not in Gemini"
948+
+ " Enterprise Agent Platform mode.");
924949
}
925950

926951
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"partMetadata"}))) {
927952
throw new IllegalArgumentException(
928-
"partMetadata parameter is not supported in Gemini Enterprise Agent Platform.");
953+
"partMetadata parameter is only supported in Gemini Developer API mode, not in Gemini"
954+
+ " Enterprise Agent Platform mode.");
929955
}
930956

931957
return toObject;
@@ -982,8 +1008,8 @@ ObjectNode toolConfigToVertex(JsonNode fromObject, ObjectNode parentObject) {
9821008
if (!Common.isZero(
9831009
Common.getValueByPath(fromObject, new String[] {"includeServerSideToolInvocations"}))) {
9841010
throw new IllegalArgumentException(
985-
"includeServerSideToolInvocations parameter is not supported in Gemini Enterprise Agent"
986-
+ " Platform.");
1011+
"includeServerSideToolInvocations parameter is only supported in Gemini Developer API"
1012+
+ " mode, not in Gemini Enterprise Agent Platform mode.");
9871013
}
9881014

9891015
return toObject;
@@ -993,7 +1019,9 @@ ObjectNode toolConfigToVertex(JsonNode fromObject, ObjectNode parentObject) {
9931019
ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
9941020
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
9951021
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"retrieval"}))) {
996-
throw new IllegalArgumentException("retrieval parameter is not supported in Gemini API.");
1022+
throw new IllegalArgumentException(
1023+
"retrieval parameter is only supported in Gemini Enterprise Agent Platform mode, not in"
1024+
+ " Gemini Developer API mode.");
9971025
}
9981026

9991027
if (Common.getValueByPath(fromObject, new String[] {"computerUse"}) != null) {
@@ -1039,7 +1067,8 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
10391067

10401068
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"enterpriseWebSearch"}))) {
10411069
throw new IllegalArgumentException(
1042-
"enterpriseWebSearch parameter is not supported in Gemini API.");
1070+
"enterpriseWebSearch parameter is only supported in Gemini Enterprise Agent Platform"
1071+
+ " mode, not in Gemini Developer API mode.");
10431072
}
10441073

10451074
if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) {
@@ -1058,7 +1087,8 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
10581087

10591088
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"parallelAiSearch"}))) {
10601089
throw new IllegalArgumentException(
1061-
"parallelAiSearch parameter is not supported in Gemini API.");
1090+
"parallelAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode,"
1091+
+ " not in Gemini Developer API mode.");
10621092
}
10631093

10641094
if (Common.getValueByPath(fromObject, new String[] {"urlContext"}) != null) {
@@ -1097,7 +1127,8 @@ ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) {
10971127

10981128
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"fileSearch"}))) {
10991129
throw new IllegalArgumentException(
1100-
"fileSearch parameter is not supported in Gemini Enterprise Agent Platform.");
1130+
"fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini"
1131+
+ " Enterprise Agent Platform mode.");
11011132
}
11021133

11031134
if (Common.getValueByPath(fromObject, new String[] {"googleSearch"}) != null) {
@@ -1158,7 +1189,8 @@ ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) {
11581189

11591190
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"mcpServers"}))) {
11601191
throw new IllegalArgumentException(
1161-
"mcpServers parameter is not supported in Gemini Enterprise Agent Platform.");
1192+
"mcpServers parameter is only supported in Gemini Developer API mode, not in Gemini"
1193+
+ " Enterprise Agent Platform mode.");
11621194
}
11631195

11641196
return toObject;

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ BuiltRequest buildRequestForGet(String name, GetDocumentConfig config) {
178178
String path;
179179
if (this.apiClient.vertexAI()) {
180180
throw new UnsupportedOperationException(
181-
"This method is only supported in the Gemini Developer client.");
181+
"This method is only supported in Gemini Developer API mode, not in Gemini Enterprise"
182+
+ " Agent Platform mode.");
182183
} else {
183184
body = getDocumentParametersToMldev(parameterNode, null);
184185
if (body.get("_url") != null) {
@@ -218,7 +219,8 @@ Document processResponseForGet(ApiResponse response, GetDocumentConfig config) {
218219

219220
if (this.apiClient.vertexAI()) {
220221
throw new UnsupportedOperationException(
221-
"This method is only supported in the Gemini Developer client.");
222+
"This method is only supported in Gemini Developer API mode, not in Gemini Enterprise"
223+
+ " Agent Platform mode.");
222224
}
223225

224226
return JsonSerializable.fromJsonNode(responseNode, Document.class);
@@ -251,7 +253,8 @@ BuiltRequest buildRequestForDelete(String name, DeleteDocumentConfig config) {
251253
String path;
252254
if (this.apiClient.vertexAI()) {
253255
throw new UnsupportedOperationException(
254-
"This method is only supported in the Gemini Developer client.");
256+
"This method is only supported in Gemini Developer API mode, not in Gemini Enterprise"
257+
+ " Agent Platform mode.");
255258
} else {
256259
body = deleteDocumentParametersToMldev(parameterNode, null);
257260
if (body.get("_url") != null) {
@@ -304,7 +307,8 @@ BuiltRequest buildRequestForPrivateList(String parent, ListDocumentsConfig confi
304307
String path;
305308
if (this.apiClient.vertexAI()) {
306309
throw new UnsupportedOperationException(
307-
"This method is only supported in the Gemini Developer client.");
310+
"This method is only supported in Gemini Developer API mode, not in Gemini Enterprise"
311+
+ " Agent Platform mode.");
308312
} else {
309313
body = listDocumentsParametersToMldev(parameterNode, null);
310314
if (body.get("_url") != null) {
@@ -345,7 +349,8 @@ ListDocumentsResponse processResponseForPrivateList(
345349

346350
if (this.apiClient.vertexAI()) {
347351
throw new UnsupportedOperationException(
348-
"This method is only supported in the Gemini Developer client.");
352+
"This method is only supported in Gemini Developer API mode, not in Gemini Enterprise"
353+
+ " Agent Platform mode.");
349354
}
350355

351356
if (!this.apiClient.vertexAI()) {

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

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,8 @@ BuiltRequest buildRequestForCreate(CreateFileSearchStoreConfig config) {
421421
String path;
422422
if (this.apiClient.vertexAI()) {
423423
throw new UnsupportedOperationException(
424-
"This method is only supported in the Gemini Developer client.");
424+
"This method is only supported in Gemini Developer API mode, not in Gemini Enterprise"
425+
+ " Agent Platform mode.");
425426
} else {
426427
body = createFileSearchStoreParametersToMldev(this.apiClient, parameterNode, null);
427428
if (body.get("_url") != null) {
@@ -462,7 +463,8 @@ FileSearchStore processResponseForCreate(
462463

463464
if (this.apiClient.vertexAI()) {
464465
throw new UnsupportedOperationException(
465-
"This method is only supported in the Gemini Developer client.");
466+
"This method is only supported in Gemini Developer API mode, not in Gemini Enterprise"
467+
+ " Agent Platform mode.");
466468
}
467469

468470
return JsonSerializable.fromJsonNode(responseNode, FileSearchStore.class);
@@ -495,7 +497,8 @@ BuiltRequest buildRequestForGet(String name, GetFileSearchStoreConfig config) {
495497
String path;
496498
if (this.apiClient.vertexAI()) {
497499
throw new UnsupportedOperationException(
498-
"This method is only supported in the Gemini Developer client.");
500+
"This method is only supported in Gemini Developer API mode, not in Gemini Enterprise"
501+
+ " Agent Platform mode.");
499502
} else {
500503
body = getFileSearchStoreParametersToMldev(parameterNode, null);
501504
if (body.get("_url") != null) {
@@ -535,7 +538,8 @@ FileSearchStore processResponseForGet(ApiResponse response, GetFileSearchStoreCo
535538

536539
if (this.apiClient.vertexAI()) {
537540
throw new UnsupportedOperationException(
538-
"This method is only supported in the Gemini Developer client.");
541+
"This method is only supported in Gemini Developer API mode, not in Gemini Enterprise"
542+
+ " Agent Platform mode.");
539543
}
540544

541545
return JsonSerializable.fromJsonNode(responseNode, FileSearchStore.class);
@@ -569,7 +573,8 @@ BuiltRequest buildRequestForDelete(String name, DeleteFileSearchStoreConfig conf
569573
String path;
570574
if (this.apiClient.vertexAI()) {
571575
throw new UnsupportedOperationException(
572-
"This method is only supported in the Gemini Developer client.");
576+
"This method is only supported in Gemini Developer API mode, not in Gemini Enterprise"
577+
+ " Agent Platform mode.");
573578
} else {
574579
body = deleteFileSearchStoreParametersToMldev(parameterNode, null);
575580
if (body.get("_url") != null) {
@@ -620,7 +625,8 @@ BuiltRequest buildRequestForPrivateList(ListFileSearchStoresConfig config) {
620625
String path;
621626
if (this.apiClient.vertexAI()) {
622627
throw new UnsupportedOperationException(
623-
"This method is only supported in the Gemini Developer client.");
628+
"This method is only supported in Gemini Developer API mode, not in Gemini Enterprise"
629+
+ " Agent Platform mode.");
624630
} else {
625631
body = listFileSearchStoresParametersToMldev(parameterNode, null);
626632
if (body.get("_url") != null) {
@@ -661,7 +667,8 @@ ListFileSearchStoresResponse processResponseForPrivateList(
661667

662668
if (this.apiClient.vertexAI()) {
663669
throw new UnsupportedOperationException(
664-
"This method is only supported in the Gemini Developer client.");
670+
"This method is only supported in Gemini Developer API mode, not in Gemini Enterprise"
671+
+ " Agent Platform mode.");
665672
}
666673

667674
if (!this.apiClient.vertexAI()) {
@@ -700,7 +707,8 @@ BuiltRequest buildRequestForPrivateUploadToFileSearchStore(
700707
String path;
701708
if (this.apiClient.vertexAI()) {
702709
throw new UnsupportedOperationException(
703-
"This method is only supported in the Gemini Developer client.");
710+
"This method is only supported in Gemini Developer API mode, not in Gemini Enterprise"
711+
+ " Agent Platform mode.");
704712
} else {
705713
body = uploadToFileSearchStoreParametersToMldev(parameterNode, null);
706714
if (body.get("_url") != null) {
@@ -759,7 +767,8 @@ UploadToFileSearchStoreResumableResponse processResponseForPrivateUploadToFileSe
759767

760768
if (this.apiClient.vertexAI()) {
761769
throw new UnsupportedOperationException(
762-
"This method is only supported in the Gemini Developer client.");
770+
"This method is only supported in Gemini Developer API mode, not in Gemini Enterprise"
771+
+ " Agent Platform mode.");
763772
}
764773

765774
if (!this.apiClient.vertexAI()) {
@@ -803,7 +812,8 @@ BuiltRequest buildRequestForImportFile(
803812
String path;
804813
if (this.apiClient.vertexAI()) {
805814
throw new UnsupportedOperationException(
806-
"This method is only supported in the Gemini Developer client.");
815+
"This method is only supported in Gemini Developer API mode, not in Gemini Enterprise"
816+
+ " Agent Platform mode.");
807817
} else {
808818
body = importFileParametersToMldev(parameterNode, null);
809819
if (body.get("_url") != null) {
@@ -843,7 +853,8 @@ ImportFileOperation processResponseForImportFile(ApiResponse response, ImportFil
843853

844854
if (this.apiClient.vertexAI()) {
845855
throw new UnsupportedOperationException(
846-
"This method is only supported in the Gemini Developer client.");
856+
"This method is only supported in Gemini Developer API mode, not in Gemini Enterprise"
857+
+ " Agent Platform mode.");
847858
}
848859

849860
if (!this.apiClient.vertexAI()) {

0 commit comments

Comments
 (0)