diff --git a/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseAudio.java b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseAudio.java index 68745312156..4ca58d079b5 100644 --- a/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseAudio.java +++ b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseAudio.java @@ -48,6 +48,7 @@ import com.google.genai.gaos.models.interactions.Model; import com.google.genai.gaos.models.interactions.ResponseModality; import com.google.genai.gaos.models.interactions.SpeechConfig; +import com.google.genai.gaos.models.interactions.SpeechConfigUnion; import com.google.genai.gaos.models.interactions.Step; import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; import com.google.genai.gaos.models.operations.CreateInteractionResponse; @@ -61,7 +62,9 @@ private static void createInteractions(Client client) { SpeechConfig speechConfig = SpeechConfig.builder().voice("achernar").language("en-US").build(); GenerationConfig generationConfig = - GenerationConfig.builder().speechConfig(Arrays.asList(speechConfig)).build(); + GenerationConfig.builder() + .speechConfig(SpeechConfigUnion.of(Arrays.asList(speechConfig))) + .build(); CreateModelInteraction params = CreateModelInteraction.builder() diff --git a/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseAudioWithGenerateContent.java b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseAudioWithGenerateContent.java index 2dcf5af81d2..14c2e6a70b2 100644 --- a/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseAudioWithGenerateContent.java +++ b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseAudioWithGenerateContent.java @@ -50,6 +50,7 @@ import com.google.genai.gaos.models.interactions.Model; import com.google.genai.gaos.models.interactions.ResponseModality; import com.google.genai.gaos.models.interactions.SpeechConfig; +import com.google.genai.gaos.models.interactions.SpeechConfigUnion; import com.google.genai.gaos.models.interactions.Step; import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; import com.google.genai.gaos.models.operations.CreateInteractionResponse; @@ -75,7 +76,9 @@ public static void main(String[] args) { SpeechConfig speechConfig = SpeechConfig.builder().voice("achernar").language("en-US").build(); GenerationConfig generationConfig = - GenerationConfig.builder().speechConfig(Collections.singletonList(speechConfig)).build(); + GenerationConfig.builder() + .speechConfig(SpeechConfigUnion.of(Collections.singletonList(speechConfig))) + .build(); CreateModelInteraction params = CreateModelInteraction.builder() diff --git a/src/main/java/com/google/genai/errors/ApiException.java b/src/main/java/com/google/genai/errors/ApiException.java index 437ebae5424..fabc0cc2e5c 100644 --- a/src/main/java/com/google/genai/errors/ApiException.java +++ b/src/main/java/com/google/genai/errors/ApiException.java @@ -51,6 +51,17 @@ public ApiException(int code, String status, String message) { this.message = message; } + /** + * Creates a new ApiException carrying the originating cause (e.g. a reparented gaos error). Lets + * translated interaction errors keep their original stack/message. + */ + public ApiException(int code, String status, String message, Throwable cause) { + super(String.format("%d %s. %s", code, status, message), cause); + this.code = code; + this.status = status; + this.message = message; + } + /** * Throws an ApiException from the response if the response is not a OK status. diff --git a/src/main/java/com/google/genai/errors/ClientException.java b/src/main/java/com/google/genai/errors/ClientException.java index f41bd597aa0..5fc53a49db1 100644 --- a/src/main/java/com/google/genai/errors/ClientException.java +++ b/src/main/java/com/google/genai/errors/ClientException.java @@ -17,10 +17,15 @@ package com.google.genai.errors; /** Client exception raised by the GenAI API. */ -public final class ClientException extends ApiException { +public class ClientException extends ApiException { /** Creates a new ClientException with the specified message. */ public ClientException(int code, String status, String message) { super(code, status, message); } + + /** Creates a new ClientException carrying the originating cause. */ + public ClientException(int code, String status, String message, Throwable cause) { + super(code, status, message, cause); + } } diff --git a/src/main/java/com/google/genai/errors/ServerException.java b/src/main/java/com/google/genai/errors/ServerException.java index 180ce95d282..d17bb135216 100644 --- a/src/main/java/com/google/genai/errors/ServerException.java +++ b/src/main/java/com/google/genai/errors/ServerException.java @@ -17,10 +17,15 @@ package com.google.genai.errors; /** Server exception raised by the GenAI API. */ -public final class ServerException extends ApiException { +public class ServerException extends ApiException { /** Creates a new ServerException with the specified message. */ public ServerException(int code, String status, String message) { super(code, status, message); } + + /** Creates a new ServerException carrying the originating cause. */ + public ServerException(int code, String status, String message, Throwable cause) { + super(code, status, message, cause); + } } diff --git a/src/main/java/com/google/genai/gaos/hooks/SDKHooks.java b/src/main/java/com/google/genai/gaos/hooks/SDKHooks.java index 2e8be322ec3..0755b4ae428 100644 --- a/src/main/java/com/google/genai/gaos/hooks/SDKHooks.java +++ b/src/main/java/com/google/genai/gaos/hooks/SDKHooks.java @@ -35,55 +35,55 @@ private SDKHooks() { } public static void initialize(com.google.genai.gaos.utils.Hooks hooks) { - hooks.registerBeforeRequest( - (context, request) -> { - if (context.securitySource().isPresent()) { - HasSecurity hasSecurity = context.securitySource().get().getSecurity(); - if (hasSecurity instanceof Security) { - Security security = (Security) hasSecurity; - HttpRequest.Builder builder = request.toBuilder(); + hooks.registerBeforeRequest( + (context, request) -> { + if (context.securitySource().isPresent()) { + HasSecurity hasSecurity = context.securitySource().get().getSecurity(); + if (hasSecurity instanceof Security) { + Security security = (Security) hasSecurity; + HttpRequest.Builder builder = request.toBuilder(); - if (security.defaultHeaders().isPresent()) { - for (Map.Entry entry : security.defaultHeaders().get().entrySet()) { - builder.setHeader(entry.getKey(), entry.getValue()); + if (security.defaultHeaders().isPresent()) { + for (Map.Entry entry : security.defaultHeaders().get().entrySet()) { + builder.setHeader(entry.getKey(), entry.getValue()); + } + } + if (security.apiKey().isPresent()) { + builder.setHeader("x-goog-api-key", security.apiKey().get()); + } else if (security.accessToken().isPresent()) { + builder.setHeader("Authorization", "Bearer " + security.accessToken().get()); + } + return builder.build(); } } - if (security.apiKey().isPresent()) { - builder.setHeader("x-goog-api-key", security.apiKey().get()); - } else if (security.accessToken().isPresent()) { - builder.setHeader("Authorization", "Bearer " + security.accessToken().get()); - } - return builder.build(); - } - } - return request; - }); + return request; + }); } public static void initialize(com.google.genai.gaos.utils.AsyncHooks asyncHooks) { - asyncHooks.registerBeforeRequest( - (context, request) -> { - if (context.securitySource().isPresent()) { - HasSecurity hasSecurity = context.securitySource().get().getSecurity(); - if (hasSecurity instanceof Security) { - Security security = (Security) hasSecurity; - HttpRequest.Builder builder = request.toBuilder(); + asyncHooks.registerBeforeRequest( + (context, request) -> { + if (context.securitySource().isPresent()) { + HasSecurity hasSecurity = context.securitySource().get().getSecurity(); + if (hasSecurity instanceof Security) { + Security security = (Security) hasSecurity; + HttpRequest.Builder builder = request.toBuilder(); - if (security.defaultHeaders().isPresent()) { - for (Map.Entry entry : security.defaultHeaders().get().entrySet()) { - builder.setHeader(entry.getKey(), entry.getValue()); + if (security.defaultHeaders().isPresent()) { + for (Map.Entry entry : security.defaultHeaders().get().entrySet()) { + builder.setHeader(entry.getKey(), entry.getValue()); + } + } + if (security.apiKey().isPresent()) { + builder.setHeader("x-goog-api-key", security.apiKey().get()); + } else if (security.accessToken().isPresent()) { + builder.setHeader("Authorization", "Bearer " + security.accessToken().get()); + } + return CompletableFuture.completedFuture(builder.build()); } } - if (security.apiKey().isPresent()) { - builder.setHeader("x-goog-api-key", security.apiKey().get()); - } else if (security.accessToken().isPresent()) { - builder.setHeader("Authorization", "Bearer " + security.accessToken().get()); - } - return CompletableFuture.completedFuture(builder.build()); - } - } - return CompletableFuture.completedFuture(request); - }); + return CompletableFuture.completedFuture(request); + }); } } diff --git a/src/main/java/com/google/genai/gaos/models/errors/AuthException.java b/src/main/java/com/google/genai/gaos/models/errors/AuthException.java index 8a53836c7b6..6df38fa9e50 100644 --- a/src/main/java/com/google/genai/gaos/models/errors/AuthException.java +++ b/src/main/java/com/google/genai/gaos/models/errors/AuthException.java @@ -27,7 +27,7 @@ * An exception associated with Authentication or Authorization. */ @SuppressWarnings("serial") -public class AuthException extends GenAiException { +public class AuthException extends GaosClientException { public AuthException(String message, int code, byte[] body, HttpResponse rawResponse) { super(message, code, body, rawResponse, null); diff --git a/src/main/java/com/google/genai/gaos/models/errors/CancelInteractionByIdClientError.java b/src/main/java/com/google/genai/gaos/models/errors/CancelInteractionByIdClientError.java index 61cd897a6d4..8ce93db6fb8 100644 --- a/src/main/java/com/google/genai/gaos/models/errors/CancelInteractionByIdClientError.java +++ b/src/main/java/com/google/genai/gaos/models/errors/CancelInteractionByIdClientError.java @@ -35,7 +35,7 @@ import java.util.Optional; @SuppressWarnings("serial") -public class CancelInteractionByIdClientError extends GenAiException { +public class CancelInteractionByIdClientError extends GaosClientException { @Nullable private final Data data; diff --git a/src/main/java/com/google/genai/gaos/models/errors/CancelInteractionByIdServerError.java b/src/main/java/com/google/genai/gaos/models/errors/CancelInteractionByIdServerError.java index 9b648ab343c..5a65b926a61 100644 --- a/src/main/java/com/google/genai/gaos/models/errors/CancelInteractionByIdServerError.java +++ b/src/main/java/com/google/genai/gaos/models/errors/CancelInteractionByIdServerError.java @@ -35,7 +35,7 @@ import java.util.Optional; @SuppressWarnings("serial") -public class CancelInteractionByIdServerError extends GenAiException { +public class CancelInteractionByIdServerError extends GaosServerException { @Nullable private final Data data; diff --git a/src/main/java/com/google/genai/gaos/models/errors/CreateInteractionClientError.java b/src/main/java/com/google/genai/gaos/models/errors/CreateInteractionClientError.java index e2ef8d40337..5d3eebeedb0 100644 --- a/src/main/java/com/google/genai/gaos/models/errors/CreateInteractionClientError.java +++ b/src/main/java/com/google/genai/gaos/models/errors/CreateInteractionClientError.java @@ -35,7 +35,7 @@ import java.util.Optional; @SuppressWarnings("serial") -public class CreateInteractionClientError extends GenAiException { +public class CreateInteractionClientError extends GaosClientException { @Nullable private final Data data; diff --git a/src/main/java/com/google/genai/gaos/models/errors/CreateInteractionServerError.java b/src/main/java/com/google/genai/gaos/models/errors/CreateInteractionServerError.java index 69140c0f501..76d0833773a 100644 --- a/src/main/java/com/google/genai/gaos/models/errors/CreateInteractionServerError.java +++ b/src/main/java/com/google/genai/gaos/models/errors/CreateInteractionServerError.java @@ -35,7 +35,7 @@ import java.util.Optional; @SuppressWarnings("serial") -public class CreateInteractionServerError extends GenAiException { +public class CreateInteractionServerError extends GaosServerException { @Nullable private final Data data; diff --git a/src/main/java/com/google/genai/gaos/models/errors/DeleteInteractionClientError.java b/src/main/java/com/google/genai/gaos/models/errors/DeleteInteractionClientError.java index 1d0045ebe82..2f191b6a79e 100644 --- a/src/main/java/com/google/genai/gaos/models/errors/DeleteInteractionClientError.java +++ b/src/main/java/com/google/genai/gaos/models/errors/DeleteInteractionClientError.java @@ -35,7 +35,7 @@ import java.util.Optional; @SuppressWarnings("serial") -public class DeleteInteractionClientError extends GenAiException { +public class DeleteInteractionClientError extends GaosClientException { @Nullable private final Data data; diff --git a/src/main/java/com/google/genai/gaos/models/errors/DeleteInteractionServerError.java b/src/main/java/com/google/genai/gaos/models/errors/DeleteInteractionServerError.java index 322280134d9..db7d8d18d71 100644 --- a/src/main/java/com/google/genai/gaos/models/errors/DeleteInteractionServerError.java +++ b/src/main/java/com/google/genai/gaos/models/errors/DeleteInteractionServerError.java @@ -35,7 +35,7 @@ import java.util.Optional; @SuppressWarnings("serial") -public class DeleteInteractionServerError extends GenAiException { +public class DeleteInteractionServerError extends GaosServerException { @Nullable private final Data data; diff --git a/src/main/java/com/google/genai/gaos/models/errors/SDKException.java b/src/main/java/com/google/genai/gaos/models/errors/GaosApiException.java similarity index 83% rename from src/main/java/com/google/genai/gaos/models/errors/SDKException.java rename to src/main/java/com/google/genai/gaos/models/errors/GaosApiException.java index 0469707e433..dd00f7c9fb1 100644 --- a/src/main/java/com/google/genai/gaos/models/errors/SDKException.java +++ b/src/main/java/com/google/genai/gaos/models/errors/GaosApiException.java @@ -30,9 +30,9 @@ * Thrown by a service call when an error response occurs. Contains details about the response. */ @SuppressWarnings("serial") -public class SDKException extends GenAiException { +public class GaosApiException extends GaosBaseException { - public SDKException( + public GaosApiException( String message, int code, @Nullable byte[] body, @@ -41,18 +41,18 @@ public SDKException( super(message, code, body, rawResponse, cause); } - public static SDKException from(String message, HttpResponse rawResponse) { + public static GaosApiException from(String message, HttpResponse rawResponse) { return from(message, rawResponse, null); } - public static SDKException from(String message, HttpResponse rawResponse, @Nullable Throwable cause) { + public static GaosApiException from(String message, HttpResponse rawResponse, @Nullable Throwable cause) { try { - return new SDKException( + return new GaosApiException( message, rawResponse.statusCode(), Utils.extractByteArrayFromBody(rawResponse), rawResponse, cause); } catch (IOException e) { // Gracefully handle IOExceptions that occur while reading the body // by returning an error without a body. - return new SDKException( + return new GaosApiException( message, rawResponse.statusCode(), null, rawResponse, cause); } } diff --git a/src/main/java/com/google/genai/gaos/models/errors/GenAiException.java b/src/main/java/com/google/genai/gaos/models/errors/GaosBaseException.java similarity index 85% rename from src/main/java/com/google/genai/gaos/models/errors/GenAiException.java rename to src/main/java/com/google/genai/gaos/models/errors/GaosBaseException.java index d63785ad989..a9a27426e51 100644 --- a/src/main/java/com/google/genai/gaos/models/errors/GenAiException.java +++ b/src/main/java/com/google/genai/gaos/models/errors/GaosBaseException.java @@ -29,14 +29,14 @@ import java.util.Optional; @SuppressWarnings("serial") -public abstract class GenAiException extends RuntimeException { +public abstract class GaosBaseException extends com.google.genai.errors.ApiException { private int code; private byte[] body; private HttpResponse rawResponse; - public GenAiException(String message, int code, @Nullable byte[] body, HttpResponse rawResponse, @Nullable Throwable cause) { - super(message, cause); + public GaosBaseException(String message, int code, @Nullable byte[] body, HttpResponse rawResponse, @Nullable Throwable cause) { + super(code, "", message, cause); Utils.checkNotNull(message, "message"); Utils.checkNotNull(rawResponse, "rawResponse"); this.body = body; @@ -52,6 +52,7 @@ public Optional bodyAsString() { return body().map(x -> new String(x, StandardCharsets.UTF_8)); } + @Override public int code() { return code; } @@ -76,22 +77,23 @@ public Headers headers() { } // present for backwards compatibility + @Override public String message() { return getMessage(); } - public GenAiException withCode(int code) { + public GaosBaseException withCode(int code) { this.code = code; return this; } - public GenAiException withBody(@Nullable byte[] body) { + public GaosBaseException withBody(@Nullable byte[] body) { Utils.checkNotNull(body, "body"); this.body = body; return this; } - public GenAiException withRawResponse(HttpResponse rawResponse) { + public GaosBaseException withRawResponse(HttpResponse rawResponse) { Utils.checkNotNull(rawResponse, "rawResponse"); this.rawResponse = rawResponse; return this; diff --git a/src/main/java/com/google/genai/gaos/models/errors/GaosClientException.java b/src/main/java/com/google/genai/gaos/models/errors/GaosClientException.java new file mode 100644 index 00000000000..763a38d9269 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/errors/GaosClientException.java @@ -0,0 +1,59 @@ +/* + * Copyright 2026 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 + * + * http://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. + */ + +/* + * Injected by scripts/sync_speakeasy_outputs.py DO NOT EDIT. + */ +package com.google.genai.gaos.models.errors; + +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.transport.HttpResponse; +import jakarta.annotation.Nullable; +import java.nio.charset.StandardCharsets; +import java.util.Optional; + +/** + * Carrier base bridging gaos 4xx errors onto the native ClientException hierarchy while + * preserving the gaos body/rawResponse/headers surface. + */ +@SuppressWarnings("serial") +public abstract class GaosClientException extends com.google.genai.errors.ClientException { + + private byte[] body; + private HttpResponse rawResponse; + + public GaosClientException(String message, int code, @Nullable byte[] body, HttpResponse rawResponse, @Nullable Throwable cause) { + super(code, "", message, cause); + this.body = body; + this.rawResponse = rawResponse; + } + + public Optional body() { + return Optional.ofNullable(body); + } + + public Optional bodyAsString() { + return body().map(x -> new String(x, StandardCharsets.UTF_8)); + } + + public HttpResponse rawResponse() { + return rawResponse; + } + + public Headers headers() { + return new Headers(rawResponse.headers().map()); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/errors/GaosServerException.java b/src/main/java/com/google/genai/gaos/models/errors/GaosServerException.java new file mode 100644 index 00000000000..10a64e482da --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/errors/GaosServerException.java @@ -0,0 +1,59 @@ +/* + * Copyright 2026 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 + * + * http://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. + */ + +/* + * Injected by scripts/sync_speakeasy_outputs.py DO NOT EDIT. + */ +package com.google.genai.gaos.models.errors; + +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.transport.HttpResponse; +import jakarta.annotation.Nullable; +import java.nio.charset.StandardCharsets; +import java.util.Optional; + +/** + * Carrier base bridging gaos 5xx errors onto the native ServerException hierarchy while + * preserving the gaos body/rawResponse/headers surface. + */ +@SuppressWarnings("serial") +public abstract class GaosServerException extends com.google.genai.errors.ServerException { + + private byte[] body; + private HttpResponse rawResponse; + + public GaosServerException(String message, int code, @Nullable byte[] body, HttpResponse rawResponse, @Nullable Throwable cause) { + super(code, "", message, cause); + this.body = body; + this.rawResponse = rawResponse; + } + + public Optional body() { + return Optional.ofNullable(body); + } + + public Optional bodyAsString() { + return body().map(x -> new String(x, StandardCharsets.UTF_8)); + } + + public HttpResponse rawResponse() { + return rawResponse; + } + + public Headers headers() { + return new Headers(rawResponse.headers().map()); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/errors/GetInteractionByIdClientError.java b/src/main/java/com/google/genai/gaos/models/errors/GetInteractionByIdClientError.java index bacf864b9ae..041e7f9c2c6 100644 --- a/src/main/java/com/google/genai/gaos/models/errors/GetInteractionByIdClientError.java +++ b/src/main/java/com/google/genai/gaos/models/errors/GetInteractionByIdClientError.java @@ -35,7 +35,7 @@ import java.util.Optional; @SuppressWarnings("serial") -public class GetInteractionByIdClientError extends GenAiException { +public class GetInteractionByIdClientError extends GaosClientException { @Nullable private final Data data; diff --git a/src/main/java/com/google/genai/gaos/models/errors/GetInteractionByIdServerError.java b/src/main/java/com/google/genai/gaos/models/errors/GetInteractionByIdServerError.java index d12f905b974..d13bdc6feb3 100644 --- a/src/main/java/com/google/genai/gaos/models/errors/GetInteractionByIdServerError.java +++ b/src/main/java/com/google/genai/gaos/models/errors/GetInteractionByIdServerError.java @@ -35,7 +35,7 @@ import java.util.Optional; @SuppressWarnings("serial") -public class GetInteractionByIdServerError extends GenAiException { +public class GetInteractionByIdServerError extends GaosServerException { @Nullable private final Data data; diff --git a/src/main/java/com/google/genai/gaos/models/interactions/GenerationConfig.java b/src/main/java/com/google/genai/gaos/models/interactions/GenerationConfig.java index 131f4773e40..e7fcfbf6a4e 100644 --- a/src/main/java/com/google/genai/gaos/models/interactions/GenerationConfig.java +++ b/src/main/java/com/google/genai/gaos/models/interactions/GenerationConfig.java @@ -62,13 +62,6 @@ public class GenerationConfig { @JsonProperty("seed") private Integer seed; - /** - * Configuration for speech interaction. - */ - @JsonInclude(Include.NON_ABSENT) - @JsonProperty("speech_config") - private List speechConfig; - /** * A list of character sequences that will stop output interaction. */ @@ -107,28 +100,35 @@ public class GenerationConfig { @JsonProperty("video_config") private VideoConfig videoConfig; + /** + * Optional. Speech and multi-speaker configuration. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("speech_config") + private SpeechConfigUnion speechConfig; + @JsonCreator public GenerationConfig( @JsonProperty("image_config") @Nullable ImageConfig imageConfig, @JsonProperty("max_output_tokens") @Nullable Integer maxOutputTokens, @JsonProperty("seed") @Nullable Integer seed, - @JsonProperty("speech_config") @Nullable List speechConfig, @JsonProperty("stop_sequences") @Nullable List stopSequences, @JsonProperty("thinking_level") @Nullable ThinkingLevel thinkingLevel, @JsonProperty("thinking_summaries") @Nullable ThinkingSummaries thinkingSummaries, @JsonProperty("tool_choice") @Nullable ToolChoice toolChoice, @JsonProperty("transcription_config") @Nullable TranscriptionConfig transcriptionConfig, - @JsonProperty("video_config") @Nullable VideoConfig videoConfig) { + @JsonProperty("video_config") @Nullable VideoConfig videoConfig, + @JsonProperty("speech_config") @Nullable SpeechConfigUnion speechConfig) { this.imageConfig = imageConfig; this.maxOutputTokens = maxOutputTokens; this.seed = seed; - this.speechConfig = speechConfig; this.stopSequences = stopSequences; this.thinkingLevel = thinkingLevel; this.thinkingSummaries = thinkingSummaries; this.toolChoice = toolChoice; this.transcriptionConfig = transcriptionConfig; this.videoConfig = videoConfig; + this.speechConfig = speechConfig; } public GenerationConfig() { @@ -162,13 +162,6 @@ public Optional seed() { return Optional.ofNullable(this.seed); } - /** - * Configuration for speech interaction. - */ - public Optional> speechConfig() { - return Optional.ofNullable(this.speechConfig); - } - /** * A list of character sequences that will stop output interaction. */ @@ -205,6 +198,13 @@ public Optional videoConfig() { return Optional.ofNullable(this.videoConfig); } + /** + * Optional. Speech and multi-speaker configuration. + */ + public Optional speechConfig() { + return Optional.ofNullable(this.speechConfig); + } + public static Builder builder() { return new Builder(); } @@ -240,15 +240,6 @@ public GenerationConfig withSeed(@Nullable Integer seed) { } - /** - * Configuration for speech interaction. - */ - public GenerationConfig withSpeechConfig(@Nullable List speechConfig) { - this.speechConfig = speechConfig; - return this; - } - - /** * A list of character sequences that will stop output interaction. */ @@ -297,6 +288,15 @@ public GenerationConfig withVideoConfig(@Nullable VideoConfig videoConfig) { } + /** + * Optional. Speech and multi-speaker configuration. + */ + public GenerationConfig withSpeechConfig(@Nullable SpeechConfigUnion speechConfig) { + this.speechConfig = speechConfig; + return this; + } + + @Override public boolean equals(java.lang.Object o) { if (this == o) { @@ -310,22 +310,22 @@ public boolean equals(java.lang.Object o) { Utils.enhancedDeepEquals(this.imageConfig, other.imageConfig) && Utils.enhancedDeepEquals(this.maxOutputTokens, other.maxOutputTokens) && Utils.enhancedDeepEquals(this.seed, other.seed) && - Utils.enhancedDeepEquals(this.speechConfig, other.speechConfig) && Utils.enhancedDeepEquals(this.stopSequences, other.stopSequences) && Utils.enhancedDeepEquals(this.thinkingLevel, other.thinkingLevel) && Utils.enhancedDeepEquals(this.thinkingSummaries, other.thinkingSummaries) && Utils.enhancedDeepEquals(this.toolChoice, other.toolChoice) && Utils.enhancedDeepEquals(this.transcriptionConfig, other.transcriptionConfig) && - Utils.enhancedDeepEquals(this.videoConfig, other.videoConfig); + Utils.enhancedDeepEquals(this.videoConfig, other.videoConfig) && + Utils.enhancedDeepEquals(this.speechConfig, other.speechConfig); } @Override public int hashCode() { return Utils.enhancedHash( imageConfig, maxOutputTokens, seed, - speechConfig, stopSequences, thinkingLevel, - thinkingSummaries, toolChoice, transcriptionConfig, - videoConfig); + stopSequences, thinkingLevel, thinkingSummaries, + toolChoice, transcriptionConfig, videoConfig, + speechConfig); } @Override @@ -334,13 +334,13 @@ public String toString() { "imageConfig", imageConfig, "maxOutputTokens", maxOutputTokens, "seed", seed, - "speechConfig", speechConfig, "stopSequences", stopSequences, "thinkingLevel", thinkingLevel, "thinkingSummaries", thinkingSummaries, "toolChoice", toolChoice, "transcriptionConfig", transcriptionConfig, - "videoConfig", videoConfig); + "videoConfig", videoConfig, + "speechConfig", speechConfig); } @SuppressWarnings("UnusedReturnValue") @@ -353,8 +353,6 @@ public final static class Builder { private Integer seed; - private List speechConfig; - private List stopSequences; private ThinkingLevel thinkingLevel; @@ -367,6 +365,8 @@ public final static class Builder { private VideoConfig videoConfig; + private SpeechConfigUnion speechConfig; + private Builder() { // force use of static builder() method } @@ -398,14 +398,6 @@ public Builder seed(@Nullable Integer seed) { return this; } - /** - * Configuration for speech interaction. - */ - public Builder speechConfig(@Nullable List speechConfig) { - this.speechConfig = speechConfig; - return this; - } - /** * A list of character sequences that will stop output interaction. */ @@ -448,12 +440,20 @@ public Builder videoConfig(@Nullable VideoConfig videoConfig) { return this; } + /** + * Optional. Speech and multi-speaker configuration. + */ + public Builder speechConfig(@Nullable SpeechConfigUnion speechConfig) { + this.speechConfig = speechConfig; + return this; + } + public GenerationConfig build() { return new GenerationConfig( imageConfig, maxOutputTokens, seed, - speechConfig, stopSequences, thinkingLevel, - thinkingSummaries, toolChoice, transcriptionConfig, - videoConfig); + stopSequences, thinkingLevel, thinkingSummaries, + toolChoice, transcriptionConfig, videoConfig, + speechConfig); } } diff --git a/src/main/java/com/google/genai/gaos/models/interactions/InteractionsInput.java b/src/main/java/com/google/genai/gaos/models/interactions/InteractionsInput.java index fb93aa2f18b..9baeca4aa82 100644 --- a/src/main/java/com/google/genai/gaos/models/interactions/InteractionsInput.java +++ b/src/main/java/com/google/genai/gaos/models/interactions/InteractionsInput.java @@ -64,11 +64,6 @@ public static InteractionsInput ofContent(List value) { return new InteractionsInput(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference>(){})); } - public static InteractionsInput ofTurn(List value) { - Utils.checkNotNull(value, "value"); - return new InteractionsInput(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference>(){})); - } - public static InteractionsInput of(Content value) { Utils.checkNotNull(value, "value"); return new InteractionsInput(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference(){})); @@ -115,20 +110,6 @@ public Optional> arrayOfContent() { return Optional.empty(); } - /** - * Returns an {@link Optional} containing the value if it is of type {@code List}, - * otherwise returns an empty {@link Optional}. - * - * @return an {@link Optional} containing the {@code List} value, or empty if not of this type - */ - @SuppressWarnings("unchecked") - public Optional> arrayOfTurn() { - if (value.value() instanceof List) { - return Optional.of((List) value.value()); - } - return Optional.empty(); - } - /** * Returns an {@link Optional} containing the value if it is of type {@code Content}, * otherwise returns an empty {@link Optional}. @@ -179,7 +160,6 @@ public _Deserializer() { TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), TypeReferenceWithShape.of(new TypeReference>() {}, JsonShape.DEFAULT), TypeReferenceWithShape.of(new TypeReference>() {}, JsonShape.DEFAULT), - TypeReferenceWithShape.of(new TypeReference>() {}, JsonShape.DEFAULT), TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); } } diff --git a/src/main/java/com/google/genai/gaos/models/interactions/MediaProcessing.java b/src/main/java/com/google/genai/gaos/models/interactions/MediaProcessing.java new file mode 100644 index 00000000000..6b5715c4f8f --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/MediaProcessing.java @@ -0,0 +1,109 @@ +/* + * Copyright 2026 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 + * + * http://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. + */ + +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.google.genai.gaos.models.interactions; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.genai.gaos.utils.OneOfDeserializer; +import com.google.genai.gaos.utils.TypedObject; +import com.google.genai.gaos.utils.Utils.JsonShape; +import com.google.genai.gaos.utils.Utils.TypeReferenceWithShape; +import com.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +@JsonDeserialize(using = MediaProcessing._Deserializer.class) +public class MediaProcessing { + + @JsonValue + private final TypedObject value; + + private MediaProcessing(TypedObject value) { + this.value = value; + } + + public static MediaProcessing of(StaticMediaProcessing value) { + Utils.checkNotNull(value, "value"); + return new MediaProcessing(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference(){})); + } + + /** + * Returns an {@link Optional} containing the value if it is of type {@code StaticMediaProcessing}, + * otherwise returns an empty {@link Optional}. + * + * @return an {@link Optional} containing the {@code StaticMediaProcessing} value, or empty if not of this type + */ + public Optional staticMediaProcessing() { + if (value.value() instanceof StaticMediaProcessing) { + return Optional.of((StaticMediaProcessing) value.value()); + } + return Optional.empty(); + } + /** + * Returns an {@link Optional} containing the value as a {@code JsonNode}. + * This accessor returns the raw JSON when the value doesn't match any of the defined union types. + * + * @return an {@link Optional} containing the {@code JsonNode} value, or empty if value matched a known type + */ + public Optional asJson() { + if (value.value() instanceof JsonNode) { + return Optional.of((JsonNode) value.value()); + } + return Optional.empty(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MediaProcessing other = (MediaProcessing) o; + return Utils.enhancedDeepEquals(this.value.value(), other.value.value()); + } + + @Override + public int hashCode() { + return Utils.enhancedHash(value.value()); + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends OneOfDeserializer { + + public _Deserializer() { + super(MediaProcessing.class, false, + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(MediaProcessing.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Model.java b/src/main/java/com/google/genai/gaos/models/interactions/Model.java index 082a624d073..1517aa3ec2f 100644 --- a/src/main/java/com/google/genai/gaos/models/interactions/Model.java +++ b/src/main/java/com/google/genai/gaos/models/interactions/Model.java @@ -60,6 +60,7 @@ public class Model { public static final Model GEMINI31_FLASH_IMAGE = new Model("gemini-3.1-flash-image"); public static final Model GEMINI35_FLASH = new Model("gemini-3.5-flash"); public static final Model GEMINI36_FLASH = new Model("gemini-3.6-flash"); + public static final Model GEMINI37_FLASH = new Model("gemini-3.7-flash"); public static final Model LYRIA3_CLIP_PREVIEW = new Model("lyria-3-clip-preview"); public static final Model LYRIA3_PRO_PREVIEW = new Model("lyria-3-pro-preview"); public static final Model GEMINI_ROBOTICS_ER16_PREVIEW = new Model("gemini-robotics-er-1.6-preview"); @@ -155,6 +156,7 @@ private static final Map createValuesMap() { map.put("gemini-3.1-flash-image", GEMINI31_FLASH_IMAGE); map.put("gemini-3.5-flash", GEMINI35_FLASH); map.put("gemini-3.6-flash", GEMINI36_FLASH); + map.put("gemini-3.7-flash", GEMINI37_FLASH); map.put("lyria-3-clip-preview", LYRIA3_CLIP_PREVIEW); map.put("lyria-3-pro-preview", LYRIA3_PRO_PREVIEW); map.put("gemini-robotics-er-1.6-preview", GEMINI_ROBOTICS_ER16_PREVIEW); @@ -182,6 +184,7 @@ private static final Map createEnumsMap() { map.put("gemini-3.1-flash-image", ModelEnum.GEMINI31_FLASH_IMAGE); map.put("gemini-3.5-flash", ModelEnum.GEMINI35_FLASH); map.put("gemini-3.6-flash", ModelEnum.GEMINI36_FLASH); + map.put("gemini-3.7-flash", ModelEnum.GEMINI37_FLASH); map.put("lyria-3-clip-preview", ModelEnum.LYRIA3_CLIP_PREVIEW); map.put("lyria-3-pro-preview", ModelEnum.LYRIA3_PRO_PREVIEW); map.put("gemini-robotics-er-1.6-preview", ModelEnum.GEMINI_ROBOTICS_ER16_PREVIEW); @@ -210,6 +213,7 @@ public enum ModelEnum { GEMINI31_FLASH_IMAGE("gemini-3.1-flash-image"), GEMINI35_FLASH("gemini-3.5-flash"), GEMINI36_FLASH("gemini-3.6-flash"), + GEMINI37_FLASH("gemini-3.7-flash"), LYRIA3_CLIP_PREVIEW("lyria-3-clip-preview"), LYRIA3_PRO_PREVIEW("lyria-3-pro-preview"), GEMINI_ROBOTICS_ER16_PREVIEW("gemini-robotics-er-1.6-preview"), diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Processing.java b/src/main/java/com/google/genai/gaos/models/interactions/Processing.java new file mode 100644 index 00000000000..58c0799fddf --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Processing.java @@ -0,0 +1,133 @@ +/* + * Copyright 2026 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 + * + * http://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. + */ + +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.google.genai.gaos.models.interactions; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.genai.gaos.utils.OneOfDeserializer; +import com.google.genai.gaos.utils.TypedObject; +import com.google.genai.gaos.utils.Utils.JsonShape; +import com.google.genai.gaos.utils.Utils.TypeReferenceWithShape; +import com.google.genai.gaos.utils.Utils; +import java.lang.Override; +import java.lang.String; +import java.lang.SuppressWarnings; +import java.util.Optional; + +/** + * Processing + * + *

How the model processes this video for understanding. + */ +@JsonDeserialize(using = Processing._Deserializer.class) +public class Processing { + + @JsonValue + private final TypedObject value; + + private Processing(TypedObject value) { + this.value = value; + } + + public static Processing of(MediaProcessing value) { + Utils.checkNotNull(value, "value"); + return new Processing(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference(){})); + } + + public static Processing of(ProcessingEnum value) { + Utils.checkNotNull(value, "value"); + return new Processing(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference(){})); + } + + /** + * Returns an {@link Optional} containing the value if it is of type {@code MediaProcessing}, + * otherwise returns an empty {@link Optional}. + * + * @return an {@link Optional} containing the {@code MediaProcessing} value, or empty if not of this type + */ + public Optional mediaProcessing() { + if (value.value() instanceof MediaProcessing) { + return Optional.of((MediaProcessing) value.value()); + } + return Optional.empty(); + } + + /** + * Returns an {@link Optional} containing the value if it is of type {@code ProcessingEnum}, + * otherwise returns an empty {@link Optional}. + * + * @return an {@link Optional} containing the {@code ProcessingEnum} value, or empty if not of this type + */ + public Optional processingEnum() { + if (value.value() instanceof ProcessingEnum) { + return Optional.of((ProcessingEnum) value.value()); + } + return Optional.empty(); + } + /** + * Returns an {@link Optional} containing the value as a {@code JsonNode}. + * This accessor returns the raw JSON when the value doesn't match any of the defined union types. + * + * @return an {@link Optional} containing the {@code JsonNode} value, or empty if value matched a known type + */ + public Optional asJson() { + if (value.value() instanceof JsonNode) { + return Optional.of((JsonNode) value.value()); + } + return Optional.empty(); + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Processing other = (Processing) o; + return Utils.enhancedDeepEquals(this.value.value(), other.value.value()); + } + + @Override + public int hashCode() { + return Utils.enhancedHash(value.value()); + } + + @SuppressWarnings("serial") + public static final class _Deserializer extends OneOfDeserializer { + + public _Deserializer() { + super(Processing.class, false, + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + } + } + + @Override + public String toString() { + return Utils.toString(Processing.class, + "value", value); + } + +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/ProcessingEnum.java b/src/main/java/com/google/genai/gaos/models/interactions/ProcessingEnum.java new file mode 100644 index 00000000000..385784ae2d5 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/ProcessingEnum.java @@ -0,0 +1,143 @@ +/* + * Copyright 2026 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 + * + * http://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. + */ + +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.google.genai.gaos.models.interactions; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.lang.Override; +import java.lang.String; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Wrapper for an "open" enum that can handle unknown values from API responses + * without runtime errors. Instances are immutable singletons with reference equality. + * Use {@code asEnum()} for switch expressions. + */ +public class ProcessingEnum { + + public static final ProcessingEnum STATIC = new ProcessingEnum("static"); + public static final ProcessingEnum AGENTIC = new ProcessingEnum("agentic"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); + + private final String value; + + private ProcessingEnum(String value) { + this.value = value; + } + + /** + * Returns a ProcessingEnum with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as ProcessingEnum + */ + @JsonCreator + public static ProcessingEnum of(String value) { + synchronized (ProcessingEnum.class) { + return values.computeIfAbsent(value, v -> new ProcessingEnum(v)); + } + } + + @JsonValue + public String value() { + return value; + } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ProcessingEnum other = (ProcessingEnum) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "ProcessingEnum [value=" + value + "]"; + } + + // return an array just like an enum + public static ProcessingEnum[] values() { + synchronized (ProcessingEnum.class) { + return values.values().toArray(new ProcessingEnum[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("static", STATIC); + map.put("agentic", AGENTIC); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("static", ProcessingEnumEnum.STATIC); + map.put("agentic", ProcessingEnumEnum.AGENTIC); + return map; + } + + + public enum ProcessingEnumEnum { + + STATIC("static"), + AGENTIC("agentic"),; + + private final String value; + + private ProcessingEnumEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Resolution.java b/src/main/java/com/google/genai/gaos/models/interactions/Resolution.java new file mode 100644 index 00000000000..8ac6e9dd830 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/Resolution.java @@ -0,0 +1,156 @@ +/* + * Copyright 2026 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 + * + * http://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. + */ + +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.google.genai.gaos.models.interactions; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.lang.Override; +import java.lang.String; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Wrapper for an "open" enum that can handle unknown values from API responses + * without runtime errors. Instances are immutable singletons with reference equality. + * Use {@code asEnum()} for switch expressions. + */ +/** + * Resolution + * + *

The video output resolution. Defaults to 720p. + */ +public class Resolution { + + public static final Resolution THREE_HUNDRED_AND_SIXTYP = new Resolution("360p"); + public static final Resolution SEVEN_HUNDRED_AND_TWENTYP = new Resolution("720p"); + public static final Resolution ONE_THOUSAND_AND_EIGHTYP = new Resolution("1080p"); + public static final Resolution FOURK = new Resolution("4k"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); + + private final String value; + + private Resolution(String value) { + this.value = value; + } + + /** + * Returns a Resolution with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as Resolution + */ + @JsonCreator + public static Resolution of(String value) { + synchronized (Resolution.class) { + return values.computeIfAbsent(value, v -> new Resolution(v)); + } + } + + @JsonValue + public String value() { + return value; + } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Resolution other = (Resolution) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "Resolution [value=" + value + "]"; + } + + // return an array just like an enum + public static Resolution[] values() { + synchronized (Resolution.class) { + return values.values().toArray(new Resolution[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("360p", THREE_HUNDRED_AND_SIXTYP); + map.put("720p", SEVEN_HUNDRED_AND_TWENTYP); + map.put("1080p", ONE_THOUSAND_AND_EIGHTYP); + map.put("4k", FOURK); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("360p", ResolutionEnum.THREE_HUNDRED_AND_SIXTYP); + map.put("720p", ResolutionEnum.SEVEN_HUNDRED_AND_TWENTYP); + map.put("1080p", ResolutionEnum.ONE_THOUSAND_AND_EIGHTYP); + map.put("4k", ResolutionEnum.FOURK); + return map; + } + + + public enum ResolutionEnum { + + THREE_HUNDRED_AND_SIXTYP("360p"), + SEVEN_HUNDRED_AND_TWENTYP("720p"), + ONE_THOUSAND_AND_EIGHTYP("1080p"), + FOURK("4k"),; + + private final String value; + + private ResolutionEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Source.java b/src/main/java/com/google/genai/gaos/models/interactions/Source.java index 57f44d8deca..40ba173bfa9 100644 --- a/src/main/java/com/google/genai/gaos/models/interactions/Source.java +++ b/src/main/java/com/google/genai/gaos/models/interactions/Source.java @@ -51,7 +51,7 @@ public class Source { /** * The source of the environment. - * For GCS, this is the GCS path. + * For Cloud Storage, this is the Cloud Storage path. * For GitHub, this is the GitHub path. */ @JsonInclude(Include.NON_ABSENT) @@ -105,7 +105,7 @@ public Optional encoding() { /** * The source of the environment. - * For GCS, this is the GCS path. + * For Cloud Storage, this is the Cloud Storage path. * For GitHub, this is the GitHub path. */ public Optional source() { @@ -148,7 +148,7 @@ public Source withEncoding(@Nullable String encoding) { /** * The source of the environment. - * For GCS, this is the GCS path. + * For Cloud Storage, this is the Cloud Storage path. * For GitHub, this is the GitHub path. */ public Source withSource(@Nullable String source) { @@ -241,7 +241,7 @@ public Builder encoding(@Nullable String encoding) { /** * The source of the environment. - * For GCS, this is the GCS path. + * For Cloud Storage, this is the Cloud Storage path. * For GitHub, this is the GitHub path. */ public Builder source(@Nullable String source) { diff --git a/src/main/java/com/google/genai/gaos/models/interactions/SpeakerConfig.java b/src/main/java/com/google/genai/gaos/models/interactions/SpeakerConfig.java new file mode 100644 index 00000000000..46a0a6ef24c --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/SpeakerConfig.java @@ -0,0 +1,125 @@ +/* + * Copyright 2026 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 + * + * http://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. + */ + +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.google.genai.gaos.models.interactions; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.genai.gaos.utils.Utils; +import jakarta.annotation.Nullable; +import java.lang.Override; +import java.lang.String; +import java.util.List; +import java.util.Optional; + +/** + * SpeakerConfig + * + *

Configuration for multi-speaker and speech generation. + */ +public class SpeakerConfig { + /** + * Individual speaker configurations. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("speakers") + private List speakers; + + @JsonCreator + public SpeakerConfig( + @JsonProperty("speakers") @Nullable List speakers) { + this.speakers = speakers; + } + + public SpeakerConfig() { + this(null); + } + + /** + * Individual speaker configurations. + */ + public Optional> speakers() { + return Optional.ofNullable(this.speakers); + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Individual speaker configurations. + */ + public SpeakerConfig withSpeakers(@Nullable List speakers) { + this.speakers = speakers; + return this; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SpeakerConfig other = (SpeakerConfig) o; + return + Utils.enhancedDeepEquals(this.speakers, other.speakers); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + speakers); + } + + @Override + public String toString() { + return Utils.toString(SpeakerConfig.class, + "speakers", speakers); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private List speakers; + + private Builder() { + // force use of static builder() method + } + + /** + * Individual speaker configurations. + */ + public Builder speakers(@Nullable List speakers) { + this.speakers = speakers; + return this; + } + + public SpeakerConfig build() { + return new SpeakerConfig( + speakers); + } + + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/TurnContent.java b/src/main/java/com/google/genai/gaos/models/interactions/SpeechConfigUnion.java similarity index 67% rename from src/main/java/com/google/genai/gaos/models/interactions/TurnContent.java rename to src/main/java/com/google/genai/gaos/models/interactions/SpeechConfigUnion.java index 8b78863b589..ffca366e4c0 100644 --- a/src/main/java/com/google/genai/gaos/models/interactions/TurnContent.java +++ b/src/main/java/com/google/genai/gaos/models/interactions/SpeechConfigUnion.java @@ -34,49 +34,54 @@ import java.util.List; import java.util.Optional; -@JsonDeserialize(using = TurnContent._Deserializer.class) -public class TurnContent { +/** + * SpeechConfigUnion + * + *

Optional. Speech and multi-speaker configuration. + */ +@JsonDeserialize(using = SpeechConfigUnion._Deserializer.class) +public class SpeechConfigUnion { @JsonValue private final TypedObject value; - private TurnContent(TypedObject value) { + private SpeechConfigUnion(TypedObject value) { this.value = value; } - public static TurnContent of(List value) { + public static SpeechConfigUnion of(SpeakerConfig value) { Utils.checkNotNull(value, "value"); - return new TurnContent(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference>(){})); + return new SpeechConfigUnion(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference(){})); } - public static TurnContent of(String value) { + public static SpeechConfigUnion of(List value) { Utils.checkNotNull(value, "value"); - return new TurnContent(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference(){})); + return new SpeechConfigUnion(TypedObject.of(value, JsonShape.DEFAULT, new TypeReference>(){})); } /** - * Returns an {@link Optional} containing the value if it is of type {@code List}, + * Returns an {@link Optional} containing the value if it is of type {@code SpeakerConfig}, * otherwise returns an empty {@link Optional}. * - * @return an {@link Optional} containing the {@code List} value, or empty if not of this type + * @return an {@link Optional} containing the {@code SpeakerConfig} value, or empty if not of this type */ - @SuppressWarnings("unchecked") - public Optional> arrayOfContent() { - if (value.value() instanceof List) { - return Optional.of((List) value.value()); + public Optional speakerConfig() { + if (value.value() instanceof SpeakerConfig) { + return Optional.of((SpeakerConfig) value.value()); } return Optional.empty(); } /** - * Returns an {@link Optional} containing the value if it is of type {@code String}, + * Returns an {@link Optional} containing the value if it is of type {@code List}, * otherwise returns an empty {@link Optional}. * - * @return an {@link Optional} containing the {@code String} value, or empty if not of this type + * @return an {@link Optional} containing the {@code List} value, or empty if not of this type */ - public Optional string() { - if (value.value() instanceof String) { - return Optional.of((String) value.value()); + @SuppressWarnings("unchecked") + public Optional> arrayOfSpeechConfig() { + if (value.value() instanceof List) { + return Optional.of((List) value.value()); } return Optional.empty(); } @@ -101,7 +106,7 @@ public boolean equals(java.lang.Object o) { if (o == null || getClass() != o.getClass()) { return false; } - TurnContent other = (TurnContent) o; + SpeechConfigUnion other = (SpeechConfigUnion) o; return Utils.enhancedDeepEquals(this.value.value(), other.value.value()); } @@ -111,18 +116,18 @@ public int hashCode() { } @SuppressWarnings("serial") - public static final class _Deserializer extends OneOfDeserializer { + public static final class _Deserializer extends OneOfDeserializer { public _Deserializer() { - super(TurnContent.class, false, - TypeReferenceWithShape.of(new TypeReference>() {}, JsonShape.DEFAULT), - TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT)); + super(SpeechConfigUnion.class, false, + TypeReferenceWithShape.of(new TypeReference() {}, JsonShape.DEFAULT), + TypeReferenceWithShape.of(new TypeReference>() {}, JsonShape.DEFAULT)); } } @Override public String toString() { - return Utils.toString(TurnContent.class, + return Utils.toString(SpeechConfigUnion.class, "value", value); } diff --git a/src/main/java/com/google/genai/gaos/models/interactions/StaticMediaProcessing.java b/src/main/java/com/google/genai/gaos/models/interactions/StaticMediaProcessing.java new file mode 100644 index 00000000000..acda343b8bf --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/StaticMediaProcessing.java @@ -0,0 +1,227 @@ +/* + * Copyright 2026 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 + * + * http://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. + */ + +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.google.genai.gaos.models.interactions; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.type.TypeReference; +import com.google.genai.gaos.utils.LazySingletonValue; +import com.google.genai.gaos.utils.Utils; +import jakarta.annotation.Nullable; +import java.lang.Double; +import java.lang.Override; +import java.lang.String; +import java.util.Optional; + + +public class StaticMediaProcessing { + /** + * Optional. Segment end time. Specified as a decimal number of seconds followed + * by an 's' suffix, e.g., "30s". Must be non-negative and greater than + * `start_offset` if `start_offset` is set. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("end_offset") + private String endOffset; + + /** + * Optional. Video frame-rate sampling density. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("fps") + private Double fps; + + /** + * Optional. Segment start time. Specified as a decimal number of seconds followed + * by an 's' suffix, e.g., "10.5s". Must be non-negative. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("start_offset") + private String startOffset; + + + @JsonProperty("type") + private String type; + + @JsonCreator + public StaticMediaProcessing( + @JsonProperty("end_offset") @Nullable String endOffset, + @JsonProperty("fps") @Nullable Double fps, + @JsonProperty("start_offset") @Nullable String startOffset) { + this.endOffset = endOffset; + this.fps = fps; + this.startOffset = startOffset; + this.type = Builder._SINGLETON_VALUE_Type.value(); + } + + public StaticMediaProcessing() { + this(null, null, null); + } + + /** + * Optional. Segment end time. Specified as a decimal number of seconds followed + * by an 's' suffix, e.g., "30s". Must be non-negative and greater than + * `start_offset` if `start_offset` is set. + */ + public Optional endOffset() { + return Optional.ofNullable(this.endOffset); + } + + /** + * Optional. Video frame-rate sampling density. + */ + public Optional fps() { + return Optional.ofNullable(this.fps); + } + + /** + * Optional. Segment start time. Specified as a decimal number of seconds followed + * by an 's' suffix, e.g., "10.5s". Must be non-negative. + */ + public Optional startOffset() { + return Optional.ofNullable(this.startOffset); + } + + public Optional type() { + return Optional.ofNullable(this.type); + } + + public static Builder builder() { + return new Builder(); + } + + + /** + * Optional. Segment end time. Specified as a decimal number of seconds followed + * by an 's' suffix, e.g., "30s". Must be non-negative and greater than + * `start_offset` if `start_offset` is set. + */ + public StaticMediaProcessing withEndOffset(@Nullable String endOffset) { + this.endOffset = endOffset; + return this; + } + + + /** + * Optional. Video frame-rate sampling density. + */ + public StaticMediaProcessing withFps(@Nullable Double fps) { + this.fps = fps; + return this; + } + + + /** + * Optional. Segment start time. Specified as a decimal number of seconds followed + * by an 's' suffix, e.g., "10.5s". Must be non-negative. + */ + public StaticMediaProcessing withStartOffset(@Nullable String startOffset) { + this.startOffset = startOffset; + return this; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + StaticMediaProcessing other = (StaticMediaProcessing) o; + return + Utils.enhancedDeepEquals(this.endOffset, other.endOffset) && + Utils.enhancedDeepEquals(this.fps, other.fps) && + Utils.enhancedDeepEquals(this.startOffset, other.startOffset) && + Utils.enhancedDeepEquals(this.type, other.type); + } + + @Override + public int hashCode() { + return Utils.enhancedHash( + endOffset, fps, startOffset, + type); + } + + @Override + public String toString() { + return Utils.toString(StaticMediaProcessing.class, + "endOffset", endOffset, + "fps", fps, + "startOffset", startOffset, + "type", type); + } + + @SuppressWarnings("UnusedReturnValue") + public final static class Builder { + + private String endOffset; + + private Double fps; + + private String startOffset; + + private Builder() { + // force use of static builder() method + } + + /** + * Optional. Segment end time. Specified as a decimal number of seconds followed + * by an 's' suffix, e.g., "30s". Must be non-negative and greater than + * `start_offset` if `start_offset` is set. + */ + public Builder endOffset(@Nullable String endOffset) { + this.endOffset = endOffset; + return this; + } + + /** + * Optional. Video frame-rate sampling density. + */ + public Builder fps(@Nullable Double fps) { + this.fps = fps; + return this; + } + + /** + * Optional. Segment start time. Specified as a decimal number of seconds followed + * by an 's' suffix, e.g., "10.5s". Must be non-negative. + */ + public Builder startOffset(@Nullable String startOffset) { + this.startOffset = startOffset; + return this; + } + + public StaticMediaProcessing build() { + return new StaticMediaProcessing( + endOffset, fps, startOffset); + } + + + private static final LazySingletonValue _SINGLETON_VALUE_Type = + new LazySingletonValue<>( + "type", + "\"static\"", + new TypeReference() {}); + } +} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Task.java b/src/main/java/com/google/genai/gaos/models/interactions/Task.java index 881fbad7300..0822afc44c3 100644 --- a/src/main/java/com/google/genai/gaos/models/interactions/Task.java +++ b/src/main/java/com/google/genai/gaos/models/interactions/Task.java @@ -47,6 +47,7 @@ public class Task { public static final Task IMAGE_TO_VIDEO = new Task("image_to_video"); public static final Task REFERENCE_TO_VIDEO = new Task("reference_to_video"); public static final Task EDIT = new Task("edit"); + public static final Task EXTEND = new Task("extend"); // This map will grow whenever a Color gets created with a new // unrecognized value (a potential memory leak if the user is not @@ -124,6 +125,7 @@ private static final Map createValuesMap() { map.put("image_to_video", IMAGE_TO_VIDEO); map.put("reference_to_video", REFERENCE_TO_VIDEO); map.put("edit", EDIT); + map.put("extend", EXTEND); return map; } @@ -133,6 +135,7 @@ private static final Map createEnumsMap() { map.put("image_to_video", TaskEnum.IMAGE_TO_VIDEO); map.put("reference_to_video", TaskEnum.REFERENCE_TO_VIDEO); map.put("edit", TaskEnum.EDIT); + map.put("extend", TaskEnum.EXTEND); return map; } @@ -142,7 +145,8 @@ public enum TaskEnum { TEXT_TO_VIDEO("text_to_video"), IMAGE_TO_VIDEO("image_to_video"), REFERENCE_TO_VIDEO("reference_to_video"), - EDIT("edit"),; + EDIT("edit"), + EXTEND("extend"),; private final String value; diff --git a/src/main/java/com/google/genai/gaos/models/interactions/TranscriptionConfig.java b/src/main/java/com/google/genai/gaos/models/interactions/TranscriptionConfig.java index e82e30d3540..e9020c936a9 100644 --- a/src/main/java/com/google/genai/gaos/models/interactions/TranscriptionConfig.java +++ b/src/main/java/com/google/genai/gaos/models/interactions/TranscriptionConfig.java @@ -70,6 +70,15 @@ public class TranscriptionConfig { @JsonProperty("language_codes") private List languageCodes; + /** + * Configures transcription mode. Supported values: `VERBATIM`, `SMART`. If + * unspecified, defaults to `VERBATIM` transcription. Mutually exclusive with + * `timestamp_granularities` and `diarization_mode`. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("mode") + private TranscriptionMode mode; + /** * Optional. The granularity of timestamps to include in the transcription output. * Supported values: "word". If empty, no timestamps are generated. @@ -84,17 +93,19 @@ public TranscriptionConfig( @JsonProperty("custom_vocabulary") @Nullable List customVocabulary, @JsonProperty("diarization_mode") @Nullable String diarizationMode, @JsonProperty("language_codes") @Nullable List languageCodes, + @JsonProperty("mode") @Nullable TranscriptionMode mode, @JsonProperty("timestamp_granularities") @Nullable List timestampGranularities) { this.adaptationPhrases = adaptationPhrases; this.customVocabulary = customVocabulary; this.diarizationMode = diarizationMode; this.languageCodes = languageCodes; + this.mode = mode; this.timestampGranularities = timestampGranularities; } public TranscriptionConfig() { this(null, null, null, - null, null); + null, null, null); } /** @@ -130,6 +141,15 @@ public Optional> languageCodes() { return Optional.ofNullable(this.languageCodes); } + /** + * Configures transcription mode. Supported values: `VERBATIM`, `SMART`. If + * unspecified, defaults to `VERBATIM` transcription. Mutually exclusive with + * `timestamp_granularities` and `diarization_mode`. + */ + public Optional mode() { + return Optional.ofNullable(this.mode); + } + /** * Optional. The granularity of timestamps to include in the transcription output. * Supported values: "word". If empty, no timestamps are generated. @@ -184,6 +204,17 @@ public TranscriptionConfig withLanguageCodes(@Nullable List languageCode } + /** + * Configures transcription mode. Supported values: `VERBATIM`, `SMART`. If + * unspecified, defaults to `VERBATIM` transcription. Mutually exclusive with + * `timestamp_granularities` and `diarization_mode`. + */ + public TranscriptionConfig withMode(@Nullable TranscriptionMode mode) { + this.mode = mode; + return this; + } + + /** * Optional. The granularity of timestamps to include in the transcription output. * Supported values: "word". If empty, no timestamps are generated. @@ -208,6 +239,7 @@ public boolean equals(java.lang.Object o) { Utils.enhancedDeepEquals(this.customVocabulary, other.customVocabulary) && Utils.enhancedDeepEquals(this.diarizationMode, other.diarizationMode) && Utils.enhancedDeepEquals(this.languageCodes, other.languageCodes) && + Utils.enhancedDeepEquals(this.mode, other.mode) && Utils.enhancedDeepEquals(this.timestampGranularities, other.timestampGranularities); } @@ -215,7 +247,7 @@ public boolean equals(java.lang.Object o) { public int hashCode() { return Utils.enhancedHash( adaptationPhrases, customVocabulary, diarizationMode, - languageCodes, timestampGranularities); + languageCodes, mode, timestampGranularities); } @Override @@ -225,6 +257,7 @@ public String toString() { "customVocabulary", customVocabulary, "diarizationMode", diarizationMode, "languageCodes", languageCodes, + "mode", mode, "timestampGranularities", timestampGranularities); } @@ -240,6 +273,8 @@ public final static class Builder { private List languageCodes; + private TranscriptionMode mode; + private List timestampGranularities; private Builder() { @@ -283,6 +318,16 @@ public Builder languageCodes(@Nullable List languageCodes) { return this; } + /** + * Configures transcription mode. Supported values: `VERBATIM`, `SMART`. If + * unspecified, defaults to `VERBATIM` transcription. Mutually exclusive with + * `timestamp_granularities` and `diarization_mode`. + */ + public Builder mode(@Nullable TranscriptionMode mode) { + this.mode = mode; + return this; + } + /** * Optional. The granularity of timestamps to include in the transcription output. * Supported values: "word". If empty, no timestamps are generated. @@ -295,7 +340,7 @@ public Builder timestampGranularities(@Nullable List timestampGranularit public TranscriptionConfig build() { return new TranscriptionConfig( adaptationPhrases, customVocabulary, diarizationMode, - languageCodes, timestampGranularities); + languageCodes, mode, timestampGranularities); } } diff --git a/src/main/java/com/google/genai/gaos/models/interactions/TranscriptionMode.java b/src/main/java/com/google/genai/gaos/models/interactions/TranscriptionMode.java new file mode 100644 index 00000000000..bd062fde8d2 --- /dev/null +++ b/src/main/java/com/google/genai/gaos/models/interactions/TranscriptionMode.java @@ -0,0 +1,150 @@ +/* + * Copyright 2026 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 + * + * http://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. + */ + +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ +package com.google.genai.gaos.models.interactions; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.lang.Override; +import java.lang.String; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Wrapper for an "open" enum that can handle unknown values from API responses + * without runtime errors. Instances are immutable singletons with reference equality. + * Use {@code asEnum()} for switch expressions. + */ +/** + * TranscriptionMode + * + *

Configures transcription mode. Supported values: `VERBATIM`, `SMART`. If + * unspecified, defaults to `VERBATIM` transcription. Mutually exclusive with + * `timestamp_granularities` and `diarization_mode`. + */ +public class TranscriptionMode { + + public static final TranscriptionMode VERBATIM = new TranscriptionMode("verbatim"); + public static final TranscriptionMode SMART = new TranscriptionMode("smart"); + + // This map will grow whenever a Color gets created with a new + // unrecognized value (a potential memory leak if the user is not + // careful). Keep this field lower case to avoid clashing with + // generated member names which will always be upper cased (Java + // convention) + private static final Map values = createValuesMap(); + private static final Map enums = createEnumsMap(); + + private final String value; + + private TranscriptionMode(String value) { + this.value = value; + } + + /** + * Returns a TranscriptionMode with the given value. For a specific value the + * returned object will always be a singleton so reference equality + * is satisfied when the values are the same. + * + * @param value value to be wrapped as TranscriptionMode + */ + @JsonCreator + public static TranscriptionMode of(String value) { + synchronized (TranscriptionMode.class) { + return values.computeIfAbsent(value, v -> new TranscriptionMode(v)); + } + } + + @JsonValue + public String value() { + return value; + } + + public Optional asEnum() { + return Optional.ofNullable(enums.getOrDefault(value, null)); + } + + public boolean isKnown() { + return asEnum().isPresent(); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(java.lang.Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + TranscriptionMode other = (TranscriptionMode) obj; + return Objects.equals(value, other.value); + } + + @Override + public String toString() { + return "TranscriptionMode [value=" + value + "]"; + } + + // return an array just like an enum + public static TranscriptionMode[] values() { + synchronized (TranscriptionMode.class) { + return values.values().toArray(new TranscriptionMode[] {}); + } + } + + private static final Map createValuesMap() { + Map map = new LinkedHashMap<>(); + map.put("verbatim", VERBATIM); + map.put("smart", SMART); + return map; + } + + private static final Map createEnumsMap() { + Map map = new HashMap<>(); + map.put("verbatim", TranscriptionModeEnum.VERBATIM); + map.put("smart", TranscriptionModeEnum.SMART); + return map; + } + + + public enum TranscriptionModeEnum { + + VERBATIM("verbatim"), + SMART("smart"),; + + private final String value; + + private TranscriptionModeEnum(String value) { + this.value = value; + } + + public String value() { + return value; + } + } +} + diff --git a/src/main/java/com/google/genai/gaos/models/interactions/Turn.java b/src/main/java/com/google/genai/gaos/models/interactions/Turn.java deleted file mode 100644 index 704d07ce421..00000000000 --- a/src/main/java/com/google/genai/gaos/models/interactions/Turn.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright 2026 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 - * - * http://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. - */ - -/* - * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - */ -package com.google.genai.gaos.models.interactions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.genai.gaos.utils.Utils; -import jakarta.annotation.Nullable; -import java.lang.Deprecated; -import java.lang.Override; -import java.lang.String; -import java.util.Optional; - -/** - * Turn - * - * @deprecated class: This will be removed in a future release, please migrate away from it as soon as possible. - */ -@Deprecated -public class Turn { - - @JsonInclude(Include.NON_ABSENT) - @JsonProperty("content") - private TurnContent content; - - /** - * The originator of this turn. Must be user for input or model for - * model output. - */ - @JsonInclude(Include.NON_ABSENT) - @JsonProperty("role") - private String role; - - @JsonCreator - public Turn( - @JsonProperty("content") @Nullable TurnContent content, - @JsonProperty("role") @Nullable String role) { - this.content = content; - this.role = role; - } - - public Turn() { - this(null, null); - } - - public Optional content() { - return Optional.ofNullable(this.content); - } - - /** - * The originator of this turn. Must be user for input or model for - * model output. - */ - public Optional role() { - return Optional.ofNullable(this.role); - } - - public static Builder builder() { - return new Builder(); - } - - - public Turn withContent(@Nullable TurnContent content) { - this.content = content; - return this; - } - - - /** - * The originator of this turn. Must be user for input or model for - * model output. - */ - public Turn withRole(@Nullable String role) { - this.role = role; - return this; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Turn other = (Turn) o; - return - Utils.enhancedDeepEquals(this.content, other.content) && - Utils.enhancedDeepEquals(this.role, other.role); - } - - @Override - public int hashCode() { - return Utils.enhancedHash( - content, role); - } - - @Override - public String toString() { - return Utils.toString(Turn.class, - "content", content, - "role", role); - } - - @SuppressWarnings("UnusedReturnValue") - public final static class Builder { - - private TurnContent content; - - private String role; - - private Builder() { - // force use of static builder() method - } - - public Builder content(@Nullable TurnContent content) { - this.content = content; - return this; - } - - /** - * The originator of this turn. Must be user for input or model for - * model output. - */ - public Builder role(@Nullable String role) { - this.role = role; - return this; - } - - public Turn build() { - return new Turn( - content, role); - } - - } -} diff --git a/src/main/java/com/google/genai/gaos/models/interactions/VideoContent.java b/src/main/java/com/google/genai/gaos/models/interactions/VideoContent.java index ea781a33a42..40608bf2f73 100644 --- a/src/main/java/com/google/genai/gaos/models/interactions/VideoContent.java +++ b/src/main/java/com/google/genai/gaos/models/interactions/VideoContent.java @@ -44,6 +44,13 @@ public class VideoContent implements Content { @JsonProperty("data") private String data; + /** + * How the model processes this video for understanding. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("processing") + private Processing processing; + @JsonInclude(Include.NON_ABSENT) @JsonProperty("resolution") @@ -70,10 +77,12 @@ public class VideoContent implements Content { @JsonCreator public VideoContent( @JsonProperty("data") @Nullable String data, + @JsonProperty("processing") @Nullable Processing processing, @JsonProperty("resolution") @Nullable MediaResolution resolution, @JsonProperty("uri") @Nullable String uri, @JsonProperty("mime_type") @Nullable VideoContentMimeType mimeType) { this.data = data; + this.processing = processing; this.resolution = resolution; this.type = Builder._SINGLETON_VALUE_Type.value(); this.uri = uri; @@ -82,7 +91,7 @@ public VideoContent( public VideoContent() { this(null, null, null, - null); + null, null); } /** @@ -92,6 +101,13 @@ public Optional data() { return Optional.ofNullable(this.data); } + /** + * How the model processes this video for understanding. + */ + public Optional processing() { + return Optional.ofNullable(this.processing); + } + public Optional resolution() { return Optional.ofNullable(this.resolution); } @@ -129,6 +145,15 @@ public VideoContent withData(@Nullable String data) { } + /** + * How the model processes this video for understanding. + */ + public VideoContent withProcessing(@Nullable Processing processing) { + this.processing = processing; + return this; + } + + public VideoContent withResolution(@Nullable MediaResolution resolution) { this.resolution = resolution; return this; @@ -164,6 +189,7 @@ public boolean equals(java.lang.Object o) { VideoContent other = (VideoContent) o; return Utils.enhancedDeepEquals(this.data, other.data) && + Utils.enhancedDeepEquals(this.processing, other.processing) && Utils.enhancedDeepEquals(this.resolution, other.resolution) && Utils.enhancedDeepEquals(this.type, other.type) && Utils.enhancedDeepEquals(this.uri, other.uri) && @@ -173,14 +199,15 @@ public boolean equals(java.lang.Object o) { @Override public int hashCode() { return Utils.enhancedHash( - data, resolution, type, - uri, mimeType); + data, processing, resolution, + type, uri, mimeType); } @Override public String toString() { return Utils.toString(VideoContent.class, "data", data, + "processing", processing, "resolution", resolution, "type", type, "uri", uri, @@ -192,6 +219,8 @@ public final static class Builder { private String data; + private Processing processing; + private MediaResolution resolution; private String uri; @@ -210,6 +239,14 @@ public Builder data(@Nullable String data) { return this; } + /** + * How the model processes this video for understanding. + */ + public Builder processing(@Nullable Processing processing) { + this.processing = processing; + return this; + } + public Builder resolution(@Nullable MediaResolution resolution) { this.resolution = resolution; return this; @@ -233,8 +270,8 @@ public Builder mimeType(@Nullable VideoContentMimeType mimeType) { public VideoContent build() { return new VideoContent( - data, resolution, uri, - mimeType); + data, processing, resolution, + uri, mimeType); } diff --git a/src/main/java/com/google/genai/gaos/models/interactions/VideoResponseFormat.java b/src/main/java/com/google/genai/gaos/models/interactions/VideoResponseFormat.java index 9d1e65b5181..2a1ed4f8c25 100644 --- a/src/main/java/com/google/genai/gaos/models/interactions/VideoResponseFormat.java +++ b/src/main/java/com/google/genai/gaos/models/interactions/VideoResponseFormat.java @@ -59,13 +59,20 @@ public class VideoResponseFormat { private String duration; /** - * The GCS URI to store the video output. Required for Vertex if delivery mode - * is URI. + * The Cloud Storage URI to store the video output. Required for Vertex if + * delivery mode is URI. */ @JsonInclude(Include.NON_ABSENT) @JsonProperty("gcs_uri") private String gcsUri; + /** + * The video output resolution. Defaults to 720p. + */ + @JsonInclude(Include.NON_ABSENT) + @JsonProperty("resolution") + private Resolution resolution; + @JsonProperty("type") private String type; @@ -75,17 +82,19 @@ public VideoResponseFormat( @JsonProperty("aspect_ratio") @Nullable VideoResponseFormatAspectRatio aspectRatio, @JsonProperty("delivery") @Nullable VideoResponseFormatDelivery delivery, @JsonProperty("duration") @Nullable String duration, - @JsonProperty("gcs_uri") @Nullable String gcsUri) { + @JsonProperty("gcs_uri") @Nullable String gcsUri, + @JsonProperty("resolution") @Nullable Resolution resolution) { this.aspectRatio = aspectRatio; this.delivery = delivery; this.duration = duration; this.gcsUri = gcsUri; + this.resolution = resolution; this.type = Builder._SINGLETON_VALUE_Type.value(); } public VideoResponseFormat() { this(null, null, null, - null); + null, null); } /** @@ -110,13 +119,20 @@ public Optional duration() { } /** - * The GCS URI to store the video output. Required for Vertex if delivery mode - * is URI. + * The Cloud Storage URI to store the video output. Required for Vertex if + * delivery mode is URI. */ public Optional gcsUri() { return Optional.ofNullable(this.gcsUri); } + /** + * The video output resolution. Defaults to 720p. + */ + public Optional resolution() { + return Optional.ofNullable(this.resolution); + } + public Optional type() { return Optional.ofNullable(this.type); } @@ -154,8 +170,8 @@ public VideoResponseFormat withDuration(@Nullable String duration) { /** - * The GCS URI to store the video output. Required for Vertex if delivery mode - * is URI. + * The Cloud Storage URI to store the video output. Required for Vertex if + * delivery mode is URI. */ public VideoResponseFormat withGcsUri(@Nullable String gcsUri) { this.gcsUri = gcsUri; @@ -163,6 +179,15 @@ public VideoResponseFormat withGcsUri(@Nullable String gcsUri) { } + /** + * The video output resolution. Defaults to 720p. + */ + public VideoResponseFormat withResolution(@Nullable Resolution resolution) { + this.resolution = resolution; + return this; + } + + @Override public boolean equals(java.lang.Object o) { if (this == o) { @@ -177,6 +202,7 @@ public boolean equals(java.lang.Object o) { Utils.enhancedDeepEquals(this.delivery, other.delivery) && Utils.enhancedDeepEquals(this.duration, other.duration) && Utils.enhancedDeepEquals(this.gcsUri, other.gcsUri) && + Utils.enhancedDeepEquals(this.resolution, other.resolution) && Utils.enhancedDeepEquals(this.type, other.type); } @@ -184,7 +210,7 @@ public boolean equals(java.lang.Object o) { public int hashCode() { return Utils.enhancedHash( aspectRatio, delivery, duration, - gcsUri, type); + gcsUri, resolution, type); } @Override @@ -194,6 +220,7 @@ public String toString() { "delivery", delivery, "duration", duration, "gcsUri", gcsUri, + "resolution", resolution, "type", type); } @@ -208,6 +235,8 @@ public final static class Builder { private String gcsUri; + private Resolution resolution; + private Builder() { // force use of static builder() method } @@ -237,18 +266,26 @@ public Builder duration(@Nullable String duration) { } /** - * The GCS URI to store the video output. Required for Vertex if delivery mode - * is URI. + * The Cloud Storage URI to store the video output. Required for Vertex if + * delivery mode is URI. */ public Builder gcsUri(@Nullable String gcsUri) { this.gcsUri = gcsUri; return this; } + /** + * The video output resolution. Defaults to 720p. + */ + public Builder resolution(@Nullable Resolution resolution) { + this.resolution = resolution; + return this; + } + public VideoResponseFormat build() { return new VideoResponseFormat( aspectRatio, delivery, duration, - gcsUri); + gcsUri, resolution); } diff --git a/src/main/java/com/google/genai/gaos/operations/CancelInteractionById.java b/src/main/java/com/google/genai/gaos/operations/CancelInteractionById.java index 10a03e85808..66368d664de 100644 --- a/src/main/java/com/google/genai/gaos/operations/CancelInteractionById.java +++ b/src/main/java/com/google/genai/gaos/operations/CancelInteractionById.java @@ -28,7 +28,7 @@ import com.google.genai.gaos.SecuritySource; import com.google.genai.gaos.models.errors.CancelInteractionByIdClientError; import com.google.genai.gaos.models.errors.CancelInteractionByIdServerError; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.interactions.Interaction; import com.google.genai.gaos.models.operations.CancelInteractionByIdRequest; import com.google.genai.gaos.models.operations.CancelInteractionByIdResponse; @@ -218,24 +218,24 @@ public CancelInteractionByIdResponse handleResponse(HttpResponse re if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withInteraction(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { if (Utils.contentTypeMatches(contentType, "application/json")) { throw CancelInteractionByIdClientError.from(response); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { if (Utils.contentTypeMatches(contentType, "application/json")) { throw CancelInteractionByIdServerError.from(response); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -311,24 +311,24 @@ public com.google.genai.gaos.models.operations.async.CancelInteractionByIdRespon if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withInteraction(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { if (Utils.contentTypeMatches(contentType, "application/json")) { throw CancelInteractionByIdClientError.from(response); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { if (Utils.contentTypeMatches(contentType, "application/json")) { throw CancelInteractionByIdServerError.from(response); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/CreateAgent.java b/src/main/java/com/google/genai/gaos/operations/CreateAgent.java index fce75babad8..a5411d922bc 100644 --- a/src/main/java/com/google/genai/gaos/operations/CreateAgent.java +++ b/src/main/java/com/google/genai/gaos/operations/CreateAgent.java @@ -27,7 +27,7 @@ import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; import com.google.genai.gaos.models.agents.Agent; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.operations.CreateAgentRequest; import com.google.genai.gaos.models.operations.CreateAgentResponse; import com.google.genai.gaos.utils.AsyncRetries; @@ -231,20 +231,20 @@ public CreateAgentResponse handleResponse(HttpResponse response) { if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withAgent(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -318,20 +318,20 @@ public com.google.genai.gaos.models.operations.async.CreateAgentResponse handleR if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withAgent(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/CreateEnvironment.java b/src/main/java/com/google/genai/gaos/operations/CreateEnvironment.java index 59f52f6f5f9..158d645c738 100644 --- a/src/main/java/com/google/genai/gaos/operations/CreateEnvironment.java +++ b/src/main/java/com/google/genai/gaos/operations/CreateEnvironment.java @@ -27,7 +27,7 @@ import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; import com.google.genai.gaos.models.environments.Environment; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.operations.CreateEnvironmentRequest; import com.google.genai.gaos.models.operations.CreateEnvironmentResponse; import com.google.genai.gaos.utils.AsyncRetries; @@ -231,20 +231,20 @@ public CreateEnvironmentResponse handleResponse(HttpResponse respon if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withEnvironment(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -318,20 +318,20 @@ public com.google.genai.gaos.models.operations.async.CreateEnvironmentResponse h if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withEnvironment(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/CreateInteraction.java b/src/main/java/com/google/genai/gaos/operations/CreateInteraction.java index 836486971f2..b93d87f9a14 100644 --- a/src/main/java/com/google/genai/gaos/operations/CreateInteraction.java +++ b/src/main/java/com/google/genai/gaos/operations/CreateInteraction.java @@ -28,7 +28,7 @@ import com.google.genai.gaos.SecuritySource; import com.google.genai.gaos.models.errors.CreateInteractionClientError; import com.google.genai.gaos.models.errors.CreateInteractionServerError; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.interactions.Interaction; import com.google.genai.gaos.models.operations.CreateInteractionRequest; import com.google.genai.gaos.models.operations.CreateInteractionResponse; @@ -239,24 +239,24 @@ public CreateInteractionResponse handleResponse(HttpResponse respon Utils.setSseSentinel(res, "[DONE]"); return res; } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { if (Utils.contentTypeMatches(contentType, "application/json")) { throw CreateInteractionClientError.from(response); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { if (Utils.contentTypeMatches(contentType, "application/json")) { throw CreateInteractionServerError.from(response); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -336,24 +336,24 @@ public com.google.genai.gaos.models.operations.async.CreateInteractionResponse h Utils.setSseSentinel(res, "[DONE]"); return res; } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { if (Utils.contentTypeMatches(contentType, "application/json")) { throw CreateInteractionClientError.from(response); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { if (Utils.contentTypeMatches(contentType, "application/json")) { throw CreateInteractionServerError.from(response); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/CreateTrigger.java b/src/main/java/com/google/genai/gaos/operations/CreateTrigger.java index 2e0b8e7e60a..c15b423883a 100644 --- a/src/main/java/com/google/genai/gaos/operations/CreateTrigger.java +++ b/src/main/java/com/google/genai/gaos/operations/CreateTrigger.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.operations.CreateTriggerRequest; import com.google.genai.gaos.models.operations.CreateTriggerResponse; import com.google.genai.gaos.models.triggers.Trigger; @@ -233,18 +233,18 @@ public CreateTriggerResponse handleResponse(HttpResponse response) if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withTrigger(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -320,18 +320,18 @@ public com.google.genai.gaos.models.operations.async.CreateTriggerResponse handl if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withTrigger(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/CreateWebhook.java b/src/main/java/com/google/genai/gaos/operations/CreateWebhook.java index 0f6515be02a..dc3906ae69a 100644 --- a/src/main/java/com/google/genai/gaos/operations/CreateWebhook.java +++ b/src/main/java/com/google/genai/gaos/operations/CreateWebhook.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.operations.CreateWebhookRequest; import com.google.genai.gaos.models.operations.CreateWebhookResponse; import com.google.genai.gaos.models.webhooks.Webhook; @@ -231,20 +231,20 @@ public CreateWebhookResponse handleResponse(HttpResponse response) if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withWebhook(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -318,20 +318,20 @@ public com.google.genai.gaos.models.operations.async.CreateWebhookResponse handl if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withWebhook(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/DeleteAgent.java b/src/main/java/com/google/genai/gaos/operations/DeleteAgent.java index 96ce109df86..24ee00de123 100644 --- a/src/main/java/com/google/genai/gaos/operations/DeleteAgent.java +++ b/src/main/java/com/google/genai/gaos/operations/DeleteAgent.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.interactions.Empty; import com.google.genai.gaos.models.operations.DeleteAgentRequest; import com.google.genai.gaos.models.operations.DeleteAgentResponse; @@ -214,20 +214,20 @@ public DeleteAgentResponse handleResponse(HttpResponse response) { if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withEmpty(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -301,20 +301,20 @@ public com.google.genai.gaos.models.operations.async.DeleteAgentResponse handleR if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withEmpty(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/DeleteEnvironment.java b/src/main/java/com/google/genai/gaos/operations/DeleteEnvironment.java index 1611185575b..52e3d6b4a31 100644 --- a/src/main/java/com/google/genai/gaos/operations/DeleteEnvironment.java +++ b/src/main/java/com/google/genai/gaos/operations/DeleteEnvironment.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.interactions.Empty; import com.google.genai.gaos.models.operations.DeleteEnvironmentRequest; import com.google.genai.gaos.models.operations.DeleteEnvironmentResponse; @@ -214,20 +214,20 @@ public DeleteEnvironmentResponse handleResponse(HttpResponse respon if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withEmpty(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -301,20 +301,20 @@ public com.google.genai.gaos.models.operations.async.DeleteEnvironmentResponse h if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withEmpty(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/DeleteInteraction.java b/src/main/java/com/google/genai/gaos/operations/DeleteInteraction.java index 94d7a27c986..213b9ce1e34 100644 --- a/src/main/java/com/google/genai/gaos/operations/DeleteInteraction.java +++ b/src/main/java/com/google/genai/gaos/operations/DeleteInteraction.java @@ -27,7 +27,7 @@ import com.google.genai.gaos.SecuritySource; import com.google.genai.gaos.models.errors.DeleteInteractionClientError; import com.google.genai.gaos.models.errors.DeleteInteractionServerError; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.operations.DeleteInteractionRequest; import com.google.genai.gaos.models.operations.DeleteInteractionResponse; import com.google.genai.gaos.utils.AsyncRetries; @@ -221,17 +221,17 @@ public DeleteInteractionResponse handleResponse(HttpResponse respon if (Utils.contentTypeMatches(contentType, "application/json")) { throw DeleteInteractionClientError.from(response); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { if (Utils.contentTypeMatches(contentType, "application/json")) { throw DeleteInteractionServerError.from(response); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -312,17 +312,17 @@ public com.google.genai.gaos.models.operations.async.DeleteInteractionResponse h if (Utils.contentTypeMatches(contentType, "application/json")) { throw DeleteInteractionClientError.from(response); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { if (Utils.contentTypeMatches(contentType, "application/json")) { throw DeleteInteractionServerError.from(response); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/DeleteTrigger.java b/src/main/java/com/google/genai/gaos/operations/DeleteTrigger.java index d8de8f54c31..adf5cd9179c 100644 --- a/src/main/java/com/google/genai/gaos/operations/DeleteTrigger.java +++ b/src/main/java/com/google/genai/gaos/operations/DeleteTrigger.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.interactions.Empty; import com.google.genai.gaos.models.operations.DeleteTriggerRequest; import com.google.genai.gaos.models.operations.DeleteTriggerResponse; @@ -216,18 +216,18 @@ public DeleteTriggerResponse handleResponse(HttpResponse response) if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withEmpty(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -303,18 +303,18 @@ public com.google.genai.gaos.models.operations.async.DeleteTriggerResponse handl if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withEmpty(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/DeleteWebhook.java b/src/main/java/com/google/genai/gaos/operations/DeleteWebhook.java index d6de2853e66..ef918018628 100644 --- a/src/main/java/com/google/genai/gaos/operations/DeleteWebhook.java +++ b/src/main/java/com/google/genai/gaos/operations/DeleteWebhook.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.interactions.Empty; import com.google.genai.gaos.models.operations.DeleteWebhookRequest; import com.google.genai.gaos.models.operations.DeleteWebhookResponse; @@ -214,20 +214,20 @@ public DeleteWebhookResponse handleResponse(HttpResponse response) if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withEmpty(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -301,20 +301,20 @@ public com.google.genai.gaos.models.operations.async.DeleteWebhookResponse handl if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withEmpty(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/GetAgent.java b/src/main/java/com/google/genai/gaos/operations/GetAgent.java index 6366bd2917c..6dcc96835be 100644 --- a/src/main/java/com/google/genai/gaos/operations/GetAgent.java +++ b/src/main/java/com/google/genai/gaos/operations/GetAgent.java @@ -27,7 +27,7 @@ import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; import com.google.genai.gaos.models.agents.Agent; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.operations.GetAgentRequest; import com.google.genai.gaos.models.operations.GetAgentResponse; import com.google.genai.gaos.utils.AsyncRetries; @@ -214,20 +214,20 @@ public GetAgentResponse handleResponse(HttpResponse response) { if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withAgent(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -301,20 +301,20 @@ public com.google.genai.gaos.models.operations.async.GetAgentResponse handleResp if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withAgent(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/GetEnvironment.java b/src/main/java/com/google/genai/gaos/operations/GetEnvironment.java index 978fbe6d1f8..5cf2947b31e 100644 --- a/src/main/java/com/google/genai/gaos/operations/GetEnvironment.java +++ b/src/main/java/com/google/genai/gaos/operations/GetEnvironment.java @@ -27,7 +27,7 @@ import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; import com.google.genai.gaos.models.environments.Environment; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.operations.GetEnvironmentRequest; import com.google.genai.gaos.models.operations.GetEnvironmentResponse; import com.google.genai.gaos.utils.AsyncRetries; @@ -214,20 +214,20 @@ public GetEnvironmentResponse handleResponse(HttpResponse response) if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withEnvironment(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -301,20 +301,20 @@ public com.google.genai.gaos.models.operations.async.GetEnvironmentResponse hand if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withEnvironment(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/GetInteractionById.java b/src/main/java/com/google/genai/gaos/operations/GetInteractionById.java index a71b9ea207d..6f0726ce246 100644 --- a/src/main/java/com/google/genai/gaos/operations/GetInteractionById.java +++ b/src/main/java/com/google/genai/gaos/operations/GetInteractionById.java @@ -26,9 +26,9 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.errors.GetInteractionByIdClientError; import com.google.genai.gaos.models.errors.GetInteractionByIdServerError; -import com.google.genai.gaos.models.errors.SDKException; import com.google.genai.gaos.models.interactions.Interaction; import com.google.genai.gaos.models.operations.GetInteractionByIdRequest; import com.google.genai.gaos.models.operations.GetInteractionByIdResponse; @@ -227,24 +227,24 @@ public GetInteractionByIdResponse handleResponse(HttpResponse respo Utils.setSseSentinel(res, "[DONE]"); return res; } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { if (Utils.contentTypeMatches(contentType, "application/json")) { throw GetInteractionByIdClientError.from(response); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { if (Utils.contentTypeMatches(contentType, "application/json")) { throw GetInteractionByIdServerError.from(response); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -324,24 +324,24 @@ public com.google.genai.gaos.models.operations.async.GetInteractionByIdResponse Utils.setSseSentinel(res, "[DONE]"); return res; } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { if (Utils.contentTypeMatches(contentType, "application/json")) { throw GetInteractionByIdClientError.from(response); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { if (Utils.contentTypeMatches(contentType, "application/json")) { throw GetInteractionByIdServerError.from(response); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/GetTrigger.java b/src/main/java/com/google/genai/gaos/operations/GetTrigger.java index f9579438e24..4f7a0c9b46a 100644 --- a/src/main/java/com/google/genai/gaos/operations/GetTrigger.java +++ b/src/main/java/com/google/genai/gaos/operations/GetTrigger.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.operations.GetTriggerRequest; import com.google.genai.gaos.models.operations.GetTriggerResponse; import com.google.genai.gaos.models.triggers.Trigger; @@ -216,18 +216,18 @@ public GetTriggerResponse handleResponse(HttpResponse response) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withTrigger(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -303,18 +303,18 @@ public com.google.genai.gaos.models.operations.async.GetTriggerResponse handleRe if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withTrigger(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/GetWebhook.java b/src/main/java/com/google/genai/gaos/operations/GetWebhook.java index 979555c6423..bc06fb35e85 100644 --- a/src/main/java/com/google/genai/gaos/operations/GetWebhook.java +++ b/src/main/java/com/google/genai/gaos/operations/GetWebhook.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.operations.GetWebhookRequest; import com.google.genai.gaos.models.operations.GetWebhookResponse; import com.google.genai.gaos.models.webhooks.Webhook; @@ -214,20 +214,20 @@ public GetWebhookResponse handleResponse(HttpResponse response) { if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withWebhook(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -301,20 +301,20 @@ public com.google.genai.gaos.models.operations.async.GetWebhookResponse handleRe if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withWebhook(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/ListAgents.java b/src/main/java/com/google/genai/gaos/operations/ListAgents.java index de5700c05c7..e27800efd36 100644 --- a/src/main/java/com/google/genai/gaos/operations/ListAgents.java +++ b/src/main/java/com/google/genai/gaos/operations/ListAgents.java @@ -27,7 +27,7 @@ import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; import com.google.genai.gaos.models.agents.AgentListResponse; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.operations.ListAgentsRequest; import com.google.genai.gaos.models.operations.ListAgentsResponse; import com.google.genai.gaos.utils.AsyncRetries; @@ -219,20 +219,20 @@ public ListAgentsResponse handleResponse(HttpResponse response) { if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withAgentListResponse(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -306,20 +306,20 @@ public com.google.genai.gaos.models.operations.async.ListAgentsResponse handleRe if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withAgentListResponse(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/ListEnvironments.java b/src/main/java/com/google/genai/gaos/operations/ListEnvironments.java index 409e7d24379..da70a87ecff 100644 --- a/src/main/java/com/google/genai/gaos/operations/ListEnvironments.java +++ b/src/main/java/com/google/genai/gaos/operations/ListEnvironments.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.operations.ListEnvironmentsRequest; import com.google.genai.gaos.models.operations.ListEnvironmentsResponse; import com.google.genai.gaos.utils.AsyncRetries; @@ -218,20 +218,20 @@ public ListEnvironmentsResponse handleResponse(HttpResponse respons if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withListEnvironmentsResponse(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -305,20 +305,20 @@ public com.google.genai.gaos.models.operations.async.ListEnvironmentsResponse ha if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withListEnvironmentsResponse(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/ListTriggerExecutions.java b/src/main/java/com/google/genai/gaos/operations/ListTriggerExecutions.java index 59646ebe9bd..52017d98fc4 100644 --- a/src/main/java/com/google/genai/gaos/operations/ListTriggerExecutions.java +++ b/src/main/java/com/google/genai/gaos/operations/ListTriggerExecutions.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.operations.ListTriggerExecutionsRequest; import com.google.genai.gaos.models.operations.ListTriggerExecutionsResponse; import com.google.genai.gaos.utils.AsyncRetries; @@ -220,18 +220,18 @@ public ListTriggerExecutionsResponse handleResponse(HttpResponse re if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withListTriggerExecutionsResponse(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -307,18 +307,18 @@ public com.google.genai.gaos.models.operations.async.ListTriggerExecutionsRespon if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withListTriggerExecutionsResponse(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/ListTriggers.java b/src/main/java/com/google/genai/gaos/operations/ListTriggers.java index 57e9f1bc6ff..b8e69c3bcb8 100644 --- a/src/main/java/com/google/genai/gaos/operations/ListTriggers.java +++ b/src/main/java/com/google/genai/gaos/operations/ListTriggers.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.operations.ListTriggersRequest; import com.google.genai.gaos.models.operations.ListTriggersResponse; import com.google.genai.gaos.utils.AsyncRetries; @@ -220,18 +220,18 @@ public ListTriggersResponse handleResponse(HttpResponse response) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withListTriggersResponse(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -307,18 +307,18 @@ public com.google.genai.gaos.models.operations.async.ListTriggersResponse handle if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withListTriggersResponse(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/ListWebhooks.java b/src/main/java/com/google/genai/gaos/operations/ListWebhooks.java index e54ce766142..ce8a0df96a7 100644 --- a/src/main/java/com/google/genai/gaos/operations/ListWebhooks.java +++ b/src/main/java/com/google/genai/gaos/operations/ListWebhooks.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.operations.ListWebhooksRequest; import com.google.genai.gaos.models.operations.ListWebhooksResponse; import com.google.genai.gaos.models.webhooks.WebhookListResponse; @@ -219,20 +219,20 @@ public ListWebhooksResponse handleResponse(HttpResponse response) { if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withWebhookListResponse(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -306,20 +306,20 @@ public com.google.genai.gaos.models.operations.async.ListWebhooksResponse handle if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withWebhookListResponse(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/PingWebhook.java b/src/main/java/com/google/genai/gaos/operations/PingWebhook.java index ec7acdc43b7..10661e095ca 100644 --- a/src/main/java/com/google/genai/gaos/operations/PingWebhook.java +++ b/src/main/java/com/google/genai/gaos/operations/PingWebhook.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.operations.PingWebhookRequest; import com.google.genai.gaos.models.operations.PingWebhookResponse; import com.google.genai.gaos.models.webhooks.WebhookPingResponse; @@ -227,20 +227,20 @@ public PingWebhookResponse handleResponse(HttpResponse response) { if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withWebhookPingResponse(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -314,20 +314,20 @@ public com.google.genai.gaos.models.operations.async.PingWebhookResponse handleR if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withWebhookPingResponse(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/RotateSigningSecret.java b/src/main/java/com/google/genai/gaos/operations/RotateSigningSecret.java index 22837a0e4ea..1e616961a1b 100644 --- a/src/main/java/com/google/genai/gaos/operations/RotateSigningSecret.java +++ b/src/main/java/com/google/genai/gaos/operations/RotateSigningSecret.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.operations.RotateSigningSecretRequest; import com.google.genai.gaos.models.operations.RotateSigningSecretResponse; import com.google.genai.gaos.models.webhooks.WebhookRotateSigningSecretResponse; @@ -227,20 +227,20 @@ public RotateSigningSecretResponse handleResponse(HttpResponse resp if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withWebhookRotateSigningSecretResponse(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -314,20 +314,20 @@ public com.google.genai.gaos.models.operations.async.RotateSigningSecretResponse if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withWebhookRotateSigningSecretResponse(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/RunTrigger.java b/src/main/java/com/google/genai/gaos/operations/RunTrigger.java index 498891a4bfc..d4cd3df22ea 100644 --- a/src/main/java/com/google/genai/gaos/operations/RunTrigger.java +++ b/src/main/java/com/google/genai/gaos/operations/RunTrigger.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.operations.RunTriggerRequest; import com.google.genai.gaos.models.operations.RunTriggerResponse; import com.google.genai.gaos.models.triggers.TriggerExecution; @@ -216,18 +216,18 @@ public RunTriggerResponse handleResponse(HttpResponse response) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withTriggerExecution(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -303,18 +303,18 @@ public com.google.genai.gaos.models.operations.async.RunTriggerResponse handleRe if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withTriggerExecution(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/UpdateTrigger.java b/src/main/java/com/google/genai/gaos/operations/UpdateTrigger.java index 09a8ef0b7a2..3b9af99c533 100644 --- a/src/main/java/com/google/genai/gaos/operations/UpdateTrigger.java +++ b/src/main/java/com/google/genai/gaos/operations/UpdateTrigger.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.operations.UpdateTriggerRequest; import com.google.genai.gaos.models.operations.UpdateTriggerResponse; import com.google.genai.gaos.models.triggers.Trigger; @@ -233,18 +233,18 @@ public UpdateTriggerResponse handleResponse(HttpResponse response) if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withTrigger(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -320,18 +320,18 @@ public com.google.genai.gaos.models.operations.async.UpdateTriggerResponse handl if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withTrigger(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/operations/UpdateWebhook.java b/src/main/java/com/google/genai/gaos/operations/UpdateWebhook.java index 452fd28f406..99f954a261d 100644 --- a/src/main/java/com/google/genai/gaos/operations/UpdateWebhook.java +++ b/src/main/java/com/google/genai/gaos/operations/UpdateWebhook.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.google.genai.gaos.SDKConfiguration; import com.google.genai.gaos.SecuritySource; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import com.google.genai.gaos.models.operations.UpdateWebhookRequest; import com.google.genai.gaos.models.operations.UpdateWebhookResponse; import com.google.genai.gaos.models.webhooks.Webhook; @@ -232,20 +232,20 @@ public UpdateWebhookResponse handleResponse(HttpResponse response) if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withWebhook(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } public static class Async extends Base @@ -319,20 +319,20 @@ public com.google.genai.gaos.models.operations.async.UpdateWebhookResponse handl if (Utils.statusCodeMatches(response.statusCode(), "4XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "5XX")) { // no content - throw SDKException.from("API error occurred", response); + throw GaosApiException.from("API error occurred", response); } if (Utils.statusCodeMatches(response.statusCode(), "default")) { if (Utils.contentTypeMatches(contentType, "application/json")) { return res.withWebhook(Utils.unmarshal(response, new TypeReference() {})); } else { - throw SDKException.from("Unexpected content-type received: " + contentType, response); + throw GaosApiException.from("Unexpected content-type received: " + contentType, response); } } - throw SDKException.from("Unexpected status code received: " + response.statusCode(), response); + throw GaosApiException.from("Unexpected status code received: " + response.statusCode(), response); } } } diff --git a/src/main/java/com/google/genai/gaos/utils/Utils.java b/src/main/java/com/google/genai/gaos/utils/Utils.java index 79d1afaf400..a1c1418c9b2 100644 --- a/src/main/java/com/google/genai/gaos/utils/Utils.java +++ b/src/main/java/com/google/genai/gaos/utils/Utils.java @@ -83,7 +83,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.google.genai.gaos.models.errors.SDKException; +import com.google.genai.gaos.models.errors.GaosApiException; import java.lang.String; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -1457,7 +1457,7 @@ public static T unmarshal(HttpResponse response, TypeReference< Utils.extractByteArrayFromBody(response), typeReference); } catch (Exception e) { - throw SDKException.from( + throw GaosApiException.from( "Error deserializing response body: " + e.getMessage(), response, e); } } diff --git a/src/test/java/com/google/genai/GaosClientTest.java b/src/test/java/com/google/genai/GaosClientTest.java new file mode 100644 index 00000000000..97fb70347d3 --- /dev/null +++ b/src/test/java/com/google/genai/GaosClientTest.java @@ -0,0 +1,398 @@ +/* + * Copyright 2026 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. + */ + +package com.google.genai; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.google.auth.oauth2.AccessToken; +import com.google.auth.oauth2.GoogleCredentials; +import com.google.common.collect.ImmutableMap; +import com.google.genai.gaos.SDKConfiguration; +import com.google.genai.gaos.models.operations.CreateInteractionRequestBody; +import com.google.genai.gaos.utils.HTTPClient; +import com.google.genai.gaos.utils.Headers; +import com.google.genai.gaos.utils.transport.HttpRequest; +import com.google.genai.gaos.utils.transport.HttpResponse; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.lang.reflect.Field; +import java.net.URI; +import java.util.Date; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.atomic.AtomicReference; +import org.junit.jupiter.api.Test; + +public final class GaosClientTest { + + private static final String PROJECT = "test-project"; + private static final String LOCATION = "us-central1"; + private static final GoogleCredentials CREDENTIALS = + GoogleCredentials.newBuilder() + .setAccessToken( + new AccessToken("test-token", new Date(System.currentTimeMillis() + 3600 * 1000))) + .build(); + + private static HttpResponse createMockResponse( + HttpRequest request, int statusCode, String jsonBody) { + Headers headers = new Headers(); + headers.add("Content-Type", "application/json"); + return new HttpResponse<>( + request, statusCode, headers, new ByteArrayInputStream(jsonBody.getBytes())); + } + + private void setMockGaosClient(Client client, HTTPClient mockClient) throws Exception { + Field sdkConfigField = client.interactions.getClass().getDeclaredField("sdkConfiguration"); + sdkConfigField.setAccessible(true); + SDKConfiguration sdkConfig = (SDKConfiguration) sdkConfigField.get(client.interactions); + + HTTPClient existingClient = sdkConfig.client(); + Class gaosHttpClientClass = + Class.forName("com.google.genai.Client$GenAiGaosHttpClient"); + java.lang.reflect.Method authorizeMethod = + gaosHttpClientClass.getDeclaredMethod("authorize", HttpRequest.class); + authorizeMethod.setAccessible(true); + + HTTPClient delegatingClient = + new HTTPClient() { + @Override + public HttpResponse send(HttpRequest request) { + try { + HttpRequest authorized = + (HttpRequest) authorizeMethod.invoke(existingClient, request); + return mockClient.send(authorized); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public CompletableFuture> sendAsync(HttpRequest request) { + try { + HttpRequest authorized = + (HttpRequest) authorizeMethod.invoke(existingClient, request); + return mockClient.sendAsync(authorized); + } catch (Exception e) { + CompletableFuture> future = new CompletableFuture<>(); + future.completeExceptionally(e); + return future; + } + } + }; + + sdkConfig.setClient(delegatingClient); + } + + @Test + public void testInteractionsUrl_vertex() throws Exception { + Client client = + Client.builder() + .project(PROJECT) + .location(LOCATION) + .credentials(CREDENTIALS) + .vertexAI(true) + .build(); + + AtomicReference capturedRequest = new AtomicReference<>(); + HTTPClient mockClient = + new HTTPClient() { + @Override + public HttpResponse send(HttpRequest request) { + capturedRequest.set(request); + return createMockResponse(request, 200, "{\"status\": \"completed\"}"); + } + + @Override + public CompletableFuture> sendAsync(HttpRequest request) { + return CompletableFuture.completedFuture(send(request)); + } + }; + setMockGaosClient(client, mockClient); + + com.google.genai.gaos.models.interactions.CreateModelInteraction body = + com.google.genai.gaos.models.interactions.CreateModelInteraction.builder() + .model("gemini-2.5-flash") + .input(com.google.genai.gaos.models.interactions.InteractionsInput.of("test-input")) + .build(); + CreateInteractionRequestBody requestBody = CreateInteractionRequestBody.of(body); + + client.interactions.create(requestBody); + + HttpRequest req = capturedRequest.get(); + assertNotNull(req); + assertEquals("POST", req.method()); + + URI expectedUri = + URI.create( + "https://" + + LOCATION + + "-aiplatform.googleapis.com/v1beta1/projects/" + + PROJECT + + "/locations/" + + LOCATION + + "/interactions"); + assertEquals(expectedUri, req.uri()); + assertTrue(req.headers().firstValue("Authorization").orElse("").contains("Bearer test-token")); + } + + @Test + public void testInteractionsUrl_gemini() throws Exception { + Client client = Client.builder().apiKey("test-api-key").vertexAI(false).build(); + + AtomicReference capturedRequest = new AtomicReference<>(); + HTTPClient mockClient = + new HTTPClient() { + @Override + public HttpResponse send(HttpRequest request) { + capturedRequest.set(request); + return createMockResponse(request, 200, "{\"status\": \"completed\"}"); + } + + @Override + public CompletableFuture> sendAsync(HttpRequest request) { + return CompletableFuture.completedFuture(send(request)); + } + }; + setMockGaosClient(client, mockClient); + + com.google.genai.gaos.models.interactions.CreateModelInteraction body = + com.google.genai.gaos.models.interactions.CreateModelInteraction.builder() + .model("gemini-2.5-flash") + .input(com.google.genai.gaos.models.interactions.InteractionsInput.of("test-input")) + .build(); + CreateInteractionRequestBody requestBody = CreateInteractionRequestBody.of(body); + + client.interactions.create(requestBody); + + HttpRequest req = capturedRequest.get(); + assertNotNull(req); + assertEquals("POST", req.method()); + + URI expectedUri = URI.create("https://generativelanguage.googleapis.com/v1beta/interactions"); + assertEquals(expectedUri, req.uri()); + assertEquals("test-api-key", req.headers().firstValue("x-goog-api-key").orElse(null)); + } + + @Test + public void testClientHeadersPropagation() throws Exception { + Map customHeaders = + ImmutableMap.of( + "custom-header-key", "custom-header-value", + "user-agent", "google-genai-sdk/1.12.0"); + com.google.genai.types.HttpOptions httpOptions = + com.google.genai.types.HttpOptions.builder().headers(customHeaders).build(); + + Client client = + Client.builder().apiKey("test-api-key").vertexAI(false).httpOptions(httpOptions).build(); + + AtomicReference capturedRequest = new AtomicReference<>(); + HTTPClient mockClient = + new HTTPClient() { + @Override + public HttpResponse send(HttpRequest request) { + capturedRequest.set(request); + return createMockResponse(request, 200, "{\"status\": \"completed\"}"); + } + + @Override + public CompletableFuture> sendAsync(HttpRequest request) { + return CompletableFuture.completedFuture(send(request)); + } + }; + setMockGaosClient(client, mockClient); + + com.google.genai.gaos.models.interactions.CreateModelInteraction body = + com.google.genai.gaos.models.interactions.CreateModelInteraction.builder() + .model("gemini-2.5-flash") + .input(com.google.genai.gaos.models.interactions.InteractionsInput.of("test-input")) + .build(); + CreateInteractionRequestBody requestBody = CreateInteractionRequestBody.of(body); + + client.interactions.create(requestBody); + + HttpRequest req = capturedRequest.get(); + assertNotNull(req); + assertEquals("custom-header-value", req.headers().firstValue("custom-header-key").orElse(null)); + // Verify rewrite of user-agent + assertTrue( + req.headers().firstValue("user-agent").orElse("").contains("google-genai-sdk")); + // Verify rewrite or injection of x-goog-api-client + assertTrue( + req.headers() + .firstValue("x-goog-api-client") + .orElse("") + .contains("google-genai-sdk")); + } + + @Test + public void testOtherInteractionsPaths_vertex() throws Exception { + Client client = + Client.builder() + .project(PROJECT) + .location(LOCATION) + .credentials(CREDENTIALS) + .vertexAI(true) + .build(); + + AtomicReference capturedRequest = new AtomicReference<>(); + HTTPClient mockClient = + new HTTPClient() { + @Override + public HttpResponse send(HttpRequest request) { + capturedRequest.set(request); + return createMockResponse(request, 200, "{\"status\": \"completed\"}"); + } + + @Override + public CompletableFuture> sendAsync(HttpRequest request) { + return CompletableFuture.completedFuture(send(request)); + } + }; + setMockGaosClient(client, mockClient); + + String interactionId = "test-interaction-id"; + String expectedUrlPrefix = + "https://" + + LOCATION + + "-aiplatform.googleapis.com/v1beta1/projects/" + + PROJECT + + "/locations/" + + LOCATION; + + // 1. Test Get + client.interactions.get( + com.google.genai.gaos.models.operations.GetInteractionByIdRequest.builder() + .id(interactionId) + .build()); + HttpRequest req = capturedRequest.get(); + assertNotNull(req); + assertEquals("GET", req.method()); + assertEquals( + URI.create( + expectedUrlPrefix + + "/interactions/" + + interactionId + + "?stream=false&include_input=false"), + req.uri()); + + // 2. Test Cancel + capturedRequest.set(null); + client.interactions.cancel(interactionId); + req = capturedRequest.get(); + assertNotNull(req); + assertEquals("POST", req.method()); + assertEquals( + URI.create(expectedUrlPrefix + "/interactions/" + interactionId + "/cancel"), req.uri()); + + // 3. Test Delete + capturedRequest.set(null); + client.interactions.delete(interactionId); + req = capturedRequest.get(); + assertNotNull(req); + assertEquals("DELETE", req.method()); + assertEquals(URI.create(expectedUrlPrefix + "/interactions/" + interactionId), req.uri()); + } + + @Test + public void testLegacyLyriaOutputsNormalization() throws Exception { + String legacyJson = + "{\n" + + " \"id\": \"test-interaction-id\",\n" + + " \"status\": \"completed\",\n" + + " \"model\": \"lyria-3-pro-preview\",\n" + + " \"outputs\": [\n" + + " {\n" + + " \"parts\": [\n" + + " {\n" + + " \"text\": \"Hello Lyria\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + "}"; + + com.fasterxml.jackson.databind.ObjectMapper mapper = com.google.genai.gaos.utils.Utils.mapper(); + com.google.genai.gaos.models.interactions.Interaction interaction = + mapper.readValue(legacyJson, com.google.genai.gaos.models.interactions.Interaction.class); + + assertNotNull(interaction); + assertEquals("test-interaction-id", interaction.id().orElse(null)); + assertEquals( + com.google.genai.gaos.models.interactions.InteractionStatus.COMPLETED, + interaction.status().orElse(null)); + + assertTrue(interaction.steps().isPresent()); + java.util.List steps = + interaction.steps().get(); + assertEquals(1, steps.size()); + + com.google.genai.gaos.models.interactions.Step step = steps.get(0); + assertTrue(step instanceof com.google.genai.gaos.models.interactions.ModelOutputStep); + + com.google.genai.gaos.models.interactions.ModelOutputStep modelOutput = + (com.google.genai.gaos.models.interactions.ModelOutputStep) step; + assertEquals("model_output", modelOutput.type()); + assertTrue(modelOutput.content().isPresent()); + + java.util.List contents = + modelOutput.content().get(); + assertEquals(1, contents.size()); + } + + @Test + public void testAgentsAndWebhooksPaths_gemini() throws Exception { + Client client = Client.builder().apiKey("test-api-key").vertexAI(false).build(); + + AtomicReference capturedRequest = new AtomicReference<>(); + HTTPClient mockClient = + new HTTPClient() { + @Override + public HttpResponse send(HttpRequest request) { + capturedRequest.set(request); + return createMockResponse( + request, 200, "{\"uri\": \"https://example.com\", \"subscribed_events\": []}"); + } + + @Override + public CompletableFuture> sendAsync(HttpRequest request) { + return CompletableFuture.completedFuture(send(request)); + } + }; + setMockGaosClient(client, mockClient); + + String agentId = "test-agent-id"; + String webhookId = "test-webhook-id"; + String expectedUrlPrefix = "https://generativelanguage.googleapis.com/v1beta"; + + // 1. Test Get Agent + client.agents.get(agentId); + HttpRequest req = capturedRequest.get(); + assertNotNull(req); + assertEquals("GET", req.method()); + assertEquals(URI.create(expectedUrlPrefix + "/agents/" + agentId), req.uri()); + + // 2. Test Get Webhook + capturedRequest.set(null); + client.webhooks.get(webhookId); + req = capturedRequest.get(); + assertNotNull(req); + assertEquals("GET", req.method()); + assertEquals(URI.create(expectedUrlPrefix + "/webhooks/" + webhookId), req.uri()); + } +} diff --git a/src/test/java/com/google/genai/errors/NativeReparentContractTest.java b/src/test/java/com/google/genai/errors/NativeReparentContractTest.java new file mode 100644 index 00000000000..f1dcb54476d --- /dev/null +++ b/src/test/java/com/google/genai/errors/NativeReparentContractTest.java @@ -0,0 +1,71 @@ +/* + * Copyright 2026 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. + */ + +package com.google.genai.errors; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.google.genai.gaos.models.errors.GaosApiException; +import com.google.genai.gaos.models.errors.GaosClientException; +import com.google.genai.gaos.models.errors.GaosServerException; +import org.junit.jupiter.api.Test; + +/** + * CI trip-wire for the error-hierarchy reparent's native prerequisites — the hand edits to + * {@code com.google.genai.errors} in the checked-in wrapper (de-finalized + * {@code ClientException}/{@code ServerException} + four-arg cause constructors) that + * {@code scripts/sync_speakeasy_outputs.py} relies on. + */ +final class NativeReparentContractTest { + + @Test + void nativeExceptionsExposeCauseCarryingConstructors() { + Throwable cause = new IllegalStateException("origin"); + + // These four-arg constructors are the hand edit the reparent rides on. Referencing them here is + // the compile-time guard; the assertions double as a runtime check that the cause is retained. + ApiException api = new ApiException(400, "", "boom", cause); + ClientException client = new ClientException(429, "", "slow down", cause); + ServerException server = new ServerException(500, "", "kaboom", cause); + + assertSame(cause, api.getCause(), "ApiException must retain the reparented cause"); + assertSame(cause, client.getCause(), "ClientException must retain the reparented cause"); + assertSame(cause, server.getCause(), "ServerException must retain the reparented cause"); + assertEquals(429, client.code(), "code preserved through the cause constructor"); + assertEquals(500, server.code(), "code preserved through the cause constructor"); + } + + @Test + void gaosCarriersRemainReparentedOntoNativeTree() { + // 4xx carrier -> native ClientException, 5xx carrier -> native ServerException, generic -> + // bare ApiException. If de-finalization or the sync reparent regresses, these detach. + assertTrue( + ClientException.class.isAssignableFrom(GaosClientException.class), + "GaosClientException must extend native ClientException"); + assertTrue( + ServerException.class.isAssignableFrom(GaosServerException.class), + "GaosServerException must extend native ServerException"); + assertTrue( + ApiException.class.isAssignableFrom(GaosApiException.class), + "GaosApiException must extend native ApiException"); + + // And the carriers are themselves ApiExceptions, so a single catch (ApiException) covers all. + assertTrue(ApiException.class.isAssignableFrom(GaosClientException.class)); + assertTrue(ApiException.class.isAssignableFrom(GaosServerException.class)); + } +} diff --git a/src/test/java/com/google/genai/gaos/hooks/SDKHooksTest.java b/src/test/java/com/google/genai/gaos/hooks/SDKHooksTest.java new file mode 100644 index 00000000000..9d7280094c1 --- /dev/null +++ b/src/test/java/com/google/genai/gaos/hooks/SDKHooksTest.java @@ -0,0 +1,157 @@ +/* + * Copyright 2026 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. + */ + +package com.google.genai.gaos.hooks; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; + +import com.google.genai.gaos.SecuritySource; +import com.google.genai.gaos.models.shared.Security; +import com.google.genai.gaos.utils.AsyncHooks; +import com.google.genai.gaos.utils.Hook; +import com.google.genai.gaos.utils.Hooks; +import com.google.genai.gaos.utils.transport.HttpRequest; +import java.net.URI; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.Test; + +/** + * Tests for {@link SDKHooks} to verify that request authorization headers + * (x-goog-api-key, Authorization, defaultHeaders) are properly configured + * and not accidentally cleared during SDK regeneration. + */ +public final class SDKHooksTest { + + private static final String API_KEY = "test-api-key-12345"; + private static final String ACCESS_TOKEN = "test-access-token-abcde"; + + private Hook.BeforeRequestContext createContext(Security security) { + return new Hook.BeforeRequestContextImpl( + null, + "https://generativelanguage.googleapis.com", + "createInteraction", + Optional.empty(), + security != null ? Optional.of(SecuritySource.of(security)) : Optional.empty()); + } + + private HttpRequest createBaseRequest() { + return HttpRequest.builder() + .method("POST") + .uri(URI.create("https://generativelanguage.googleapis.com/v1beta/interactions")) + .build(); + } + + @Test + public void testSyncHookSetsApiKeyHeader() throws Exception { + Hooks hooks = new Hooks(); + SDKHooks.initialize(hooks); + + Security security = Security.builder().apiKey(API_KEY).build(); + Hook.BeforeRequestContext context = createContext(security); + HttpRequest request = createBaseRequest(); + + HttpRequest modified = hooks.beforeRequest(context, request); + assertEquals(API_KEY, modified.headers().firstValue("x-goog-api-key").orElse(null)); + } + + @Test + public void testSyncHookSetsAuthorizationHeader() throws Exception { + Hooks hooks = new Hooks(); + SDKHooks.initialize(hooks); + + Security security = Security.builder().accessToken(ACCESS_TOKEN).build(); + Hook.BeforeRequestContext context = createContext(security); + HttpRequest request = createBaseRequest(); + + HttpRequest modified = hooks.beforeRequest(context, request); + assertEquals("Bearer " + ACCESS_TOKEN, modified.headers().firstValue("Authorization").orElse(null)); + } + + @Test + public void testSyncHookSetsDefaultHeaders() throws Exception { + Hooks hooks = new Hooks(); + SDKHooks.initialize(hooks); + + Map defaultHeaders = new HashMap<>(); + defaultHeaders.put("X-Custom-Header", "custom-value"); + defaultHeaders.put("Api-Revision", "2026-05-20"); + + Security security = Security.builder().defaultHeaders(defaultHeaders).build(); + Hook.BeforeRequestContext context = createContext(security); + HttpRequest request = createBaseRequest(); + + HttpRequest modified = hooks.beforeRequest(context, request); + assertEquals("custom-value", modified.headers().firstValue("X-Custom-Header").orElse(null)); + assertEquals("2026-05-20", modified.headers().firstValue("Api-Revision").orElse(null)); + } + + @Test + public void testAsyncHookSetsApiKeyHeader() throws Exception { + AsyncHooks asyncHooks = new AsyncHooks(); + SDKHooks.initialize(asyncHooks); + + Security security = Security.builder().apiKey(API_KEY).build(); + Hook.BeforeRequestContext context = createContext(security); + HttpRequest request = createBaseRequest(); + + HttpRequest modified = asyncHooks.beforeRequest(context, request).get(); + assertEquals(API_KEY, modified.headers().firstValue("x-goog-api-key").orElse(null)); + } + + @Test + public void testAsyncHookSetsAuthorizationHeader() throws Exception { + AsyncHooks asyncHooks = new AsyncHooks(); + SDKHooks.initialize(asyncHooks); + + Security security = Security.builder().accessToken(ACCESS_TOKEN).build(); + Hook.BeforeRequestContext context = createContext(security); + HttpRequest request = createBaseRequest(); + + HttpRequest modified = asyncHooks.beforeRequest(context, request).get(); + assertEquals("Bearer " + ACCESS_TOKEN, modified.headers().firstValue("Authorization").orElse(null)); + } + + @Test + public void testAsyncHookSetsDefaultHeaders() throws Exception { + AsyncHooks asyncHooks = new AsyncHooks(); + SDKHooks.initialize(asyncHooks); + + Map defaultHeaders = new HashMap<>(); + defaultHeaders.put("X-Custom-Header", "custom-value"); + + Security security = Security.builder().defaultHeaders(defaultHeaders).build(); + Hook.BeforeRequestContext context = createContext(security); + HttpRequest request = createBaseRequest(); + + HttpRequest modified = asyncHooks.beforeRequest(context, request).get(); + assertEquals("custom-value", modified.headers().firstValue("X-Custom-Header").orElse(null)); + } + + @Test + public void testHookWithoutSecurityPassesRequestThrough() throws Exception { + Hooks hooks = new Hooks(); + SDKHooks.initialize(hooks); + + Hook.BeforeRequestContext context = createContext(null); + HttpRequest request = createBaseRequest(); + + HttpRequest modified = hooks.beforeRequest(context, request); + assertSame(request, modified); + } +}